text
stringlengths 30
1.67M
|
|---|
<s> package org . eclipse . jdt . core . util ; public interface IClassFileDisassembler { int DETAILED = <NUM_LIT:1> ; int DEFAULT = <NUM_LIT:2> ; String disassemble ( IClassFileReader classFileReader , String lineSeparator ) ; String disassemble ( IClassFileReader classFileReader , String lineSeparator , int mode ) ; } </s>
|
<s> package org . eclipse . jdt . core . util ; public interface IVerificationTypeInfo { public static final int ITEM_TOP = <NUM_LIT:0> ; public static final int ITEM_INTEGER = <NUM_LIT:1> ; public static final int ITEM_FLOAT = <NUM_LIT:2> ; public static final int ITEM_DOUBLE = <NUM_LIT:3> ; public static final int ITEM_LONG = <NUM_LIT:4> ; public static final int ITEM_NULL = <NUM_LIT:5> ; public static final int ITEM_UNINITIALIZED_THIS = <NUM_LIT:6> ; public static final int ITEM_OBJECT = <NUM_LIT:7> ; public static final int ITEM_UNINITIALIZED = <NUM_LIT:8> ; int getTag ( ) ; int getOffset ( ) ; int getConstantPoolIndex ( ) ; char [ ] getClassTypeName ( ) ; } </s>
|
<s> package org . eclipse . jdt . core . util ; public interface IRuntimeInvisibleAnnotationsAttribute extends IClassFileAttribute { int getAnnotationsNumber ( ) ; IAnnotation [ ] getAnnotations ( ) ; } </s>
|
<s> package org . eclipse . jdt . core . util ; public interface IModifierConstants { int ACC_PUBLIC = <NUM_LIT> ; int ACC_PRIVATE = <NUM_LIT> ; int ACC_PROTECTED = <NUM_LIT> ; int ACC_STATIC = <NUM_LIT> ; int ACC_FINAL = <NUM_LIT> ; int ACC_SUPER = <NUM_LIT> ; int ACC_SYNCHRONIZED = <NUM_LIT> ; int ACC_VOLATILE = <NUM_LIT> ; int ACC_BRIDGE = <NUM_LIT> ; int ACC_TRANSIENT = <NUM_LIT> ; int ACC_VARARGS = <NUM_LIT> ; int ACC_NATIVE = <NUM_LIT> ; int ACC_INTERFACE = <NUM_LIT> ; int ACC_ABSTRACT = <NUM_LIT> ; int ACC_STRICT = <NUM_LIT> ; int ACC_SYNTHETIC = <NUM_LIT> ; int ACC_ANNOTATION = <NUM_LIT> ; int ACC_ENUM = <NUM_LIT> ; } </s>
|
<s> package org . eclipse . jdt . core . util ; public class ByteCodeVisitorAdapter implements IBytecodeVisitor { public void _aaload ( int pc ) { } public void _aastore ( int pc ) { } public void _aconst_null ( int pc ) { } public void _aload_0 ( int pc ) { } public void _aload_1 ( int pc ) { } public void _aload_2 ( int pc ) { } public void _aload_3 ( int pc ) { } public void _aload ( int pc , int index ) { } public void _anewarray ( int pc , int index , IConstantPoolEntry constantClass ) { } public void _areturn ( int pc ) { } public void _arraylength ( int pc ) { } public void _astore_0 ( int pc ) { } public void _astore_1 ( int pc ) { } public void _astore_2 ( int pc ) { } public void _astore_3 ( int pc ) { } public void _astore ( int pc , int index ) { } public void _athrow ( int pc ) { } public void _baload ( int pc ) { } public void _bastore ( int pc ) { } public void _bipush ( int pc , byte _byte ) { } public void _caload ( int pc ) { } public void _castore ( int pc ) { } public void _checkcast ( int pc , int index , IConstantPoolEntry constantClass ) { } public void _d2f ( int pc ) { } public void _d2i ( int pc ) { } public void _d2l ( int pc ) { } public void _dadd ( int pc ) { } public void _daload ( int pc ) { } public void _dastore ( int pc ) { } public void _dcmpg ( int pc ) { } public void _dcmpl ( int pc ) { } public void _dconst_0 ( int pc ) { } public void _dconst_1 ( int pc ) { } public void _ddiv ( int pc ) { } public void _dload_0 ( int pc ) { } public void _dload_1 ( int pc ) { } public void _dload_2 ( int pc ) { } public void _dload_3 ( int pc ) { } public void _dload ( int pc , int index ) { } public void _dmul ( int pc ) { } public void _dneg ( int pc ) { } public void _drem ( int pc ) { } public void _dreturn ( int pc ) { } public void _dstore_0 ( int pc ) { } public void _dstore_1 ( int pc ) { } public void _dstore_2 ( int pc ) { } public void _dstore_3 ( int pc ) { } public void _dstore ( int pc , int index ) { } public void _dsub ( int pc ) { } public void _dup_x1 ( int pc ) { } public void _dup_x2 ( int pc ) { } public void _dup ( int pc ) { } public void _dup2_x1 ( int pc ) { } public void _dup2_x2 ( int pc ) { } public void _dup2 ( int pc ) { } public void _f2d ( int pc ) { } public void _f2i ( int pc ) { } public void _f2l ( int pc ) { } public void _fadd ( int pc ) { } public void _faload ( int pc ) { } public void _fastore ( int pc ) { } public void _fcmpg ( int pc ) { } public void _fcmpl ( int pc ) { } public void _fconst_0 ( int pc ) { } public void _fconst_1 ( int pc ) { } public void _fconst_2 ( int pc ) { } public void _fdiv ( int pc ) { } public void _fload_0 ( int pc ) { } public void _fload_1 ( int pc ) { } public void _fload_2 ( int pc ) { } public void _fload_3 ( int pc ) { } public void _fload ( int pc , int index ) { } public void _fmul ( int pc ) { } public void _fneg ( int pc ) { } public void _frem ( int pc ) { } public void _freturn ( int pc ) { } public void _fstore_0 ( int pc ) { } public void _fstore_1 ( int pc ) { } public void _fstore_2 ( int pc ) { } public void _fstore_3 ( int pc ) { } public void _fstore ( int pc , int index ) { } public void _fsub ( int pc ) { } public void _getfield ( int pc , int index , IConstantPoolEntry constantFieldref ) { } public void _getstatic ( int pc , int index , IConstantPoolEntry constantFieldref ) { } public void _goto_w ( int pc , int branchOffset ) { } public void _goto ( int pc , int branchOffset ) { } public void _i2b ( int pc ) { } public void _i2c ( int pc ) { } public void _i2d ( int pc ) { } public void _i2f ( int pc ) { } public void _i2l ( int pc ) { } public void _i2s ( int pc ) { } public void _iadd ( int pc ) { } public void _iaload ( int pc ) { } public void _iand ( int pc ) { } public void _iastore ( int pc ) { } public void _iconst_0 ( int pc ) { } public void _iconst_1 ( int pc ) { } public void _iconst_2 ( int pc ) { } public void _iconst_3 ( int pc ) { } public void _iconst_4 ( int pc ) { } public void _iconst_5 ( int pc ) { } public void _iconst_m1 ( int pc ) { } public void _idiv ( int pc ) { } public void _if_acmpeq ( int pc , int branchOffset ) { } public void _if_acmpne ( int pc , int branchOffset ) { } public void _if_icmpeq ( int pc , int branchOffset ) { } public void _if_icmpge ( int pc , int branchOffset ) { } public void _if_icmpgt ( int pc , int branchOffset ) { } public void _if_icmple ( int pc , int branchOffset ) { } public void _if_icmplt ( int pc , int branchOffset ) { } public void _if_icmpne ( int pc , int branchOffset ) { } public void _ifeq ( int pc , int branchOffset ) { } public void _ifge ( int pc , int branchOffset ) { } public void _ifgt ( int pc , int branchOffset ) { } public void _ifle ( int pc , int branchOffset ) { } public void _iflt ( int pc , int branchOffset ) { } public void _ifne ( int pc , int branchOffset ) { } public void _ifnonnull ( int pc , int branchOffset ) { } public void _ifnull ( int pc , int branchOffset ) { } public void _iinc ( int pc , int index , int _const ) { } public void _iload_0 ( int pc ) { } public void _iload_1 ( int pc ) { } public void _iload_2 ( int pc ) { } public void _iload_3 ( int pc ) { } public void _iload ( int pc , int index ) { } public void _imul ( int pc ) { } public void _ineg ( int pc ) { } public void _instanceof ( int pc , int index , IConstantPoolEntry constantClass ) { } public void _invokedynamic ( int pc , int index , IConstantPoolEntry nameEntry , IConstantPoolEntry descriptorEntry ) { } public void _invokeinterface ( int pc , int index , byte nargs , IConstantPoolEntry constantInterfaceMethodref ) { } public void _invokespecial ( int pc , int index , IConstantPoolEntry constantMethodref ) { } public void _invokestatic ( int pc , int index , IConstantPoolEntry constantMethodref ) { } public void _invokevirtual ( int pc , int index , IConstantPoolEntry constantMethodref ) { } public void _ior ( int pc ) { } public void _irem ( int pc ) { } public void _ireturn ( int pc ) { } public void _ishl ( int pc ) { } public void _ishr ( int pc ) { } public void _istore_0 ( int pc ) { } public void _istore_1 ( int pc ) { } public void _istore_2 ( int pc ) { } public void _istore_3 ( int pc ) { } public void _istore ( int pc , int index ) { } public void _isub ( int pc ) { } public void _iushr ( int pc ) { } public void _ixor ( int pc ) { } public void _jsr_w ( int pc , int branchOffset ) { } public void _jsr ( int pc , int branchOffset ) { } public void _l2d ( int pc ) { } public void _l2f ( int pc ) { } public void _l2i ( int pc ) { } public void _ladd ( int pc ) { } public void _laload ( int pc ) { } public void _land ( int pc ) { } public void _lastore ( int pc ) { } public void _lcmp ( int pc ) { } public void _lconst_0 ( int pc ) { } public void _lconst_1 ( int pc ) { } public void _ldc_w ( int pc , int index , IConstantPoolEntry constantPoolEntry ) { } public void _ldc ( int pc , int index , IConstantPoolEntry constantPoolEntry ) { } public void _ldc2_w ( int pc , int index , IConstantPoolEntry constantPoolEntry ) { } public void _ldiv ( int pc ) { } public void _lload_0 ( int pc ) { } public void _lload_1 ( int pc ) { } public void _lload_2 ( int pc ) { } public void _lload_3 ( int pc ) { } public void _lload ( int pc , int index ) { } public void _lmul ( int pc ) { } public void _lneg ( int pc ) { } public void _lookupswitch ( int pc , int defaultoffset , int npairs , int [ ] [ ] offset_pairs ) { } public void _lor ( int pc ) { } public void _lrem ( int pc ) { } public void _lreturn ( int pc ) { } public void _lshl ( int pc ) { } public void _lshr ( int pc ) { } public void _lstore_0 ( int pc ) { } public void _lstore_1 ( int pc ) { } public void _lstore_2 ( int pc ) { } public void _lstore_3 ( int pc ) { } public void _lstore ( int pc , int index ) { } public void _lsub ( int pc ) { } public void _lushr ( int pc ) { } public void _lxor ( int pc ) { } public void _monitorenter ( int pc ) { } public void _monitorexit ( int pc ) { } public void _multianewarray ( int pc , int index , int dimensions , IConstantPoolEntry constantClass ) { } public void _new ( int pc , int index , IConstantPoolEntry constantClass ) { } public void _newarray ( int pc , int atype ) { } public void _nop ( int pc ) { } public void _pop ( int pc ) { } public void _pop2 ( int pc ) { } public void _putfield ( int pc , int index , IConstantPoolEntry constantFieldref ) { } public void _putstatic ( int pc , int index , IConstantPoolEntry constantFieldref ) { } public void _ret ( int pc , int index ) { } public void _return ( int pc ) { } public void _saload ( int pc ) { } public void _sastore ( int pc ) { } public void _sipush ( int pc , short value ) { } public void _swap ( int pc ) { } public void _tableswitch ( int pc , int defaultoffset , int low , int high , int [ ] jump_offsets ) { } public void _wide ( int pc , int iincopcode , int index , int _const ) { } public void _wide ( int pc , int opcode , int index ) { } public void _breakpoint ( int pc ) { } public void _impdep1 ( int pc ) { } public void _impdep2 ( int pc ) { } } </s>
|
<s> package org . eclipse . jdt . core . util ; public interface IClassFileAttribute { int getAttributeNameIndex ( ) ; char [ ] getAttributeName ( ) ; long getAttributeLength ( ) ; } </s>
|
<s> package org . eclipse . jdt . core . util ; public interface IAnnotationComponentValue { int BYTE_TAG = '<CHAR_LIT>' ; int CHAR_TAG = '<CHAR_LIT>' ; int DOUBLE_TAG = '<CHAR_LIT>' ; int FLOAT_TAG = '<CHAR_LIT>' ; int INTEGER_TAG = '<CHAR_LIT>' ; int LONG_TAG = '<CHAR_LIT>' ; int SHORT_TAG = '<CHAR_LIT>' ; int BOOLEAN_TAG = '<CHAR_LIT:Z>' ; int STRING_TAG = '<CHAR_LIT>' ; int ENUM_TAG = '<CHAR_LIT:e>' ; int CLASS_TAG = '<CHAR_LIT:c>' ; int ANNOTATION_TAG = '<CHAR_LIT>' ; int ARRAY_TAG = '<CHAR_LIT:[>' ; IAnnotationComponentValue [ ] getAnnotationComponentValues ( ) ; IAnnotation getAnnotationValue ( ) ; IConstantPoolEntry getClassInfo ( ) ; int getClassInfoIndex ( ) ; IConstantPoolEntry getConstantValue ( ) ; int getConstantValueIndex ( ) ; char [ ] getEnumConstantName ( ) ; int getEnumConstantNameIndex ( ) ; char [ ] getEnumConstantTypeName ( ) ; int getEnumConstantTypeNameIndex ( ) ; int getTag ( ) ; int getValuesNumber ( ) ; } </s>
|
<s> package org . eclipse . jdt . core . util ; public interface IExceptionTableEntry { int getStartPC ( ) ; int getEndPC ( ) ; int getHandlerPC ( ) ; int getCatchTypeIndex ( ) ; char [ ] getCatchType ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import java . util . Hashtable ; import java . util . Map ; import org . eclipse . core . resources . * ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . parser . * ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; public class CorrectionEngine { protected int correctionStart ; protected int correctionEnd ; protected int prefixLength ; protected ICompilationUnit compilationUnit ; protected ICorrectionRequestor correctionRequestor ; protected static final int CLASSES = <NUM_LIT> ; protected static final int INTERFACES = <NUM_LIT> ; protected static final int IMPORT = <NUM_LIT> ; protected static final int METHOD = <NUM_LIT> ; protected static final int FIELD = <NUM_LIT> ; protected static final int LOCAL = <NUM_LIT> ; protected int filter ; public CorrectionEngine ( Map setting ) { } public void computeCorrections ( IMarker marker , ICompilationUnit targetUnit , int positionOffset , ICorrectionRequestor requestor ) throws JavaModelException { IJavaElement element = targetUnit == null ? JavaCore . create ( marker . getResource ( ) ) : targetUnit ; if ( ! ( element instanceof ICompilationUnit ) ) return ; ICompilationUnit unit = ( ICompilationUnit ) element ; int id = marker . getAttribute ( IJavaModelMarker . ID , - <NUM_LIT:1> ) ; String [ ] args = Util . getProblemArgumentsFromMarker ( marker . getAttribute ( IJavaModelMarker . ARGUMENTS , "<STR_LIT>" ) ) ; int start = marker . getAttribute ( IMarker . CHAR_START , - <NUM_LIT:1> ) ; int end = marker . getAttribute ( IMarker . CHAR_END , - <NUM_LIT:1> ) ; computeCorrections ( unit , id , start + positionOffset , end + positionOffset , args , requestor ) ; } public void computeCorrections ( IProblem problem , ICompilationUnit targetUnit , ICorrectionRequestor requestor ) throws JavaModelException { if ( requestor == null ) { throw new IllegalArgumentException ( Messages . correction_nullUnit ) ; } this . computeCorrections ( targetUnit , problem . getID ( ) , problem . getSourceStart ( ) , problem . getSourceEnd ( ) , problem . getArguments ( ) , requestor ) ; } private void computeCorrections ( ICompilationUnit unit , int id , int start , int end , String [ ] arguments , ICorrectionRequestor requestor ) { if ( id == - <NUM_LIT:1> || arguments == null || start == - <NUM_LIT:1> || end == - <NUM_LIT:1> ) return ; if ( requestor == null ) { throw new IllegalArgumentException ( Messages . correction_nullRequestor ) ; } this . correctionRequestor = requestor ; this . correctionStart = start ; this . correctionEnd = end ; this . compilationUnit = unit ; String argument = null ; try { switch ( id ) { case IProblem . ImportNotFound : this . filter = IMPORT ; argument = arguments [ <NUM_LIT:0> ] ; break ; case IProblem . UndefinedType : this . filter = CLASSES | INTERFACES ; argument = arguments [ <NUM_LIT:0> ] ; break ; case IProblem . UndefinedMethod : this . filter = METHOD ; argument = arguments [ <NUM_LIT:1> ] ; break ; case IProblem . UndefinedField : this . filter = FIELD ; argument = arguments [ <NUM_LIT:0> ] ; break ; case IProblem . UndefinedName : case IProblem . UnresolvedVariable : this . filter = FIELD | LOCAL ; argument = arguments [ <NUM_LIT:0> ] ; break ; } } catch ( ArrayIndexOutOfBoundsException e ) { return ; } if ( argument != null ) { correct ( argument . toCharArray ( ) ) ; } } private void correct ( char [ ] argument ) { try { String source = this . compilationUnit . getSource ( ) ; Map currentProjectOptions = this . compilationUnit . getJavaProject ( ) . getOptions ( true ) ; long sourceLevel = CompilerOptions . versionToJdkLevel ( currentProjectOptions . get ( JavaCore . COMPILER_SOURCE ) ) ; long complianceLevel = CompilerOptions . versionToJdkLevel ( currentProjectOptions . get ( JavaCore . COMPILER_COMPLIANCE ) ) ; Scanner scanner = new Scanner ( false , false , false , sourceLevel , complianceLevel , null , null , true ) ; scanner . setSource ( source . toCharArray ( ) ) ; scanner . resetTo ( this . correctionStart , this . correctionEnd ) ; int token = <NUM_LIT:0> ; char [ ] argumentSource = CharOperation . NO_CHAR ; while ( true ) { token = scanner . getNextToken ( ) ; if ( token == TerminalTokens . TokenNameEOF ) return ; char [ ] tokenSource = scanner . getCurrentTokenSource ( ) ; argumentSource = CharOperation . concat ( argumentSource , tokenSource ) ; if ( ! CharOperation . prefixEquals ( argumentSource , argument ) ) return ; if ( CharOperation . equals ( argument , argumentSource ) ) { this . correctionStart = scanner . startPosition ; this . correctionEnd = scanner . currentPosition ; this . prefixLength = CharOperation . lastIndexOf ( '<CHAR_LIT:.>' , argument ) + <NUM_LIT:1> ; break ; } } int completionPosition = this . correctionStart ; scanner . resetTo ( completionPosition , this . correctionEnd ) ; int position = completionPosition ; for ( int i = <NUM_LIT:0> ; i < <NUM_LIT:4> ; i ++ ) { if ( scanner . getNextCharAsJavaIdentifierPart ( ) ) { completionPosition = position ; position = scanner . currentPosition ; } else { break ; } } Hashtable oldOptions = JavaCore . getOptions ( ) ; try { Hashtable options = new Hashtable ( oldOptions ) ; options . put ( JavaCore . CODEASSIST_CAMEL_CASE_MATCH , JavaCore . DISABLED ) ; JavaCore . setOptions ( options ) ; this . compilationUnit . codeComplete ( completionPosition , this . completionRequestor ) ; } finally { JavaCore . setOptions ( oldOptions ) ; } } catch ( JavaModelException e ) { return ; } catch ( InvalidInputException e ) { return ; } } protected CompletionRequestor completionRequestor = new CompletionRequestor ( ) { public void accept ( CompletionProposal proposal ) { switch ( proposal . getKind ( ) ) { case CompletionProposal . TYPE_REF : int flags = proposal . getFlags ( ) ; if ( ! ( Flags . isEnum ( flags ) || Flags . isAnnotation ( flags ) ) ) { if ( ( CorrectionEngine . this . filter & ( CLASSES | INTERFACES ) ) != <NUM_LIT:0> ) { char [ ] completionName = proposal . getCompletion ( ) ; CorrectionEngine . this . correctionRequestor . acceptClass ( proposal . getDeclarationSignature ( ) , Signature . getSignatureSimpleName ( proposal . getSignature ( ) ) , CharOperation . subarray ( completionName , CorrectionEngine . this . prefixLength , completionName . length ) , proposal . getFlags ( ) , CorrectionEngine . this . correctionStart , CorrectionEngine . this . correctionEnd ) ; } else if ( ( CorrectionEngine . this . filter & IMPORT ) != <NUM_LIT:0> ) { char [ ] packageName = proposal . getDeclarationSignature ( ) ; char [ ] className = Signature . getSignatureSimpleName ( proposal . getSignature ( ) ) ; char [ ] fullName = CharOperation . concat ( packageName , className , '<CHAR_LIT:.>' ) ; CorrectionEngine . this . correctionRequestor . acceptClass ( packageName , className , CharOperation . subarray ( fullName , CorrectionEngine . this . prefixLength , fullName . length ) , proposal . getFlags ( ) , CorrectionEngine . this . correctionStart , CorrectionEngine . this . correctionEnd ) ; } } break ; case CompletionProposal . FIELD_REF : if ( ( CorrectionEngine . this . filter & FIELD ) != <NUM_LIT:0> ) { char [ ] declaringSignature = proposal . getDeclarationSignature ( ) ; char [ ] signature = proposal . getSignature ( ) ; CorrectionEngine . this . correctionRequestor . acceptField ( Signature . getSignatureQualifier ( declaringSignature ) , Signature . getSignatureSimpleName ( declaringSignature ) , proposal . getName ( ) , Signature . getSignatureQualifier ( signature ) , Signature . getSignatureSimpleName ( signature ) , proposal . getName ( ) , proposal . getFlags ( ) , CorrectionEngine . this . correctionStart , CorrectionEngine . this . correctionEnd ) ; } break ; case CompletionProposal . LOCAL_VARIABLE_REF : if ( ( CorrectionEngine . this . filter & LOCAL ) != <NUM_LIT:0> ) { char [ ] signature = proposal . getSignature ( ) ; CorrectionEngine . this . correctionRequestor . acceptLocalVariable ( proposal . getName ( ) , Signature . getSignatureQualifier ( signature ) , Signature . getSignatureSimpleName ( signature ) , proposal . getFlags ( ) , CorrectionEngine . this . correctionStart , CorrectionEngine . this . correctionEnd ) ; } break ; case CompletionProposal . METHOD_REF : if ( ( CorrectionEngine . this . filter & METHOD ) != <NUM_LIT:0> ) { char [ ] declaringSignature = proposal . getDeclarationSignature ( ) ; char [ ] signature = proposal . getSignature ( ) ; char [ ] [ ] parameterTypeSignatures = Signature . getParameterTypes ( signature ) ; int length = parameterTypeSignatures . length ; char [ ] [ ] parameterPackageNames = new char [ length ] [ ] ; char [ ] [ ] parameterTypeNames = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { parameterPackageNames [ i ] = Signature . getSignatureQualifier ( parameterTypeSignatures [ i ] ) ; parameterTypeNames [ i ] = Signature . getSignatureSimpleName ( parameterTypeSignatures [ i ] ) ; } char [ ] returnTypeSignature = Signature . getReturnType ( signature ) ; CorrectionEngine . this . correctionRequestor . acceptMethod ( Signature . getSignatureQualifier ( declaringSignature ) , Signature . getSignatureSimpleName ( declaringSignature ) , proposal . getName ( ) , parameterPackageNames , parameterTypeNames , proposal . findParameterNames ( null ) , Signature . getSignatureQualifier ( returnTypeSignature ) , Signature . getSignatureSimpleName ( returnTypeSignature ) , proposal . getName ( ) , proposal . getFlags ( ) , CorrectionEngine . this . correctionStart , CorrectionEngine . this . correctionEnd ) ; } break ; case CompletionProposal . PACKAGE_REF : if ( ( CorrectionEngine . this . filter & ( CLASSES | INTERFACES | IMPORT ) ) != <NUM_LIT:0> ) { char [ ] packageName = proposal . getDeclarationSignature ( ) ; CorrectionEngine . this . correctionRequestor . acceptPackage ( packageName , CharOperation . subarray ( packageName , CorrectionEngine . this . prefixLength , packageName . length ) , CorrectionEngine . this . correctionStart , CorrectionEngine . this . correctionEnd ) ; } break ; } } } ; public static String [ ] getAllWarningTokens ( ) { return CompilerOptions . warningTokens ; } public static String [ ] getProblemArguments ( IMarker problemMarker ) { String argumentsString = problemMarker . getAttribute ( IJavaModelMarker . ARGUMENTS , null ) ; return Util . getProblemArgumentsFromMarker ( argumentsString ) ; } public static String getWarningToken ( int problemID ) { int irritant = ProblemReporter . getIrritant ( problemID ) ; if ( irritant != <NUM_LIT:0> ) { return CompilerOptions . warningTokenFromIrritant ( irritant ) ; } return null ; } } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . text . edits . TextEdit ; import org . eclipse . text . edits . UndoEdit ; public interface IBuffer { public interface ITextEditCapability { public UndoEdit applyTextEdit ( TextEdit edit , IProgressMonitor monitor ) throws JavaModelException ; } public void addBufferChangedListener ( IBufferChangedListener listener ) ; public void append ( char [ ] text ) ; public void append ( String text ) ; public void close ( ) ; public char getChar ( int position ) ; public char [ ] getCharacters ( ) ; public String getContents ( ) ; public int getLength ( ) ; public IOpenable getOwner ( ) ; public String getText ( int offset , int length ) throws IndexOutOfBoundsException ; public IResource getUnderlyingResource ( ) ; public boolean hasUnsavedChanges ( ) ; public boolean isClosed ( ) ; public boolean isReadOnly ( ) ; public void removeBufferChangedListener ( IBufferChangedListener listener ) ; public void replace ( int position , int length , char [ ] text ) ; public void replace ( int position , int length , String text ) ; public void save ( IProgressMonitor progress , boolean force ) throws JavaModelException ; public void setContents ( char [ ] contents ) ; public void setContents ( String contents ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import java . io . File ; import java . io . IOException ; import java . io . InputStream ; import java . util . HashMap ; import java . util . Map ; import java . util . zip . ZipEntry ; import java . util . zip . ZipFile ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . core . compiler . IScanner ; import org . eclipse . jdt . core . compiler . ITerminalSymbols ; import org . eclipse . jdt . core . formatter . CodeFormatter ; import org . eclipse . jdt . core . formatter . DefaultCodeFormatterConstants ; import org . eclipse . jdt . core . util . ClassFileBytesDisassembler ; import org . eclipse . jdt . core . util . ClassFormatException ; import org . eclipse . jdt . core . util . IClassFileReader ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jdt . internal . core . JarPackageFragmentRoot ; import org . eclipse . jdt . internal . core . JavaElement ; import org . eclipse . jdt . internal . core . JavaModelManager ; import org . eclipse . jdt . internal . core . PackageFragment ; import org . eclipse . jdt . internal . core . util . ClassFileReader ; import org . eclipse . jdt . internal . core . util . Disassembler ; import org . eclipse . jdt . internal . core . util . PublicScanner ; import org . eclipse . jdt . internal . formatter . DefaultCodeFormatter ; public class ToolFactory { public static final int M_FORMAT_NEW = new Integer ( <NUM_LIT:0> ) . intValue ( ) ; public static final int M_FORMAT_EXISTING = new Integer ( <NUM_LIT:1> ) . intValue ( ) ; public static ICodeFormatter createCodeFormatter ( ) { Plugin jdtCorePlugin = JavaCore . getPlugin ( ) ; if ( jdtCorePlugin == null ) return null ; IExtensionPoint extension = jdtCorePlugin . getDescriptor ( ) . getExtensionPoint ( JavaModelManager . FORMATTER_EXTPOINT_ID ) ; if ( extension != null ) { IExtension [ ] extensions = extension . getExtensions ( ) ; for ( int i = <NUM_LIT:0> ; i < extensions . length ; i ++ ) { IConfigurationElement [ ] configElements = extensions [ i ] . getConfigurationElements ( ) ; for ( int j = <NUM_LIT:0> ; j < configElements . length ; j ++ ) { try { Object execExt = configElements [ j ] . createExecutableExtension ( "<STR_LIT:class>" ) ; if ( execExt instanceof ICodeFormatter ) { return ( ICodeFormatter ) execExt ; } } catch ( CoreException e ) { } } } } return createDefaultCodeFormatter ( null ) ; } public static CodeFormatter createCodeFormatter ( Map options ) { return createCodeFormatter ( options , M_FORMAT_NEW ) ; } public static CodeFormatter createCodeFormatter ( Map options , int mode ) { if ( options == null ) options = JavaCore . getOptions ( ) ; Map currentOptions = new HashMap ( options ) ; if ( mode == M_FORMAT_NEW ) { currentOptions . put ( DefaultCodeFormatterConstants . FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN , DefaultCodeFormatterConstants . TRUE ) ; currentOptions . put ( DefaultCodeFormatterConstants . FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN , DefaultCodeFormatterConstants . FALSE ) ; currentOptions . put ( DefaultCodeFormatterConstants . FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN , DefaultCodeFormatterConstants . FALSE ) ; } return new DefaultCodeFormatter ( currentOptions ) ; } public static ClassFileBytesDisassembler createDefaultClassFileBytesDisassembler ( ) { return new Disassembler ( ) ; } public static org . eclipse . jdt . core . util . IClassFileDisassembler createDefaultClassFileDisassembler ( ) { class DeprecatedDisassembler extends Disassembler implements org . eclipse . jdt . core . util . IClassFileDisassembler { } return new DeprecatedDisassembler ( ) ; } public static IClassFileReader createDefaultClassFileReader ( IClassFile classfile , int decodingFlag ) { IPackageFragmentRoot root = ( IPackageFragmentRoot ) classfile . getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; if ( root != null ) { try { if ( root instanceof JarPackageFragmentRoot ) { String archiveName = null ; ZipFile jar = null ; try { jar = ( ( JarPackageFragmentRoot ) root ) . getJar ( ) ; archiveName = jar . getName ( ) ; } finally { JavaModelManager . getJavaModelManager ( ) . closeZipFile ( jar ) ; } PackageFragment packageFragment = ( PackageFragment ) classfile . getParent ( ) ; String classFileName = classfile . getElementName ( ) ; String entryName = org . eclipse . jdt . internal . core . util . Util . concatWith ( packageFragment . names , classFileName , '<CHAR_LIT:/>' ) ; return createDefaultClassFileReader ( archiveName , entryName , decodingFlag ) ; } else { InputStream in = null ; try { in = ( ( IFile ) ( ( JavaElement ) classfile ) . resource ( ) ) . getContents ( ) ; return createDefaultClassFileReader ( in , decodingFlag ) ; } finally { if ( in != null ) try { in . close ( ) ; } catch ( IOException e ) { } } } } catch ( CoreException e ) { } } return null ; } public static IClassFileReader createDefaultClassFileReader ( InputStream stream , int decodingFlag ) { try { return new ClassFileReader ( Util . getInputStreamAsByteArray ( stream , - <NUM_LIT:1> ) , decodingFlag ) ; } catch ( ClassFormatException e ) { return null ; } catch ( IOException e ) { return null ; } } public static IClassFileReader createDefaultClassFileReader ( String fileName , int decodingFlag ) { try { return new ClassFileReader ( Util . getFileByteContent ( new File ( fileName ) ) , decodingFlag ) ; } catch ( ClassFormatException e ) { return null ; } catch ( IOException e ) { return null ; } } public static IClassFileReader createDefaultClassFileReader ( String zipFileName , String zipEntryName , int decodingFlag ) { ZipFile zipFile = null ; try { if ( JavaModelManager . ZIP_ACCESS_VERBOSE ) { System . out . println ( "<STR_LIT:(>" + Thread . currentThread ( ) + "<STR_LIT>" + zipFileName ) ; } zipFile = new ZipFile ( zipFileName ) ; ZipEntry zipEntry = zipFile . getEntry ( zipEntryName ) ; if ( zipEntry == null ) { return null ; } if ( ! zipEntryName . toLowerCase ( ) . endsWith ( SuffixConstants . SUFFIX_STRING_class ) ) { return null ; } byte classFileBytes [ ] = Util . getZipEntryByteContent ( zipEntry , zipFile ) ; return new ClassFileReader ( classFileBytes , decodingFlag ) ; } catch ( ClassFormatException e ) { return null ; } catch ( IOException e ) { return null ; } finally { if ( zipFile != null ) { try { zipFile . close ( ) ; } catch ( IOException e ) { } } } } public static ICodeFormatter createDefaultCodeFormatter ( Map options ) { if ( options == null ) options = JavaCore . getOptions ( ) ; return new org . eclipse . jdt . internal . formatter . old . CodeFormatter ( options ) ; } public static IScanner createScanner ( boolean tokenizeComments , boolean tokenizeWhiteSpace , boolean assertMode , boolean recordLineSeparator ) { long complianceLevelValue = CompilerOptions . versionToJdkLevel ( JavaCore . getOption ( JavaCore . COMPILER_COMPLIANCE ) ) ; if ( complianceLevelValue == <NUM_LIT:0> ) complianceLevelValue = ClassFileConstants . JDK1_4 ; PublicScanner scanner = new PublicScanner ( tokenizeComments , tokenizeWhiteSpace , false , assertMode ? ClassFileConstants . JDK1_4 : ClassFileConstants . JDK1_3 , complianceLevelValue , null , null , true ) ; scanner . recordLineSeparator = recordLineSeparator ; return scanner ; } public static IScanner createScanner ( boolean tokenizeComments , boolean tokenizeWhiteSpace , boolean recordLineSeparator , String sourceLevel ) { long complianceLevelValue = CompilerOptions . versionToJdkLevel ( JavaCore . getOption ( JavaCore . COMPILER_COMPLIANCE ) ) ; if ( complianceLevelValue == <NUM_LIT:0> ) complianceLevelValue = ClassFileConstants . JDK1_4 ; long sourceLevelValue = CompilerOptions . versionToJdkLevel ( sourceLevel ) ; if ( sourceLevelValue == <NUM_LIT:0> ) sourceLevelValue = ClassFileConstants . JDK1_3 ; PublicScanner scanner = new PublicScanner ( tokenizeComments , tokenizeWhiteSpace , false , sourceLevelValue , complianceLevelValue , null , null , true ) ; scanner . recordLineSeparator = recordLineSeparator ; return scanner ; } public static IScanner createScanner ( boolean tokenizeComments , boolean tokenizeWhiteSpace , boolean recordLineSeparator , String sourceLevel , String complianceLevel ) { PublicScanner scanner = null ; long sourceLevelValue = CompilerOptions . versionToJdkLevel ( sourceLevel ) ; if ( sourceLevelValue == <NUM_LIT:0> ) sourceLevelValue = ClassFileConstants . JDK1_3 ; long complianceLevelValue = CompilerOptions . versionToJdkLevel ( complianceLevel ) ; if ( complianceLevelValue == <NUM_LIT:0> ) complianceLevelValue = ClassFileConstants . JDK1_4 ; scanner = new PublicScanner ( tokenizeComments , tokenizeWhiteSpace , false , sourceLevelValue , complianceLevelValue , null , null , true ) ; scanner . recordLineSeparator = recordLineSeparator ; return scanner ; } } </s>
|
<s> package org . eclipse . jdt . core ; public final class SourceRange implements ISourceRange { public static boolean isAvailable ( ISourceRange range ) { return range != null && range . getOffset ( ) != - <NUM_LIT:1> ; } private int offset ; private int length ; public SourceRange ( int offset , int length ) { this . offset = offset ; this . length = length ; } public boolean equals ( Object obj ) { if ( ! ( obj instanceof ISourceRange ) ) return false ; ISourceRange sourceRange = ( ISourceRange ) obj ; return sourceRange . getOffset ( ) == this . offset && sourceRange . getLength ( ) == this . length ; } public int getLength ( ) { return this . length ; } public int getOffset ( ) { return this . offset ; } public int hashCode ( ) { return this . length ^ this . offset ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . offset ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . length ) ; buffer . append ( "<STR_LIT:]>" ) ; return buffer . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IWorkspace ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; public interface IJavaModel extends IJavaElement , IOpenable , IParent { boolean contains ( IResource resource ) ; void copy ( IJavaElement [ ] elements , IJavaElement [ ] containers , IJavaElement [ ] siblings , String [ ] renamings , boolean replace , IProgressMonitor monitor ) throws JavaModelException ; void delete ( IJavaElement [ ] elements , boolean force , IProgressMonitor monitor ) throws JavaModelException ; IJavaProject getJavaProject ( String name ) ; IJavaProject [ ] getJavaProjects ( ) throws JavaModelException ; Object [ ] getNonJavaResources ( ) throws JavaModelException ; IWorkspace getWorkspace ( ) ; void move ( IJavaElement [ ] elements , IJavaElement [ ] containers , IJavaElement [ ] siblings , String [ ] renamings , boolean replace , IProgressMonitor monitor ) throws JavaModelException ; void refreshExternalArchives ( IJavaElement [ ] elementsScope , IProgressMonitor monitor ) throws JavaModelException ; void rename ( IJavaElement [ ] elements , IJavaElement [ ] destinations , String [ ] names , boolean replace , IProgressMonitor monitor ) throws JavaModelException ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface IClasspathAttribute { String JAVADOC_LOCATION_ATTRIBUTE_NAME = "<STR_LIT>" ; String OPTIONAL = "<STR_LIT>" ; String getName ( ) ; String getValue ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . resources . IMarker ; public interface ICodeCompletionRequestor { void acceptClass ( char [ ] packageName , char [ ] className , char [ ] completionName , int modifiers , int completionStart , int completionEnd ) ; void acceptError ( IMarker marker ) ; void acceptField ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] name , char [ ] typePackageName , char [ ] typeName , char [ ] completionName , int modifiers , int completionStart , int completionEnd ) ; void acceptInterface ( char [ ] packageName , char [ ] interfaceName , char [ ] completionName , int modifiers , int completionStart , int completionEnd ) ; void acceptKeyword ( char [ ] keywordName , int completionStart , int completionEnd ) ; void acceptLabel ( char [ ] labelName , int completionStart , int completionEnd ) ; void acceptLocalVariable ( char [ ] name , char [ ] typePackageName , char [ ] typeName , int modifiers , int completionStart , int completionEnd ) ; void acceptMethod ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] selector , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] returnTypePackageName , char [ ] returnTypeName , char [ ] completionName , int modifiers , int completionStart , int completionEnd ) ; void acceptModifier ( char [ ] modifierName , int completionStart , int completionEnd ) ; void acceptPackage ( char [ ] packageName , char [ ] completionName , int completionStart , int completionEnd ) ; void acceptType ( char [ ] packageName , char [ ] typeName , char [ ] completionName , int completionStart , int completionEnd ) ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface IAnnotation extends IJavaElement , ISourceReference { String getElementName ( ) ; IMemberValuePair [ ] getMemberValuePairs ( ) throws JavaModelException ; int getOccurrenceCount ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . runtime . IProgressMonitor ; public interface IOpenable { public void close ( ) throws JavaModelException ; public String findRecommendedLineSeparator ( ) throws JavaModelException ; public IBuffer getBuffer ( ) throws JavaModelException ; boolean hasUnsavedChanges ( ) throws JavaModelException ; boolean isConsistent ( ) throws JavaModelException ; boolean isOpen ( ) ; void makeConsistent ( IProgressMonitor progress ) throws JavaModelException ; public void open ( IProgressMonitor progress ) throws JavaModelException ; public void save ( IProgressMonitor progress , boolean force ) throws JavaModelException ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface ISourceRange { int getLength ( ) ; int getOffset ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . resources . IResourceDelta ; import org . eclipse . jdt . core . dom . CompilationUnit ; public interface IJavaElementDelta { public int ADDED = <NUM_LIT:1> ; public int REMOVED = <NUM_LIT:2> ; public int CHANGED = <NUM_LIT:4> ; public int F_CONTENT = <NUM_LIT> ; public int F_MODIFIERS = <NUM_LIT> ; public int F_CHILDREN = <NUM_LIT> ; public int F_MOVED_FROM = <NUM_LIT> ; public int F_MOVED_TO = <NUM_LIT> ; public int F_ADDED_TO_CLASSPATH = <NUM_LIT> ; public int F_REMOVED_FROM_CLASSPATH = <NUM_LIT> ; public int F_CLASSPATH_REORDER = <NUM_LIT> ; public int F_REORDER = <NUM_LIT> ; public int F_OPENED = <NUM_LIT> ; public int F_CLOSED = <NUM_LIT> ; public int F_SUPER_TYPES = <NUM_LIT> ; public int F_SOURCEATTACHED = <NUM_LIT> ; public int F_SOURCEDETACHED = <NUM_LIT> ; public int F_FINE_GRAINED = <NUM_LIT> ; public int F_ARCHIVE_CONTENT_CHANGED = <NUM_LIT> ; public int F_PRIMARY_WORKING_COPY = <NUM_LIT> ; public int F_CLASSPATH_CHANGED = <NUM_LIT> ; public int F_PRIMARY_RESOURCE = <NUM_LIT> ; public int F_AST_AFFECTED = <NUM_LIT> ; public int F_CATEGORIES = <NUM_LIT> ; public int F_RESOLVED_CLASSPATH_CHANGED = <NUM_LIT> ; public int F_ANNOTATIONS = <NUM_LIT> ; public IJavaElementDelta [ ] getAddedChildren ( ) ; public IJavaElementDelta [ ] getAffectedChildren ( ) ; public IJavaElementDelta [ ] getAnnotationDeltas ( ) ; public CompilationUnit getCompilationUnitAST ( ) ; public IJavaElementDelta [ ] getChangedChildren ( ) ; public IJavaElement getElement ( ) ; public int getFlags ( ) ; public int getKind ( ) ; public IJavaElement getMovedFromElement ( ) ; public IJavaElement getMovedToElement ( ) ; public IJavaElementDelta [ ] getRemovedChildren ( ) ; public IResourceDelta [ ] getResourceDeltas ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . internal . codeassist . InternalCompletionProposal ; public class CompletionProposal { public static final int ANONYMOUS_CLASS_DECLARATION = <NUM_LIT:1> ; public static final int FIELD_REF = <NUM_LIT:2> ; public static final int KEYWORD = <NUM_LIT:3> ; public static final int LABEL_REF = <NUM_LIT:4> ; public static final int LOCAL_VARIABLE_REF = <NUM_LIT:5> ; public static final int METHOD_REF = <NUM_LIT:6> ; public static final int METHOD_DECLARATION = <NUM_LIT:7> ; public static final int PACKAGE_REF = <NUM_LIT:8> ; public static final int TYPE_REF = <NUM_LIT:9> ; public static final int VARIABLE_DECLARATION = <NUM_LIT:10> ; public static final int POTENTIAL_METHOD_DECLARATION = <NUM_LIT:11> ; public static final int METHOD_NAME_REFERENCE = <NUM_LIT:12> ; public static final int ANNOTATION_ATTRIBUTE_REF = <NUM_LIT> ; public static final int JAVADOC_FIELD_REF = <NUM_LIT> ; public static final int JAVADOC_METHOD_REF = <NUM_LIT:15> ; public static final int JAVADOC_TYPE_REF = <NUM_LIT:16> ; public static final int JAVADOC_VALUE_REF = <NUM_LIT> ; public static final int JAVADOC_PARAM_REF = <NUM_LIT> ; public static final int JAVADOC_BLOCK_TAG = <NUM_LIT> ; public static final int JAVADOC_INLINE_TAG = <NUM_LIT:20> ; public static final int FIELD_IMPORT = <NUM_LIT> ; public static final int METHOD_IMPORT = <NUM_LIT> ; public static final int TYPE_IMPORT = <NUM_LIT> ; public static final int METHOD_REF_WITH_CASTED_RECEIVER = <NUM_LIT:24> ; public static final int FIELD_REF_WITH_CASTED_RECEIVER = <NUM_LIT> ; public static final int CONSTRUCTOR_INVOCATION = <NUM_LIT> ; public static final int ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION = <NUM_LIT> ; protected static final int FIRST_KIND = ANONYMOUS_CLASS_DECLARATION ; protected static final int LAST_KIND = ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION ; public static CompletionProposal create ( int kind , int completionOffset ) { return new InternalCompletionProposal ( kind , completionOffset ) ; } public int getAdditionalFlags ( ) { return - <NUM_LIT:1> ; } public void setAdditionalFlags ( int additionalFlags ) { } public int getKind ( ) { return - <NUM_LIT:1> ; } public int getCompletionLocation ( ) { return - <NUM_LIT:1> ; } public int getTokenStart ( ) { return - <NUM_LIT:1> ; } public int getTokenEnd ( ) { return - <NUM_LIT:1> ; } public void setTokenRange ( int startIndex , int endIndex ) { } public char [ ] getCompletion ( ) { return null ; } public void setCompletion ( char [ ] completion ) { } public int getReplaceStart ( ) { return - <NUM_LIT:1> ; } public int getReplaceEnd ( ) { return - <NUM_LIT:1> ; } public void setReplaceRange ( int startIndex , int endIndex ) { } public int getRelevance ( ) { return - <NUM_LIT:1> ; } public void setRelevance ( int rating ) { } public char [ ] getDeclarationSignature ( ) { return null ; } public char [ ] getDeclarationKey ( ) { return null ; } public void setDeclarationSignature ( char [ ] signature ) { } public void setDeclarationKey ( char [ ] key ) { } public char [ ] getName ( ) { return null ; } public void setName ( char [ ] name ) { } public char [ ] getSignature ( ) { return null ; } public char [ ] getKey ( ) { return null ; } public void setSignature ( char [ ] signature ) { } public void setKey ( char [ ] key ) { } public int getFlags ( ) { return - <NUM_LIT:1> ; } public void setFlags ( int flags ) { } public CompletionProposal [ ] getRequiredProposals ( ) { return null ; } public void setRequiredProposals ( CompletionProposal [ ] proposals ) { } public char [ ] [ ] findParameterNames ( IProgressMonitor monitor ) { return null ; } public void setParameterNames ( char [ ] [ ] parameterNames ) { } public int getAccessibility ( ) { return - <NUM_LIT:1> ; } public boolean isConstructor ( ) { return false ; } public char [ ] getReceiverSignature ( ) { return null ; } public int getReceiverStart ( ) { return - <NUM_LIT:1> ; } public int getReceiverEnd ( ) { return - <NUM_LIT:1> ; } public void setReceiverSignature ( char [ ] signature ) { } public void setReceiverRange ( int startIndex , int endIndex ) { } public boolean canUseDiamond ( CompletionContext coreContext ) { return false ; } } </s>
|
<s> package org . eclipse . jdt . core ; public interface IImportDeclaration extends IJavaElement , ISourceReference , ISourceManipulation { String getElementName ( ) ; int getFlags ( ) throws JavaModelException ; boolean isOnDemand ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface ITypeHierarchyChangedListener { void typeHierarchyChanged ( ITypeHierarchy typeHierarchy ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . jdt . core . compiler . IProblem ; public abstract class CompletionRequestor { private int ignoreSet = <NUM_LIT:0> ; private String [ ] favoriteReferences ; private int requiredProposalAllowSet [ ] = null ; private boolean requireExtendedContext = false ; public CompletionRequestor ( ) { this ( false ) ; } public CompletionRequestor ( boolean ignoreAll ) { this . ignoreSet = ignoreAll ? <NUM_LIT> : <NUM_LIT> ; } public boolean isIgnored ( int completionProposalKind ) { if ( completionProposalKind < CompletionProposal . FIRST_KIND || completionProposalKind > CompletionProposal . LAST_KIND ) { throw new IllegalArgumentException ( "<STR_LIT>" + completionProposalKind ) ; } return <NUM_LIT:0> != ( this . ignoreSet & ( <NUM_LIT:1> << completionProposalKind ) ) ; } public void setIgnored ( int completionProposalKind , boolean ignore ) { if ( completionProposalKind < CompletionProposal . FIRST_KIND || completionProposalKind > CompletionProposal . LAST_KIND ) { throw new IllegalArgumentException ( "<STR_LIT>" + completionProposalKind ) ; } if ( ignore ) { this . ignoreSet |= ( <NUM_LIT:1> << completionProposalKind ) ; } else { this . ignoreSet &= ~ ( <NUM_LIT:1> << completionProposalKind ) ; } } public boolean isAllowingRequiredProposals ( int proposalKind , int requiredProposalKind ) { if ( proposalKind < CompletionProposal . FIRST_KIND || proposalKind > CompletionProposal . LAST_KIND ) { throw new IllegalArgumentException ( "<STR_LIT>" + requiredProposalKind ) ; } if ( requiredProposalKind < CompletionProposal . FIRST_KIND || requiredProposalKind > CompletionProposal . LAST_KIND ) { throw new IllegalArgumentException ( "<STR_LIT>" + requiredProposalKind ) ; } if ( this . requiredProposalAllowSet == null ) return false ; return <NUM_LIT:0> != ( this . requiredProposalAllowSet [ proposalKind ] & ( <NUM_LIT:1> << requiredProposalKind ) ) ; } public void setAllowsRequiredProposals ( int proposalKind , int requiredProposalKind , boolean allow ) { if ( proposalKind < CompletionProposal . FIRST_KIND || proposalKind > CompletionProposal . LAST_KIND ) { throw new IllegalArgumentException ( "<STR_LIT>" + requiredProposalKind ) ; } if ( requiredProposalKind < CompletionProposal . FIRST_KIND || requiredProposalKind > CompletionProposal . LAST_KIND ) { throw new IllegalArgumentException ( "<STR_LIT>" + requiredProposalKind ) ; } if ( this . requiredProposalAllowSet == null ) { this . requiredProposalAllowSet = new int [ CompletionProposal . LAST_KIND + <NUM_LIT:1> ] ; } if ( allow ) { this . requiredProposalAllowSet [ proposalKind ] |= ( <NUM_LIT:1> << requiredProposalKind ) ; } else { this . requiredProposalAllowSet [ proposalKind ] &= ~ ( <NUM_LIT:1> << requiredProposalKind ) ; } } public String [ ] getFavoriteReferences ( ) { return this . favoriteReferences ; } public void setFavoriteReferences ( String [ ] favoriteImports ) { this . favoriteReferences = favoriteImports ; } public void beginReporting ( ) { } public void endReporting ( ) { } public void completionFailure ( IProblem problem ) { } public abstract void accept ( CompletionProposal proposal ) ; public void acceptContext ( CompletionContext context ) { } public boolean isExtendedContextRequired ( ) { return this . requireExtendedContext ; } public void setRequireExtendedContext ( boolean require ) { this . requireExtendedContext = require ; } } </s>
|
<s> package org . eclipse . jdt . core ; public interface IMethod extends IMember , IAnnotatable { IMemberValuePair getDefaultValue ( ) throws JavaModelException ; String getElementName ( ) ; String [ ] getExceptionTypes ( ) throws JavaModelException ; String [ ] getTypeParameterSignatures ( ) throws JavaModelException ; ITypeParameter [ ] getTypeParameters ( ) throws JavaModelException ; int getNumberOfParameters ( ) ; ILocalVariable [ ] getParameters ( ) throws JavaModelException ; String getKey ( ) ; String [ ] getParameterNames ( ) throws JavaModelException ; String [ ] getParameterTypes ( ) ; String [ ] getRawParameterNames ( ) throws JavaModelException ; String getReturnType ( ) throws JavaModelException ; String getSignature ( ) throws JavaModelException ; ITypeParameter getTypeParameter ( String name ) ; boolean isConstructor ( ) throws JavaModelException ; boolean isMainMethod ( ) throws JavaModelException ; boolean isResolved ( ) ; boolean isSimilar ( IMethod method ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . jdt . core . compiler . IProblem ; public class CompletionRequestorAdapter implements ICompletionRequestor { public void acceptAnonymousType ( char [ ] superTypePackageName , char [ ] superTypeName , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] [ ] parameterNames , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) { } public void acceptClass ( char [ ] packageName , char [ ] className , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) { } public void acceptError ( IProblem error ) { } public void acceptField ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] name , char [ ] typePackageName , char [ ] typeName , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) { } public void acceptInterface ( char [ ] packageName , char [ ] interfaceName , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) { } public void acceptKeyword ( char [ ] keywordName , int completionStart , int completionEnd , int relevance ) { } public void acceptLabel ( char [ ] labelName , int completionStart , int completionEnd , int relevance ) { } public void acceptLocalVariable ( char [ ] name , char [ ] typePackageName , char [ ] typeName , int modifiers , int completionStart , int completionEnd , int relevance ) { } public void acceptMethod ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] selector , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] [ ] parameterNames , char [ ] returnTypePackageName , char [ ] returnTypeName , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) { } public void acceptMethodDeclaration ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] selector , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] [ ] parameterNames , char [ ] returnTypePackageName , char [ ] returnTypeName , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) { } public void acceptModifier ( char [ ] modifierName , int completionStart , int completionEnd , int relevance ) { } public void acceptPackage ( char [ ] packageName , char [ ] completionName , int completionStart , int completionEnd , int relevance ) { } public void acceptType ( char [ ] packageName , char [ ] typeName , char [ ] completionName , int completionStart , int completionEnd , int relevance ) { } public void acceptVariableName ( char [ ] typePackageName , char [ ] typeName , char [ ] name , char [ ] completionName , int completionStart , int completionEnd , int relevance ) { } } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . resources . IStorage ; import org . eclipse . core . runtime . IPath ; public interface IJarEntryResource extends IStorage { IJarEntryResource [ ] getChildren ( ) ; IPath getFullPath ( ) ; Object getParent ( ) ; IPackageFragmentRoot getPackageFragmentRoot ( ) ; boolean isFile ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface ICorrectionRequestor { void acceptClass ( char [ ] packageName , char [ ] className , char [ ] correctionName , int modifiers , int correctionStart , int correctionEnd ) ; void acceptField ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] name , char [ ] typePackageName , char [ ] typeName , char [ ] correctionName , int modifiers , int correctionStart , int correctionEnd ) ; void acceptInterface ( char [ ] packageName , char [ ] interfaceName , char [ ] correctionName , int modifiers , int correctionStart , int correctionEnd ) ; void acceptLocalVariable ( char [ ] name , char [ ] typePackageName , char [ ] typeName , int modifiers , int correctionStart , int correctionEnd ) ; void acceptMethod ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] selector , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] [ ] parameterNames , char [ ] returnTypePackageName , char [ ] returnTypeName , char [ ] correctionName , int modifiers , int correctionStart , int correctionEnd ) ; void acceptPackage ( char [ ] packageName , char [ ] correctionName , int correctionStart , int correctionEnd ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import java . util . StringTokenizer ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IWorkspace ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . Status ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; import org . eclipse . jdt . internal . core . * ; import org . eclipse . jdt . internal . core . util . Messages ; public final class JavaConventions { private static final char DOT = '<CHAR_LIT:.>' ; private static final String PACKAGE_INFO = new String ( TypeConstants . PACKAGE_INFO_NAME ) ; private static final Scanner SCANNER = new Scanner ( false , true , false , ClassFileConstants . JDK1_3 , null , null , true ) ; private JavaConventions ( ) { } public static boolean isOverlappingRoots ( IPath rootPath1 , IPath rootPath2 ) { if ( rootPath1 == null || rootPath2 == null ) { return false ; } return rootPath1 . isPrefixOf ( rootPath2 ) || rootPath2 . isPrefixOf ( rootPath1 ) ; } private static synchronized char [ ] scannedIdentifier ( String id , String sourceLevel , String complianceLevel ) { if ( id == null ) { return null ; } SCANNER . sourceLevel = sourceLevel == null ? ClassFileConstants . JDK1_3 : CompilerOptions . versionToJdkLevel ( sourceLevel ) ; SCANNER . complianceLevel = complianceLevel == null ? ClassFileConstants . JDK1_3 : CompilerOptions . versionToJdkLevel ( complianceLevel ) ; try { SCANNER . setSource ( id . toCharArray ( ) ) ; int token = SCANNER . scanIdentifier ( ) ; if ( token != TerminalTokens . TokenNameIdentifier ) return null ; if ( SCANNER . currentPosition == SCANNER . eofPosition ) { try { return SCANNER . getCurrentIdentifierSource ( ) ; } catch ( ArrayIndexOutOfBoundsException e ) { return null ; } } else { return null ; } } catch ( InvalidInputException e ) { return null ; } } public static IStatus validateCompilationUnitName ( String name ) { return validateCompilationUnitName ( name , CompilerOptions . VERSION_1_3 , CompilerOptions . VERSION_1_3 ) ; } public static IStatus validateCompilationUnitName ( String name , String sourceLevel , String complianceLevel ) { if ( name == null ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_unit_nullName , null ) ; } if ( ! org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( name ) ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_unit_notJavaName , null ) ; } String identifier ; int index ; index = name . lastIndexOf ( '<CHAR_LIT:.>' ) ; if ( index == - <NUM_LIT:1> ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_unit_notJavaName , null ) ; } identifier = name . substring ( <NUM_LIT:0> , index ) ; if ( ! identifier . equals ( PACKAGE_INFO ) ) { IStatus status = validateIdentifier ( identifier , sourceLevel , complianceLevel ) ; if ( ! status . isOK ( ) ) { return status ; } } IStatus status = ResourcesPlugin . getWorkspace ( ) . validateName ( name , IResource . FILE ) ; if ( ! status . isOK ( ) ) { return status ; } return JavaModelStatus . VERIFIED_OK ; } public static IStatus validateClassFileName ( String name ) { return validateClassFileName ( name , CompilerOptions . VERSION_1_3 , CompilerOptions . VERSION_1_3 ) ; } public static IStatus validateClassFileName ( String name , String sourceLevel , String complianceLevel ) { if ( name == null ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_classFile_nullName , null ) ; } if ( ! org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( name ) ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_classFile_notClassFileName , null ) ; } String identifier ; int index ; index = name . lastIndexOf ( '<CHAR_LIT:.>' ) ; if ( index == - <NUM_LIT:1> ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_classFile_notClassFileName , null ) ; } identifier = name . substring ( <NUM_LIT:0> , index ) ; if ( ! identifier . equals ( PACKAGE_INFO ) ) { IStatus status = validateIdentifier ( identifier , sourceLevel , complianceLevel ) ; if ( ! status . isOK ( ) ) { return status ; } } IStatus status = ResourcesPlugin . getWorkspace ( ) . validateName ( name , IResource . FILE ) ; if ( ! status . isOK ( ) ) { return status ; } return JavaModelStatus . VERIFIED_OK ; } public static IStatus validateFieldName ( String name ) { return validateIdentifier ( name , CompilerOptions . VERSION_1_3 , CompilerOptions . VERSION_1_3 ) ; } public static IStatus validateFieldName ( String name , String sourceLevel , String complianceLevel ) { return validateIdentifier ( name , sourceLevel , complianceLevel ) ; } public static IStatus validateIdentifier ( String id ) { return validateIdentifier ( id , CompilerOptions . VERSION_1_3 , CompilerOptions . VERSION_1_3 ) ; } public static IStatus validateIdentifier ( String id , String sourceLevel , String complianceLevel ) { if ( scannedIdentifier ( id , sourceLevel , complianceLevel ) != null ) { return JavaModelStatus . VERIFIED_OK ; } else { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . bind ( Messages . convention_illegalIdentifier , id ) , null ) ; } } public static IStatus validateImportDeclaration ( String name ) { return validateImportDeclaration ( name , CompilerOptions . VERSION_1_3 , CompilerOptions . VERSION_1_3 ) ; } public static IStatus validateImportDeclaration ( String name , String sourceLevel , String complianceLevel ) { if ( name == null || name . length ( ) == <NUM_LIT:0> ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_import_nullImport , null ) ; } if ( name . charAt ( name . length ( ) - <NUM_LIT:1> ) == '<CHAR_LIT>' ) { if ( name . charAt ( name . length ( ) - <NUM_LIT:2> ) == '<CHAR_LIT:.>' ) { return validatePackageName ( name . substring ( <NUM_LIT:0> , name . length ( ) - <NUM_LIT:2> ) , sourceLevel , complianceLevel ) ; } else { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_import_unqualifiedImport , null ) ; } } return validatePackageName ( name , sourceLevel , complianceLevel ) ; } public static IStatus validateJavaTypeName ( String name ) { return validateJavaTypeName ( name , JavaCore . VERSION_1_3 , JavaCore . VERSION_1_3 ) ; } public static IStatus validateJavaTypeName ( String name , String sourceLevel , String complianceLevel ) { if ( name == null ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_type_nullName , null ) ; } String trimmed = name . trim ( ) ; if ( ! name . equals ( trimmed ) ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_type_nameWithBlanks , null ) ; } int index = name . lastIndexOf ( '<CHAR_LIT:.>' ) ; char [ ] scannedID ; if ( index == - <NUM_LIT:1> ) { scannedID = scannedIdentifier ( name , sourceLevel , complianceLevel ) ; } else { String pkg = name . substring ( <NUM_LIT:0> , index ) . trim ( ) ; IStatus status = validatePackageName ( pkg , sourceLevel , complianceLevel ) ; if ( ! status . isOK ( ) ) { return status ; } String type = name . substring ( index + <NUM_LIT:1> ) . trim ( ) ; scannedID = scannedIdentifier ( type , sourceLevel , complianceLevel ) ; } if ( scannedID != null ) { IStatus status = ResourcesPlugin . getWorkspace ( ) . validateName ( new String ( scannedID ) , IResource . FILE ) ; if ( ! status . isOK ( ) ) { return status ; } if ( CharOperation . contains ( '<CHAR_LIT>' , scannedID ) ) { return new Status ( IStatus . WARNING , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_type_dollarName , null ) ; } if ( ( scannedID . length > <NUM_LIT:0> && ScannerHelper . isLowerCase ( scannedID [ <NUM_LIT:0> ] ) ) ) { return new Status ( IStatus . WARNING , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_type_lowercaseName , null ) ; } return JavaModelStatus . VERIFIED_OK ; } else { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . bind ( Messages . convention_type_invalidName , name ) , null ) ; } } public static IStatus validateMethodName ( String name ) { return validateMethodName ( name , CompilerOptions . VERSION_1_3 , CompilerOptions . VERSION_1_3 ) ; } public static IStatus validateMethodName ( String name , String sourceLevel , String complianceLevel ) { return validateIdentifier ( name , sourceLevel , complianceLevel ) ; } public static IStatus validatePackageName ( String name ) { return validatePackageName ( name , CompilerOptions . VERSION_1_3 , CompilerOptions . VERSION_1_3 ) ; } public static IStatus validatePackageName ( String name , String sourceLevel , String complianceLevel ) { if ( name == null ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_package_nullName , null ) ; } int length ; if ( ( length = name . length ( ) ) == <NUM_LIT:0> ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_package_emptyName , null ) ; } if ( name . charAt ( <NUM_LIT:0> ) == DOT || name . charAt ( length - <NUM_LIT:1> ) == DOT ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_package_dotName , null ) ; } if ( CharOperation . isWhitespace ( name . charAt ( <NUM_LIT:0> ) ) || CharOperation . isWhitespace ( name . charAt ( name . length ( ) - <NUM_LIT:1> ) ) ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_package_nameWithBlanks , null ) ; } int dot = <NUM_LIT:0> ; while ( dot != - <NUM_LIT:1> && dot < length - <NUM_LIT:1> ) { if ( ( dot = name . indexOf ( DOT , dot + <NUM_LIT:1> ) ) != - <NUM_LIT:1> && dot < length - <NUM_LIT:1> && name . charAt ( dot + <NUM_LIT:1> ) == DOT ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_package_consecutiveDotsName , null ) ; } } IWorkspace workspace = ResourcesPlugin . getWorkspace ( ) ; StringTokenizer st = new StringTokenizer ( name , "<STR_LIT:.>" ) ; boolean firstToken = true ; IStatus warningStatus = null ; while ( st . hasMoreTokens ( ) ) { String typeName = st . nextToken ( ) ; typeName = typeName . trim ( ) ; char [ ] scannedID = scannedIdentifier ( typeName , sourceLevel , complianceLevel ) ; if ( scannedID == null ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . bind ( Messages . convention_illegalIdentifier , typeName ) , null ) ; } IStatus status = workspace . validateName ( new String ( scannedID ) , IResource . FOLDER ) ; if ( ! status . isOK ( ) ) { return status ; } if ( firstToken && scannedID . length > <NUM_LIT:0> && ScannerHelper . isUpperCase ( scannedID [ <NUM_LIT:0> ] ) ) { if ( warningStatus == null ) { warningStatus = new Status ( IStatus . WARNING , JavaCore . PLUGIN_ID , - <NUM_LIT:1> , Messages . convention_package_uppercaseName , null ) ; } } firstToken = false ; } if ( warningStatus != null ) { return warningStatus ; } return JavaModelStatus . VERIFIED_OK ; } public static IJavaModelStatus validateClasspath ( IJavaProject javaProject , IClasspathEntry [ ] rawClasspath , IPath projectOutputLocation ) { return ClasspathEntry . validateClasspath ( javaProject , rawClasspath , projectOutputLocation ) ; } public static IJavaModelStatus validateClasspathEntry ( IJavaProject project , IClasspathEntry entry , boolean checkSourceAttachment ) { return ClasspathEntry . validateClasspathEntry ( project , entry , checkSourceAttachment , false ) ; } public static IStatus validateTypeVariableName ( String name ) { return validateIdentifier ( name , CompilerOptions . VERSION_1_3 , CompilerOptions . VERSION_1_3 ) ; } public static IStatus validateTypeVariableName ( String name , String sourceLevel , String complianceLevel ) { return validateIdentifier ( name , sourceLevel , complianceLevel ) ; } } </s>
|
<s> package org . eclipse . jdt . core ; import java . util . EventObject ; public class BufferChangedEvent extends EventObject { private int length ; private int offset ; private String text ; private static final long serialVersionUID = <NUM_LIT> ; public BufferChangedEvent ( IBuffer buffer , int offset , int length , String text ) { super ( buffer ) ; this . offset = offset ; this . length = length ; this . text = text ; } public IBuffer getBuffer ( ) { return ( IBuffer ) this . source ; } public int getLength ( ) { return this . length ; } public int getOffset ( ) { return this . offset ; } public String getText ( ) { return this . text ; } } </s>
|
<s> package org . eclipse . jdt . core ; public class CompletionContext { public static final int TL_MEMBER_START = <NUM_LIT:1> ; public static final int TL_STATEMENT_START = <NUM_LIT:2> ; public static final int TOKEN_KIND_UNKNOWN = <NUM_LIT:0> ; public static final int TOKEN_KIND_NAME = <NUM_LIT:1> ; public static final int TOKEN_KIND_STRING_LITERAL = <NUM_LIT:2> ; public boolean isInJavadoc ( ) { return false ; } public boolean isInJavadocText ( ) { return false ; } public boolean isInJavadocFormalReference ( ) { return false ; } public boolean isExtended ( ) { return false ; } public char [ ] [ ] getExpectedTypesSignatures ( ) { return null ; } public char [ ] [ ] getExpectedTypesKeys ( ) { return null ; } public char [ ] getToken ( ) { return null ; } public int getTokenKind ( ) { return - <NUM_LIT:1> ; } public int getTokenLocation ( ) { return - <NUM_LIT:1> ; } public int getTokenStart ( ) { return - <NUM_LIT:1> ; } public int getTokenEnd ( ) { return - <NUM_LIT:1> ; } public int getOffset ( ) { return - <NUM_LIT:1> ; } public IJavaElement getEnclosingElement ( ) { return null ; } public IJavaElement [ ] getVisibleElements ( String typeSignature ) { return null ; } } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . core . INamingRequestor ; import org . eclipse . jdt . internal . core . InternalNamingConventions ; public final class NamingConventions { static class NamingRequestor implements INamingRequestor { private final static int SIZE = <NUM_LIT:10> ; private char [ ] [ ] firstPrefixAndFirstSuffixResults = new char [ SIZE ] [ ] ; private int firstPrefixAndFirstSuffixResultsCount = <NUM_LIT:0> ; private char [ ] [ ] firstPrefixAndSuffixResults = new char [ SIZE ] [ ] ; private int firstPrefixAndSuffixResultsCount = <NUM_LIT:0> ; private char [ ] [ ] prefixAndFirstSuffixResults = new char [ SIZE ] [ ] ; private int prefixAndFirstSuffixResultsCount = <NUM_LIT:0> ; private char [ ] [ ] prefixAndSuffixResults = new char [ SIZE ] [ ] ; private int prefixAndSuffixResultsCount = <NUM_LIT:0> ; private char [ ] [ ] firstPrefixResults = new char [ SIZE ] [ ] ; private int firstPrefixResultsCount = <NUM_LIT:0> ; private char [ ] [ ] prefixResults = new char [ SIZE ] [ ] ; private int prefixResultsCount = <NUM_LIT:0> ; private char [ ] [ ] firstSuffixResults = new char [ SIZE ] [ ] ; private int firstSuffixResultsCount = <NUM_LIT:0> ; private char [ ] [ ] suffixResults = new char [ SIZE ] [ ] ; private int suffixResultsCount = <NUM_LIT:0> ; private char [ ] [ ] otherResults = new char [ SIZE ] [ ] ; private int otherResultsCount = <NUM_LIT:0> ; public void acceptNameWithoutPrefixAndSuffix ( char [ ] name , int reusedCharacters ) { int length = this . otherResults . length ; if ( length == this . otherResultsCount ) { System . arraycopy ( this . otherResults , <NUM_LIT:0> , this . otherResults = new char [ length * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , length ) ; } this . otherResults [ this . otherResultsCount ++ ] = name ; } public void acceptNameWithPrefix ( char [ ] name , boolean isFirstPrefix , int reusedCharacters ) { if ( isFirstPrefix ) { int length = this . firstPrefixResults . length ; if ( length == this . firstPrefixResultsCount ) { System . arraycopy ( this . firstPrefixResults , <NUM_LIT:0> , this . firstPrefixResults = new char [ length * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , length ) ; } this . firstPrefixResults [ this . firstPrefixResultsCount ++ ] = name ; } else { int length = this . prefixResults . length ; if ( length == this . prefixResultsCount ) { System . arraycopy ( this . prefixResults , <NUM_LIT:0> , this . prefixResults = new char [ length * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , length ) ; } this . prefixResults [ this . prefixResultsCount ++ ] = name ; } } public void acceptNameWithPrefixAndSuffix ( char [ ] name , boolean isFirstPrefix , boolean isFirstSuffix , int reusedCharacters ) { if ( isFirstPrefix && isFirstSuffix ) { int length = this . firstPrefixAndFirstSuffixResults . length ; if ( length == this . firstPrefixAndFirstSuffixResultsCount ) { System . arraycopy ( this . firstPrefixAndFirstSuffixResults , <NUM_LIT:0> , this . firstPrefixAndFirstSuffixResults = new char [ length * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , length ) ; } this . firstPrefixAndFirstSuffixResults [ this . firstPrefixAndFirstSuffixResultsCount ++ ] = name ; } else if ( isFirstPrefix ) { int length = this . firstPrefixAndSuffixResults . length ; if ( length == this . firstPrefixAndSuffixResultsCount ) { System . arraycopy ( this . firstPrefixAndSuffixResults , <NUM_LIT:0> , this . firstPrefixAndSuffixResults = new char [ length * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , length ) ; } this . firstPrefixAndSuffixResults [ this . firstPrefixAndSuffixResultsCount ++ ] = name ; } else if ( isFirstSuffix ) { int length = this . prefixAndFirstSuffixResults . length ; if ( length == this . prefixAndFirstSuffixResultsCount ) { System . arraycopy ( this . prefixAndFirstSuffixResults , <NUM_LIT:0> , this . prefixAndFirstSuffixResults = new char [ length * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , length ) ; } this . prefixAndFirstSuffixResults [ this . prefixAndFirstSuffixResultsCount ++ ] = name ; } else { int length = this . prefixAndSuffixResults . length ; if ( length == this . prefixAndSuffixResultsCount ) { System . arraycopy ( this . prefixAndSuffixResults , <NUM_LIT:0> , this . prefixAndSuffixResults = new char [ length * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , length ) ; } this . prefixAndSuffixResults [ this . prefixAndSuffixResultsCount ++ ] = name ; } } public void acceptNameWithSuffix ( char [ ] name , boolean isFirstSuffix , int reusedCharacters ) { if ( isFirstSuffix ) { int length = this . firstSuffixResults . length ; if ( length == this . firstSuffixResultsCount ) { System . arraycopy ( this . firstSuffixResults , <NUM_LIT:0> , this . firstSuffixResults = new char [ length * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , length ) ; } this . firstSuffixResults [ this . firstSuffixResultsCount ++ ] = name ; } else { int length = this . suffixResults . length ; if ( length == this . suffixResultsCount ) { System . arraycopy ( this . suffixResults , <NUM_LIT:0> , this . suffixResults = new char [ length * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , length ) ; } this . suffixResults [ this . suffixResultsCount ++ ] = name ; } } public char [ ] [ ] getResults ( ) { int count = this . firstPrefixAndFirstSuffixResultsCount + this . firstPrefixAndSuffixResultsCount + this . prefixAndFirstSuffixResultsCount + this . prefixAndSuffixResultsCount + this . firstPrefixResultsCount + this . prefixResultsCount + this . firstSuffixResultsCount + this . suffixResultsCount + this . otherResultsCount ; char [ ] [ ] results = new char [ count ] [ ] ; int index = <NUM_LIT:0> ; System . arraycopy ( this . firstPrefixAndFirstSuffixResults , <NUM_LIT:0> , results , index , this . firstPrefixAndFirstSuffixResultsCount ) ; index += this . firstPrefixAndFirstSuffixResultsCount ; System . arraycopy ( this . firstPrefixAndSuffixResults , <NUM_LIT:0> , results , index , this . firstPrefixAndSuffixResultsCount ) ; index += this . firstPrefixAndSuffixResultsCount ; System . arraycopy ( this . prefixAndFirstSuffixResults , <NUM_LIT:0> , results , index , this . prefixAndFirstSuffixResultsCount ) ; index += this . prefixAndFirstSuffixResultsCount ; System . arraycopy ( this . prefixAndSuffixResults , <NUM_LIT:0> , results , index , this . prefixAndSuffixResultsCount ) ; index += this . prefixAndSuffixResultsCount ; System . arraycopy ( this . firstPrefixResults , <NUM_LIT:0> , results , index , this . firstPrefixResultsCount ) ; index += this . firstPrefixResultsCount ; System . arraycopy ( this . prefixResults , <NUM_LIT:0> , results , index , this . prefixResultsCount ) ; index += this . prefixResultsCount ; System . arraycopy ( this . firstSuffixResults , <NUM_LIT:0> , results , index , this . firstSuffixResultsCount ) ; index += this . firstSuffixResultsCount ; System . arraycopy ( this . suffixResults , <NUM_LIT:0> , results , index , this . suffixResultsCount ) ; index += this . suffixResultsCount ; System . arraycopy ( this . otherResults , <NUM_LIT:0> , results , index , this . otherResultsCount ) ; return results ; } } private static final char [ ] GETTER_BOOL_NAME = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] GETTER_NAME = "<STR_LIT:get>" . toCharArray ( ) ; private static final char [ ] SETTER_NAME = "<STR_LIT>" . toCharArray ( ) ; public static final int VK_STATIC_FIELD = InternalNamingConventions . VK_STATIC_FIELD ; public static final int VK_INSTANCE_FIELD = InternalNamingConventions . VK_INSTANCE_FIELD ; public static final int VK_STATIC_FINAL_FIELD = InternalNamingConventions . VK_STATIC_FINAL_FIELD ; public static final int VK_PARAMETER = InternalNamingConventions . VK_PARAMETER ; public static final int VK_LOCAL = InternalNamingConventions . VK_LOCAL ; public static final int BK_NAME = InternalNamingConventions . BK_SIMPLE_NAME ; public static final int BK_TYPE_NAME = InternalNamingConventions . BK_SIMPLE_TYPE_NAME ; private static String [ ] convertCharsToString ( char [ ] [ ] c ) { int length = c == null ? <NUM_LIT:0> : c . length ; String [ ] s = new String [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { s [ i ] = String . valueOf ( c [ i ] ) ; } return s ; } private static char [ ] [ ] convertStringToChars ( String [ ] s ) { int length = s == null ? <NUM_LIT:0> : s . length ; char [ ] [ ] c = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( s [ i ] == null ) { c [ i ] = CharOperation . NO_CHAR ; } else { c [ i ] = s [ i ] . toCharArray ( ) ; } } return c ; } public static char [ ] removePrefixAndSuffixForArgumentName ( IJavaProject javaProject , char [ ] argumentName ) { return InternalNamingConventions . removeVariablePrefixAndSuffix ( VK_PARAMETER , javaProject , argumentName ) ; } public static String removePrefixAndSuffixForArgumentName ( IJavaProject javaProject , String argumentName ) { return String . valueOf ( removePrefixAndSuffixForArgumentName ( javaProject , argumentName . toCharArray ( ) ) ) ; } public static char [ ] removePrefixAndSuffixForFieldName ( IJavaProject javaProject , char [ ] fieldName , int modifiers ) { return InternalNamingConventions . removeVariablePrefixAndSuffix ( Flags . isStatic ( modifiers ) ? VK_STATIC_FIELD : VK_INSTANCE_FIELD , javaProject , fieldName ) ; } public static String removePrefixAndSuffixForFieldName ( IJavaProject javaProject , String fieldName , int modifiers ) { return String . valueOf ( removePrefixAndSuffixForFieldName ( javaProject , fieldName . toCharArray ( ) , modifiers ) ) ; } public static char [ ] removePrefixAndSuffixForLocalVariableName ( IJavaProject javaProject , char [ ] localName ) { return InternalNamingConventions . removeVariablePrefixAndSuffix ( VK_LOCAL , javaProject , localName ) ; } public static String removePrefixAndSuffixForLocalVariableName ( IJavaProject javaProject , String localName ) { return String . valueOf ( removePrefixAndSuffixForLocalVariableName ( javaProject , localName . toCharArray ( ) ) ) ; } public static String getBaseName ( int variableKind , String variableName , IJavaProject javaProject ) { return String . valueOf ( InternalNamingConventions . getBaseName ( variableKind , javaProject , variableName . toCharArray ( ) , true ) ) ; } private static int getFieldVariableKind ( int modifiers ) { if ( Flags . isStatic ( modifiers ) ) { if ( Flags . isFinal ( modifiers ) ) { return VK_STATIC_FINAL_FIELD ; } return VK_STATIC_FIELD ; } return VK_INSTANCE_FIELD ; } private static char [ ] suggestAccessorName ( IJavaProject project , char [ ] fieldName , int modifiers ) { char [ ] name = InternalNamingConventions . getBaseName ( getFieldVariableKind ( modifiers ) , project , fieldName , false ) ; if ( name . length > <NUM_LIT:0> && ScannerHelper . isLowerCase ( name [ <NUM_LIT:0> ] ) ) { if ( name . length == <NUM_LIT:1> || ! ScannerHelper . isUpperCase ( name [ <NUM_LIT:1> ] ) ) { name [ <NUM_LIT:0> ] = ScannerHelper . toUpperCase ( name [ <NUM_LIT:0> ] ) ; } } return name ; } public static char [ ] [ ] suggestArgumentNames ( IJavaProject javaProject , char [ ] packageName , char [ ] qualifiedTypeName , int dim , char [ ] [ ] excludedNames ) { if ( qualifiedTypeName == null || qualifiedTypeName . length == <NUM_LIT:0> ) return CharOperation . NO_CHAR_CHAR ; char [ ] typeName = CharOperation . lastSegment ( qualifiedTypeName , '<CHAR_LIT:.>' ) ; NamingRequestor requestor = new NamingRequestor ( ) ; InternalNamingConventions . suggestVariableNames ( VK_PARAMETER , BK_TYPE_NAME , typeName , javaProject , dim , null , excludedNames , true , requestor ) ; return requestor . getResults ( ) ; } public static String [ ] suggestArgumentNames ( IJavaProject javaProject , String packageName , String qualifiedTypeName , int dim , String [ ] excludedNames ) { return convertCharsToString ( suggestArgumentNames ( javaProject , packageName . toCharArray ( ) , qualifiedTypeName . toCharArray ( ) , dim , convertStringToChars ( excludedNames ) ) ) ; } public static char [ ] [ ] suggestFieldNames ( IJavaProject javaProject , char [ ] packageName , char [ ] qualifiedTypeName , int dim , int modifiers , char [ ] [ ] excludedNames ) { if ( qualifiedTypeName == null || qualifiedTypeName . length == <NUM_LIT:0> ) return CharOperation . NO_CHAR_CHAR ; char [ ] typeName = CharOperation . lastSegment ( qualifiedTypeName , '<CHAR_LIT:.>' ) ; NamingRequestor requestor = new NamingRequestor ( ) ; InternalNamingConventions . suggestVariableNames ( Flags . isStatic ( modifiers ) ? VK_STATIC_FIELD : VK_INSTANCE_FIELD , BK_TYPE_NAME , typeName , javaProject , dim , null , excludedNames , true , requestor ) ; return requestor . getResults ( ) ; } public static String [ ] suggestFieldNames ( IJavaProject javaProject , String packageName , String qualifiedTypeName , int dim , int modifiers , String [ ] excludedNames ) { return convertCharsToString ( suggestFieldNames ( javaProject , packageName . toCharArray ( ) , qualifiedTypeName . toCharArray ( ) , dim , modifiers , convertStringToChars ( excludedNames ) ) ) ; } public static char [ ] suggestGetterName ( IJavaProject project , char [ ] fieldName , int modifiers , boolean isBoolean , char [ ] [ ] excludedNames ) { if ( isBoolean ) { char [ ] name = InternalNamingConventions . getBaseName ( getFieldVariableKind ( modifiers ) , project , fieldName , false ) ; int prefixLen = GETTER_BOOL_NAME . length ; if ( CharOperation . prefixEquals ( GETTER_BOOL_NAME , name ) && name . length > prefixLen && ScannerHelper . isUpperCase ( name [ prefixLen ] ) ) { return suggestNewName ( name , excludedNames ) ; } else { return suggestNewName ( CharOperation . concat ( GETTER_BOOL_NAME , suggestAccessorName ( project , fieldName , modifiers ) ) , excludedNames ) ; } } else { return suggestNewName ( CharOperation . concat ( GETTER_NAME , suggestAccessorName ( project , fieldName , modifiers ) ) , excludedNames ) ; } } public static String suggestGetterName ( IJavaProject project , String fieldName , int modifiers , boolean isBoolean , String [ ] excludedNames ) { return String . valueOf ( suggestGetterName ( project , fieldName . toCharArray ( ) , modifiers , isBoolean , convertStringToChars ( excludedNames ) ) ) ; } public static char [ ] [ ] suggestLocalVariableNames ( IJavaProject javaProject , char [ ] packageName , char [ ] qualifiedTypeName , int dim , char [ ] [ ] excludedNames ) { if ( qualifiedTypeName == null || qualifiedTypeName . length == <NUM_LIT:0> ) return CharOperation . NO_CHAR_CHAR ; char [ ] typeName = CharOperation . lastSegment ( qualifiedTypeName , '<CHAR_LIT:.>' ) ; NamingRequestor requestor = new NamingRequestor ( ) ; InternalNamingConventions . suggestVariableNames ( VK_LOCAL , BK_TYPE_NAME , typeName , javaProject , dim , null , excludedNames , true , requestor ) ; return requestor . getResults ( ) ; } public static String [ ] suggestLocalVariableNames ( IJavaProject javaProject , String packageName , String qualifiedTypeName , int dim , String [ ] excludedNames ) { return convertCharsToString ( suggestLocalVariableNames ( javaProject , packageName . toCharArray ( ) , qualifiedTypeName . toCharArray ( ) , dim , convertStringToChars ( excludedNames ) ) ) ; } private static char [ ] suggestNewName ( char [ ] name , char [ ] [ ] excludedNames ) { if ( excludedNames == null ) { return name ; } char [ ] newName = name ; int count = <NUM_LIT:2> ; int i = <NUM_LIT:0> ; while ( i < excludedNames . length ) { if ( CharOperation . equals ( newName , excludedNames [ i ] , false ) ) { newName = CharOperation . concat ( name , String . valueOf ( count ++ ) . toCharArray ( ) ) ; i = <NUM_LIT:0> ; } else { i ++ ; } } return newName ; } public static char [ ] suggestSetterName ( IJavaProject project , char [ ] fieldName , int modifiers , boolean isBoolean , char [ ] [ ] excludedNames ) { if ( isBoolean ) { char [ ] name = InternalNamingConventions . getBaseName ( getFieldVariableKind ( modifiers ) , project , fieldName , false ) ; int prefixLen = GETTER_BOOL_NAME . length ; if ( CharOperation . prefixEquals ( GETTER_BOOL_NAME , name ) && name . length > prefixLen && ScannerHelper . isUpperCase ( name [ prefixLen ] ) ) { name = CharOperation . subarray ( name , prefixLen , name . length ) ; return suggestNewName ( CharOperation . concat ( SETTER_NAME , suggestAccessorName ( project , name , modifiers ) ) , excludedNames ) ; } else { return suggestNewName ( CharOperation . concat ( SETTER_NAME , suggestAccessorName ( project , fieldName , modifiers ) ) , excludedNames ) ; } } else { return suggestNewName ( CharOperation . concat ( SETTER_NAME , suggestAccessorName ( project , fieldName , modifiers ) ) , excludedNames ) ; } } public static String suggestSetterName ( IJavaProject project , String fieldName , int modifiers , boolean isBoolean , String [ ] excludedNames ) { return String . valueOf ( suggestSetterName ( project , fieldName . toCharArray ( ) , modifiers , isBoolean , convertStringToChars ( excludedNames ) ) ) ; } public static String [ ] suggestVariableNames ( int variableKind , int baseNameKind , String baseName , IJavaProject javaProject , int dim , String [ ] excluded , boolean evaluateDefault ) { NamingRequestor requestor = new NamingRequestor ( ) ; InternalNamingConventions . suggestVariableNames ( variableKind , baseNameKind , baseName . toCharArray ( ) , javaProject , dim , null , convertStringToChars ( excluded ) , evaluateDefault , requestor ) ; return convertCharsToString ( requestor . getResults ( ) ) ; } private NamingConventions ( ) { } } </s>
|
<s> package org . eclipse . jdt . core ; public abstract class ClasspathVariableInitializer { public ClasspathVariableInitializer ( ) { } public abstract void initialize ( String variable ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . runtime . IPath ; public interface IClasspathEntry { int CPE_LIBRARY = <NUM_LIT:1> ; int CPE_PROJECT = <NUM_LIT:2> ; int CPE_SOURCE = <NUM_LIT:3> ; int CPE_VARIABLE = <NUM_LIT:4> ; int CPE_CONTAINER = <NUM_LIT:5> ; boolean combineAccessRules ( ) ; IAccessRule [ ] getAccessRules ( ) ; int getContentKind ( ) ; int getEntryKind ( ) ; IPath [ ] getExclusionPatterns ( ) ; IClasspathAttribute [ ] getExtraAttributes ( ) ; IPath [ ] getInclusionPatterns ( ) ; IPath getOutputLocation ( ) ; IPath getPath ( ) ; IPath getSourceAttachmentPath ( ) ; IPath getSourceAttachmentRootPath ( ) ; IClasspathEntry getReferencingEntry ( ) ; boolean isExported ( ) ; IClasspathEntry getResolvedEntry ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . internal . core . JavaModelStatus ; public abstract class ClasspathContainerInitializer { public static final int ATTRIBUTE_NOT_SUPPORTED = <NUM_LIT:1> ; public static final int ATTRIBUTE_READ_ONLY = <NUM_LIT:2> ; public ClasspathContainerInitializer ( ) { } public abstract void initialize ( IPath containerPath , IJavaProject project ) throws CoreException ; public boolean canUpdateClasspathContainer ( IPath containerPath , IJavaProject project ) { return false ; } public void requestClasspathContainerUpdate ( IPath containerPath , IJavaProject project , IClasspathContainer containerSuggestion ) throws CoreException { } public String getDescription ( IPath containerPath , IJavaProject project ) { return containerPath . makeRelative ( ) . toString ( ) ; } public IClasspathContainer getFailureContainer ( final IPath containerPath , IJavaProject project ) { final String description = getDescription ( containerPath , project ) ; return new IClasspathContainer ( ) { public IClasspathEntry [ ] getClasspathEntries ( ) { return new IClasspathEntry [ <NUM_LIT:0> ] ; } public String getDescription ( ) { return description ; } public int getKind ( ) { return <NUM_LIT:0> ; } public IPath getPath ( ) { return containerPath ; } public String toString ( ) { return getDescription ( ) ; } } ; } public Object getComparisonID ( IPath containerPath , IJavaProject project ) { if ( containerPath == null ) { return null ; } else { return containerPath . segment ( <NUM_LIT:0> ) ; } } public IStatus getAccessRulesStatus ( IPath containerPath , IJavaProject project ) { if ( canUpdateClasspathContainer ( containerPath , project ) ) { return Status . OK_STATUS ; } return new JavaModelStatus ( ATTRIBUTE_READ_ONLY ) ; } public IStatus getAttributeStatus ( IPath containerPath , IJavaProject project , String attributeKey ) { if ( canUpdateClasspathContainer ( containerPath , project ) ) { return Status . OK_STATUS ; } return new JavaModelStatus ( ATTRIBUTE_READ_ONLY ) ; } public IStatus getSourceAttachmentStatus ( IPath containerPath , IJavaProject project ) { if ( canUpdateClasspathContainer ( containerPath , project ) ) { return Status . OK_STATUS ; } return new JavaModelStatus ( ATTRIBUTE_READ_ONLY ) ; } } </s>
|
<s> package org . eclipse . jdt . core ; import java . io . InputStream ; import org . eclipse . core . runtime . IProgressMonitor ; public interface IType extends IMember , IAnnotatable { void codeComplete ( char [ ] snippet , int insertion , int position , char [ ] [ ] localVariableTypeNames , char [ ] [ ] localVariableNames , int [ ] localVariableModifiers , boolean isStatic , ICompletionRequestor requestor ) throws JavaModelException ; void codeComplete ( char [ ] snippet , int insertion , int position , char [ ] [ ] localVariableTypeNames , char [ ] [ ] localVariableNames , int [ ] localVariableModifiers , boolean isStatic , ICompletionRequestor requestor , WorkingCopyOwner owner ) throws JavaModelException ; void codeComplete ( char [ ] snippet , int insertion , int position , char [ ] [ ] localVariableTypeNames , char [ ] [ ] localVariableNames , int [ ] localVariableModifiers , boolean isStatic , CompletionRequestor requestor ) throws JavaModelException ; void codeComplete ( char [ ] snippet , int insertion , int position , char [ ] [ ] localVariableTypeNames , char [ ] [ ] localVariableNames , int [ ] localVariableModifiers , boolean isStatic , CompletionRequestor requestor , IProgressMonitor monitor ) throws JavaModelException ; void codeComplete ( char [ ] snippet , int insertion , int position , char [ ] [ ] localVariableTypeNames , char [ ] [ ] localVariableNames , int [ ] localVariableModifiers , boolean isStatic , CompletionRequestor requestor , WorkingCopyOwner owner ) throws JavaModelException ; void codeComplete ( char [ ] snippet , int insertion , int position , char [ ] [ ] localVariableTypeNames , char [ ] [ ] localVariableNames , int [ ] localVariableModifiers , boolean isStatic , CompletionRequestor requestor , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException ; IField createField ( String contents , IJavaElement sibling , boolean force , IProgressMonitor monitor ) throws JavaModelException ; IInitializer createInitializer ( String contents , IJavaElement sibling , IProgressMonitor monitor ) throws JavaModelException ; IMethod createMethod ( String contents , IJavaElement sibling , boolean force , IProgressMonitor monitor ) throws JavaModelException ; IType createType ( String contents , IJavaElement sibling , boolean force , IProgressMonitor monitor ) throws JavaModelException ; IMethod [ ] findMethods ( IMethod method ) ; IJavaElement [ ] getChildrenForCategory ( String category ) throws JavaModelException ; String getElementName ( ) ; IField getField ( String name ) ; IField [ ] getFields ( ) throws JavaModelException ; String getFullyQualifiedName ( ) ; String getFullyQualifiedName ( char enclosingTypeSeparator ) ; String getFullyQualifiedParameterizedName ( ) throws JavaModelException ; IInitializer getInitializer ( int occurrenceCount ) ; IInitializer [ ] getInitializers ( ) throws JavaModelException ; String getKey ( ) ; IMethod getMethod ( String name , String [ ] parameterTypeSignatures ) ; IMethod [ ] getMethods ( ) throws JavaModelException ; IPackageFragment getPackageFragment ( ) ; String getSuperclassName ( ) throws JavaModelException ; String getSuperclassTypeSignature ( ) throws JavaModelException ; String [ ] getSuperInterfaceTypeSignatures ( ) throws JavaModelException ; String [ ] getSuperInterfaceNames ( ) throws JavaModelException ; String [ ] getTypeParameterSignatures ( ) throws JavaModelException ; ITypeParameter [ ] getTypeParameters ( ) throws JavaModelException ; IType getType ( String name ) ; ITypeParameter getTypeParameter ( String name ) ; String getTypeQualifiedName ( ) ; String getTypeQualifiedName ( char enclosingTypeSeparator ) ; IType [ ] getTypes ( ) throws JavaModelException ; boolean isAnonymous ( ) throws JavaModelException ; boolean isClass ( ) throws JavaModelException ; boolean isEnum ( ) throws JavaModelException ; boolean isInterface ( ) throws JavaModelException ; boolean isAnnotation ( ) throws JavaModelException ; boolean isLocal ( ) throws JavaModelException ; boolean isMember ( ) throws JavaModelException ; boolean isResolved ( ) ; ITypeHierarchy loadTypeHierachy ( InputStream input , IProgressMonitor monitor ) throws JavaModelException ; ITypeHierarchy newSupertypeHierarchy ( IProgressMonitor monitor ) throws JavaModelException ; ITypeHierarchy newSupertypeHierarchy ( ICompilationUnit [ ] workingCopies , IProgressMonitor monitor ) throws JavaModelException ; ITypeHierarchy newSupertypeHierarchy ( IWorkingCopy [ ] workingCopies , IProgressMonitor monitor ) throws JavaModelException ; ITypeHierarchy newSupertypeHierarchy ( WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException ; ITypeHierarchy newTypeHierarchy ( IJavaProject project , IProgressMonitor monitor ) throws JavaModelException ; ITypeHierarchy newTypeHierarchy ( IJavaProject project , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException ; ITypeHierarchy newTypeHierarchy ( IProgressMonitor monitor ) throws JavaModelException ; ITypeHierarchy newTypeHierarchy ( ICompilationUnit [ ] workingCopies , IProgressMonitor monitor ) throws JavaModelException ; ITypeHierarchy newTypeHierarchy ( IWorkingCopy [ ] workingCopies , IProgressMonitor monitor ) throws JavaModelException ; ITypeHierarchy newTypeHierarchy ( WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException ; String [ ] [ ] resolveType ( String typeName ) throws JavaModelException ; String [ ] [ ] resolveType ( String typeName , WorkingCopyOwner owner ) throws JavaModelException ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . jdt . core . compiler . IProblem ; public interface ICompletionRequestor { void acceptAnonymousType ( char [ ] superTypePackageName , char [ ] superTypeName , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] [ ] parameterNames , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) ; void acceptClass ( char [ ] packageName , char [ ] className , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) ; void acceptError ( IProblem error ) ; void acceptField ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] name , char [ ] typePackageName , char [ ] typeName , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) ; void acceptInterface ( char [ ] packageName , char [ ] interfaceName , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) ; void acceptKeyword ( char [ ] keywordName , int completionStart , int completionEnd , int relevance ) ; void acceptLabel ( char [ ] labelName , int completionStart , int completionEnd , int relevance ) ; void acceptLocalVariable ( char [ ] name , char [ ] typePackageName , char [ ] typeName , int modifiers , int completionStart , int completionEnd , int relevance ) ; void acceptMethod ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] selector , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] [ ] parameterNames , char [ ] returnTypePackageName , char [ ] returnTypeName , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) ; void acceptMethodDeclaration ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] selector , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] [ ] parameterNames , char [ ] returnTypePackageName , char [ ] returnTypeName , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) ; void acceptModifier ( char [ ] modifierName , int completionStart , int completionEnd , int relevance ) ; void acceptPackage ( char [ ] packageName , char [ ] completionName , int completionStart , int completionEnd , int relevance ) ; void acceptType ( char [ ] packageName , char [ ] typeName , char [ ] completionName , int completionStart , int completionEnd , int relevance ) ; void acceptVariableName ( char [ ] typePackageName , char [ ] typeName , char [ ] name , char [ ] completionName , int completionStart , int completionEnd , int relevance ) ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface IAnnotatable { IAnnotation getAnnotation ( String name ) ; IAnnotation [ ] getAnnotations ( ) throws JavaModelException ; } </s>
|
<s> package org . eclipse . jdt . core ; import java . io . OutputStream ; import org . eclipse . core . runtime . IProgressMonitor ; public interface ITypeHierarchy { void addTypeHierarchyChangedListener ( ITypeHierarchyChangedListener listener ) ; boolean contains ( IType type ) ; boolean exists ( ) ; IType [ ] getAllClasses ( ) ; IType [ ] getAllInterfaces ( ) ; IType [ ] getAllSubtypes ( IType type ) ; IType [ ] getAllSuperclasses ( IType type ) ; IType [ ] getAllSuperInterfaces ( IType type ) ; IType [ ] getAllSupertypes ( IType type ) ; IType [ ] getAllTypes ( ) ; int getCachedFlags ( IType type ) ; IType [ ] getExtendingInterfaces ( IType type ) ; IType [ ] getImplementingClasses ( IType type ) ; IType [ ] getRootClasses ( ) ; IType [ ] getRootInterfaces ( ) ; IType [ ] getSubclasses ( IType type ) ; IType [ ] getSubtypes ( IType type ) ; IType getSuperclass ( IType type ) ; IType [ ] getSuperInterfaces ( IType type ) ; IType [ ] getSupertypes ( IType type ) ; IType getType ( ) ; void refresh ( IProgressMonitor monitor ) throws JavaModelException ; void removeTypeHierarchyChangedListener ( ITypeHierarchyChangedListener listener ) ; void store ( OutputStream outputStream , IProgressMonitor monitor ) throws JavaModelException ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface ILocalVariable extends IJavaElement , ISourceReference , IAnnotatable { String getElementName ( ) ; ISourceRange getNameRange ( ) ; String getTypeSignature ( ) ; boolean isParameter ( ) ; int getFlags ( ) ; IMember getDeclaringMember ( ) ; ITypeRoot getTypeRoot ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IStatus ; public interface IJavaModelStatus extends IStatus { IJavaElement [ ] getElements ( ) ; IPath getPath ( ) ; String getString ( ) ; boolean isDoesNotExist ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . runtime . IProgressMonitor ; public interface ISourceManipulation { void copy ( IJavaElement container , IJavaElement sibling , String rename , boolean replace , IProgressMonitor monitor ) throws JavaModelException ; void delete ( boolean force , IProgressMonitor monitor ) throws JavaModelException ; void move ( IJavaElement container , IJavaElement sibling , String rename , boolean replace , IProgressMonitor monitor ) throws JavaModelException ; void rename ( String name , boolean replace , IProgressMonitor monitor ) throws JavaModelException ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . runtime . IPath ; public interface IClasspathContainer { int K_APPLICATION = <NUM_LIT:1> ; int K_SYSTEM = <NUM_LIT:2> ; int K_DEFAULT_SYSTEM = <NUM_LIT:3> ; IClasspathEntry [ ] getClasspathEntries ( ) ; String getDescription ( ) ; int getKind ( ) ; IPath getPath ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import java . util . Map ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . dom . IAnnotationBinding ; import org . eclipse . jdt . core . dom . IMethodBinding ; import org . eclipse . jdt . core . dom . IPackageBinding ; import org . eclipse . jdt . core . dom . ITypeBinding ; import org . eclipse . jdt . core . dom . IVariableBinding ; import org . eclipse . jdt . core . eval . IEvaluationContext ; public interface IJavaProject extends IParent , IJavaElement , IOpenable { String CLASSPATH_FILE_NAME = "<STR_LIT>" ; IClasspathEntry decodeClasspathEntry ( String encodedEntry ) ; String encodeClasspathEntry ( IClasspathEntry classpathEntry ) ; IJavaElement findElement ( IPath path ) throws JavaModelException ; IJavaElement findElement ( IPath path , WorkingCopyOwner owner ) throws JavaModelException ; IJavaElement findElement ( String bindingKey , WorkingCopyOwner owner ) throws JavaModelException ; IPackageFragment findPackageFragment ( IPath path ) throws JavaModelException ; IPackageFragmentRoot findPackageFragmentRoot ( IPath path ) throws JavaModelException ; IPackageFragmentRoot [ ] findPackageFragmentRoots ( IClasspathEntry entry ) ; IType findType ( String fullyQualifiedName ) throws JavaModelException ; IType findType ( String fullyQualifiedName , IProgressMonitor progressMonitor ) throws JavaModelException ; IType findType ( String fullyQualifiedName , WorkingCopyOwner owner ) throws JavaModelException ; IType findType ( String fullyQualifiedName , WorkingCopyOwner owner , IProgressMonitor progressMonitor ) throws JavaModelException ; IType findType ( String packageName , String typeQualifiedName ) throws JavaModelException ; IType findType ( String packageName , String typeQualifiedName , IProgressMonitor progressMonitor ) throws JavaModelException ; IType findType ( String packageName , String typeQualifiedName , WorkingCopyOwner owner ) throws JavaModelException ; IType findType ( String packageName , String typeQualifiedName , WorkingCopyOwner owner , IProgressMonitor progressMonitor ) throws JavaModelException ; IPackageFragmentRoot [ ] getAllPackageFragmentRoots ( ) throws JavaModelException ; Object [ ] getNonJavaResources ( ) throws JavaModelException ; String getOption ( String optionName , boolean inheritJavaCoreOptions ) ; Map getOptions ( boolean inheritJavaCoreOptions ) ; IPath getOutputLocation ( ) throws JavaModelException ; IPackageFragmentRoot getPackageFragmentRoot ( String externalLibraryPath ) ; IPackageFragmentRoot getPackageFragmentRoot ( IResource resource ) ; IPackageFragmentRoot [ ] getPackageFragmentRoots ( ) throws JavaModelException ; IPackageFragmentRoot [ ] getPackageFragmentRoots ( IClasspathEntry entry ) ; IPackageFragment [ ] getPackageFragments ( ) throws JavaModelException ; IProject getProject ( ) ; IClasspathEntry [ ] getRawClasspath ( ) throws JavaModelException ; String [ ] getRequiredProjectNames ( ) throws JavaModelException ; IClasspathEntry [ ] getResolvedClasspath ( boolean ignoreUnresolvedEntry ) throws JavaModelException ; boolean hasBuildState ( ) ; boolean hasClasspathCycle ( IClasspathEntry [ ] entries ) ; boolean isOnClasspath ( IJavaElement element ) ; boolean isOnClasspath ( IResource resource ) ; IEvaluationContext newEvaluationContext ( ) ; ITypeHierarchy newTypeHierarchy ( IRegion region , IProgressMonitor monitor ) throws JavaModelException ; ITypeHierarchy newTypeHierarchy ( IRegion region , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException ; ITypeHierarchy newTypeHierarchy ( IType type , IRegion region , IProgressMonitor monitor ) throws JavaModelException ; ITypeHierarchy newTypeHierarchy ( IType type , IRegion region , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException ; IPath readOutputLocation ( ) ; IClasspathEntry [ ] readRawClasspath ( ) ; void setOption ( String optionName , String optionValue ) ; void setOptions ( Map newOptions ) ; void setOutputLocation ( IPath path , IProgressMonitor monitor ) throws JavaModelException ; void setRawClasspath ( IClasspathEntry [ ] entries , IPath outputLocation , boolean canModifyResources , IProgressMonitor monitor ) throws JavaModelException ; void setRawClasspath ( IClasspathEntry [ ] entries , boolean canModifyResources , IProgressMonitor monitor ) throws JavaModelException ; void setRawClasspath ( IClasspathEntry [ ] entries , IClasspathEntry [ ] referencedEntries , IPath outputLocation , IProgressMonitor monitor ) throws JavaModelException ; IClasspathEntry [ ] getReferencedClasspathEntries ( ) throws JavaModelException ; void setRawClasspath ( IClasspathEntry [ ] entries , IProgressMonitor monitor ) throws JavaModelException ; void setRawClasspath ( IClasspathEntry [ ] entries , IPath outputLocation , IProgressMonitor monitor ) throws JavaModelException ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface IJavaModelStatusConstants { public static final int INVALID_CP_CONTAINER_ENTRY = <NUM_LIT> ; public static final int CP_CONTAINER_PATH_UNBOUND = <NUM_LIT> ; public static final int INVALID_CLASSPATH = <NUM_LIT> ; public static final int CP_VARIABLE_PATH_UNBOUND = <NUM_LIT> ; public static final int CORE_EXCEPTION = <NUM_LIT> ; public static final int INVALID_ELEMENT_TYPES = <NUM_LIT> ; public static final int NO_ELEMENTS_TO_PROCESS = <NUM_LIT> ; public static final int ELEMENT_DOES_NOT_EXIST = <NUM_LIT> ; public static final int NULL_PATH = <NUM_LIT> ; public static final int PATH_OUTSIDE_PROJECT = <NUM_LIT> ; public static final int RELATIVE_PATH = <NUM_LIT> ; public static final int DEVICE_PATH = <NUM_LIT> ; public static final int NULL_STRING = <NUM_LIT> ; public static final int READ_ONLY = <NUM_LIT> ; public static final int NAME_COLLISION = <NUM_LIT> ; public static final int INVALID_DESTINATION = <NUM_LIT> ; public static final int INVALID_PATH = <NUM_LIT> ; public static final int INDEX_OUT_OF_BOUNDS = <NUM_LIT> ; public static final int UPDATE_CONFLICT = <NUM_LIT> ; public static final int NULL_NAME = <NUM_LIT> ; public static final int INVALID_NAME = <NUM_LIT> ; public static final int INVALID_CONTENTS = <NUM_LIT> ; public static final int IO_EXCEPTION = <NUM_LIT> ; public static final int DOM_EXCEPTION = <NUM_LIT> ; public static final int TARGET_EXCEPTION = <NUM_LIT> ; public static final int BUILDER_INITIALIZATION_ERROR = <NUM_LIT> ; public static final int BUILDER_SERIALIZATION_ERROR = <NUM_LIT> ; public static final int EVALUATION_ERROR = <NUM_LIT> ; public static final int INVALID_SIBLING = <NUM_LIT> ; public static final int INVALID_RESOURCE = <NUM_LIT> ; public static final int INVALID_RESOURCE_TYPE = <NUM_LIT> ; public static final int INVALID_PROJECT = <NUM_LIT> ; public static final int INVALID_PACKAGE = <NUM_LIT> ; public static final int NO_LOCAL_CONTENTS = <NUM_LIT> ; public static final int INVALID_CLASSPATH_FILE_FORMAT = <NUM_LIT:1000> ; public static final int CLASSPATH_CYCLE = <NUM_LIT> ; public static final int DISABLED_CP_EXCLUSION_PATTERNS = <NUM_LIT> ; public static final int DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS = <NUM_LIT> ; public static final int INCOMPATIBLE_JDK_LEVEL = <NUM_LIT> ; public static final int COMPILER_FAILURE = <NUM_LIT> ; public static final int ELEMENT_NOT_ON_CLASSPATH = <NUM_LIT> ; public static final int CANNOT_RETRIEVE_ATTACHED_JAVADOC = <NUM_LIT> ; public static final int UNKNOWN_JAVADOC_FORMAT = <NUM_LIT> ; public static final int DEPRECATED_VARIABLE = <NUM_LIT> ; public static final int BAD_TEXT_EDIT_LOCATION = <NUM_LIT> ; public static final int CANNOT_RETRIEVE_ATTACHED_JAVADOC_TIMEOUT = <NUM_LIT> ; public static final int OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE = <NUM_LIT> ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface IRegion { void add ( IJavaElement element ) ; boolean contains ( IJavaElement element ) ; IJavaElement [ ] getElements ( ) ; boolean remove ( IJavaElement element ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . runtime . IPath ; public interface IAccessRule { int K_ACCESSIBLE = <NUM_LIT:0> ; int K_NON_ACCESSIBLE = <NUM_LIT:1> ; int K_DISCOURAGED = <NUM_LIT:2> ; int IGNORE_IF_BETTER = <NUM_LIT> ; IPath getPattern ( ) ; int getKind ( ) ; boolean ignoreIfBetter ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface IMember extends IJavaElement , ISourceReference , ISourceManipulation , IParent { String [ ] getCategories ( ) throws JavaModelException ; IClassFile getClassFile ( ) ; ICompilationUnit getCompilationUnit ( ) ; IType getDeclaringType ( ) ; int getFlags ( ) throws JavaModelException ; ISourceRange getJavadocRange ( ) throws JavaModelException ; int getOccurrenceCount ( ) ; ITypeRoot getTypeRoot ( ) ; IType getType ( String name , int occurrenceCount ) ; boolean isBinary ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import java . util . EventObject ; public class ElementChangedEvent extends EventObject { public static final int POST_CHANGE = <NUM_LIT:1> ; public static final int PRE_AUTO_BUILD = <NUM_LIT:2> ; public static final int POST_RECONCILE = <NUM_LIT:4> ; private static final long serialVersionUID = - <NUM_LIT> ; private int type ; public ElementChangedEvent ( IJavaElementDelta delta , int type ) { super ( delta ) ; this . type = type ; } public IJavaElementDelta getDelta ( ) { return ( IJavaElementDelta ) this . source ; } public int getType ( ) { return this . type ; } } </s>
|
<s> package org . eclipse . jdt . core ; public interface ICodeFormatter { String format ( String string , int indentationLevel , int [ ] positions , String lineSeparator ) ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface IBufferChangedListener { public void bufferChanged ( BufferChangedEvent event ) ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface IElementChangedListener { public void elementChanged ( ElementChangedEvent event ) ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface IMemberValuePair { int K_INT = <NUM_LIT:1> ; int K_BYTE = <NUM_LIT:2> ; int K_SHORT = <NUM_LIT:3> ; int K_CHAR = <NUM_LIT:4> ; int K_FLOAT = <NUM_LIT:5> ; int K_DOUBLE = <NUM_LIT:6> ; int K_LONG = <NUM_LIT:7> ; int K_BOOLEAN = <NUM_LIT:8> ; int K_STRING = <NUM_LIT:9> ; int K_ANNOTATION = <NUM_LIT:10> ; int K_CLASS = <NUM_LIT:11> ; int K_QUALIFIED_NAME = <NUM_LIT:12> ; int K_SIMPLE_NAME = <NUM_LIT> ; int K_UNKNOWN = <NUM_LIT> ; String getMemberName ( ) ; Object getValue ( ) ; int getValueKind ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . runtime . IProgressMonitor ; public interface IClassFile extends ITypeRoot { ICompilationUnit becomeWorkingCopy ( IProblemRequestor problemRequestor , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException ; byte [ ] getBytes ( ) throws JavaModelException ; IType getType ( ) ; IJavaElement getWorkingCopy ( IProgressMonitor monitor , IBufferFactory factory ) throws JavaModelException ; boolean isClass ( ) throws JavaModelException ; boolean isInterface ( ) throws JavaModelException ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . dom . ASTParser ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . core . dom . AST ; import org . eclipse . jdt . core . dom . IBinding ; import org . eclipse . text . edits . TextEdit ; import org . eclipse . text . edits . UndoEdit ; public interface ICompilationUnit extends ITypeRoot , IWorkingCopy , ISourceManipulation { public static final int NO_AST = <NUM_LIT:0> ; public static final int FORCE_PROBLEM_DETECTION = <NUM_LIT> ; public static final int ENABLE_STATEMENTS_RECOVERY = <NUM_LIT> ; public static final int ENABLE_BINDINGS_RECOVERY = <NUM_LIT> ; public static final int IGNORE_METHOD_BODIES = <NUM_LIT> ; public UndoEdit applyTextEdit ( TextEdit edit , IProgressMonitor monitor ) throws JavaModelException ; void becomeWorkingCopy ( IProblemRequestor problemRequestor , IProgressMonitor monitor ) throws JavaModelException ; void becomeWorkingCopy ( IProgressMonitor monitor ) throws JavaModelException ; void commitWorkingCopy ( boolean force , IProgressMonitor monitor ) throws JavaModelException ; IImportDeclaration createImport ( String name , IJavaElement sibling , IProgressMonitor monitor ) throws JavaModelException ; IImportDeclaration createImport ( String name , IJavaElement sibling , int flags , IProgressMonitor monitor ) throws JavaModelException ; IPackageDeclaration createPackageDeclaration ( String name , IProgressMonitor monitor ) throws JavaModelException ; IType createType ( String contents , IJavaElement sibling , boolean force , IProgressMonitor monitor ) throws JavaModelException ; void discardWorkingCopy ( ) throws JavaModelException ; IJavaElement [ ] findElements ( IJavaElement element ) ; ICompilationUnit findWorkingCopy ( WorkingCopyOwner owner ) ; IType [ ] getAllTypes ( ) throws JavaModelException ; IImportDeclaration getImport ( String name ) ; IImportContainer getImportContainer ( ) ; IImportDeclaration [ ] getImports ( ) throws JavaModelException ; ICompilationUnit getPrimary ( ) ; WorkingCopyOwner getOwner ( ) ; IPackageDeclaration getPackageDeclaration ( String name ) ; IPackageDeclaration [ ] getPackageDeclarations ( ) throws JavaModelException ; IType getType ( String name ) ; IType [ ] getTypes ( ) throws JavaModelException ; ICompilationUnit getWorkingCopy ( IProgressMonitor monitor ) throws JavaModelException ; ICompilationUnit getWorkingCopy ( WorkingCopyOwner owner , IProblemRequestor problemRequestor , IProgressMonitor monitor ) throws JavaModelException ; public boolean hasResourceChanged ( ) ; boolean isWorkingCopy ( ) ; CompilationUnit reconcile ( int astLevel , boolean forceProblemDetection , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException ; CompilationUnit reconcile ( int astLevel , boolean forceProblemDetection , boolean enableStatementsRecovery , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException ; CompilationUnit reconcile ( int astLevel , int reconcileFlags , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException ; void restore ( ) throws JavaModelException ; } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . HashMap ; import java . util . Iterator ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModel ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . util . Util ; public class SetVariablesOperation extends ChangeClasspathOperation { String [ ] variableNames ; IPath [ ] variablePaths ; boolean updatePreferences ; public SetVariablesOperation ( String [ ] variableNames , IPath [ ] variablePaths , boolean updatePreferences ) { super ( new IJavaElement [ ] { JavaModelManager . getJavaModelManager ( ) . getJavaModel ( ) } , ! ResourcesPlugin . getWorkspace ( ) . isTreeLocked ( ) ) ; this . variableNames = variableNames ; this . variablePaths = variablePaths ; this . updatePreferences = updatePreferences ; } protected void executeOperation ( ) throws JavaModelException { checkCanceled ( ) ; try { beginTask ( "<STR_LIT>" , <NUM_LIT:1> ) ; if ( JavaModelManager . CP_RESOLVE_VERBOSE ) verbose_set_variables ( ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; if ( manager . variablePutIfInitializingWithSameValue ( this . variableNames , this . variablePaths ) ) return ; int varLength = this . variableNames . length ; final HashMap affectedProjectClasspaths = new HashMap ( <NUM_LIT:5> ) ; IJavaModel model = getJavaModel ( ) ; int discardCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < varLength ; i ++ ) { String variableName = this . variableNames [ i ] ; IPath oldPath = manager . variableGet ( variableName ) ; if ( oldPath == JavaModelManager . VARIABLE_INITIALIZATION_IN_PROGRESS ) { oldPath = null ; } if ( oldPath != null && oldPath . equals ( this . variablePaths [ i ] ) ) { this . variableNames [ i ] = null ; discardCount ++ ; } } if ( discardCount > <NUM_LIT:0> ) { if ( discardCount == varLength ) return ; int changedLength = varLength - discardCount ; String [ ] changedVariableNames = new String [ changedLength ] ; IPath [ ] changedVariablePaths = new IPath [ changedLength ] ; for ( int i = <NUM_LIT:0> , index = <NUM_LIT:0> ; i < varLength ; i ++ ) { if ( this . variableNames [ i ] != null ) { changedVariableNames [ index ] = this . variableNames [ i ] ; changedVariablePaths [ index ] = this . variablePaths [ i ] ; index ++ ; } } this . variableNames = changedVariableNames ; this . variablePaths = changedVariablePaths ; varLength = changedLength ; } if ( isCanceled ( ) ) return ; IJavaProject [ ] projects = model . getJavaProjects ( ) ; nextProject : for ( int i = <NUM_LIT:0> , projectLength = projects . length ; i < projectLength ; i ++ ) { JavaProject project = ( JavaProject ) projects [ i ] ; IClasspathEntry [ ] classpath = project . getRawClasspath ( ) ; for ( int j = <NUM_LIT:0> , cpLength = classpath . length ; j < cpLength ; j ++ ) { IClasspathEntry entry = classpath [ j ] ; for ( int k = <NUM_LIT:0> ; k < varLength ; k ++ ) { String variableName = this . variableNames [ k ] ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_VARIABLE ) { if ( variableName . equals ( entry . getPath ( ) . segment ( <NUM_LIT:0> ) ) ) { affectedProjectClasspaths . put ( project , project . getResolvedClasspath ( ) ) ; continue nextProject ; } IPath sourcePath , sourceRootPath ; if ( ( ( sourcePath = entry . getSourceAttachmentPath ( ) ) != null && variableName . equals ( sourcePath . segment ( <NUM_LIT:0> ) ) ) || ( ( sourceRootPath = entry . getSourceAttachmentRootPath ( ) ) != null && variableName . equals ( sourceRootPath . segment ( <NUM_LIT:0> ) ) ) ) { affectedProjectClasspaths . put ( project , project . getResolvedClasspath ( ) ) ; continue nextProject ; } } } } } for ( int i = <NUM_LIT:0> ; i < varLength ; i ++ ) { manager . variablePut ( this . variableNames [ i ] , this . variablePaths [ i ] ) ; if ( this . updatePreferences ) manager . variablePreferencesPut ( this . variableNames [ i ] , this . variablePaths [ i ] ) ; } if ( ! affectedProjectClasspaths . isEmpty ( ) ) { String [ ] dbgVariableNames = this . variableNames ; try { Iterator projectsToUpdate = affectedProjectClasspaths . keySet ( ) . iterator ( ) ; while ( projectsToUpdate . hasNext ( ) ) { if ( this . progressMonitor != null && this . progressMonitor . isCanceled ( ) ) return ; JavaProject affectedProject = ( JavaProject ) projectsToUpdate . next ( ) ; if ( JavaModelManager . CP_RESOLVE_VERBOSE_ADVANCED ) verbose_update_project ( dbgVariableNames , affectedProject ) ; ClasspathChange classpathChange = affectedProject . getPerProjectInfo ( ) . resetResolvedClasspath ( ) ; classpathChanged ( classpathChange , true ) ; if ( this . canChangeResources ) { affectedProject . getProject ( ) . touch ( this . progressMonitor ) ; } } } catch ( CoreException e ) { if ( JavaModelManager . CP_RESOLVE_VERBOSE || JavaModelManager . CP_RESOLVE_VERBOSE_FAILURE ) { verbose_failure ( dbgVariableNames ) ; e . printStackTrace ( ) ; } if ( e instanceof JavaModelException ) { throw ( JavaModelException ) e ; } else { throw new JavaModelException ( e ) ; } } } } finally { done ( ) ; } } private void verbose_failure ( String [ ] dbgVariableNames ) { Util . verbose ( "<STR_LIT>" + "<STR_LIT>" + org . eclipse . jdt . internal . compiler . util . Util . toString ( dbgVariableNames ) , System . err ) ; } private void verbose_update_project ( String [ ] dbgVariableNames , JavaProject affectedProject ) { Util . verbose ( "<STR_LIT>" + "<STR_LIT>" + affectedProject . getElementName ( ) + '<STR_LIT:\n>' + "<STR_LIT>" + org . eclipse . jdt . internal . compiler . util . Util . toString ( dbgVariableNames ) ) ; } private void verbose_set_variables ( ) { Util . verbose ( "<STR_LIT>" + "<STR_LIT>" + org . eclipse . jdt . internal . compiler . util . Util . toString ( this . variableNames ) + '<STR_LIT:\n>' + "<STR_LIT>" + org . eclipse . jdt . internal . compiler . util . Util . toString ( this . variablePaths ) ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . Flags ; import org . eclipse . jdt . core . IField ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . ITypeParameter ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . AnnotationMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ConstructorDeclaration ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . lookup . ExtraCompilerModifiers ; import org . eclipse . jdt . internal . compiler . parser . TypeConverter ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . core . util . HashSetOfCharArrayArray ; import org . eclipse . jdt . internal . core . util . Util ; public class BinaryTypeConverter extends TypeConverter { private CompilationResult compilationResult ; private HashSetOfCharArrayArray typeNames ; public BinaryTypeConverter ( ProblemReporter problemReporter , CompilationResult compilationResult , HashSetOfCharArrayArray typeNames ) { super ( problemReporter , Signature . C_DOLLAR ) ; this . compilationResult = compilationResult ; this . typeNames = typeNames ; } public ImportReference [ ] buildImports ( ClassFileReader reader ) { int [ ] constantPoolOffsets = reader . getConstantPoolOffsets ( ) ; int constantPoolCount = constantPoolOffsets . length ; for ( int i = <NUM_LIT:0> ; i < constantPoolCount ; i ++ ) { int tag = reader . u1At ( constantPoolOffsets [ i ] ) ; char [ ] name = null ; switch ( tag ) { case ClassFileConstants . MethodRefTag : case ClassFileConstants . InterfaceMethodRefTag : int constantPoolIndex = reader . u2At ( constantPoolOffsets [ i ] + <NUM_LIT:3> ) ; int utf8Offset = constantPoolOffsets [ reader . u2At ( constantPoolOffsets [ constantPoolIndex ] + <NUM_LIT:3> ) ] ; name = reader . utf8At ( utf8Offset + <NUM_LIT:3> , reader . u2At ( utf8Offset + <NUM_LIT:1> ) ) ; break ; case ClassFileConstants . ClassTag : utf8Offset = constantPoolOffsets [ reader . u2At ( constantPoolOffsets [ i ] + <NUM_LIT:1> ) ] ; name = reader . utf8At ( utf8Offset + <NUM_LIT:3> , reader . u2At ( utf8Offset + <NUM_LIT:1> ) ) ; break ; } if ( name == null || ( name . length > <NUM_LIT:0> && name [ <NUM_LIT:0> ] == '<CHAR_LIT:[>' ) ) break ; this . typeNames . add ( CharOperation . splitOn ( '<CHAR_LIT:/>' , name ) ) ; } int typeNamesLength = this . typeNames . size ( ) ; ImportReference [ ] imports = new ImportReference [ typeNamesLength ] ; char [ ] [ ] [ ] set = this . typeNames . set ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , length = set . length ; i < length ; i ++ ) { char [ ] [ ] typeName = set [ i ] ; if ( typeName != null ) { imports [ index ++ ] = new ImportReference ( typeName , new long [ typeName . length ] , false , <NUM_LIT:0> ) ; } } return imports ; } public TypeDeclaration buildTypeDeclaration ( IType type , CompilationUnitDeclaration compilationUnit ) throws JavaModelException { PackageFragment pkg = ( PackageFragment ) type . getPackageFragment ( ) ; char [ ] [ ] packageName = Util . toCharArrays ( pkg . names ) ; if ( packageName . length > <NUM_LIT:0> ) { compilationUnit . currentPackage = new ImportReference ( packageName , new long [ ] { <NUM_LIT:0> } , false , ClassFileConstants . AccDefault ) ; } TypeDeclaration typeDeclaration = convert ( type , null , null ) ; IType alreadyComputedMember = type ; IType parent = type . getDeclaringType ( ) ; TypeDeclaration previousDeclaration = typeDeclaration ; while ( parent != null ) { TypeDeclaration declaration = convert ( parent , alreadyComputedMember , previousDeclaration ) ; alreadyComputedMember = parent ; previousDeclaration = declaration ; parent = parent . getDeclaringType ( ) ; } compilationUnit . types = new TypeDeclaration [ ] { previousDeclaration } ; return typeDeclaration ; } private FieldDeclaration convert ( IField field , IType type ) throws JavaModelException { TypeReference typeReference = createTypeReference ( field . getTypeSignature ( ) ) ; if ( typeReference == null ) return null ; FieldDeclaration fieldDeclaration = new FieldDeclaration ( ) ; fieldDeclaration . name = field . getElementName ( ) . toCharArray ( ) ; fieldDeclaration . type = typeReference ; fieldDeclaration . modifiers = field . getFlags ( ) ; return fieldDeclaration ; } private AbstractMethodDeclaration convert ( IMethod method , IType type ) throws JavaModelException { AbstractMethodDeclaration methodDeclaration ; org . eclipse . jdt . internal . compiler . ast . TypeParameter [ ] typeParams = null ; if ( this . has1_5Compliance ) { ITypeParameter [ ] typeParameters = method . getTypeParameters ( ) ; if ( typeParameters != null && typeParameters . length > <NUM_LIT:0> ) { int parameterCount = typeParameters . length ; typeParams = new org . eclipse . jdt . internal . compiler . ast . TypeParameter [ parameterCount ] ; for ( int i = <NUM_LIT:0> ; i < parameterCount ; i ++ ) { ITypeParameter typeParameter = typeParameters [ i ] ; typeParams [ i ] = createTypeParameter ( typeParameter . getElementName ( ) . toCharArray ( ) , stringArrayToCharArray ( typeParameter . getBounds ( ) ) , <NUM_LIT:0> , <NUM_LIT:0> ) ; } } } if ( method . isConstructor ( ) ) { ConstructorDeclaration decl = new ConstructorDeclaration ( this . compilationResult ) ; decl . bits &= ~ ASTNode . IsDefaultConstructor ; decl . typeParameters = typeParams ; methodDeclaration = decl ; } else { MethodDeclaration decl = type . isAnnotation ( ) ? new AnnotationMethodDeclaration ( this . compilationResult ) : new MethodDeclaration ( this . compilationResult ) ; TypeReference typeReference = createTypeReference ( method . getReturnType ( ) ) ; if ( typeReference == null ) return null ; decl . returnType = typeReference ; decl . typeParameters = typeParams ; methodDeclaration = decl ; } methodDeclaration . selector = method . getElementName ( ) . toCharArray ( ) ; int flags = method . getFlags ( ) ; boolean isVarargs = Flags . isVarargs ( flags ) ; methodDeclaration . modifiers = flags & ~ Flags . AccVarargs ; String [ ] argumentTypeNames = method . getParameterTypes ( ) ; String [ ] argumentNames = method . getParameterNames ( ) ; int argumentCount = argumentTypeNames == null ? <NUM_LIT:0> : argumentTypeNames . length ; int startIndex = ( method . isConstructor ( ) && type . isMember ( ) && ! Flags . isStatic ( type . getFlags ( ) ) ) ? <NUM_LIT:1> : <NUM_LIT:0> ; argumentCount -= startIndex ; methodDeclaration . arguments = new Argument [ argumentCount ] ; for ( int i = <NUM_LIT:0> ; i < argumentCount ; i ++ ) { String argumentTypeName = argumentTypeNames [ startIndex + i ] ; TypeReference typeReference = createTypeReference ( argumentTypeName ) ; if ( typeReference == null ) return null ; if ( isVarargs && i == argumentCount - <NUM_LIT:1> ) { typeReference . bits |= ASTNode . IsVarArgs ; } methodDeclaration . arguments [ i ] = new Argument ( argumentNames [ i ] . toCharArray ( ) , <NUM_LIT:0> , typeReference , ClassFileConstants . AccDefault ) ; } String [ ] exceptionTypeNames = method . getExceptionTypes ( ) ; int exceptionCount = exceptionTypeNames == null ? <NUM_LIT:0> : exceptionTypeNames . length ; if ( exceptionCount > <NUM_LIT:0> ) { methodDeclaration . thrownExceptions = new TypeReference [ exceptionCount ] ; for ( int i = <NUM_LIT:0> ; i < exceptionCount ; i ++ ) { TypeReference typeReference = createTypeReference ( exceptionTypeNames [ i ] ) ; if ( typeReference == null ) return null ; methodDeclaration . thrownExceptions [ i ] = typeReference ; } } return methodDeclaration ; } private TypeDeclaration convert ( IType type , IType alreadyComputedMember , TypeDeclaration alreadyComputedMemberDeclaration ) throws JavaModelException { TypeDeclaration typeDeclaration = new TypeDeclaration ( this . compilationResult ) ; if ( type . getDeclaringType ( ) != null ) { typeDeclaration . bits |= ASTNode . IsMemberType ; } typeDeclaration . name = type . getElementName ( ) . toCharArray ( ) ; typeDeclaration . modifiers = type . getFlags ( ) ; if ( type . getSuperclassName ( ) != null ) { TypeReference typeReference = createTypeReference ( type . getSuperclassTypeSignature ( ) ) ; if ( typeReference != null ) { typeDeclaration . superclass = typeReference ; typeDeclaration . superclass . bits |= ASTNode . IsSuperType ; } } String [ ] interfaceTypes = type . getSuperInterfaceTypeSignatures ( ) ; int interfaceCount = interfaceTypes == null ? <NUM_LIT:0> : interfaceTypes . length ; typeDeclaration . superInterfaces = new TypeReference [ interfaceCount ] ; int count = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < interfaceCount ; i ++ ) { TypeReference typeReference = createTypeReference ( interfaceTypes [ i ] ) ; if ( typeReference != null ) { typeDeclaration . superInterfaces [ count ] = typeReference ; typeDeclaration . superInterfaces [ count ++ ] . bits |= ASTNode . IsSuperType ; } } if ( count != interfaceCount ) { System . arraycopy ( typeDeclaration . fields , <NUM_LIT:0> , typeDeclaration . superInterfaces = new TypeReference [ interfaceCount ] , <NUM_LIT:0> , interfaceCount ) ; } if ( this . has1_5Compliance ) { ITypeParameter [ ] typeParameters = type . getTypeParameters ( ) ; if ( typeParameters != null && typeParameters . length > <NUM_LIT:0> ) { int parameterCount = typeParameters . length ; org . eclipse . jdt . internal . compiler . ast . TypeParameter [ ] typeParams = new org . eclipse . jdt . internal . compiler . ast . TypeParameter [ parameterCount ] ; for ( int i = <NUM_LIT:0> ; i < parameterCount ; i ++ ) { ITypeParameter typeParameter = typeParameters [ i ] ; typeParams [ i ] = createTypeParameter ( typeParameter . getElementName ( ) . toCharArray ( ) , stringArrayToCharArray ( typeParameter . getBounds ( ) ) , <NUM_LIT:0> , <NUM_LIT:0> ) ; } typeDeclaration . typeParameters = typeParams ; } } IType [ ] memberTypes = type . getTypes ( ) ; int memberTypeCount = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; typeDeclaration . memberTypes = new TypeDeclaration [ memberTypeCount ] ; for ( int i = <NUM_LIT:0> ; i < memberTypeCount ; i ++ ) { if ( alreadyComputedMember != null && alreadyComputedMember . getFullyQualifiedName ( ) . equals ( memberTypes [ i ] . getFullyQualifiedName ( ) ) ) { typeDeclaration . memberTypes [ i ] = alreadyComputedMemberDeclaration ; } else { typeDeclaration . memberTypes [ i ] = convert ( memberTypes [ i ] , null , null ) ; } typeDeclaration . memberTypes [ i ] . enclosingType = typeDeclaration ; } IField [ ] fields = type . getFields ( ) ; int fieldCount = fields == null ? <NUM_LIT:0> : fields . length ; typeDeclaration . fields = new FieldDeclaration [ fieldCount ] ; count = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < fieldCount ; i ++ ) { FieldDeclaration fieldDeclaration = convert ( fields [ i ] , type ) ; if ( fieldDeclaration != null ) { typeDeclaration . fields [ count ++ ] = fieldDeclaration ; } } if ( count != fieldCount ) { System . arraycopy ( typeDeclaration . fields , <NUM_LIT:0> , typeDeclaration . fields = new FieldDeclaration [ count ] , <NUM_LIT:0> , count ) ; } IMethod [ ] methods = type . getMethods ( ) ; int methodCount = methods == null ? <NUM_LIT:0> : methods . length ; int neededCount = <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < methodCount ; i ++ ) { if ( methods [ i ] . isConstructor ( ) ) { neededCount = <NUM_LIT:0> ; break ; } } boolean isInterface = type . isInterface ( ) ; neededCount = isInterface ? <NUM_LIT:0> : neededCount ; typeDeclaration . methods = new AbstractMethodDeclaration [ methodCount + neededCount ] ; if ( neededCount != <NUM_LIT:0> ) { typeDeclaration . methods [ <NUM_LIT:0> ] = typeDeclaration . createDefaultConstructor ( false , false ) ; } boolean hasAbstractMethods = false ; count = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < methodCount ; i ++ ) { AbstractMethodDeclaration method = convert ( methods [ i ] , type ) ; if ( method != null ) { boolean isAbstract ; if ( ( isAbstract = method . isAbstract ( ) ) || isInterface ) { method . modifiers |= ExtraCompilerModifiers . AccSemicolonBody ; } if ( isAbstract ) { hasAbstractMethods = true ; } typeDeclaration . methods [ neededCount + ( count ++ ) ] = method ; } } if ( count != methodCount ) { System . arraycopy ( typeDeclaration . methods , <NUM_LIT:0> , typeDeclaration . methods = new AbstractMethodDeclaration [ count + neededCount ] , <NUM_LIT:0> , count + neededCount ) ; } if ( hasAbstractMethods ) { typeDeclaration . bits |= ASTNode . HasAbstractMethods ; } return typeDeclaration ; } private static char [ ] [ ] stringArrayToCharArray ( String [ ] strings ) { if ( strings == null ) return null ; int length = strings . length ; if ( length == <NUM_LIT:0> ) return CharOperation . NO_CHAR_CHAR ; char [ ] [ ] result = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { result [ i ] = strings [ i ] . toCharArray ( ) ; } return result ; } private TypeReference createTypeReference ( String typeSignature ) { TypeReference result = createTypeReference ( typeSignature , <NUM_LIT:0> , <NUM_LIT:0> ) ; if ( this . typeNames != null && result instanceof QualifiedTypeReference ) { this . typeNames . add ( ( ( QualifiedTypeReference ) result ) . tokens ) ; } return result ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . IContainer ; import org . eclipse . core . resources . IResource ; import org . eclipse . jdt . core . JavaModelException ; class PackageFragmentInfo extends OpenableElementInfo { protected Object [ ] nonJavaResources ; public PackageFragmentInfo ( ) { this . nonJavaResources = null ; } boolean containsJavaResources ( ) { return this . children . length != <NUM_LIT:0> ; } Object [ ] getNonJavaResources ( IResource underlyingResource , PackageFragmentRoot rootHandle ) { if ( this . nonJavaResources == null ) { try { this . nonJavaResources = PackageFragmentRootInfo . computeFolderNonJavaResources ( rootHandle , ( IContainer ) underlyingResource , rootHandle . fullInclusionPatternChars ( ) , rootHandle . fullExclusionPatternChars ( ) ) ; } catch ( JavaModelException e ) { this . nonJavaResources = NO_NON_JAVA_RESOURCES ; } } return this . nonJavaResources ; } void setNonJavaResources ( Object [ ] resources ) { this . nonJavaResources = resources ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . ByteArrayInputStream ; import java . io . InputStream ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . jdt . core . IJarEntryResource ; public class JarEntryDirectory extends JarEntryResource { private IJarEntryResource [ ] children ; public JarEntryDirectory ( String simpleName ) { super ( simpleName ) ; } public JarEntryResource clone ( Object newParent ) { JarEntryDirectory dir = new JarEntryDirectory ( this . simpleName ) ; dir . setParent ( newParent ) ; int length = this . children . length ; if ( length > <NUM_LIT:0> ) { IJarEntryResource [ ] newChildren = new IJarEntryResource [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { JarEntryResource child = ( JarEntryResource ) this . children [ i ] ; newChildren [ i ] = child . clone ( dir ) ; } dir . setChildren ( newChildren ) ; } return dir ; } public IJarEntryResource [ ] getChildren ( ) { return this . children ; } public InputStream getContents ( ) throws CoreException { return new ByteArrayInputStream ( new byte [ <NUM_LIT:0> ] ) ; } public boolean isFile ( ) { return false ; } public void setChildren ( IJarEntryResource [ ] children ) { this . children = children ; } public String toString ( ) { return "<STR_LIT>" + getEntryName ( ) + "<STR_LIT:]>" ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . internal . core . util . Messages ; public class CopyPackageFragmentRootOperation extends JavaModelOperation { IPath destination ; int updateResourceFlags ; int updateModelFlags ; IClasspathEntry sibling ; public CopyPackageFragmentRootOperation ( IPackageFragmentRoot root , IPath destination , int updateResourceFlags , int updateModelFlags , IClasspathEntry sibling ) { super ( root ) ; this . destination = destination ; this . updateResourceFlags = updateResourceFlags ; this . updateModelFlags = updateModelFlags ; this . sibling = sibling ; } protected void executeOperation ( ) throws JavaModelException { IPackageFragmentRoot root = ( IPackageFragmentRoot ) getElementToProcess ( ) ; IClasspathEntry rootEntry = root . getRawClasspathEntry ( ) ; IWorkspaceRoot workspaceRoot = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ; if ( ! root . isExternal ( ) && ( this . updateModelFlags & IPackageFragmentRoot . NO_RESOURCE_MODIFICATION ) == <NUM_LIT:0> ) { copyResource ( root , rootEntry , workspaceRoot ) ; } if ( ( this . updateModelFlags & IPackageFragmentRoot . DESTINATION_PROJECT_CLASSPATH ) != <NUM_LIT:0> ) { addEntryToClasspath ( rootEntry , workspaceRoot ) ; } } protected void copyResource ( IPackageFragmentRoot root , IClasspathEntry rootEntry , final IWorkspaceRoot workspaceRoot ) throws JavaModelException { final char [ ] [ ] exclusionPatterns = ( ( ClasspathEntry ) rootEntry ) . fullExclusionPatternChars ( ) ; IResource rootResource = ( ( JavaElement ) root ) . resource ( ) ; if ( root . getKind ( ) == IPackageFragmentRoot . K_BINARY || exclusionPatterns == null ) { try { IResource destRes ; if ( ( this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> ) { if ( rootEntry . getPath ( ) . equals ( this . destination ) ) return ; if ( ( destRes = workspaceRoot . findMember ( this . destination ) ) != null ) { destRes . delete ( this . updateResourceFlags , this . progressMonitor ) ; } } rootResource . copy ( this . destination , this . updateResourceFlags , this . progressMonitor ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } else { final int sourceSegmentCount = rootEntry . getPath ( ) . segmentCount ( ) ; final IFolder destFolder = workspaceRoot . getFolder ( this . destination ) ; final IPath [ ] nestedFolders = getNestedFolders ( root ) ; IResourceProxyVisitor visitor = new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) throws CoreException { if ( proxy . getType ( ) == IResource . FOLDER ) { IPath path = proxy . requestFullPath ( ) ; if ( prefixesOneOf ( path , nestedFolders ) ) { if ( equalsOneOf ( path , nestedFolders ) ) { return false ; } else { IFolder folder = destFolder . getFolder ( path . removeFirstSegments ( sourceSegmentCount ) ) ; if ( ( CopyPackageFragmentRootOperation . this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> && folder . exists ( ) ) { return true ; } folder . create ( CopyPackageFragmentRootOperation . this . updateResourceFlags , true , CopyPackageFragmentRootOperation . this . progressMonitor ) ; return true ; } } else { IPath destPath = CopyPackageFragmentRootOperation . this . destination . append ( path . removeFirstSegments ( sourceSegmentCount ) ) ; IResource destRes ; if ( ( CopyPackageFragmentRootOperation . this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> && ( destRes = workspaceRoot . findMember ( destPath ) ) != null ) { destRes . delete ( CopyPackageFragmentRootOperation . this . updateResourceFlags , CopyPackageFragmentRootOperation . this . progressMonitor ) ; } proxy . requestResource ( ) . copy ( destPath , CopyPackageFragmentRootOperation . this . updateResourceFlags , CopyPackageFragmentRootOperation . this . progressMonitor ) ; return false ; } } else { IPath path = proxy . requestFullPath ( ) ; IPath destPath = CopyPackageFragmentRootOperation . this . destination . append ( path . removeFirstSegments ( sourceSegmentCount ) ) ; IResource destRes ; if ( ( CopyPackageFragmentRootOperation . this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> && ( destRes = workspaceRoot . findMember ( destPath ) ) != null ) { destRes . delete ( CopyPackageFragmentRootOperation . this . updateResourceFlags , CopyPackageFragmentRootOperation . this . progressMonitor ) ; } proxy . requestResource ( ) . copy ( destPath , CopyPackageFragmentRootOperation . this . updateResourceFlags , CopyPackageFragmentRootOperation . this . progressMonitor ) ; return false ; } } } ; try { rootResource . accept ( visitor , IResource . NONE ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; } protected void addEntryToClasspath ( IClasspathEntry rootEntry , IWorkspaceRoot workspaceRoot ) throws JavaModelException { IProject destProject = workspaceRoot . getProject ( this . destination . segment ( <NUM_LIT:0> ) ) ; IJavaProject jProject = JavaCore . create ( destProject ) ; IClasspathEntry [ ] classpath = jProject . getRawClasspath ( ) ; int length = classpath . length ; IClasspathEntry [ ] newClasspath ; if ( ( this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( this . destination . equals ( classpath [ i ] . getPath ( ) ) ) { newClasspath = new IClasspathEntry [ length ] ; System . arraycopy ( classpath , <NUM_LIT:0> , newClasspath , <NUM_LIT:0> , length ) ; newClasspath [ i ] = copy ( rootEntry ) ; jProject . setRawClasspath ( newClasspath , this . progressMonitor ) ; return ; } } } int position ; if ( this . sibling == null ) { position = length ; } else { position = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( this . sibling . equals ( classpath [ i ] ) ) { position = i ; break ; } } } if ( position == - <NUM_LIT:1> ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_SIBLING , this . sibling . toString ( ) ) ) ; } newClasspath = new IClasspathEntry [ length + <NUM_LIT:1> ] ; if ( position != <NUM_LIT:0> ) { System . arraycopy ( classpath , <NUM_LIT:0> , newClasspath , <NUM_LIT:0> , position ) ; } if ( position != length ) { System . arraycopy ( classpath , position , newClasspath , position + <NUM_LIT:1> , length - position ) ; } IClasspathEntry newEntry = copy ( rootEntry ) ; newClasspath [ position ] = newEntry ; jProject . setRawClasspath ( newClasspath , this . progressMonitor ) ; } protected IClasspathEntry copy ( IClasspathEntry entry ) throws JavaModelException { switch ( entry . getEntryKind ( ) ) { case IClasspathEntry . CPE_CONTAINER : return JavaCore . newContainerEntry ( entry . getPath ( ) , entry . getAccessRules ( ) , entry . getExtraAttributes ( ) , entry . isExported ( ) ) ; case IClasspathEntry . CPE_LIBRARY : try { return JavaCore . newLibraryEntry ( this . destination , entry . getSourceAttachmentPath ( ) , entry . getSourceAttachmentRootPath ( ) , entry . getAccessRules ( ) , entry . getExtraAttributes ( ) , entry . isExported ( ) ) ; } catch ( ClasspathEntry . AssertionFailedException e ) { IJavaModelStatus status = new JavaModelStatus ( IJavaModelStatusConstants . INVALID_PATH , e . getMessage ( ) ) ; throw new JavaModelException ( status ) ; } case IClasspathEntry . CPE_PROJECT : return JavaCore . newProjectEntry ( entry . getPath ( ) , entry . getAccessRules ( ) , entry . combineAccessRules ( ) , entry . getExtraAttributes ( ) , entry . isExported ( ) ) ; case IClasspathEntry . CPE_SOURCE : return JavaCore . newSourceEntry ( this . destination , entry . getInclusionPatterns ( ) , entry . getExclusionPatterns ( ) , entry . getOutputLocation ( ) , entry . getExtraAttributes ( ) ) ; case IClasspathEntry . CPE_VARIABLE : try { return JavaCore . newVariableEntry ( entry . getPath ( ) , entry . getSourceAttachmentPath ( ) , entry . getSourceAttachmentRootPath ( ) , entry . getAccessRules ( ) , entry . getExtraAttributes ( ) , entry . isExported ( ) ) ; } catch ( ClasspathEntry . AssertionFailedException e ) { IJavaModelStatus status = new JavaModelStatus ( IJavaModelStatusConstants . INVALID_PATH , e . getMessage ( ) ) ; throw new JavaModelException ( status ) ; } default : throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST , getElementToProcess ( ) ) ) ; } } public IJavaModelStatus verify ( ) { IJavaModelStatus status = super . verify ( ) ; if ( ! status . isOK ( ) ) { return status ; } PackageFragmentRoot root = ( PackageFragmentRoot ) getElementToProcess ( ) ; if ( root == null || ! root . exists ( ) ) { return new JavaModelStatus ( IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST , root ) ; } IResource resource = root . resource ( ) ; if ( resource instanceof IFolder ) { if ( resource . isLinked ( ) ) { return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_RESOURCE , root ) ; } } if ( ( this . updateModelFlags & IPackageFragmentRoot . DESTINATION_PROJECT_CLASSPATH ) != <NUM_LIT:0> ) { String destProjectName = this . destination . segment ( <NUM_LIT:0> ) ; IProject project = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getProject ( destProjectName ) ; if ( JavaProject . hasJavaNature ( project ) ) { try { IJavaProject destProject = JavaCore . create ( project ) ; IClasspathEntry [ ] destClasspath = destProject . getRawClasspath ( ) ; boolean foundSibling = false ; boolean foundExistingEntry = false ; for ( int i = <NUM_LIT:0> , length = destClasspath . length ; i < length ; i ++ ) { IClasspathEntry entry = destClasspath [ i ] ; if ( entry . equals ( this . sibling ) ) { foundSibling = true ; break ; } if ( entry . getPath ( ) . equals ( this . destination ) ) { foundExistingEntry = true ; } } if ( this . sibling != null && ! foundSibling ) { return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_SIBLING , this . sibling . toString ( ) ) ; } if ( foundExistingEntry && ( this . updateModelFlags & IPackageFragmentRoot . REPLACE ) == <NUM_LIT:0> ) { return new JavaModelStatus ( IJavaModelStatusConstants . NAME_COLLISION , Messages . bind ( Messages . status_nameCollision , new String [ ] { this . destination . toString ( ) } ) ) ; } } catch ( JavaModelException e ) { return e . getJavaModelStatus ( ) ; } } } return JavaModelStatus . VERIFIED_OK ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . text . NumberFormat ; import java . util . Enumeration ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IResource ; import org . eclipse . jdt . core . IBuffer ; import org . eclipse . jdt . core . IOpenable ; public class BufferManager { protected static BufferManager DEFAULT_BUFFER_MANAGER ; protected static boolean VERBOSE ; private BufferCache openBuffers = new BufferCache ( <NUM_LIT> ) ; protected org . eclipse . jdt . core . IBufferFactory defaultBufferFactory = new org . eclipse . jdt . core . IBufferFactory ( ) { public IBuffer createBuffer ( IOpenable owner ) { return BufferManager . createBuffer ( owner ) ; } } ; protected void addBuffer ( IBuffer buffer ) { if ( VERBOSE ) { String owner = ( ( Openable ) buffer . getOwner ( ) ) . toStringWithAncestors ( ) ; System . out . println ( "<STR_LIT>" + owner ) ; } synchronized ( this . openBuffers ) { this . openBuffers . put ( buffer . getOwner ( ) , buffer ) ; } this . openBuffers . closeBuffers ( ) ; if ( VERBOSE ) { System . out . println ( "<STR_LIT>" + NumberFormat . getInstance ( ) . format ( this . openBuffers . fillingRatio ( ) ) + "<STR_LIT:%>" ) ; } } public static IBuffer createBuffer ( IOpenable owner ) { JavaElement element = ( JavaElement ) owner ; IResource resource = element . resource ( ) ; return new Buffer ( resource instanceof IFile ? ( IFile ) resource : null , owner , element . isReadOnly ( ) ) ; } public static IBuffer createNullBuffer ( IOpenable owner ) { JavaElement element = ( JavaElement ) owner ; IResource resource = element . resource ( ) ; return new NullBuffer ( resource instanceof IFile ? ( IFile ) resource : null , owner , element . isReadOnly ( ) ) ; } public IBuffer getBuffer ( IOpenable owner ) { synchronized ( this . openBuffers ) { return ( IBuffer ) this . openBuffers . get ( owner ) ; } } public synchronized static BufferManager getDefaultBufferManager ( ) { if ( DEFAULT_BUFFER_MANAGER == null ) { DEFAULT_BUFFER_MANAGER = new BufferManager ( ) ; } return DEFAULT_BUFFER_MANAGER ; } public org . eclipse . jdt . core . IBufferFactory getDefaultBufferFactory ( ) { return this . defaultBufferFactory ; } public Enumeration getOpenBuffers ( ) { Enumeration result ; synchronized ( this . openBuffers ) { this . openBuffers . shrink ( ) ; result = this . openBuffers . elements ( ) ; } this . openBuffers . closeBuffers ( ) ; return result ; } protected void removeBuffer ( IBuffer buffer ) { if ( VERBOSE ) { String owner = ( ( Openable ) buffer . getOwner ( ) ) . toStringWithAncestors ( ) ; System . out . println ( "<STR_LIT>" + owner ) ; } synchronized ( this . openBuffers ) { this . openBuffers . remove ( buffer . getOwner ( ) ) ; } this . openBuffers . closeBuffers ( ) ; if ( VERBOSE ) { System . out . println ( "<STR_LIT>" + NumberFormat . getInstance ( ) . format ( this . openBuffers . fillingRatio ( ) ) + "<STR_LIT:%>" ) ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IField ; import org . eclipse . jdt . core . IInitializer ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IType ; class SingleTypeRequestor implements IJavaElementRequestor { protected IType element = null ; public void acceptField ( IField field ) { } public void acceptInitializer ( IInitializer initializer ) { } public void acceptMemberType ( IType type ) { this . element = type ; } public void acceptMethod ( IMethod method ) { } public void acceptPackageFragment ( IPackageFragment packageFragment ) { } public void acceptType ( IType type ) { this . element = type ; } public IType getType ( ) { return this . element ; } public boolean isCanceled ( ) { return this . element != null ; } public void reset ( ) { this . element = null ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . * ; public class DeletePackageFragmentRootOperation extends JavaModelOperation { int updateResourceFlags ; int updateModelFlags ; public DeletePackageFragmentRootOperation ( IPackageFragmentRoot root , int updateResourceFlags , int updateModelFlags ) { super ( root ) ; this . updateResourceFlags = updateResourceFlags ; this . updateModelFlags = updateModelFlags ; } protected void executeOperation ( ) throws JavaModelException { IPackageFragmentRoot root = ( IPackageFragmentRoot ) getElementToProcess ( ) ; IClasspathEntry rootEntry = root . getRawClasspathEntry ( ) ; DeltaProcessor deltaProcessor = JavaModelManager . getJavaModelManager ( ) . getDeltaProcessor ( ) ; if ( deltaProcessor . oldRoots == null ) deltaProcessor . oldRoots = new HashMap ( ) ; if ( ( this . updateModelFlags & IPackageFragmentRoot . ORIGINATING_PROJECT_CLASSPATH ) != <NUM_LIT:0> ) { updateProjectClasspath ( rootEntry . getPath ( ) , root . getJavaProject ( ) , deltaProcessor . oldRoots ) ; } if ( ( this . updateModelFlags & IPackageFragmentRoot . OTHER_REFERRING_PROJECTS_CLASSPATH ) != <NUM_LIT:0> ) { updateReferringProjectClasspaths ( rootEntry . getPath ( ) , root . getJavaProject ( ) , deltaProcessor . oldRoots ) ; } if ( ! root . isExternal ( ) && ( this . updateModelFlags & IPackageFragmentRoot . NO_RESOURCE_MODIFICATION ) == <NUM_LIT:0> ) { deleteResource ( root , rootEntry ) ; } } protected void deleteResource ( IPackageFragmentRoot root , IClasspathEntry rootEntry ) throws JavaModelException { final char [ ] [ ] exclusionPatterns = ( ( ClasspathEntry ) rootEntry ) . fullExclusionPatternChars ( ) ; IResource rootResource = ( ( JavaElement ) root ) . resource ( ) ; if ( rootEntry . getEntryKind ( ) != IClasspathEntry . CPE_SOURCE || exclusionPatterns == null ) { try { rootResource . delete ( this . updateResourceFlags , this . progressMonitor ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } else { final IPath [ ] nestedFolders = getNestedFolders ( root ) ; IResourceProxyVisitor visitor = new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) throws CoreException { if ( proxy . getType ( ) == IResource . FOLDER ) { IPath path = proxy . requestFullPath ( ) ; if ( prefixesOneOf ( path , nestedFolders ) ) { return ! equalsOneOf ( path , nestedFolders ) ; } else { proxy . requestResource ( ) . delete ( DeletePackageFragmentRootOperation . this . updateResourceFlags , DeletePackageFragmentRootOperation . this . progressMonitor ) ; return false ; } } else { proxy . requestResource ( ) . delete ( DeletePackageFragmentRootOperation . this . updateResourceFlags , DeletePackageFragmentRootOperation . this . progressMonitor ) ; return false ; } } } ; try { rootResource . accept ( visitor , IResource . NONE ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; } protected void updateReferringProjectClasspaths ( IPath rootPath , IJavaProject projectOfRoot , Map oldRoots ) throws JavaModelException { IJavaModel model = getJavaModel ( ) ; IJavaProject [ ] projects = model . getJavaProjects ( ) ; for ( int i = <NUM_LIT:0> , length = projects . length ; i < length ; i ++ ) { IJavaProject project = projects [ i ] ; if ( project . equals ( projectOfRoot ) ) continue ; updateProjectClasspath ( rootPath , project , oldRoots ) ; } } protected void updateProjectClasspath ( IPath rootPath , IJavaProject project , Map oldRoots ) throws JavaModelException { oldRoots . put ( project , project . getPackageFragmentRoots ( ) ) ; IClasspathEntry [ ] classpath = project . getRawClasspath ( ) ; IClasspathEntry [ ] newClasspath = null ; int cpLength = classpath . length ; int newCPIndex = - <NUM_LIT:1> ; for ( int j = <NUM_LIT:0> ; j < cpLength ; j ++ ) { IClasspathEntry entry = classpath [ j ] ; if ( rootPath . equals ( entry . getPath ( ) ) ) { if ( newClasspath == null ) { newClasspath = new IClasspathEntry [ cpLength - <NUM_LIT:1> ] ; System . arraycopy ( classpath , <NUM_LIT:0> , newClasspath , <NUM_LIT:0> , j ) ; newCPIndex = j ; } } else if ( newClasspath != null ) { newClasspath [ newCPIndex ++ ] = entry ; } } if ( newClasspath != null ) { if ( newCPIndex < newClasspath . length ) { System . arraycopy ( newClasspath , <NUM_LIT:0> , newClasspath = new IClasspathEntry [ newCPIndex ] , <NUM_LIT:0> , newCPIndex ) ; } project . setRawClasspath ( newClasspath , this . progressMonitor ) ; } } protected IJavaModelStatus verify ( ) { IJavaModelStatus status = super . verify ( ) ; if ( ! status . isOK ( ) ) { return status ; } IJavaElement root = getElementToProcess ( ) ; if ( root == null || ! root . exists ( ) ) { return new JavaModelStatus ( IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST , root ) ; } IResource resource = ( ( JavaElement ) root ) . resource ( ) ; if ( resource instanceof IFolder ) { if ( resource . isLinked ( ) ) { return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_RESOURCE , root ) ; } } return JavaModelStatus . VERIFIED_OK ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . ArrayList ; import org . eclipse . jdt . core . IBuffer ; import org . eclipse . jdt . internal . core . util . LRUCache ; public class BufferCache extends OverflowingLRUCache { private ThreadLocal buffersToClose = new ThreadLocal ( ) ; public BufferCache ( int size ) { super ( size ) ; } public BufferCache ( int size , int overflow ) { super ( size , overflow ) ; } protected boolean close ( LRUCacheEntry entry ) { IBuffer buffer = ( IBuffer ) entry . value ; if ( ! ( ( Openable ) buffer . getOwner ( ) ) . canBufferBeRemovedFromCache ( buffer ) ) { return false ; } else { ArrayList buffers = ( ArrayList ) this . buffersToClose . get ( ) ; if ( buffers == null ) { buffers = new ArrayList ( ) ; this . buffersToClose . set ( buffers ) ; } buffers . add ( buffer ) ; return true ; } } void closeBuffers ( ) { ArrayList buffers = ( ArrayList ) this . buffersToClose . get ( ) ; if ( buffers == null ) return ; this . buffersToClose . set ( null ) ; for ( int i = <NUM_LIT:0> , length = buffers . size ( ) ; i < length ; i ++ ) { ( ( IBuffer ) buffers . get ( i ) ) . close ( ) ; } } protected LRUCache newInstance ( int size , int newOverflow ) { return new BufferCache ( size , newOverflow ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . * ; public class MovePackageFragmentRootOperation extends CopyPackageFragmentRootOperation { protected void renameEntryInClasspath ( IPath rootPath , IJavaProject project ) throws JavaModelException { IClasspathEntry [ ] classpath = project . getRawClasspath ( ) ; IClasspathEntry [ ] newClasspath = null ; int cpLength = classpath . length ; int newCPIndex = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < cpLength ; i ++ ) { IClasspathEntry entry = classpath [ i ] ; IPath entryPath = entry . getPath ( ) ; if ( rootPath . equals ( entryPath ) ) { if ( newClasspath == null ) { newClasspath = new IClasspathEntry [ cpLength ] ; System . arraycopy ( classpath , <NUM_LIT:0> , newClasspath , <NUM_LIT:0> , i ) ; newCPIndex = i ; } newClasspath [ newCPIndex ++ ] = copy ( entry ) ; } else if ( this . destination . equals ( entryPath ) ) { if ( newClasspath == null ) { newClasspath = new IClasspathEntry [ cpLength ] ; System . arraycopy ( classpath , <NUM_LIT:0> , newClasspath , <NUM_LIT:0> , i ) ; newCPIndex = i ; } } else if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_SOURCE ) { IPath projectRelativePath = rootPath . removeFirstSegments ( <NUM_LIT:1> ) ; IPath [ ] newExclusionPatterns = renamePatterns ( projectRelativePath , entry . getExclusionPatterns ( ) ) ; IPath [ ] newInclusionPatterns = renamePatterns ( projectRelativePath , entry . getInclusionPatterns ( ) ) ; if ( newExclusionPatterns != null || newInclusionPatterns != null ) { if ( newClasspath == null ) { newClasspath = new IClasspathEntry [ cpLength ] ; System . arraycopy ( classpath , <NUM_LIT:0> , newClasspath , <NUM_LIT:0> , i ) ; newCPIndex = i ; } newClasspath [ newCPIndex ++ ] = JavaCore . newSourceEntry ( entry . getPath ( ) , newInclusionPatterns == null ? entry . getInclusionPatterns ( ) : newInclusionPatterns , newExclusionPatterns == null ? entry . getExclusionPatterns ( ) : newExclusionPatterns , entry . getOutputLocation ( ) , entry . getExtraAttributes ( ) ) ; } else if ( newClasspath != null ) { newClasspath [ newCPIndex ++ ] = entry ; } } else if ( newClasspath != null ) { newClasspath [ newCPIndex ++ ] = entry ; } } if ( newClasspath != null ) { if ( newCPIndex < newClasspath . length ) { System . arraycopy ( newClasspath , <NUM_LIT:0> , newClasspath = new IClasspathEntry [ newCPIndex ] , <NUM_LIT:0> , newCPIndex ) ; } IJavaModelStatus status = JavaConventions . validateClasspath ( project , newClasspath , project . getOutputLocation ( ) ) ; if ( status . isOK ( ) ) project . setRawClasspath ( newClasspath , this . progressMonitor ) ; } } private IPath [ ] renamePatterns ( IPath rootPath , IPath [ ] patterns ) { IPath [ ] newPatterns = null ; int newPatternsIndex = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> , length = patterns . length ; i < length ; i ++ ) { IPath pattern = patterns [ i ] ; if ( pattern . equals ( rootPath ) ) { if ( newPatterns == null ) { newPatterns = new IPath [ length ] ; System . arraycopy ( patterns , <NUM_LIT:0> , newPatterns , <NUM_LIT:0> , i ) ; newPatternsIndex = i ; } IPath newPattern = this . destination . removeFirstSegments ( <NUM_LIT:1> ) ; if ( pattern . hasTrailingSeparator ( ) ) newPattern = newPattern . addTrailingSeparator ( ) ; newPatterns [ newPatternsIndex ++ ] = newPattern ; } } return newPatterns ; } public MovePackageFragmentRootOperation ( IPackageFragmentRoot root , IPath destination , int updateResourceFlags , int updateModelFlags , IClasspathEntry sibling ) { super ( root , destination , updateResourceFlags , updateModelFlags , sibling ) ; } protected void executeOperation ( ) throws JavaModelException { IPackageFragmentRoot root = ( IPackageFragmentRoot ) getElementToProcess ( ) ; IClasspathEntry rootEntry = root . getRawClasspathEntry ( ) ; IWorkspaceRoot workspaceRoot = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ; if ( ! root . isExternal ( ) && ( this . updateModelFlags & IPackageFragmentRoot . NO_RESOURCE_MODIFICATION ) == <NUM_LIT:0> ) { moveResource ( root , rootEntry , workspaceRoot ) ; } IJavaProject originatingProject = root . getJavaProject ( ) ; if ( ( this . updateModelFlags & IPackageFragmentRoot . OTHER_REFERRING_PROJECTS_CLASSPATH ) != <NUM_LIT:0> ) { updateReferringProjectClasspaths ( rootEntry . getPath ( ) , originatingProject ) ; } boolean isRename = this . destination . segment ( <NUM_LIT:0> ) . equals ( originatingProject . getElementName ( ) ) ; boolean updateOriginating = ( this . updateModelFlags & IPackageFragmentRoot . ORIGINATING_PROJECT_CLASSPATH ) != <NUM_LIT:0> ; boolean updateDestination = ( this . updateModelFlags & IPackageFragmentRoot . DESTINATION_PROJECT_CLASSPATH ) != <NUM_LIT:0> ; if ( updateOriginating ) { if ( isRename && updateDestination ) { renameEntryInClasspath ( rootEntry . getPath ( ) , originatingProject ) ; } else { removeEntryFromClasspath ( rootEntry . getPath ( ) , originatingProject ) ; } } if ( updateDestination ) { if ( ! isRename || ! updateOriginating ) { addEntryToClasspath ( rootEntry , workspaceRoot ) ; } } } protected void moveResource ( IPackageFragmentRoot root , IClasspathEntry rootEntry , final IWorkspaceRoot workspaceRoot ) throws JavaModelException { final char [ ] [ ] exclusionPatterns = ( ( ClasspathEntry ) rootEntry ) . fullExclusionPatternChars ( ) ; IResource rootResource = ( ( JavaElement ) root ) . resource ( ) ; if ( rootEntry . getEntryKind ( ) != IClasspathEntry . CPE_SOURCE || exclusionPatterns == null ) { try { IResource destRes ; if ( ( this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> && ( destRes = workspaceRoot . findMember ( this . destination ) ) != null ) { destRes . delete ( this . updateResourceFlags , this . progressMonitor ) ; } rootResource . move ( this . destination , this . updateResourceFlags , this . progressMonitor ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } else { final int sourceSegmentCount = rootEntry . getPath ( ) . segmentCount ( ) ; final IFolder destFolder = workspaceRoot . getFolder ( this . destination ) ; final IPath [ ] nestedFolders = getNestedFolders ( root ) ; IResourceProxyVisitor visitor = new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) throws CoreException { if ( proxy . getType ( ) == IResource . FOLDER ) { IPath path = proxy . requestFullPath ( ) ; if ( prefixesOneOf ( path , nestedFolders ) ) { if ( equalsOneOf ( path , nestedFolders ) ) { return false ; } else { IFolder folder = destFolder . getFolder ( path . removeFirstSegments ( sourceSegmentCount ) ) ; if ( ( MovePackageFragmentRootOperation . this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> && folder . exists ( ) ) { return true ; } folder . create ( MovePackageFragmentRootOperation . this . updateResourceFlags , true , MovePackageFragmentRootOperation . this . progressMonitor ) ; return true ; } } else { IPath destPath = MovePackageFragmentRootOperation . this . destination . append ( path . removeFirstSegments ( sourceSegmentCount ) ) ; IResource destRes ; if ( ( MovePackageFragmentRootOperation . this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> && ( destRes = workspaceRoot . findMember ( destPath ) ) != null ) { destRes . delete ( MovePackageFragmentRootOperation . this . updateResourceFlags , MovePackageFragmentRootOperation . this . progressMonitor ) ; } proxy . requestResource ( ) . move ( destPath , MovePackageFragmentRootOperation . this . updateResourceFlags , MovePackageFragmentRootOperation . this . progressMonitor ) ; return false ; } } else { IPath path = proxy . requestFullPath ( ) ; IPath destPath = MovePackageFragmentRootOperation . this . destination . append ( path . removeFirstSegments ( sourceSegmentCount ) ) ; IResource destRes ; if ( ( MovePackageFragmentRootOperation . this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> && ( destRes = workspaceRoot . findMember ( destPath ) ) != null ) { destRes . delete ( MovePackageFragmentRootOperation . this . updateResourceFlags , MovePackageFragmentRootOperation . this . progressMonitor ) ; } proxy . requestResource ( ) . move ( destPath , MovePackageFragmentRootOperation . this . updateResourceFlags , MovePackageFragmentRootOperation . this . progressMonitor ) ; return false ; } } } ; try { rootResource . accept ( visitor , IResource . NONE ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; } protected void updateReferringProjectClasspaths ( IPath rootPath , IJavaProject projectOfRoot ) throws JavaModelException { IJavaModel model = getJavaModel ( ) ; IJavaProject [ ] projects = model . getJavaProjects ( ) ; for ( int i = <NUM_LIT:0> , length = projects . length ; i < length ; i ++ ) { IJavaProject project = projects [ i ] ; if ( project . equals ( projectOfRoot ) ) continue ; renameEntryInClasspath ( rootPath , project ) ; } } protected void removeEntryFromClasspath ( IPath rootPath , IJavaProject project ) throws JavaModelException { IClasspathEntry [ ] classpath = project . getRawClasspath ( ) ; IClasspathEntry [ ] newClasspath = null ; int cpLength = classpath . length ; int newCPIndex = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < cpLength ; i ++ ) { IClasspathEntry entry = classpath [ i ] ; if ( rootPath . equals ( entry . getPath ( ) ) ) { if ( newClasspath == null ) { newClasspath = new IClasspathEntry [ cpLength ] ; System . arraycopy ( classpath , <NUM_LIT:0> , newClasspath , <NUM_LIT:0> , i ) ; newCPIndex = i ; } } else if ( newClasspath != null ) { newClasspath [ newCPIndex ++ ] = entry ; } } if ( newClasspath != null ) { if ( newCPIndex < newClasspath . length ) { System . arraycopy ( newClasspath , <NUM_LIT:0> , newClasspath = new IClasspathEntry [ newCPIndex ] , <NUM_LIT:0> , newCPIndex ) ; } project . setRawClasspath ( newClasspath , this . progressMonitor ) ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . ByteArrayInputStream ; import java . io . IOException ; import java . io . InputStream ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . NullProgressMonitor ; import org . eclipse . core . runtime . Path ; import org . eclipse . core . runtime . jobs . ISchedulingRule ; import org . eclipse . jdt . core . IBuffer ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaElementDelta ; import org . eclipse . jdt . core . IJavaModelStatus ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . JavaConventions ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; public class CreateCompilationUnitOperation extends JavaModelOperation { protected String name ; protected String source = null ; public CreateCompilationUnitOperation ( IPackageFragment parentElement , String name , String source , boolean force ) { super ( null , new IJavaElement [ ] { parentElement } , force ) ; this . name = name ; this . source = source ; } protected void executeOperation ( ) throws JavaModelException { try { beginTask ( Messages . operation_createUnitProgress , <NUM_LIT:2> ) ; JavaElementDelta delta = newJavaElementDelta ( ) ; ICompilationUnit unit = getCompilationUnit ( ) ; IPackageFragment pkg = ( IPackageFragment ) getParentElement ( ) ; IContainer folder = ( IContainer ) pkg . getResource ( ) ; worked ( <NUM_LIT:1> ) ; IFile compilationUnitFile = folder . getFile ( new Path ( this . name ) ) ; if ( compilationUnitFile . exists ( ) ) { if ( this . force ) { IBuffer buffer = unit . getBuffer ( ) ; if ( buffer == null ) return ; buffer . setContents ( this . source ) ; unit . save ( new NullProgressMonitor ( ) , false ) ; this . resultElements = new IJavaElement [ ] { unit } ; if ( ! Util . isExcluded ( unit ) && unit . getParent ( ) . exists ( ) ) { for ( int i = <NUM_LIT:0> ; i < this . resultElements . length ; i ++ ) { delta . changed ( this . resultElements [ i ] , IJavaElementDelta . F_CONTENT ) ; } addDelta ( delta ) ; } } else { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . NAME_COLLISION , Messages . bind ( Messages . status_nameCollision , compilationUnitFile . getFullPath ( ) . toString ( ) ) ) ) ; } } else { try { String encoding = null ; try { encoding = folder . getDefaultCharset ( ) ; } catch ( CoreException ce ) { } InputStream stream = new ByteArrayInputStream ( encoding == null ? this . source . getBytes ( ) : this . source . getBytes ( encoding ) ) ; createFile ( folder , unit . getElementName ( ) , stream , this . force ) ; this . resultElements = new IJavaElement [ ] { unit } ; if ( ! Util . isExcluded ( unit ) && unit . getParent ( ) . exists ( ) ) { for ( int i = <NUM_LIT:0> ; i < this . resultElements . length ; i ++ ) { delta . added ( this . resultElements [ i ] ) ; } addDelta ( delta ) ; } } catch ( IOException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . IO_EXCEPTION ) ; } } worked ( <NUM_LIT:1> ) ; } finally { done ( ) ; } } protected ICompilationUnit getCompilationUnit ( ) { return ( ( IPackageFragment ) getParentElement ( ) ) . getCompilationUnit ( this . name ) ; } protected ISchedulingRule getSchedulingRule ( ) { IResource resource = getCompilationUnit ( ) . getResource ( ) ; IWorkspace workspace = resource . getWorkspace ( ) ; if ( resource . exists ( ) ) { return workspace . getRuleFactory ( ) . modifyRule ( resource ) ; } else { return workspace . getRuleFactory ( ) . createRule ( resource ) ; } } public IJavaModelStatus verify ( ) { if ( getParentElement ( ) == null ) { return new JavaModelStatus ( IJavaModelStatusConstants . NO_ELEMENTS_TO_PROCESS ) ; } IJavaProject project = getParentElement ( ) . getJavaProject ( ) ; if ( JavaConventions . validateCompilationUnitName ( this . name , project . getOption ( JavaCore . COMPILER_SOURCE , true ) , project . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ) . getSeverity ( ) == IStatus . ERROR ) { return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_NAME , this . name ) ; } if ( this . source == null ) { return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_CONTENTS ) ; } return JavaModelStatus . VERIFIED_OK ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . IJavaModelStatus ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . builder . JavaBuilder ; public class ClasspathValidation { private JavaProject project ; public ClasspathValidation ( JavaProject project ) { this . project = project ; } public void validate ( ) { JavaModelManager . PerProjectInfo perProjectInfo ; try { perProjectInfo = this . project . getPerProjectInfo ( ) ; } catch ( JavaModelException e ) { IProject resource = this . project . getProject ( ) ; if ( resource . isAccessible ( ) ) { this . project . flushClasspathProblemMarkers ( true , true , true ) ; JavaBuilder . removeProblemsAndTasksFor ( resource ) ; } return ; } IClasspathEntry [ ] rawClasspath ; IPath outputLocation ; IJavaModelStatus status ; synchronized ( perProjectInfo ) { rawClasspath = perProjectInfo . rawClasspath ; outputLocation = perProjectInfo . outputLocation ; status = perProjectInfo . rawClasspathStatus ; } this . project . flushClasspathProblemMarkers ( false , true , false ) ; if ( ! status . isOK ( ) ) this . project . createClasspathProblemMarker ( status ) ; this . project . flushClasspathProblemMarkers ( false , false , true ) ; this . project . flushClasspathProblemMarkers ( false , false , false ) ; if ( rawClasspath != JavaProject . INVALID_CLASSPATH && outputLocation != null ) { for ( int i = <NUM_LIT:0> ; i < rawClasspath . length ; i ++ ) { status = ClasspathEntry . validateClasspathEntry ( this . project , rawClasspath [ i ] , false , false ) ; if ( ! status . isOK ( ) ) { this . project . createClasspathProblemMarker ( status ) ; } } status = ClasspathEntry . validateClasspath ( this . project , rawClasspath , outputLocation ) ; if ( status . getCode ( ) != IStatus . OK ) this . project . createClasspathProblemMarker ( status ) ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; public class InitializerElementInfo extends MemberElementInfo { } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . runtime . preferences . IEclipsePreferences ; import org . eclipse . core . runtime . preferences . InstanceScope ; import org . eclipse . core . runtime . preferences . PreferenceModifyListener ; import org . eclipse . jdt . core . * ; import org . osgi . service . prefs . BackingStoreException ; import org . osgi . service . prefs . Preferences ; public class JavaCorePreferenceModifyListener extends PreferenceModifyListener { static int PREFIX_LENGTH = JavaModelManager . CP_CONTAINER_PREFERENCES_PREFIX . length ( ) ; JavaModel javaModel = JavaModelManager . getJavaModelManager ( ) . getJavaModel ( ) ; public IEclipsePreferences preApply ( IEclipsePreferences node ) { Preferences instance = node . node ( InstanceScope . SCOPE ) ; cleanJavaCore ( instance . node ( JavaCore . PLUGIN_ID ) ) ; return super . preApply ( node ) ; } void cleanJavaCore ( Preferences preferences ) { try { String [ ] keys = preferences . keys ( ) ; for ( int k = <NUM_LIT:0> , kl = keys . length ; k < kl ; k ++ ) { String key = keys [ k ] ; if ( key . startsWith ( JavaModelManager . CP_CONTAINER_PREFERENCES_PREFIX ) && ! isJavaProjectAccessible ( key ) ) { preferences . remove ( key ) ; } } } catch ( BackingStoreException e ) { } } boolean isJavaProjectAccessible ( String propertyName ) { int index = propertyName . indexOf ( '<CHAR_LIT>' , PREFIX_LENGTH ) ; if ( index > <NUM_LIT:0> ) { final String projectName = propertyName . substring ( PREFIX_LENGTH , index ) . trim ( ) ; JavaProject project = ( JavaProject ) this . javaModel . getJavaProject ( projectName ) ; if ( project . getProject ( ) . isAccessible ( ) ) { return true ; } } return false ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . Enumeration ; import java . util . Iterator ; import org . eclipse . jdt . internal . core . util . LRUCache ; import org . eclipse . jdt . internal . core . util . Messages ; public abstract class OverflowingLRUCache extends LRUCache { protected int overflow = <NUM_LIT:0> ; protected boolean timestampsOn = true ; protected double loadFactor = <NUM_LIT> ; public OverflowingLRUCache ( int size ) { this ( size , <NUM_LIT:0> ) ; } public OverflowingLRUCache ( int size , int overflow ) { super ( size ) ; this . overflow = overflow ; } public Object clone ( ) { OverflowingLRUCache newCache = ( OverflowingLRUCache ) newInstance ( this . spaceLimit , this . overflow ) ; LRUCacheEntry qEntry ; qEntry = this . entryQueueTail ; while ( qEntry != null ) { newCache . privateAdd ( qEntry . key , qEntry . value , qEntry . space ) ; qEntry = qEntry . previous ; } return newCache ; } protected abstract boolean close ( LRUCacheEntry entry ) ; public Enumeration elements ( ) { if ( this . entryQueue == null ) return new LRUCacheEnumerator ( null ) ; LRUCacheEnumerator . LRUEnumeratorElement head = new LRUCacheEnumerator . LRUEnumeratorElement ( this . entryQueue . value ) ; LRUCacheEntry currentEntry = this . entryQueue . next ; LRUCacheEnumerator . LRUEnumeratorElement currentElement = head ; while ( currentEntry != null ) { currentElement . next = new LRUCacheEnumerator . LRUEnumeratorElement ( currentEntry . value ) ; currentElement = currentElement . next ; currentEntry = currentEntry . next ; } return new LRUCacheEnumerator ( head ) ; } public double fillingRatio ( ) { return ( this . currentSpace + this . overflow ) * <NUM_LIT> / this . spaceLimit ; } public java . util . Hashtable getEntryTable ( ) { return this . entryTable ; } public double getLoadFactor ( ) { return this . loadFactor ; } public int getOverflow ( ) { return this . overflow ; } protected boolean makeSpace ( int space ) { int limit = this . spaceLimit ; if ( this . overflow == <NUM_LIT:0> && this . currentSpace + space <= limit ) { return true ; } int spaceNeeded = ( int ) ( ( <NUM_LIT:1> - this . loadFactor ) * limit ) ; spaceNeeded = ( spaceNeeded > space ) ? spaceNeeded : space ; LRUCacheEntry entry = this . entryQueueTail ; try { this . timestampsOn = false ; while ( this . currentSpace + spaceNeeded > limit && entry != null ) { this . privateRemoveEntry ( entry , false , false ) ; entry = entry . previous ; } } finally { this . timestampsOn = true ; } if ( this . currentSpace + space <= limit ) { this . overflow = <NUM_LIT:0> ; return true ; } this . overflow = this . currentSpace + space - limit ; return false ; } protected abstract LRUCache newInstance ( int size , int newOverflow ) ; public void printStats ( ) { int forwardListLength = <NUM_LIT:0> ; LRUCacheEntry entry = this . entryQueue ; while ( entry != null ) { forwardListLength ++ ; entry = entry . next ; } System . out . println ( "<STR_LIT>" + forwardListLength ) ; int backwardListLength = <NUM_LIT:0> ; entry = this . entryQueueTail ; while ( entry != null ) { backwardListLength ++ ; entry = entry . previous ; } System . out . println ( "<STR_LIT>" + backwardListLength ) ; Enumeration keys = this . entryTable . keys ( ) ; class Temp { public Class clazz ; public int count ; public Temp ( Class aClass ) { this . clazz = aClass ; this . count = <NUM_LIT:1> ; } public String toString ( ) { return "<STR_LIT>" + this . clazz + "<STR_LIT>" + this . count + "<STR_LIT>" ; } } java . util . HashMap h = new java . util . HashMap ( ) ; while ( keys . hasMoreElements ( ) ) { entry = ( LRUCacheEntry ) this . entryTable . get ( keys . nextElement ( ) ) ; Class key = entry . value . getClass ( ) ; Temp t = ( Temp ) h . get ( key ) ; if ( t == null ) { h . put ( key , new Temp ( key ) ) ; } else { t . count ++ ; } } for ( Iterator iter = h . values ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { System . out . println ( iter . next ( ) ) ; } } protected void privateRemoveEntry ( LRUCacheEntry entry , boolean shuffle ) { privateRemoveEntry ( entry , shuffle , true ) ; } protected void privateRemoveEntry ( LRUCacheEntry entry , boolean shuffle , boolean external ) { if ( ! shuffle ) { if ( external ) { this . entryTable . remove ( entry . key ) ; this . currentSpace -= entry . space ; } else { if ( ! close ( entry ) ) return ; if ( this . entryTable . get ( entry . key ) == null ) { return ; } else { this . entryTable . remove ( entry . key ) ; this . currentSpace -= entry . space ; } } } LRUCacheEntry previous = entry . previous ; LRUCacheEntry next = entry . next ; if ( previous == null ) { this . entryQueue = next ; } else { previous . next = next ; } if ( next == null ) { this . entryQueueTail = previous ; } else { next . previous = previous ; } } public Object put ( Object key , Object value ) { if ( this . overflow > <NUM_LIT:0> ) shrink ( ) ; int newSpace = spaceFor ( value ) ; LRUCacheEntry entry = ( LRUCacheEntry ) this . entryTable . get ( key ) ; if ( entry != null ) { int oldSpace = entry . space ; int newTotal = this . currentSpace - oldSpace + newSpace ; if ( newTotal <= this . spaceLimit ) { updateTimestamp ( entry ) ; entry . value = value ; entry . space = newSpace ; this . currentSpace = newTotal ; this . overflow = <NUM_LIT:0> ; return value ; } else { privateRemoveEntry ( entry , false , false ) ; } } makeSpace ( newSpace ) ; privateAdd ( key , value , newSpace ) ; return value ; } public Object remove ( Object key ) { return removeKey ( key ) ; } public void setLoadFactor ( double newLoadFactor ) throws IllegalArgumentException { if ( newLoadFactor <= <NUM_LIT:1.0> && newLoadFactor > <NUM_LIT:0.0> ) this . loadFactor = newLoadFactor ; else throw new IllegalArgumentException ( Messages . cache_invalidLoadFactor ) ; } public void setSpaceLimit ( int limit ) { if ( limit < this . spaceLimit ) { makeSpace ( this . spaceLimit - limit ) ; } this . spaceLimit = limit ; } public boolean shrink ( ) { if ( this . overflow > <NUM_LIT:0> ) return makeSpace ( <NUM_LIT:0> ) ; return true ; } public String toString ( ) { return toStringFillingRation ( "<STR_LIT>" ) + toStringContents ( ) ; } protected void updateTimestamp ( LRUCacheEntry entry ) { if ( this . timestampsOn ) { entry . timestamp = this . timestampCounter ++ ; if ( this . entryQueue != entry ) { this . privateRemoveEntry ( entry , true ) ; privateAddEntry ( entry , true ) ; } } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . HashSet ; import java . util . Iterator ; import org . eclipse . jdt . core . * ; public class ModelUpdater { HashSet projectsToUpdate = new HashSet ( ) ; protected void addToParentInfo ( Openable child ) { Openable parent = ( Openable ) child . getParent ( ) ; if ( parent != null && parent . isOpen ( ) ) { try { OpenableElementInfo info = ( OpenableElementInfo ) parent . getElementInfo ( ) ; info . addChild ( child ) ; } catch ( JavaModelException e ) { } } } protected static void close ( Openable element ) { try { element . close ( ) ; } catch ( JavaModelException e ) { } } protected void elementAdded ( Openable element ) { int elementType = element . getElementType ( ) ; if ( elementType == IJavaElement . JAVA_PROJECT ) { addToParentInfo ( element ) ; this . projectsToUpdate . add ( element ) ; } else { addToParentInfo ( element ) ; close ( element ) ; } switch ( elementType ) { case IJavaElement . PACKAGE_FRAGMENT_ROOT : this . projectsToUpdate . add ( element . getJavaProject ( ) ) ; break ; case IJavaElement . PACKAGE_FRAGMENT : JavaProject project = ( JavaProject ) element . getJavaProject ( ) ; project . resetCaches ( ) ; break ; } } protected void elementChanged ( Openable element ) { close ( element ) ; } protected void elementRemoved ( Openable element ) { if ( element . isOpen ( ) ) { close ( element ) ; } removeFromParentInfo ( element ) ; int elementType = element . getElementType ( ) ; switch ( elementType ) { case IJavaElement . JAVA_MODEL : JavaModelManager . getIndexManager ( ) . reset ( ) ; break ; case IJavaElement . JAVA_PROJECT : JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; JavaProject javaProject = ( JavaProject ) element ; manager . removePerProjectInfo ( javaProject , true ) ; manager . containerRemove ( javaProject ) ; break ; case IJavaElement . PACKAGE_FRAGMENT_ROOT : this . projectsToUpdate . add ( element . getJavaProject ( ) ) ; break ; case IJavaElement . PACKAGE_FRAGMENT : JavaProject project = ( JavaProject ) element . getJavaProject ( ) ; project . resetCaches ( ) ; break ; } } public void processJavaDelta ( IJavaElementDelta delta ) { try { traverseDelta ( delta , null , null ) ; Iterator iterator = this . projectsToUpdate . iterator ( ) ; while ( iterator . hasNext ( ) ) { JavaProject project = ( JavaProject ) iterator . next ( ) ; project . resetCaches ( ) ; } } finally { this . projectsToUpdate = new HashSet ( ) ; } } protected void removeFromParentInfo ( Openable child ) { Openable parent = ( Openable ) child . getParent ( ) ; if ( parent != null && parent . isOpen ( ) ) { try { OpenableElementInfo info = ( OpenableElementInfo ) parent . getElementInfo ( ) ; info . removeChild ( child ) ; } catch ( JavaModelException e ) { } } } protected void traverseDelta ( IJavaElementDelta delta , IPackageFragmentRoot root , IJavaProject project ) { boolean processChildren = true ; Openable element = ( Openable ) delta . getElement ( ) ; switch ( element . getElementType ( ) ) { case IJavaElement . JAVA_PROJECT : project = ( IJavaProject ) element ; break ; case IJavaElement . PACKAGE_FRAGMENT_ROOT : root = ( IPackageFragmentRoot ) element ; break ; case IJavaElement . COMPILATION_UNIT : CompilationUnit cu = ( CompilationUnit ) element ; if ( cu . isWorkingCopy ( ) && ! cu . isPrimary ( ) ) { return ; } case IJavaElement . CLASS_FILE : processChildren = false ; break ; } switch ( delta . getKind ( ) ) { case IJavaElementDelta . ADDED : elementAdded ( element ) ; break ; case IJavaElementDelta . REMOVED : elementRemoved ( element ) ; break ; case IJavaElementDelta . CHANGED : if ( ( delta . getFlags ( ) & IJavaElementDelta . F_CONTENT ) != <NUM_LIT:0> ) { elementChanged ( element ) ; } break ; } if ( processChildren ) { IJavaElementDelta [ ] children = delta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { IJavaElementDelta childDelta = children [ i ] ; traverseDelta ( childDelta , root , project ) ; } } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . IClassFile ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . core . IMemberValuePair ; import org . eclipse . jdt . core . ISourceRange ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . SourceRange ; import org . eclipse . jdt . internal . compiler . env . IBinaryAnnotation ; import org . eclipse . jdt . internal . compiler . env . IBinaryElementValuePair ; import org . eclipse . jdt . internal . core . util . Util ; public class Annotation extends SourceRefElement implements IAnnotation { public static final IAnnotation [ ] NO_ANNOTATIONS = new IAnnotation [ <NUM_LIT:0> ] ; public static final IMemberValuePair [ ] NO_MEMBER_VALUE_PAIRS = new IMemberValuePair [ <NUM_LIT:0> ] ; protected String name ; protected String memberValuePairName ; public Annotation ( JavaElement parent , String name ) { this ( parent , name , null ) ; } public Annotation ( JavaElement parent , String name , String memberValuePairName ) { super ( parent ) ; this . name = name ; this . memberValuePairName = memberValuePairName ; } public boolean equals ( Object o ) { if ( ! ( o instanceof Annotation ) ) { return false ; } Annotation other = ( Annotation ) o ; if ( this . memberValuePairName == null ) { if ( other . memberValuePairName != null ) return false ; } else if ( ! this . memberValuePairName . equals ( other . memberValuePairName ) ) { return false ; } return super . equals ( o ) ; } public IMember getDeclaringMember ( ) { return ( IMember ) getParent ( ) ; } public String getElementName ( ) { return this . name ; } public int getElementType ( ) { return ANNOTATION ; } protected char getHandleMementoDelimiter ( ) { return JavaElement . JEM_ANNOTATION ; } public IMemberValuePair [ ] getMemberValuePairs ( ) throws JavaModelException { Object info = getElementInfo ( ) ; if ( info instanceof AnnotationInfo ) return ( ( AnnotationInfo ) info ) . members ; IBinaryElementValuePair [ ] binaryAnnotations = ( ( IBinaryAnnotation ) info ) . getElementValuePairs ( ) ; int length = binaryAnnotations . length ; IMemberValuePair [ ] result = new IMemberValuePair [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IBinaryElementValuePair binaryAnnotation = binaryAnnotations [ i ] ; MemberValuePair memberValuePair = new MemberValuePair ( new String ( binaryAnnotation . getName ( ) ) ) ; memberValuePair . value = Util . getAnnotationMemberValue ( this , memberValuePair , binaryAnnotation . getValue ( ) ) ; result [ i ] = memberValuePair ; } return result ; } public ISourceRange getNameRange ( ) throws JavaModelException { SourceMapper mapper = getSourceMapper ( ) ; if ( mapper != null ) { ClassFile classFile = ( ClassFile ) getClassFile ( ) ; if ( classFile != null ) { classFile . getBuffer ( ) ; return mapper . getNameRange ( this ) ; } } Object info = getElementInfo ( ) ; if ( info instanceof AnnotationInfo ) { AnnotationInfo annotationInfo = ( AnnotationInfo ) info ; return new SourceRange ( annotationInfo . nameStart , annotationInfo . nameEnd - annotationInfo . nameStart + <NUM_LIT:1> ) ; } return null ; } public ISourceRange getSourceRange ( ) throws JavaModelException { SourceMapper mapper = getSourceMapper ( ) ; if ( mapper != null ) { ClassFile classFile = ( ClassFile ) getClassFile ( ) ; if ( classFile != null ) { classFile . getBuffer ( ) ; return mapper . getSourceRange ( this ) ; } } return super . getSourceRange ( ) ; } public IClassFile getClassFile ( ) { return ( ( JavaElement ) getParent ( ) ) . getClassFile ( ) ; } public int hashCode ( ) { final int prime = <NUM_LIT:31> ; int result = super . hashCode ( ) ; result = prime * result + ( ( this . memberValuePairName == null ) ? <NUM_LIT:0> : this . memberValuePairName . hashCode ( ) ) ; result = prime * result + this . name . hashCode ( ) ; return result ; } protected void toStringName ( StringBuffer buffer ) { buffer . append ( '<CHAR_LIT>' ) ; buffer . append ( getElementName ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; class JarPackageFragmentInfo extends PackageFragmentInfo { Object [ ] getNonJavaResources ( ) { return this . nonJavaResources ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; public class ResolvedSourceMethod extends SourceMethod { private String uniqueKey ; public ResolvedSourceMethod ( JavaElement parent , String name , String [ ] parameterTypes , String uniqueKey ) { super ( parent , name , parameterTypes ) ; this . uniqueKey = uniqueKey ; } public String getKey ( ) { return this . uniqueKey ; } public boolean isResolved ( ) { return true ; } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { super . toStringInfo ( tab , buffer , info , showResolvedInfo ) ; if ( showResolvedInfo ) { buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . getKey ( ) ) ; buffer . append ( "<STR_LIT:}>" ) ; } } public JavaElement unresolved ( ) { SourceRefElement handle = new SourceMethod ( this . parent , this . name , this . parameterTypes ) ; handle . occurrenceCount = this . occurrenceCount ; return handle ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . env . ISourceMethod ; public abstract class SourceMethodElementInfo extends AnnotatableInfo implements ISourceMethod { protected char [ ] [ ] argumentNames ; protected char [ ] [ ] exceptionTypes ; protected ILocalVariable [ ] arguments ; protected ITypeParameter [ ] typeParameters = TypeParameter . NO_TYPE_PARAMETERS ; public char [ ] [ ] getArgumentNames ( ) { return this . argumentNames ; } public char [ ] [ ] getExceptionTypeNames ( ) { return this . exceptionTypes ; } public abstract char [ ] getReturnTypeName ( ) ; public char [ ] [ ] [ ] getTypeParameterBounds ( ) { int length = this . typeParameters . length ; char [ ] [ ] [ ] typeParameterBounds = new char [ length ] [ ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { try { TypeParameterElementInfo info = ( TypeParameterElementInfo ) ( ( JavaElement ) this . typeParameters [ i ] ) . getElementInfo ( ) ; typeParameterBounds [ i ] = info . bounds ; } catch ( JavaModelException e ) { } } return typeParameterBounds ; } public char [ ] [ ] getTypeParameterNames ( ) { int length = this . typeParameters . length ; if ( length == <NUM_LIT:0> ) return CharOperation . NO_CHAR_CHAR ; char [ ] [ ] typeParameterNames = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { typeParameterNames [ i ] = this . typeParameters [ i ] . getElementName ( ) . toCharArray ( ) ; } return typeParameterNames ; } public abstract boolean isConstructor ( ) ; public abstract boolean isAnnotationMethod ( ) ; protected void setArgumentNames ( char [ ] [ ] names ) { this . argumentNames = names ; } protected void setExceptionTypeNames ( char [ ] [ ] types ) { this . exceptionTypes = types ; } protected abstract void setReturnType ( char [ ] type ) ; } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . internal . codeassist . ISearchRequestor ; import org . eclipse . jdt . internal . compiler . env . NameEnvironmentAnswer ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; public class CancelableNameEnvironment extends SearchableEnvironment implements INameEnvironmentWithProgress { private IProgressMonitor monitor ; public CancelableNameEnvironment ( JavaProject project , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException { super ( project , owner ) ; setMonitor ( monitor ) ; } private void checkCanceled ( ) { if ( this . monitor != null && this . monitor . isCanceled ( ) ) { if ( NameLookup . VERBOSE ) System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" ) ; throw new AbortCompilation ( true , new OperationCanceledException ( ) ) ; } } public void findPackages ( char [ ] prefix , ISearchRequestor requestor ) { checkCanceled ( ) ; super . findPackages ( prefix , requestor ) ; } public NameEnvironmentAnswer findType ( char [ ] name , char [ ] [ ] packageName ) { checkCanceled ( ) ; return super . findType ( name , packageName ) ; } public NameEnvironmentAnswer findType ( char [ ] [ ] compoundTypeName ) { checkCanceled ( ) ; return super . findType ( compoundTypeName ) ; } public void findTypes ( char [ ] prefix , boolean findMembers , boolean camelCaseMatch , int searchFor , ISearchRequestor storage , IProgressMonitor progressMonitor ) { checkCanceled ( ) ; super . findTypes ( prefix , findMembers , camelCaseMatch , searchFor , storage , progressMonitor ) ; } public void setMonitor ( IProgressMonitor monitor ) { this . monitor = monitor ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . ArrayList ; import java . util . Enumeration ; import java . util . Map ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . core . util . MementoTokenizer ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; public class PackageFragmentRoot extends Openable implements IPackageFragmentRoot { protected final static char ATTACHMENT_PROPERTY_DELIMITER = '<CHAR_LIT>' ; public final static String NO_SOURCE_ATTACHMENT = "<STR_LIT>" ; protected IResource resource ; protected PackageFragmentRoot ( IResource resource , JavaProject project ) { super ( project ) ; this . resource = resource ; } public void attachSource ( IPath sourcePath , IPath rootPath , IProgressMonitor monitor ) throws JavaModelException { try { verifyAttachSource ( sourcePath ) ; if ( monitor != null ) { monitor . beginTask ( Messages . element_attachingSource , <NUM_LIT:2> ) ; } SourceMapper oldMapper = getSourceMapper ( ) ; boolean rootNeedsToBeClosed = false ; if ( sourcePath == null ) { rootNeedsToBeClosed = true ; setSourceMapper ( null ) ; } else { IPath storedSourcePath = getSourceAttachmentPath ( ) ; IPath storedRootPath = getSourceAttachmentRootPath ( ) ; if ( monitor != null ) { monitor . worked ( <NUM_LIT:1> ) ; } if ( storedSourcePath != null ) { if ( ! ( storedSourcePath . equals ( sourcePath ) && ( rootPath != null && rootPath . equals ( storedRootPath ) ) || storedRootPath == null ) ) { rootNeedsToBeClosed = true ; } } Object target = JavaModel . getTarget ( sourcePath , false ) ; if ( target == null ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_PATH , sourcePath ) ) ; } SourceMapper mapper = createSourceMapper ( sourcePath , rootPath ) ; if ( rootPath == null && mapper . rootPath != null ) { rootPath = new Path ( mapper . rootPath ) ; } setSourceMapper ( mapper ) ; } if ( sourcePath == null ) { Util . setSourceAttachmentProperty ( getPath ( ) , null ) ; } else { Util . setSourceAttachmentProperty ( getPath ( ) , sourcePath . toString ( ) + ( rootPath == null ? "<STR_LIT>" : ( ATTACHMENT_PROPERTY_DELIMITER + rootPath . toString ( ) ) ) ) ; } if ( rootNeedsToBeClosed ) { if ( oldMapper != null ) { oldMapper . close ( ) ; } BufferManager manager = BufferManager . getDefaultBufferManager ( ) ; Enumeration openBuffers = manager . getOpenBuffers ( ) ; while ( openBuffers . hasMoreElements ( ) ) { IBuffer buffer = ( IBuffer ) openBuffers . nextElement ( ) ; IOpenable possibleMember = buffer . getOwner ( ) ; if ( isAncestorOf ( ( IJavaElement ) possibleMember ) ) { buffer . close ( ) ; } } if ( monitor != null ) { monitor . worked ( <NUM_LIT:1> ) ; } } } catch ( JavaModelException e ) { Util . setSourceAttachmentProperty ( getPath ( ) , null ) ; throw e ; } finally { if ( monitor != null ) { monitor . done ( ) ; } } } protected boolean buildStructure ( OpenableElementInfo info , IProgressMonitor pm , Map newElements , IResource underlyingResource ) throws JavaModelException { ( ( PackageFragmentRootInfo ) info ) . setRootKind ( determineKind ( underlyingResource ) ) ; return computeChildren ( info , underlyingResource ) ; } SourceMapper createSourceMapper ( IPath sourcePath , IPath rootPath ) { SourceMapper mapper = new SourceMapper ( sourcePath , rootPath == null ? null : rootPath . toOSString ( ) , getJavaProject ( ) . getOptions ( true ) ) ; return mapper ; } public void delete ( int updateResourceFlags , int updateModelFlags , IProgressMonitor monitor ) throws JavaModelException { DeletePackageFragmentRootOperation op = new DeletePackageFragmentRootOperation ( this , updateResourceFlags , updateModelFlags ) ; op . runOperation ( monitor ) ; } protected boolean computeChildren ( OpenableElementInfo info , IResource underlyingResource ) throws JavaModelException { try { if ( underlyingResource . getType ( ) == IResource . FOLDER || underlyingResource . getType ( ) == IResource . PROJECT ) { ArrayList vChildren = new ArrayList ( <NUM_LIT:5> ) ; IContainer rootFolder = ( IContainer ) underlyingResource ; char [ ] [ ] inclusionPatterns = fullInclusionPatternChars ( ) ; char [ ] [ ] exclusionPatterns = fullExclusionPatternChars ( ) ; computeFolderChildren ( rootFolder , ! Util . isExcluded ( rootFolder , inclusionPatterns , exclusionPatterns ) , CharOperation . NO_STRINGS , vChildren , inclusionPatterns , exclusionPatterns ) ; IJavaElement [ ] children = new IJavaElement [ vChildren . size ( ) ] ; vChildren . toArray ( children ) ; info . setChildren ( children ) ; } } catch ( JavaModelException e ) { info . setChildren ( new IJavaElement [ ] { } ) ; throw e ; } return true ; } protected void computeFolderChildren ( IContainer folder , boolean isIncluded , String [ ] pkgName , ArrayList vChildren , char [ ] [ ] inclusionPatterns , char [ ] [ ] exclusionPatterns ) throws JavaModelException { if ( isIncluded ) { IPackageFragment pkg = getPackageFragment ( pkgName ) ; vChildren . add ( pkg ) ; } try { JavaProject javaProject = ( JavaProject ) getJavaProject ( ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; IResource [ ] members = folder . members ( ) ; boolean hasIncluded = isIncluded ; int length = members . length ; if ( length > <NUM_LIT:0> ) { String sourceLevel = javaProject . getOption ( JavaCore . COMPILER_SOURCE , true ) ; String complianceLevel = javaProject . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IResource member = members [ i ] ; String memberName = member . getName ( ) ; switch ( member . getType ( ) ) { case IResource . FOLDER : if ( Util . isValidFolderNameForPackage ( memberName , sourceLevel , complianceLevel ) ) { if ( javaProject . contains ( member ) ) { String [ ] newNames = Util . arrayConcat ( pkgName , manager . intern ( memberName ) ) ; boolean isMemberIncluded = ! Util . isExcluded ( member , inclusionPatterns , exclusionPatterns ) ; computeFolderChildren ( ( IFolder ) member , isMemberIncluded , newNames , vChildren , inclusionPatterns , exclusionPatterns ) ; } } break ; case IResource . FILE : if ( ! hasIncluded && Util . isValidCompilationUnitName ( memberName , sourceLevel , complianceLevel ) && ! Util . isExcluded ( member , inclusionPatterns , exclusionPatterns ) ) { hasIncluded = true ; IPackageFragment pkg = getPackageFragment ( pkgName ) ; vChildren . add ( pkg ) ; } break ; } } } } catch ( IllegalArgumentException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } public void copy ( IPath destination , int updateResourceFlags , int updateModelFlags , IClasspathEntry sibling , IProgressMonitor monitor ) throws JavaModelException { CopyPackageFragmentRootOperation op = new CopyPackageFragmentRootOperation ( this , destination , updateResourceFlags , updateModelFlags , sibling ) ; op . runOperation ( monitor ) ; } protected Object createElementInfo ( ) { return new PackageFragmentRootInfo ( ) ; } public IPackageFragment createPackageFragment ( String pkgName , boolean force , IProgressMonitor monitor ) throws JavaModelException { CreatePackageFragmentOperation op = new CreatePackageFragmentOperation ( this , pkgName , force ) ; op . runOperation ( monitor ) ; return getPackageFragment ( op . pkgName ) ; } protected int determineKind ( IResource underlyingResource ) throws JavaModelException { IClasspathEntry entry = ( ( JavaProject ) getJavaProject ( ) ) . getClasspathEntryFor ( underlyingResource . getFullPath ( ) ) ; if ( entry != null ) { return entry . getContentKind ( ) ; } return IPackageFragmentRoot . K_SOURCE ; } public boolean equals ( Object o ) { if ( this == o ) return true ; if ( ! ( o instanceof PackageFragmentRoot ) ) return false ; PackageFragmentRoot other = ( PackageFragmentRoot ) o ; return resource ( ) . equals ( other . resource ( ) ) && this . parent . equals ( other . parent ) ; } private IClasspathEntry findSourceAttachmentRecommendation ( ) { try { IPath rootPath = getPath ( ) ; IClasspathEntry entry ; JavaProject parentProject = ( JavaProject ) getJavaProject ( ) ; try { entry = parentProject . getClasspathEntryFor ( rootPath ) ; if ( entry != null ) { Object target = JavaModel . getTarget ( entry . getSourceAttachmentPath ( ) , true ) ; if ( target != null ) { return entry ; } } } catch ( JavaModelException e ) { } IJavaModel model = getJavaModel ( ) ; IJavaProject [ ] jProjects = model . getJavaProjects ( ) ; for ( int i = <NUM_LIT:0> , max = jProjects . length ; i < max ; i ++ ) { JavaProject jProject = ( JavaProject ) jProjects [ i ] ; if ( jProject == parentProject ) continue ; try { entry = jProject . getClasspathEntryFor ( rootPath ) ; if ( entry != null ) { Object target = JavaModel . getTarget ( entry . getSourceAttachmentPath ( ) , true ) ; if ( target != null ) { return entry ; } } } catch ( JavaModelException e ) { } } } catch ( JavaModelException e ) { } return null ; } public char [ ] [ ] fullExclusionPatternChars ( ) { try { if ( isOpen ( ) && getKind ( ) != IPackageFragmentRoot . K_SOURCE ) return null ; ClasspathEntry entry = ( ClasspathEntry ) getRawClasspathEntry ( ) ; if ( entry == null ) { return null ; } else { return entry . fullExclusionPatternChars ( ) ; } } catch ( JavaModelException e ) { return null ; } } public char [ ] [ ] fullInclusionPatternChars ( ) { try { if ( isOpen ( ) && getKind ( ) != IPackageFragmentRoot . K_SOURCE ) return null ; ClasspathEntry entry = ( ClasspathEntry ) getRawClasspathEntry ( ) ; if ( entry == null ) { return null ; } else { return entry . fullInclusionPatternChars ( ) ; } } catch ( JavaModelException e ) { return null ; } } public String getElementName ( ) { IResource res = resource ( ) ; if ( res instanceof IFolder ) return ( ( IFolder ) res ) . getName ( ) ; return "<STR_LIT>" ; } public int getElementType ( ) { return PACKAGE_FRAGMENT_ROOT ; } protected char getHandleMementoDelimiter ( ) { return JavaElement . JEM_PACKAGEFRAGMENTROOT ; } public IJavaElement getHandleFromMemento ( String token , MementoTokenizer memento , WorkingCopyOwner owner ) { switch ( token . charAt ( <NUM_LIT:0> ) ) { case JEM_PACKAGEFRAGMENT : String [ ] pkgName ; if ( memento . hasMoreTokens ( ) ) { token = memento . nextToken ( ) ; char firstChar = token . charAt ( <NUM_LIT:0> ) ; if ( firstChar == JEM_CLASSFILE || firstChar == JEM_COMPILATIONUNIT || firstChar == JEM_COUNT ) { pkgName = CharOperation . NO_STRINGS ; } else { pkgName = Util . splitOn ( '<CHAR_LIT:.>' , token , <NUM_LIT:0> , token . length ( ) ) ; token = null ; } } else { pkgName = CharOperation . NO_STRINGS ; token = null ; } JavaElement pkg = getPackageFragment ( pkgName ) ; if ( token == null ) { return pkg . getHandleFromMemento ( memento , owner ) ; } else { return pkg . getHandleFromMemento ( token , memento , owner ) ; } } return null ; } protected void getHandleMemento ( StringBuffer buff ) { IPath path ; IResource underlyingResource = getResource ( ) ; if ( underlyingResource != null ) { if ( resource ( ) . getProject ( ) . equals ( getJavaProject ( ) . getProject ( ) ) ) { path = underlyingResource . getProjectRelativePath ( ) ; } else { path = underlyingResource . getFullPath ( ) ; } } else { path = getPath ( ) ; } ( ( JavaElement ) getParent ( ) ) . getHandleMemento ( buff ) ; buff . append ( getHandleMementoDelimiter ( ) ) ; escapeMementoName ( buff , path . toString ( ) ) ; } public int getKind ( ) throws JavaModelException { return ( ( PackageFragmentRootInfo ) getElementInfo ( ) ) . getRootKind ( ) ; } int internalKind ( ) throws JavaModelException { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; PackageFragmentRootInfo info = ( PackageFragmentRootInfo ) manager . peekAtInfo ( this ) ; if ( info == null ) { info = ( PackageFragmentRootInfo ) openWhenClosed ( createElementInfo ( ) , null ) ; } return info . getRootKind ( ) ; } public Object [ ] getNonJavaResources ( ) throws JavaModelException { return ( ( PackageFragmentRootInfo ) getElementInfo ( ) ) . getNonJavaResources ( getJavaProject ( ) , resource ( ) , this ) ; } public IPackageFragment getPackageFragment ( String packageName ) { String [ ] pkgName = Util . getTrimmedSimpleNames ( packageName ) ; return getPackageFragment ( pkgName ) ; } public PackageFragment getPackageFragment ( String [ ] pkgName ) { return new PackageFragment ( this , pkgName ) ; } protected String getPackageName ( IFolder folder ) { IPath myPath = getPath ( ) ; IPath pkgPath = folder . getFullPath ( ) ; int mySegmentCount = myPath . segmentCount ( ) ; int pkgSegmentCount = pkgPath . segmentCount ( ) ; StringBuffer pkgName = new StringBuffer ( IPackageFragment . DEFAULT_PACKAGE_NAME ) ; for ( int i = mySegmentCount ; i < pkgSegmentCount ; i ++ ) { if ( i > mySegmentCount ) { pkgName . append ( '<CHAR_LIT:.>' ) ; } pkgName . append ( pkgPath . segment ( i ) ) ; } return pkgName . toString ( ) ; } public IPath getPath ( ) { return internalPath ( ) ; } public IPath internalPath ( ) { return resource ( ) . getFullPath ( ) ; } public IClasspathEntry getRawClasspathEntry ( ) throws JavaModelException { IClasspathEntry rawEntry = null ; JavaProject project = ( JavaProject ) getJavaProject ( ) ; project . getResolvedClasspath ( ) ; Map rootPathToRawEntries = project . getPerProjectInfo ( ) . rootPathToRawEntries ; if ( rootPathToRawEntries != null ) { rawEntry = ( IClasspathEntry ) rootPathToRawEntries . get ( getPath ( ) ) ; } if ( rawEntry == null ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . ELEMENT_NOT_ON_CLASSPATH , this ) ) ; } return rawEntry ; } public IClasspathEntry getResolvedClasspathEntry ( ) throws JavaModelException { IClasspathEntry resolvedEntry = null ; JavaProject project = ( JavaProject ) getJavaProject ( ) ; project . getResolvedClasspath ( ) ; Map rootPathToResolvedEntries = project . getPerProjectInfo ( ) . rootPathToResolvedEntries ; if ( rootPathToResolvedEntries != null ) { resolvedEntry = ( IClasspathEntry ) rootPathToResolvedEntries . get ( getPath ( ) ) ; } if ( resolvedEntry == null ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . ELEMENT_NOT_ON_CLASSPATH , this ) ) ; } return resolvedEntry ; } public IResource resource ( ) { if ( this . resource != null ) return this . resource ; return super . resource ( ) ; } public IResource resource ( PackageFragmentRoot root ) { return this . resource ; } public IPath getSourceAttachmentPath ( ) throws JavaModelException { if ( getKind ( ) != K_BINARY ) return null ; IPath path = getPath ( ) ; String serverPathString = Util . getSourceAttachmentProperty ( path ) ; if ( serverPathString != null ) { int index = serverPathString . lastIndexOf ( ATTACHMENT_PROPERTY_DELIMITER ) ; if ( index < <NUM_LIT:0> ) { return new Path ( serverPathString ) ; } else { String serverSourcePathString = serverPathString . substring ( <NUM_LIT:0> , index ) ; return new Path ( serverSourcePathString ) ; } } IClasspathEntry entry = ( ( JavaProject ) getParent ( ) ) . getClasspathEntryFor ( path ) ; IPath sourceAttachmentPath ; if ( entry != null && ( sourceAttachmentPath = entry . getSourceAttachmentPath ( ) ) != null ) return sourceAttachmentPath ; entry = findSourceAttachmentRecommendation ( ) ; if ( entry != null && ( sourceAttachmentPath = entry . getSourceAttachmentPath ( ) ) != null ) { return sourceAttachmentPath ; } return null ; } public void setSourceMapper ( SourceMapper mapper ) throws JavaModelException { ( ( PackageFragmentRootInfo ) getElementInfo ( ) ) . setSourceMapper ( mapper ) ; } public IPath getSourceAttachmentRootPath ( ) throws JavaModelException { if ( getKind ( ) != K_BINARY ) return null ; IPath path = getPath ( ) ; String serverPathString = Util . getSourceAttachmentProperty ( path ) ; if ( serverPathString != null ) { int index = serverPathString . lastIndexOf ( ATTACHMENT_PROPERTY_DELIMITER ) ; if ( index == - <NUM_LIT:1> ) return null ; String serverRootPathString = IPackageFragmentRoot . DEFAULT_PACKAGEROOT_PATH ; if ( index != serverPathString . length ( ) - <NUM_LIT:1> ) { serverRootPathString = serverPathString . substring ( index + <NUM_LIT:1> ) ; } return new Path ( serverRootPathString ) ; } IClasspathEntry entry = ( ( JavaProject ) getParent ( ) ) . getClasspathEntryFor ( path ) ; IPath sourceAttachmentRootPath ; if ( entry != null && ( sourceAttachmentRootPath = entry . getSourceAttachmentRootPath ( ) ) != null ) return sourceAttachmentRootPath ; entry = findSourceAttachmentRecommendation ( ) ; if ( entry != null && ( sourceAttachmentRootPath = entry . getSourceAttachmentRootPath ( ) ) != null ) return sourceAttachmentRootPath ; return null ; } public SourceMapper getSourceMapper ( ) { SourceMapper mapper ; try { PackageFragmentRootInfo rootInfo = ( PackageFragmentRootInfo ) getElementInfo ( ) ; mapper = rootInfo . getSourceMapper ( ) ; if ( mapper == null ) { IPath sourcePath = getSourceAttachmentPath ( ) ; IPath rootPath = getSourceAttachmentRootPath ( ) ; if ( sourcePath == null ) mapper = createSourceMapper ( getPath ( ) , rootPath ) ; else mapper = createSourceMapper ( sourcePath , rootPath ) ; rootInfo . setSourceMapper ( mapper ) ; } } catch ( JavaModelException e ) { mapper = null ; } return mapper ; } public IResource getUnderlyingResource ( ) throws JavaModelException { if ( ! exists ( ) ) throw newNotPresentException ( ) ; return resource ( ) ; } public boolean hasChildren ( ) throws JavaModelException { return true ; } public int hashCode ( ) { return resource ( ) . hashCode ( ) ; } public boolean isArchive ( ) { return false ; } public boolean isExternal ( ) { return false ; } protected IStatus validateOnClasspath ( ) { IPath path = getPath ( ) ; try { JavaProject project = ( JavaProject ) getJavaProject ( ) ; IClasspathEntry entry = project . getClasspathEntryFor ( path ) ; if ( entry != null ) { return Status . OK_STATUS ; } } catch ( JavaModelException e ) { return e . getJavaModelStatus ( ) ; } return new JavaModelStatus ( IJavaModelStatusConstants . ELEMENT_NOT_ON_CLASSPATH , this ) ; } public void move ( IPath destination , int updateResourceFlags , int updateModelFlags , IClasspathEntry sibling , IProgressMonitor monitor ) throws JavaModelException { MovePackageFragmentRootOperation op = new MovePackageFragmentRootOperation ( this , destination , updateResourceFlags , updateModelFlags , sibling ) ; op . runOperation ( monitor ) ; } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { buffer . append ( tabString ( tab ) ) ; IPath path = getPath ( ) ; if ( isExternal ( ) ) { buffer . append ( path . toOSString ( ) ) ; } else if ( getJavaProject ( ) . getElementName ( ) . equals ( path . segment ( <NUM_LIT:0> ) ) ) { if ( path . segmentCount ( ) == <NUM_LIT:1> ) { buffer . append ( "<STR_LIT>" ) ; } else { buffer . append ( path . removeFirstSegments ( <NUM_LIT:1> ) . makeRelative ( ) ) ; } } else { buffer . append ( path ) ; } if ( info == null ) { buffer . append ( "<STR_LIT>" ) ; } } protected IStatus validateExistence ( IResource underlyingResource ) { IStatus status = validateOnClasspath ( ) ; if ( ! status . isOK ( ) ) return status ; if ( ! resourceExists ( underlyingResource ) ) return newDoesNotExistStatus ( ) ; return JavaModelStatus . VERIFIED_OK ; } protected void verifyAttachSource ( IPath sourcePath ) throws JavaModelException { if ( ! exists ( ) ) { throw newNotPresentException ( ) ; } else if ( getKind ( ) != K_BINARY ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_ELEMENT_TYPES , this ) ) ; } else if ( sourcePath != null && ! sourcePath . isAbsolute ( ) ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . RELATIVE_PATH , sourcePath ) ) ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . search . * ; import org . eclipse . jdt . internal . codeassist . ISearchRequestor ; import org . eclipse . jdt . internal . compiler . env . AccessRestriction ; import org . eclipse . jdt . internal . compiler . env . IBinaryType ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . env . INameEnvironment ; import org . eclipse . jdt . internal . compiler . env . ISourceType ; import org . eclipse . jdt . internal . compiler . env . NameEnvironmentAnswer ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . core . search . BasicSearchEngine ; import org . eclipse . jdt . internal . core . search . IRestrictedAccessConstructorRequestor ; import org . eclipse . jdt . internal . core . search . IRestrictedAccessTypeRequestor ; import org . eclipse . jdt . internal . core . search . indexing . IndexManager ; import org . eclipse . jdt . internal . core . util . Util ; public class SearchableEnvironment implements INameEnvironment , IJavaSearchConstants { public NameLookup nameLookup ; protected ICompilationUnit unitToSkip ; protected org . eclipse . jdt . core . ICompilationUnit [ ] workingCopies ; protected WorkingCopyOwner owner ; protected JavaProject project ; protected IJavaSearchScope searchScope ; protected boolean checkAccessRestrictions ; public SearchableEnvironment ( JavaProject project , org . eclipse . jdt . core . ICompilationUnit [ ] workingCopies ) throws JavaModelException { this . project = project ; this . checkAccessRestrictions = ! JavaCore . IGNORE . equals ( project . getOption ( JavaCore . COMPILER_PB_FORBIDDEN_REFERENCE , true ) ) || ! JavaCore . IGNORE . equals ( project . getOption ( JavaCore . COMPILER_PB_DISCOURAGED_REFERENCE , true ) ) ; this . workingCopies = workingCopies ; this . nameLookup = project . newNameLookup ( workingCopies ) ; } public SearchableEnvironment ( JavaProject project , WorkingCopyOwner owner ) throws JavaModelException { this ( project , owner == null ? null : JavaModelManager . getJavaModelManager ( ) . getWorkingCopies ( owner , true ) ) ; this . owner = owner ; } private static int convertSearchFilterToModelFilter ( int searchFilter ) { switch ( searchFilter ) { case IJavaSearchConstants . CLASS : return NameLookup . ACCEPT_CLASSES ; case IJavaSearchConstants . INTERFACE : return NameLookup . ACCEPT_INTERFACES ; case IJavaSearchConstants . ENUM : return NameLookup . ACCEPT_ENUMS ; case IJavaSearchConstants . ANNOTATION_TYPE : return NameLookup . ACCEPT_ANNOTATIONS ; case IJavaSearchConstants . CLASS_AND_ENUM : return NameLookup . ACCEPT_CLASSES | NameLookup . ACCEPT_ENUMS ; case IJavaSearchConstants . CLASS_AND_INTERFACE : return NameLookup . ACCEPT_CLASSES | NameLookup . ACCEPT_INTERFACES ; default : return NameLookup . ACCEPT_ALL ; } } protected NameEnvironmentAnswer find ( String typeName , String packageName ) { if ( packageName == null ) packageName = IPackageFragment . DEFAULT_PACKAGE_NAME ; if ( this . owner != null ) { String source = this . owner . findSource ( typeName , packageName ) ; if ( source != null ) { ICompilationUnit cu = new BasicCompilationUnit ( source . toCharArray ( ) , CharOperation . splitOn ( '<CHAR_LIT:.>' , packageName . toCharArray ( ) ) , typeName + Util . defaultJavaExtension ( ) ) ; return new NameEnvironmentAnswer ( cu , null ) ; } } NameLookup . Answer answer = this . nameLookup . findType ( typeName , packageName , false , NameLookup . ACCEPT_ALL , this . checkAccessRestrictions ) ; if ( answer != null ) { if ( answer . type instanceof BinaryType ) { try { return new NameEnvironmentAnswer ( ( IBinaryType ) ( ( BinaryType ) answer . type ) . getElementInfo ( ) , answer . restriction ) ; } catch ( JavaModelException npe ) { } } else { try { SourceTypeElementInfo sourceType = ( SourceTypeElementInfo ) ( ( SourceType ) answer . type ) . getElementInfo ( ) ; ISourceType topLevelType = sourceType ; while ( topLevelType . getEnclosingType ( ) != null ) { topLevelType = topLevelType . getEnclosingType ( ) ; } IType [ ] types = sourceType . getHandle ( ) . getCompilationUnit ( ) . getTypes ( ) ; ISourceType [ ] sourceTypes = new ISourceType [ types . length ] ; sourceTypes [ <NUM_LIT:0> ] = sourceType ; int length = types . length ; for ( int i = <NUM_LIT:0> , index = <NUM_LIT:1> ; i < length ; i ++ ) { ISourceType otherType = ( ISourceType ) ( ( JavaElement ) types [ i ] ) . getElementInfo ( ) ; if ( ! otherType . equals ( topLevelType ) && index < length ) sourceTypes [ index ++ ] = otherType ; } return new NameEnvironmentAnswer ( sourceTypes , answer . restriction ) ; } catch ( JavaModelException jme ) { if ( jme . isDoesNotExist ( ) && String . valueOf ( TypeConstants . PACKAGE_INFO_NAME ) . equals ( typeName ) ) { return new NameEnvironmentAnswer ( ( ICompilationUnit ) answer . type . getParent ( ) , answer . restriction ) ; } } } } return null ; } public void findPackages ( char [ ] prefix , ISearchRequestor requestor ) { this . nameLookup . seekPackageFragments ( new String ( prefix ) , true , new SearchableEnvironmentRequestor ( requestor ) ) ; } public void findExactTypes ( char [ ] name , final boolean findMembers , int searchFor , final ISearchRequestor storage ) { try { final String excludePath ; if ( this . unitToSkip != null ) { if ( ! ( this . unitToSkip instanceof IJavaElement ) ) { findExactTypes ( new String ( name ) , storage , convertSearchFilterToModelFilter ( searchFor ) ) ; return ; } excludePath = ( ( IJavaElement ) this . unitToSkip ) . getPath ( ) . toString ( ) ; } else { excludePath = null ; } IProgressMonitor progressMonitor = new IProgressMonitor ( ) { boolean isCanceled = false ; public void beginTask ( String n , int totalWork ) { } public void done ( ) { } public void internalWorked ( double work ) { } public boolean isCanceled ( ) { return this . isCanceled ; } public void setCanceled ( boolean value ) { this . isCanceled = value ; } public void setTaskName ( String n ) { } public void subTask ( String n ) { } public void worked ( int work ) { } } ; IRestrictedAccessTypeRequestor typeRequestor = new IRestrictedAccessTypeRequestor ( ) { public void acceptType ( int modifiers , char [ ] packageName , char [ ] simpleTypeName , char [ ] [ ] enclosingTypeNames , String path , AccessRestriction access ) { if ( excludePath != null && excludePath . equals ( path ) ) return ; if ( ! findMembers && enclosingTypeNames != null && enclosingTypeNames . length > <NUM_LIT:0> ) return ; storage . acceptType ( packageName , simpleTypeName , enclosingTypeNames , modifiers , access ) ; } } ; try { new BasicSearchEngine ( this . workingCopies ) . searchAllTypeNames ( null , SearchPattern . R_EXACT_MATCH , name , SearchPattern . R_EXACT_MATCH , searchFor , getSearchScope ( ) , typeRequestor , CANCEL_IF_NOT_READY_TO_SEARCH , progressMonitor ) ; } catch ( OperationCanceledException e ) { findExactTypes ( new String ( name ) , storage , convertSearchFilterToModelFilter ( searchFor ) ) ; } } catch ( JavaModelException e ) { findExactTypes ( new String ( name ) , storage , convertSearchFilterToModelFilter ( searchFor ) ) ; } } private void findExactTypes ( String name , ISearchRequestor storage , int type ) { SearchableEnvironmentRequestor requestor = new SearchableEnvironmentRequestor ( storage , this . unitToSkip , this . project , this . nameLookup ) ; this . nameLookup . seekTypes ( name , null , false , type , requestor ) ; } public NameEnvironmentAnswer findType ( char [ ] [ ] compoundTypeName ) { if ( compoundTypeName == null ) return null ; int length = compoundTypeName . length ; if ( length <= <NUM_LIT:1> ) { if ( length == <NUM_LIT:0> ) return null ; return find ( new String ( compoundTypeName [ <NUM_LIT:0> ] ) , null ) ; } int lengthM1 = length - <NUM_LIT:1> ; char [ ] [ ] packageName = new char [ lengthM1 ] [ ] ; System . arraycopy ( compoundTypeName , <NUM_LIT:0> , packageName , <NUM_LIT:0> , lengthM1 ) ; return find ( new String ( compoundTypeName [ lengthM1 ] ) , CharOperation . toString ( packageName ) ) ; } public NameEnvironmentAnswer findType ( char [ ] name , char [ ] [ ] packageName ) { if ( name == null ) return null ; return find ( new String ( name ) , packageName == null || packageName . length == <NUM_LIT:0> ? null : CharOperation . toString ( packageName ) ) ; } public void findTypes ( char [ ] prefix , final boolean findMembers , boolean camelCaseMatch , int searchFor , final ISearchRequestor storage ) { findTypes ( prefix , findMembers , camelCaseMatch , searchFor , storage , null ) ; } public void findTypes ( char [ ] prefix , final boolean findMembers , boolean camelCaseMatch , int searchFor , final ISearchRequestor storage , IProgressMonitor monitor ) { try { final String excludePath ; if ( this . unitToSkip != null ) { if ( ! ( this . unitToSkip instanceof IJavaElement ) ) { findTypes ( new String ( prefix ) , storage , convertSearchFilterToModelFilter ( searchFor ) ) ; return ; } excludePath = ( ( IJavaElement ) this . unitToSkip ) . getPath ( ) . toString ( ) ; } else { excludePath = null ; } int lastDotIndex = CharOperation . lastIndexOf ( '<CHAR_LIT:.>' , prefix ) ; char [ ] qualification , simpleName ; if ( lastDotIndex < <NUM_LIT:0> ) { qualification = null ; if ( camelCaseMatch ) { simpleName = prefix ; } else { simpleName = CharOperation . toLowerCase ( prefix ) ; } } else { qualification = CharOperation . subarray ( prefix , <NUM_LIT:0> , lastDotIndex ) ; if ( camelCaseMatch ) { simpleName = CharOperation . subarray ( prefix , lastDotIndex + <NUM_LIT:1> , prefix . length ) ; } else { simpleName = CharOperation . toLowerCase ( CharOperation . subarray ( prefix , lastDotIndex + <NUM_LIT:1> , prefix . length ) ) ; } } IProgressMonitor progressMonitor = new IProgressMonitor ( ) { boolean isCanceled = false ; public void beginTask ( String name , int totalWork ) { } public void done ( ) { } public void internalWorked ( double work ) { } public boolean isCanceled ( ) { return this . isCanceled ; } public void setCanceled ( boolean value ) { this . isCanceled = value ; } public void setTaskName ( String name ) { } public void subTask ( String name ) { } public void worked ( int work ) { } } ; IRestrictedAccessTypeRequestor typeRequestor = new IRestrictedAccessTypeRequestor ( ) { public void acceptType ( int modifiers , char [ ] packageName , char [ ] simpleTypeName , char [ ] [ ] enclosingTypeNames , String path , AccessRestriction access ) { if ( excludePath != null && excludePath . equals ( path ) ) return ; if ( ! findMembers && enclosingTypeNames != null && enclosingTypeNames . length > <NUM_LIT:0> ) return ; storage . acceptType ( packageName , simpleTypeName , enclosingTypeNames , modifiers , access ) ; } } ; int matchRule = SearchPattern . R_PREFIX_MATCH ; if ( camelCaseMatch ) matchRule |= SearchPattern . R_CAMELCASE_MATCH ; if ( monitor != null ) { IndexManager indexManager = JavaModelManager . getIndexManager ( ) ; if ( indexManager . awaitingJobsCount ( ) == <NUM_LIT:0> ) { new BasicSearchEngine ( this . workingCopies ) . searchAllTypeNames ( qualification , SearchPattern . R_EXACT_MATCH , simpleName , matchRule , searchFor , getSearchScope ( ) , typeRequestor , FORCE_IMMEDIATE_SEARCH , progressMonitor ) ; } else { try { Thread . sleep ( <NUM_LIT:100> ) ; } catch ( InterruptedException e ) { } if ( monitor . isCanceled ( ) ) { throw new OperationCanceledException ( ) ; } if ( indexManager . awaitingJobsCount ( ) == <NUM_LIT:0> ) { new BasicSearchEngine ( this . workingCopies ) . searchAllTypeNames ( qualification , SearchPattern . R_EXACT_MATCH , simpleName , matchRule , searchFor , getSearchScope ( ) , typeRequestor , FORCE_IMMEDIATE_SEARCH , progressMonitor ) ; } else { findTypes ( new String ( prefix ) , storage , convertSearchFilterToModelFilter ( searchFor ) ) ; } } } else { try { new BasicSearchEngine ( this . workingCopies ) . searchAllTypeNames ( qualification , SearchPattern . R_EXACT_MATCH , simpleName , matchRule , searchFor , getSearchScope ( ) , typeRequestor , CANCEL_IF_NOT_READY_TO_SEARCH , progressMonitor ) ; } catch ( OperationCanceledException e ) { findTypes ( new String ( prefix ) , storage , convertSearchFilterToModelFilter ( searchFor ) ) ; } } } catch ( JavaModelException e ) { findTypes ( new String ( prefix ) , storage , convertSearchFilterToModelFilter ( searchFor ) ) ; } } public void findConstructorDeclarations ( char [ ] prefix , boolean camelCaseMatch , final ISearchRequestor storage , IProgressMonitor monitor ) { try { final String excludePath ; if ( this . unitToSkip != null && this . unitToSkip instanceof IJavaElement ) { excludePath = ( ( IJavaElement ) this . unitToSkip ) . getPath ( ) . toString ( ) ; } else { excludePath = null ; } int lastDotIndex = CharOperation . lastIndexOf ( '<CHAR_LIT:.>' , prefix ) ; char [ ] qualification , simpleName ; if ( lastDotIndex < <NUM_LIT:0> ) { qualification = null ; if ( camelCaseMatch ) { simpleName = prefix ; } else { simpleName = CharOperation . toLowerCase ( prefix ) ; } } else { qualification = CharOperation . subarray ( prefix , <NUM_LIT:0> , lastDotIndex ) ; if ( camelCaseMatch ) { simpleName = CharOperation . subarray ( prefix , lastDotIndex + <NUM_LIT:1> , prefix . length ) ; } else { simpleName = CharOperation . toLowerCase ( CharOperation . subarray ( prefix , lastDotIndex + <NUM_LIT:1> , prefix . length ) ) ; } } IProgressMonitor progressMonitor = new IProgressMonitor ( ) { boolean isCanceled = false ; public void beginTask ( String name , int totalWork ) { } public void done ( ) { } public void internalWorked ( double work ) { } public boolean isCanceled ( ) { return this . isCanceled ; } public void setCanceled ( boolean value ) { this . isCanceled = value ; } public void setTaskName ( String name ) { } public void subTask ( String name ) { } public void worked ( int work ) { } } ; IRestrictedAccessConstructorRequestor constructorRequestor = new IRestrictedAccessConstructorRequestor ( ) { public void acceptConstructor ( int modifiers , char [ ] simpleTypeName , int parameterCount , char [ ] signature , char [ ] [ ] parameterTypes , char [ ] [ ] parameterNames , int typeModifiers , char [ ] packageName , int extraFlags , String path , AccessRestriction access ) { if ( excludePath != null && excludePath . equals ( path ) ) return ; storage . acceptConstructor ( modifiers , simpleTypeName , parameterCount , signature , parameterTypes , parameterNames , typeModifiers , packageName , extraFlags , path , access ) ; } } ; int matchRule = SearchPattern . R_PREFIX_MATCH ; if ( camelCaseMatch ) matchRule |= SearchPattern . R_CAMELCASE_MATCH ; if ( monitor != null ) { IndexManager indexManager = JavaModelManager . getIndexManager ( ) ; while ( indexManager . awaitingJobsCount ( ) > <NUM_LIT:0> ) { try { Thread . sleep ( <NUM_LIT> ) ; } catch ( InterruptedException e ) { } if ( monitor . isCanceled ( ) ) { throw new OperationCanceledException ( ) ; } } new BasicSearchEngine ( this . workingCopies ) . searchAllConstructorDeclarations ( qualification , simpleName , matchRule , getSearchScope ( ) , constructorRequestor , FORCE_IMMEDIATE_SEARCH , progressMonitor ) ; } else { try { new BasicSearchEngine ( this . workingCopies ) . searchAllConstructorDeclarations ( qualification , simpleName , matchRule , getSearchScope ( ) , constructorRequestor , CANCEL_IF_NOT_READY_TO_SEARCH , progressMonitor ) ; } catch ( OperationCanceledException e ) { } } } catch ( JavaModelException e ) { } } private void findTypes ( String prefix , ISearchRequestor storage , int type ) { SearchableEnvironmentRequestor requestor = new SearchableEnvironmentRequestor ( storage , this . unitToSkip , this . project , this . nameLookup ) ; int index = prefix . lastIndexOf ( '<CHAR_LIT:.>' ) ; if ( index == - <NUM_LIT:1> ) { this . nameLookup . seekTypes ( prefix , null , true , type , requestor ) ; } else { String packageName = prefix . substring ( <NUM_LIT:0> , index ) ; JavaElementRequestor elementRequestor = new JavaElementRequestor ( ) ; this . nameLookup . seekPackageFragments ( packageName , false , elementRequestor ) ; IPackageFragment [ ] fragments = elementRequestor . getPackageFragments ( ) ; if ( fragments != null ) { String className = prefix . substring ( index + <NUM_LIT:1> ) ; for ( int i = <NUM_LIT:0> , length = fragments . length ; i < length ; i ++ ) if ( fragments [ i ] != null ) this . nameLookup . seekTypes ( className , fragments [ i ] , true , type , requestor ) ; } } } private IJavaSearchScope getSearchScope ( ) { if ( this . searchScope == null ) { if ( this . checkAccessRestrictions ) { this . searchScope = BasicSearchEngine . createJavaSearchScope ( new IJavaElement [ ] { this . project } ) ; } else { this . searchScope = BasicSearchEngine . createJavaSearchScope ( this . nameLookup . packageFragmentRoots ) ; } } return this . searchScope ; } public boolean isPackage ( char [ ] [ ] parentPackageName , char [ ] subPackageName ) { String [ ] pkgName ; if ( parentPackageName == null ) pkgName = new String [ ] { new String ( subPackageName ) } ; else { int length = parentPackageName . length ; pkgName = new String [ length + <NUM_LIT:1> ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) pkgName [ i ] = new String ( parentPackageName [ i ] ) ; pkgName [ length ] = new String ( subPackageName ) ; } return ( this . owner != null && this . owner . isPackage ( pkgName ) ) || this . nameLookup . isPackage ( pkgName ) ; } protected String toStringChar ( char [ ] name ) { return "<STR_LIT:[>" + new String ( name ) + "<STR_LIT:]>" ; } protected String toStringCharChar ( char [ ] [ ] names ) { StringBuffer result = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> ; i < names . length ; i ++ ) { result . append ( toStringChar ( names [ i ] ) ) ; } return result . toString ( ) ; } public void cleanup ( ) { } } </s>
|
<s> package org . eclipse . jdt . internal . core ; public class ResolvedBinaryMethod extends BinaryMethod { private String uniqueKey ; public ResolvedBinaryMethod ( JavaElement parent , String name , String [ ] parameterTypes , String uniqueKey ) { super ( parent , name , parameterTypes ) ; this . uniqueKey = uniqueKey ; } public String getKey ( ) { return this . uniqueKey ; } public boolean isResolved ( ) { return true ; } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { super . toStringInfo ( tab , buffer , info , showResolvedInfo ) ; if ( showResolvedInfo ) { buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . uniqueKey ) ; buffer . append ( "<STR_LIT:}>" ) ; } } public JavaElement unresolved ( ) { SourceRefElement handle = new BinaryMethod ( this . parent , this . name , this . parameterTypes ) ; handle . occurrenceCount = this . occurrenceCount ; return handle ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IInitializer ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . codeassist . ISearchRequestor ; import org . eclipse . jdt . internal . compiler . env . AccessRuleSet ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . env . AccessRestriction ; class SearchableEnvironmentRequestor extends JavaElementRequestor { protected ISearchRequestor requestor ; protected ICompilationUnit unitToSkip ; protected IJavaProject project ; protected NameLookup nameLookup ; protected boolean checkAccessRestrictions ; public SearchableEnvironmentRequestor ( ISearchRequestor requestor ) { this . requestor = requestor ; this . unitToSkip = null ; this . project = null ; this . nameLookup = null ; this . checkAccessRestrictions = false ; } public SearchableEnvironmentRequestor ( ISearchRequestor requestor , ICompilationUnit unitToSkip , IJavaProject project , NameLookup nameLookup ) { this . requestor = requestor ; this . unitToSkip = unitToSkip ; this . project = project ; this . nameLookup = nameLookup ; this . checkAccessRestrictions = ! JavaCore . IGNORE . equals ( project . getOption ( JavaCore . COMPILER_PB_FORBIDDEN_REFERENCE , true ) ) || ! JavaCore . IGNORE . equals ( project . getOption ( JavaCore . COMPILER_PB_DISCOURAGED_REFERENCE , true ) ) ; } public void acceptInitializer ( IInitializer initializer ) { } public void acceptPackageFragment ( IPackageFragment packageFragment ) { this . requestor . acceptPackage ( packageFragment . getElementName ( ) . toCharArray ( ) ) ; } public void acceptType ( IType type ) { try { if ( this . unitToSkip != null && this . unitToSkip . equals ( type . getCompilationUnit ( ) ) ) { return ; } char [ ] packageName = type . getPackageFragment ( ) . getElementName ( ) . toCharArray ( ) ; boolean isBinary = type instanceof BinaryType ; AccessRestriction accessRestriction = null ; if ( this . checkAccessRestrictions && ( isBinary || ! type . getJavaProject ( ) . equals ( this . project ) ) ) { PackageFragmentRoot root = ( PackageFragmentRoot ) type . getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; ClasspathEntry entry = ( ClasspathEntry ) this . nameLookup . rootToResolvedEntries . get ( root ) ; if ( entry != null ) { AccessRuleSet accessRuleSet = entry . getAccessRuleSet ( ) ; if ( accessRuleSet != null ) { char [ ] [ ] packageChars = CharOperation . splitOn ( '<CHAR_LIT:.>' , packageName ) ; char [ ] fileWithoutExtension = type . getElementName ( ) . toCharArray ( ) ; accessRestriction = accessRuleSet . getViolatedRestriction ( CharOperation . concatWith ( packageChars , fileWithoutExtension , '<CHAR_LIT:/>' ) ) ; } } } this . requestor . acceptType ( packageName , type . getElementName ( ) . toCharArray ( ) , null , type . getFlags ( ) , accessRestriction ) ; } catch ( JavaModelException jme ) { } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . File ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . core . JavaModelException ; public class ExternalPackageFragmentRoot extends PackageFragmentRoot { protected final IPath externalPath ; protected ExternalPackageFragmentRoot ( IPath externalPath , JavaProject project ) { super ( null , project ) ; this . externalPath = externalPath ; } protected ExternalPackageFragmentRoot ( IResource linkedFolder , IPath externalPath , JavaProject project ) { super ( linkedFolder , project ) ; this . externalPath = externalPath == null ? linkedFolder . getLocation ( ) : externalPath ; } protected int determineKind ( IResource underlyingResource ) { return IPackageFragmentRoot . K_BINARY ; } public boolean equals ( Object o ) { if ( this == o ) return true ; if ( o instanceof ExternalPackageFragmentRoot ) { ExternalPackageFragmentRoot other = ( ExternalPackageFragmentRoot ) o ; return this . externalPath . equals ( other . externalPath ) ; } return false ; } public String getElementName ( ) { return this . externalPath . lastSegment ( ) ; } public int getKind ( ) { return IPackageFragmentRoot . K_BINARY ; } int internalKind ( ) throws JavaModelException { return IPackageFragmentRoot . K_BINARY ; } public IPath getPath ( ) { return this . externalPath ; } public IResource getUnderlyingResource ( ) throws JavaModelException { return null ; } public int hashCode ( ) { return this . externalPath . hashCode ( ) ; } public boolean isExternal ( ) { return true ; } public IResource resource ( PackageFragmentRoot root ) { if ( this . resource == null ) return this . resource = JavaModelManager . getExternalManager ( ) . getFolder ( this . externalPath ) ; return super . resource ( root ) ; } protected boolean resourceExists ( IResource underlyingResource ) { if ( underlyingResource == null ) return false ; IPath location = underlyingResource . getLocation ( ) ; if ( location == null ) return false ; File file = location . toFile ( ) ; if ( file == null ) return false ; return file . exists ( ) ; } protected void toStringAncestors ( StringBuffer buffer ) { } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . runtime . IProgressMonitor ; public class BatchInitializationMonitor implements IProgressMonitor { public ThreadLocal initializeAfterLoadMonitor = new ThreadLocal ( ) ; public String subTaskName = "<STR_LIT>" ; public int worked = <NUM_LIT:0> ; private IProgressMonitor getMonitor ( ) { return ( IProgressMonitor ) this . initializeAfterLoadMonitor . get ( ) ; } public void beginTask ( String name , int totalWork ) { IProgressMonitor monitor = getMonitor ( ) ; if ( monitor != null ) monitor . beginTask ( name , totalWork ) ; } public void done ( ) { IProgressMonitor monitor = getMonitor ( ) ; if ( monitor != null ) monitor . done ( ) ; this . worked = <NUM_LIT:0> ; this . subTaskName = "<STR_LIT>" ; } public void internalWorked ( double work ) { IProgressMonitor monitor = getMonitor ( ) ; if ( monitor != null ) monitor . internalWorked ( work ) ; } public boolean isCanceled ( ) { IProgressMonitor monitor = getMonitor ( ) ; if ( monitor != null ) return monitor . isCanceled ( ) ; return false ; } public void setCanceled ( boolean value ) { IProgressMonitor monitor = getMonitor ( ) ; if ( monitor != null ) monitor . setCanceled ( value ) ; } public void setTaskName ( String name ) { IProgressMonitor monitor = getMonitor ( ) ; if ( monitor != null ) monitor . setTaskName ( name ) ; } public void subTask ( String name ) { IProgressMonitor monitor = getMonitor ( ) ; if ( monitor != null ) monitor . subTask ( name ) ; this . subTaskName = name ; } public void worked ( int work ) { IProgressMonitor monitor = getMonitor ( ) ; if ( monitor != null ) monitor . worked ( work ) ; synchronized ( this ) { this . worked += work ; } } public synchronized int getWorked ( ) { int result = this . worked ; this . worked = <NUM_LIT:0> ; return result ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . IAccessRule ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . internal . compiler . env . AccessRule ; public class ClasspathAccessRule extends AccessRule implements IAccessRule { public ClasspathAccessRule ( IPath pattern , int kind ) { this ( pattern . toString ( ) . toCharArray ( ) , toProblemId ( kind ) ) ; } public ClasspathAccessRule ( char [ ] pattern , int problemId ) { super ( pattern , problemId ) ; } private static int toProblemId ( int kind ) { boolean ignoreIfBetter = ( kind & IAccessRule . IGNORE_IF_BETTER ) != <NUM_LIT:0> ; switch ( kind & ~ IAccessRule . IGNORE_IF_BETTER ) { case K_NON_ACCESSIBLE : return ignoreIfBetter ? IProblem . ForbiddenReference | AccessRule . IgnoreIfBetter : IProblem . ForbiddenReference ; case K_DISCOURAGED : return ignoreIfBetter ? IProblem . DiscouragedReference | AccessRule . IgnoreIfBetter : IProblem . DiscouragedReference ; default : return ignoreIfBetter ? AccessRule . IgnoreIfBetter : <NUM_LIT:0> ; } } public IPath getPattern ( ) { return new Path ( new String ( this . pattern ) ) ; } public int getKind ( ) { switch ( getProblemId ( ) ) { case IProblem . ForbiddenReference : return K_NON_ACCESSIBLE ; case IProblem . DiscouragedReference : return K_DISCOURAGED ; default : return K_ACCESSIBLE ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . Map ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . codeassist . impl . AssistOptions ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; import org . eclipse . jdt . internal . compiler . util . SimpleSetOfCharArray ; public class InternalNamingConventions { private static final char [ ] DEFAULT_NAME = "<STR_LIT:name>" . toCharArray ( ) ; private static Scanner getNameScanner ( CompilerOptions compilerOptions ) { return new Scanner ( false , false , false , compilerOptions . sourceLevel , null , null , true ) ; } private static void acceptName ( char [ ] name , char [ ] prefix , char [ ] suffix , boolean isFirstPrefix , boolean isFirstSuffix , int reusedCharacters , INamingRequestor requestor ) { if ( prefix . length > <NUM_LIT:0> && suffix . length > <NUM_LIT:0> ) { requestor . acceptNameWithPrefixAndSuffix ( name , isFirstPrefix , isFirstSuffix , reusedCharacters ) ; } else if ( prefix . length > <NUM_LIT:0> ) { requestor . acceptNameWithPrefix ( name , isFirstPrefix , reusedCharacters ) ; } else if ( suffix . length > <NUM_LIT:0> ) { requestor . acceptNameWithSuffix ( name , isFirstSuffix , reusedCharacters ) ; } else { requestor . acceptNameWithoutPrefixAndSuffix ( name , reusedCharacters ) ; } } private static char [ ] [ ] computeBaseTypeNames ( char [ ] typeName , boolean isConstantField , char [ ] [ ] excludedNames ) { if ( isConstantField ) { return computeNonBaseTypeNames ( typeName , isConstantField , false ) ; } else { char [ ] name = computeBaseTypeNames ( typeName [ <NUM_LIT:0> ] , excludedNames ) ; if ( name != null ) { return new char [ ] [ ] { name } ; } else { return computeNonBaseTypeNames ( typeName , isConstantField , false ) ; } } } private static char [ ] computeBaseTypeNames ( char firstName , char [ ] [ ] excludedNames ) { char [ ] name = new char [ ] { firstName } ; for ( int i = <NUM_LIT:0> ; i < excludedNames . length ; i ++ ) { if ( CharOperation . equals ( name , excludedNames [ i ] , false ) ) { name [ <NUM_LIT:0> ] ++ ; if ( name [ <NUM_LIT:0> ] > '<CHAR_LIT>' ) name [ <NUM_LIT:0> ] = '<CHAR_LIT:a>' ; if ( name [ <NUM_LIT:0> ] == firstName ) return null ; i = <NUM_LIT:0> ; } } return name ; } private static char [ ] [ ] computeNonBaseTypeNames ( char [ ] sourceName , boolean isConstantField , boolean onlyLongest ) { int length = sourceName . length ; if ( length == <NUM_LIT:0> ) { return CharOperation . NO_CHAR_CHAR ; } if ( length == <NUM_LIT:1> ) { if ( isConstantField ) { return generateConstantName ( new char [ ] [ ] { CharOperation . toLowerCase ( sourceName ) } , <NUM_LIT:0> , onlyLongest ) ; } else { return generateNonConstantName ( new char [ ] [ ] { CharOperation . toLowerCase ( sourceName ) } , <NUM_LIT:0> , onlyLongest ) ; } } char [ ] [ ] nameParts = new char [ length ] [ ] ; int namePartsPtr = - <NUM_LIT:1> ; int endIndex = length ; char c = sourceName [ length - <NUM_LIT:1> ] ; final int IS_LOWER_CASE = <NUM_LIT:1> ; final int IS_UPPER_CASE = <NUM_LIT:2> ; final int IS_UNDERSCORE = <NUM_LIT:3> ; final int IS_OTHER = <NUM_LIT:4> ; int previousCharKind = ScannerHelper . isLowerCase ( c ) ? IS_LOWER_CASE : ScannerHelper . isUpperCase ( c ) ? IS_UPPER_CASE : c == '<CHAR_LIT:_>' ? IS_UNDERSCORE : IS_OTHER ; for ( int i = length - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { c = sourceName [ i ] ; int charKind = ScannerHelper . isLowerCase ( c ) ? IS_LOWER_CASE : ScannerHelper . isUpperCase ( c ) ? IS_UPPER_CASE : c == '<CHAR_LIT:_>' ? IS_UNDERSCORE : IS_OTHER ; switch ( charKind ) { case IS_LOWER_CASE : if ( previousCharKind == IS_UPPER_CASE ) { nameParts [ ++ namePartsPtr ] = CharOperation . subarray ( sourceName , i + <NUM_LIT:1> , endIndex ) ; endIndex = i + <NUM_LIT:1> ; } previousCharKind = IS_LOWER_CASE ; break ; case IS_UPPER_CASE : if ( previousCharKind == IS_LOWER_CASE ) { nameParts [ ++ namePartsPtr ] = CharOperation . subarray ( sourceName , i , endIndex ) ; if ( i > <NUM_LIT:0> ) { char pc = sourceName [ i - <NUM_LIT:1> ] ; previousCharKind = ScannerHelper . isLowerCase ( pc ) ? IS_LOWER_CASE : ScannerHelper . isUpperCase ( pc ) ? IS_UPPER_CASE : pc == '<CHAR_LIT:_>' ? IS_UNDERSCORE : IS_OTHER ; } endIndex = i ; } else { previousCharKind = IS_UPPER_CASE ; } break ; case IS_UNDERSCORE : switch ( previousCharKind ) { case IS_UNDERSCORE : if ( isConstantField ) { if ( i > <NUM_LIT:0> ) { char pc = sourceName [ i - <NUM_LIT:1> ] ; previousCharKind = ScannerHelper . isLowerCase ( pc ) ? IS_LOWER_CASE : ScannerHelper . isUpperCase ( pc ) ? IS_UPPER_CASE : pc == '<CHAR_LIT:_>' ? IS_UNDERSCORE : IS_OTHER ; } endIndex = i ; } break ; case IS_LOWER_CASE : case IS_UPPER_CASE : nameParts [ ++ namePartsPtr ] = CharOperation . subarray ( sourceName , i + <NUM_LIT:1> , endIndex ) ; if ( i > <NUM_LIT:0> ) { char pc = sourceName [ i - <NUM_LIT:1> ] ; previousCharKind = ScannerHelper . isLowerCase ( pc ) ? IS_LOWER_CASE : ScannerHelper . isUpperCase ( pc ) ? IS_UPPER_CASE : pc == '<CHAR_LIT:_>' ? IS_UNDERSCORE : IS_OTHER ; } endIndex = i + <NUM_LIT:1> ; break ; default : previousCharKind = IS_UNDERSCORE ; break ; } break ; default : previousCharKind = IS_OTHER ; break ; } } if ( endIndex > <NUM_LIT:0> ) { nameParts [ ++ namePartsPtr ] = CharOperation . subarray ( sourceName , <NUM_LIT:0> , endIndex ) ; } if ( namePartsPtr == - <NUM_LIT:1> ) { return new char [ ] [ ] { sourceName } ; } if ( isConstantField ) { return generateConstantName ( nameParts , namePartsPtr , onlyLongest ) ; } else { return generateNonConstantName ( nameParts , namePartsPtr , onlyLongest ) ; } } private static char [ ] excludeNames ( char [ ] suffixName , char [ ] prefixName , char [ ] suffix , char [ ] [ ] excludedNames ) { int count = <NUM_LIT:2> ; int m = <NUM_LIT:0> ; while ( m < excludedNames . length ) { if ( CharOperation . equals ( suffixName , excludedNames [ m ] , false ) ) { suffixName = CharOperation . concat ( prefixName , String . valueOf ( count ++ ) . toCharArray ( ) , suffix ) ; m = <NUM_LIT:0> ; } else { m ++ ; } } return suffixName ; } private static char [ ] [ ] generateNonConstantName ( char [ ] [ ] nameParts , int namePartsPtr , boolean onlyLongest ) { char [ ] [ ] names ; if ( onlyLongest ) { names = new char [ <NUM_LIT:1> ] [ ] ; } else { names = new char [ namePartsPtr + <NUM_LIT:1> ] [ ] ; } char [ ] namePart = nameParts [ <NUM_LIT:0> ] ; char [ ] name = CharOperation . toLowerCase ( namePart ) ; if ( ! onlyLongest ) { names [ namePartsPtr ] = name ; } char [ ] nameSuffix = namePart ; for ( int i = <NUM_LIT:1> ; i <= namePartsPtr ; i ++ ) { namePart = nameParts [ i ] ; name = CharOperation . concat ( CharOperation . toLowerCase ( namePart ) , nameSuffix ) ; if ( ! onlyLongest ) { names [ namePartsPtr - i ] = name ; } nameSuffix = CharOperation . concat ( namePart , nameSuffix ) ; } if ( onlyLongest ) { names [ <NUM_LIT:0> ] = name ; } return names ; } private static char [ ] [ ] generateConstantName ( char [ ] [ ] nameParts , int namePartsPtr , boolean onlyLongest ) { char [ ] [ ] names ; if ( onlyLongest ) { names = new char [ <NUM_LIT:1> ] [ ] ; } else { names = new char [ namePartsPtr + <NUM_LIT:1> ] [ ] ; } char [ ] namePart = CharOperation . toUpperCase ( nameParts [ <NUM_LIT:0> ] ) ; int namePartLength = namePart . length ; System . arraycopy ( namePart , <NUM_LIT:0> , namePart , <NUM_LIT:0> , namePartLength ) ; char [ ] name = namePart ; if ( ! onlyLongest ) { names [ namePartsPtr ] = name ; } for ( int i = <NUM_LIT:1> ; i <= namePartsPtr ; i ++ ) { namePart = CharOperation . toUpperCase ( nameParts [ i ] ) ; namePartLength = namePart . length ; if ( namePart [ namePartLength - <NUM_LIT:1> ] != '<CHAR_LIT:_>' ) { name = CharOperation . concat ( namePart , name , '<CHAR_LIT:_>' ) ; } else { name = CharOperation . concat ( namePart , name ) ; } if ( ! onlyLongest ) { names [ namePartsPtr - i ] = name ; } } if ( onlyLongest ) { names [ <NUM_LIT:0> ] = name ; } return names ; } public static char [ ] getBaseName ( int variableKind , IJavaProject javaProject , char [ ] name , boolean updateFirstCharacter ) { AssistOptions assistOptions ; if ( javaProject != null ) { assistOptions = new AssistOptions ( javaProject . getOptions ( true ) ) ; } else { assistOptions = new AssistOptions ( JavaCore . getOptions ( ) ) ; } char [ ] [ ] prefixes = null ; char [ ] [ ] suffixes = null ; switch ( variableKind ) { case VK_INSTANCE_FIELD : prefixes = assistOptions . fieldPrefixes ; suffixes = assistOptions . fieldSuffixes ; break ; case VK_STATIC_FIELD : prefixes = assistOptions . staticFieldPrefixes ; suffixes = assistOptions . staticFieldSuffixes ; break ; case VK_STATIC_FINAL_FIELD : prefixes = assistOptions . staticFinalFieldPrefixes ; suffixes = assistOptions . staticFinalFieldSuffixes ; break ; case VK_LOCAL : prefixes = assistOptions . localPrefixes ; suffixes = assistOptions . localSuffixes ; break ; case VK_PARAMETER : prefixes = assistOptions . argumentPrefixes ; suffixes = assistOptions . argumentSuffixes ; break ; } return getBaseName ( name , prefixes , suffixes , variableKind == VK_STATIC_FINAL_FIELD , updateFirstCharacter ) ; } private static char [ ] getBaseName ( char [ ] name , char [ ] [ ] prefixes , char [ ] [ ] suffixes , boolean isConstant , boolean updateFirstCharacter ) { char [ ] nameWithoutPrefixAndSiffix = removeVariablePrefixAndSuffix ( name , prefixes , suffixes , updateFirstCharacter ) ; char [ ] baseName ; if ( isConstant ) { int length = nameWithoutPrefixAndSiffix . length ; baseName = new char [ length ] ; int baseNamePtr = - <NUM_LIT:1> ; boolean previousIsUnderscore = false ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char c = nameWithoutPrefixAndSiffix [ i ] ; if ( c != '<CHAR_LIT:_>' ) { if ( previousIsUnderscore ) { baseName [ ++ baseNamePtr ] = ScannerHelper . toUpperCase ( c ) ; previousIsUnderscore = false ; } else { baseName [ ++ baseNamePtr ] = ScannerHelper . toLowerCase ( c ) ; } } else { previousIsUnderscore = true ; } } System . arraycopy ( baseName , <NUM_LIT:0> , baseName = new char [ baseNamePtr + <NUM_LIT:1> ] , <NUM_LIT:0> , baseNamePtr + <NUM_LIT:1> ) ; } else { baseName = nameWithoutPrefixAndSiffix ; } return baseName ; } public static char [ ] removeVariablePrefixAndSuffix ( int variableKind , IJavaProject javaProject , char [ ] name ) { AssistOptions assistOptions ; if ( javaProject != null ) { assistOptions = new AssistOptions ( javaProject . getOptions ( true ) ) ; } else { assistOptions = new AssistOptions ( JavaCore . getOptions ( ) ) ; } char [ ] [ ] prefixes = null ; char [ ] [ ] suffixes = null ; switch ( variableKind ) { case VK_INSTANCE_FIELD : prefixes = assistOptions . fieldPrefixes ; suffixes = assistOptions . fieldSuffixes ; break ; case VK_STATIC_FIELD : prefixes = assistOptions . staticFieldPrefixes ; suffixes = assistOptions . staticFieldSuffixes ; break ; case VK_STATIC_FINAL_FIELD : prefixes = assistOptions . staticFinalFieldPrefixes ; suffixes = assistOptions . staticFinalFieldSuffixes ; break ; case VK_LOCAL : prefixes = assistOptions . localPrefixes ; suffixes = assistOptions . localSuffixes ; break ; case VK_PARAMETER : prefixes = assistOptions . argumentPrefixes ; suffixes = assistOptions . argumentSuffixes ; break ; } return InternalNamingConventions . removeVariablePrefixAndSuffix ( name , prefixes , suffixes , true ) ; } private static char [ ] removeVariablePrefixAndSuffix ( char [ ] name , char [ ] [ ] prefixes , char [ ] [ ] suffixes , boolean updateFirstCharacter ) { char [ ] withoutPrefixName = name ; if ( prefixes != null ) { int bestLength = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < prefixes . length ; i ++ ) { char [ ] prefix = prefixes [ i ] ; if ( CharOperation . prefixEquals ( prefix , name ) ) { int currLen = prefix . length ; boolean lastCharIsLetter = ScannerHelper . isLetter ( prefix [ currLen - <NUM_LIT:1> ] ) ; if ( ! lastCharIsLetter || ( lastCharIsLetter && name . length > currLen && ScannerHelper . isUpperCase ( name [ currLen ] ) ) ) { if ( bestLength < currLen && name . length != currLen ) { withoutPrefixName = CharOperation . subarray ( name , currLen , name . length ) ; bestLength = currLen ; } } } } } char [ ] withoutSuffixName = withoutPrefixName ; if ( suffixes != null ) { int bestLength = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < suffixes . length ; i ++ ) { char [ ] suffix = suffixes [ i ] ; if ( CharOperation . endsWith ( withoutPrefixName , suffix ) ) { int currLen = suffix . length ; if ( bestLength < currLen && withoutPrefixName . length != currLen ) { withoutSuffixName = CharOperation . subarray ( withoutPrefixName , <NUM_LIT:0> , withoutPrefixName . length - currLen ) ; bestLength = currLen ; } } } } if ( updateFirstCharacter ) withoutSuffixName [ <NUM_LIT:0> ] = ScannerHelper . toLowerCase ( withoutSuffixName [ <NUM_LIT:0> ] ) ; return withoutSuffixName ; } private static char [ ] removePrefix ( char [ ] name , char [ ] [ ] prefixes ) { char [ ] withoutPrefixName = name ; if ( prefixes != null ) { int bestLength = <NUM_LIT:0> ; int nameLength = name . length ; for ( int i = <NUM_LIT:0> ; i < prefixes . length ; i ++ ) { char [ ] prefix = prefixes [ i ] ; int prefixLength = prefix . length ; if ( prefixLength <= nameLength ) { if ( CharOperation . prefixEquals ( prefix , name , false ) ) { if ( prefixLength > bestLength ) { bestLength = prefixLength ; } } } else { int currLen = <NUM_LIT:0> ; for ( ; currLen < nameLength ; currLen ++ ) { if ( ScannerHelper . toLowerCase ( prefix [ currLen ] ) != ScannerHelper . toLowerCase ( name [ currLen ] ) ) { if ( currLen > bestLength ) { bestLength = currLen ; } break ; } } if ( currLen == nameLength && currLen > bestLength ) { bestLength = currLen ; } } } if ( bestLength > <NUM_LIT:0> ) { if ( bestLength == nameLength ) { withoutPrefixName = CharOperation . NO_CHAR ; } else { withoutPrefixName = CharOperation . subarray ( name , bestLength , nameLength ) ; } } } return withoutPrefixName ; } public static final int VK_STATIC_FIELD = <NUM_LIT:1> ; public static final int VK_INSTANCE_FIELD = <NUM_LIT:2> ; public static final int VK_STATIC_FINAL_FIELD = <NUM_LIT:3> ; public static final int VK_PARAMETER = <NUM_LIT:4> ; public static final int VK_LOCAL = <NUM_LIT:5> ; public static final int BK_SIMPLE_NAME = <NUM_LIT:1> ; public static final int BK_SIMPLE_TYPE_NAME = <NUM_LIT:2> ; public static void suggestVariableNames ( int variableKind , int baseNameKind , char [ ] baseName , IJavaProject javaProject , int dim , char [ ] internalPrefix , char [ ] [ ] excluded , boolean evaluateDefault , INamingRequestor requestor ) { if ( baseName == null || baseName . length == <NUM_LIT:0> ) return ; Map options ; if ( javaProject != null ) { options = javaProject . getOptions ( true ) ; } else { options = JavaCore . getOptions ( ) ; } CompilerOptions compilerOptions = new CompilerOptions ( options ) ; AssistOptions assistOptions = new AssistOptions ( options ) ; boolean isConstantField = false ; char [ ] [ ] prefixes = null ; char [ ] [ ] suffixes = null ; switch ( variableKind ) { case VK_INSTANCE_FIELD : prefixes = assistOptions . fieldPrefixes ; suffixes = assistOptions . fieldSuffixes ; break ; case VK_STATIC_FIELD : prefixes = assistOptions . staticFieldPrefixes ; suffixes = assistOptions . staticFieldSuffixes ; break ; case VK_STATIC_FINAL_FIELD : isConstantField = true ; prefixes = assistOptions . staticFinalFieldPrefixes ; suffixes = assistOptions . staticFinalFieldSuffixes ; break ; case VK_LOCAL : prefixes = assistOptions . localPrefixes ; suffixes = assistOptions . localSuffixes ; break ; case VK_PARAMETER : prefixes = assistOptions . argumentPrefixes ; suffixes = assistOptions . argumentSuffixes ; break ; } if ( prefixes == null || prefixes . length == <NUM_LIT:0> ) { prefixes = new char [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] ; } else { int length = prefixes . length ; System . arraycopy ( prefixes , <NUM_LIT:0> , prefixes = new char [ length + <NUM_LIT:1> ] [ ] , <NUM_LIT:0> , length ) ; prefixes [ length ] = CharOperation . NO_CHAR ; } if ( suffixes == null || suffixes . length == <NUM_LIT:0> ) { suffixes = new char [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] ; } else { int length = suffixes . length ; System . arraycopy ( suffixes , <NUM_LIT:0> , suffixes = new char [ length + <NUM_LIT:1> ] [ ] , <NUM_LIT:0> , length ) ; suffixes [ length ] = CharOperation . NO_CHAR ; } if ( internalPrefix == null ) { internalPrefix = CharOperation . NO_CHAR ; } else { internalPrefix = removePrefix ( internalPrefix , prefixes ) ; } char [ ] [ ] tempNames = null ; Scanner nameScanner = getNameScanner ( compilerOptions ) ; if ( baseNameKind == BK_SIMPLE_TYPE_NAME ) { boolean isBaseType = false ; try { nameScanner . setSource ( baseName ) ; switch ( nameScanner . getNextToken ( ) ) { case TerminalTokens . TokenNameint : case TerminalTokens . TokenNamebyte : case TerminalTokens . TokenNameshort : case TerminalTokens . TokenNamechar : case TerminalTokens . TokenNamelong : case TerminalTokens . TokenNamefloat : case TerminalTokens . TokenNamedouble : case TerminalTokens . TokenNameboolean : isBaseType = true ; break ; } } catch ( InvalidInputException e ) { } if ( isBaseType ) { if ( internalPrefix . length > <NUM_LIT:0> ) return ; tempNames = computeBaseTypeNames ( baseName , isConstantField , excluded ) ; } else { tempNames = computeNonBaseTypeNames ( baseName , isConstantField , false ) ; } } else { tempNames = computeNonBaseTypeNames ( baseName , isConstantField , true ) ; } boolean acceptDefaultName = true ; SimpleSetOfCharArray foundNames = new SimpleSetOfCharArray ( ) ; for ( int i = <NUM_LIT:0> ; i < tempNames . length ; i ++ ) { char [ ] tempName = tempNames [ i ] ; if ( dim > <NUM_LIT:0> ) { int length = tempName . length ; if ( isConstantField ) { if ( tempName [ length - <NUM_LIT:1> ] == '<CHAR_LIT>' ) { if ( tempName . length > <NUM_LIT:1> && tempName [ length - <NUM_LIT:2> ] == '<CHAR_LIT>' ) { System . arraycopy ( tempName , <NUM_LIT:0> , tempName = new char [ length + <NUM_LIT:2> ] , <NUM_LIT:0> , length ) ; tempName [ length ] = '<CHAR_LIT>' ; tempName [ length + <NUM_LIT:1> ] = '<CHAR_LIT>' ; } } else if ( tempName [ length - <NUM_LIT:1> ] == '<CHAR_LIT>' ) { boolean precededByAVowel = false ; if ( tempName . length > <NUM_LIT:1> ) { switch ( tempName [ length - <NUM_LIT:2> ] ) { case '<CHAR_LIT:A>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : precededByAVowel = true ; break ; } } if ( precededByAVowel ) { System . arraycopy ( tempName , <NUM_LIT:0> , tempName = new char [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; tempName [ length ] = '<CHAR_LIT>' ; } else { System . arraycopy ( tempName , <NUM_LIT:0> , tempName = new char [ length + <NUM_LIT:2> ] , <NUM_LIT:0> , length ) ; tempName [ length - <NUM_LIT:1> ] = '<CHAR_LIT>' ; tempName [ length ] = '<CHAR_LIT>' ; tempName [ length + <NUM_LIT:1> ] = '<CHAR_LIT>' ; } } else { System . arraycopy ( tempName , <NUM_LIT:0> , tempName = new char [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; tempName [ length ] = '<CHAR_LIT>' ; } } else { if ( tempName [ length - <NUM_LIT:1> ] == '<CHAR_LIT>' ) { if ( tempName . length > <NUM_LIT:1> && tempName [ length - <NUM_LIT:2> ] == '<CHAR_LIT>' ) { System . arraycopy ( tempName , <NUM_LIT:0> , tempName = new char [ length + <NUM_LIT:2> ] , <NUM_LIT:0> , length ) ; tempName [ length ] = '<CHAR_LIT:e>' ; tempName [ length + <NUM_LIT:1> ] = '<CHAR_LIT>' ; } } else if ( tempName [ length - <NUM_LIT:1> ] == '<CHAR_LIT>' ) { boolean precededByAVowel = false ; if ( tempName . length > <NUM_LIT:1> ) { switch ( tempName [ length - <NUM_LIT:2> ] ) { case '<CHAR_LIT:a>' : case '<CHAR_LIT:e>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : precededByAVowel = true ; break ; } } if ( precededByAVowel ) { System . arraycopy ( tempName , <NUM_LIT:0> , tempName = new char [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; tempName [ length ] = '<CHAR_LIT>' ; } else { System . arraycopy ( tempName , <NUM_LIT:0> , tempName = new char [ length + <NUM_LIT:2> ] , <NUM_LIT:0> , length ) ; tempName [ length - <NUM_LIT:1> ] = '<CHAR_LIT>' ; tempName [ length ] = '<CHAR_LIT:e>' ; tempName [ length + <NUM_LIT:1> ] = '<CHAR_LIT>' ; } } else { System . arraycopy ( tempName , <NUM_LIT:0> , tempName = new char [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; tempName [ length ] = '<CHAR_LIT>' ; } } } char [ ] unprefixedName = tempName ; int matchingIndex = - <NUM_LIT:1> ; if ( ! isConstantField ) { unprefixedName [ <NUM_LIT:0> ] = ScannerHelper . toUpperCase ( unprefixedName [ <NUM_LIT:0> ] ) ; done : for ( int j = <NUM_LIT:0> ; j <= internalPrefix . length ; j ++ ) { if ( j == internalPrefix . length || CharOperation . prefixEquals ( CharOperation . subarray ( internalPrefix , j , - <NUM_LIT:1> ) , unprefixedName , j != <NUM_LIT:0> ) ) { matchingIndex = j ; break done ; } } } else { done : for ( int j = <NUM_LIT:0> ; j <= internalPrefix . length ; j ++ ) { if ( j == internalPrefix . length ) { matchingIndex = j ; break done ; } else if ( CharOperation . prefixEquals ( CharOperation . subarray ( internalPrefix , j , - <NUM_LIT:1> ) , unprefixedName , j != <NUM_LIT:0> ) ) { if ( j == <NUM_LIT:0> || internalPrefix [ j - <NUM_LIT:1> ] == '<CHAR_LIT:_>' ) { matchingIndex = j ; break done ; } } } } if ( matchingIndex > - <NUM_LIT:1> ) { if ( ! isConstantField ) { tempName = CharOperation . concat ( CharOperation . subarray ( internalPrefix , <NUM_LIT:0> , matchingIndex ) , unprefixedName ) ; if ( matchingIndex == <NUM_LIT:0> ) tempName [ <NUM_LIT:0> ] = ScannerHelper . toLowerCase ( tempName [ <NUM_LIT:0> ] ) ; } else { if ( matchingIndex != <NUM_LIT:0> && tempName [ <NUM_LIT:0> ] != '<CHAR_LIT:_>' && internalPrefix [ matchingIndex - <NUM_LIT:1> ] != '<CHAR_LIT:_>' ) { tempName = CharOperation . concat ( CharOperation . subarray ( CharOperation . toUpperCase ( internalPrefix ) , <NUM_LIT:0> , matchingIndex ) , unprefixedName , '<CHAR_LIT:_>' ) ; } else { tempName = CharOperation . concat ( CharOperation . subarray ( CharOperation . toUpperCase ( internalPrefix ) , <NUM_LIT:0> , matchingIndex ) , unprefixedName ) ; } } for ( int k = <NUM_LIT:0> ; k < prefixes . length ; k ++ ) { if ( ! isConstantField ) { if ( prefixes [ k ] . length > <NUM_LIT:0> && ScannerHelper . isLetterOrDigit ( prefixes [ k ] [ prefixes [ k ] . length - <NUM_LIT:1> ] ) ) { tempName [ <NUM_LIT:0> ] = ScannerHelper . toUpperCase ( tempName [ <NUM_LIT:0> ] ) ; } else { tempName [ <NUM_LIT:0> ] = ScannerHelper . toLowerCase ( tempName [ <NUM_LIT:0> ] ) ; } } char [ ] prefixName = CharOperation . concat ( prefixes [ k ] , tempName ) ; for ( int l = <NUM_LIT:0> ; l < suffixes . length ; l ++ ) { char [ ] suffixName = CharOperation . concat ( prefixName , suffixes [ l ] ) ; suffixName = excludeNames ( suffixName , prefixName , suffixes [ l ] , excluded ) ; try { nameScanner . setSource ( suffixName ) ; switch ( nameScanner . getNextToken ( ) ) { case TerminalTokens . TokenNameIdentifier : int token = nameScanner . getNextToken ( ) ; if ( token == TerminalTokens . TokenNameEOF && nameScanner . startPosition == suffixName . length ) { if ( ! foundNames . includes ( suffixName ) ) { acceptName ( suffixName , prefixes [ k ] , suffixes [ l ] , k == <NUM_LIT:0> , l == <NUM_LIT:0> , internalPrefix . length - matchingIndex , requestor ) ; foundNames . add ( suffixName ) ; acceptDefaultName = false ; } } break ; default : suffixName = CharOperation . concat ( prefixName , String . valueOf ( <NUM_LIT:1> ) . toCharArray ( ) , suffixes [ l ] ) ; suffixName = excludeNames ( suffixName , prefixName , suffixes [ l ] , excluded ) ; nameScanner . setSource ( suffixName ) ; switch ( nameScanner . getNextToken ( ) ) { case TerminalTokens . TokenNameIdentifier : token = nameScanner . getNextToken ( ) ; if ( token == TerminalTokens . TokenNameEOF && nameScanner . startPosition == suffixName . length ) { if ( ! foundNames . includes ( suffixName ) ) { acceptName ( suffixName , prefixes [ k ] , suffixes [ l ] , k == <NUM_LIT:0> , l == <NUM_LIT:0> , internalPrefix . length - matchingIndex , requestor ) ; foundNames . add ( suffixName ) ; acceptDefaultName = false ; } } } } } catch ( InvalidInputException e ) { } } } } } if ( evaluateDefault && acceptDefaultName ) { char [ ] name = excludeNames ( DEFAULT_NAME , DEFAULT_NAME , CharOperation . NO_CHAR , excluded ) ; requestor . acceptNameWithoutPrefixAndSuffix ( name , <NUM_LIT:0> ) ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IImportDeclaration ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModelStatus ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaConventions ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . dom . AST ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . core . dom . Name ; import org . eclipse . jdt . core . dom . PackageDeclaration ; import org . eclipse . jdt . core . dom . StructuralPropertyDescriptor ; import org . eclipse . jdt . core . dom . rewrite . ASTRewrite ; import org . eclipse . jdt . internal . core . util . Messages ; public class CreatePackageDeclarationOperation extends CreateElementInCUOperation { protected String name = null ; public CreatePackageDeclarationOperation ( String name , ICompilationUnit parentElement ) { super ( parentElement ) ; this . name = name ; } protected StructuralPropertyDescriptor getChildPropertyDescriptor ( ASTNode parent ) { return CompilationUnit . PACKAGE_PROPERTY ; } protected ASTNode generateElementAST ( ASTRewrite rewriter , ICompilationUnit cu ) throws JavaModelException { IJavaElement [ ] children = getCompilationUnit ( ) . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { if ( children [ i ] . getElementType ( ) == IJavaElement . PACKAGE_DECLARATION && this . name . equals ( children [ i ] . getElementName ( ) ) ) { this . creationOccurred = false ; return null ; } } AST ast = this . cuAST . getAST ( ) ; PackageDeclaration pkgDeclaration = ast . newPackageDeclaration ( ) ; Name astName = ast . newName ( this . name ) ; pkgDeclaration . setName ( astName ) ; return pkgDeclaration ; } protected IJavaElement generateResultHandle ( ) { return getCompilationUnit ( ) . getPackageDeclaration ( this . name ) ; } public String getMainTaskName ( ) { return Messages . operation_createPackageProgress ; } protected void initializeDefaultPosition ( ) { try { ICompilationUnit cu = getCompilationUnit ( ) ; IImportDeclaration [ ] imports = cu . getImports ( ) ; if ( imports . length > <NUM_LIT:0> ) { createBefore ( imports [ <NUM_LIT:0> ] ) ; return ; } IType [ ] types = cu . getTypes ( ) ; if ( types . length > <NUM_LIT:0> ) { createBefore ( types [ <NUM_LIT:0> ] ) ; return ; } } catch ( JavaModelException e ) { } } public IJavaModelStatus verify ( ) { IJavaModelStatus status = super . verify ( ) ; if ( ! status . isOK ( ) ) { return status ; } IJavaProject project = getParentElement ( ) . getJavaProject ( ) ; if ( JavaConventions . validatePackageName ( this . name , project . getOption ( JavaCore . COMPILER_SOURCE , true ) , project . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ) . getSeverity ( ) == IStatus . ERROR ) { return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_NAME , this . name ) ; } return JavaModelStatus . VERIFIED_OK ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . IOException ; import java . util . HashMap ; import java . util . Map ; import java . util . zip . ZipEntry ; import java . util . zip . ZipFile ; import org . eclipse . core . resources . IContainer ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IFolder ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFormatException ; import org . eclipse . jdt . internal . compiler . env . IBinaryType ; import org . eclipse . jdt . internal . compiler . env . IDependent ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . util . MementoTokenizer ; import org . eclipse . jdt . internal . core . util . Util ; public class ClassFile extends Openable implements IClassFile , SuffixConstants { protected String name ; protected BinaryType binaryType = null ; protected ClassFile ( PackageFragment parent , String nameWithoutExtension ) { super ( parent ) ; this . name = nameWithoutExtension ; } public ICompilationUnit becomeWorkingCopy ( IProblemRequestor problemRequestor , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; CompilationUnit workingCopy = new ClassFileWorkingCopy ( this , owner == null ? DefaultWorkingCopyOwner . PRIMARY : owner ) ; JavaModelManager . PerWorkingCopyInfo perWorkingCopyInfo = manager . getPerWorkingCopyInfo ( workingCopy , false , true , null ) ; if ( perWorkingCopyInfo == null ) { close ( ) ; BecomeWorkingCopyOperation operation = new BecomeWorkingCopyOperation ( workingCopy , problemRequestor ) ; operation . runOperation ( monitor ) ; return workingCopy ; } return perWorkingCopyInfo . workingCopy ; } protected boolean buildStructure ( OpenableElementInfo info , IProgressMonitor pm , Map newElements , IResource underlyingResource ) throws JavaModelException { IBinaryType typeInfo = getBinaryTypeInfo ( ( IFile ) underlyingResource ) ; if ( typeInfo == null ) { info . setChildren ( new IJavaElement [ ] { } ) ; return false ; } IType type = getType ( ) ; info . setChildren ( new IJavaElement [ ] { type } ) ; newElements . put ( type , typeInfo ) ; ( ( ClassFileInfo ) info ) . readBinaryChildren ( this , ( HashMap ) newElements , typeInfo ) ; return true ; } public void codeComplete ( int offset , ICompletionRequestor requestor ) throws JavaModelException { codeComplete ( offset , requestor , DefaultWorkingCopyOwner . PRIMARY ) ; } public void codeComplete ( int offset , ICompletionRequestor requestor , WorkingCopyOwner owner ) throws JavaModelException { if ( requestor == null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } codeComplete ( offset , new org . eclipse . jdt . internal . codeassist . CompletionRequestorWrapper ( requestor ) , owner ) ; } public void codeComplete ( int offset , CompletionRequestor requestor ) throws JavaModelException { codeComplete ( offset , requestor , DefaultWorkingCopyOwner . PRIMARY ) ; } public void codeComplete ( int offset , CompletionRequestor requestor , IProgressMonitor monitor ) throws JavaModelException { codeComplete ( offset , requestor , DefaultWorkingCopyOwner . PRIMARY , monitor ) ; } public void codeComplete ( int offset , CompletionRequestor requestor , WorkingCopyOwner owner ) throws JavaModelException { codeComplete ( offset , requestor , owner , null ) ; } public void codeComplete ( int offset , CompletionRequestor requestor , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException { String source = getSource ( ) ; if ( source != null ) { BinaryType type = ( BinaryType ) getType ( ) ; BasicCompilationUnit cu = new BasicCompilationUnit ( getSource ( ) . toCharArray ( ) , null , type . sourceFileName ( ( IBinaryType ) type . getElementInfo ( ) ) , getJavaProject ( ) ) ; codeComplete ( cu , cu , offset , requestor , owner , null , monitor ) ; } } public IJavaElement [ ] codeSelect ( int offset , int length ) throws JavaModelException { return codeSelect ( offset , length , DefaultWorkingCopyOwner . PRIMARY ) ; } public IJavaElement [ ] codeSelect ( int offset , int length , WorkingCopyOwner owner ) throws JavaModelException { IBuffer buffer = getBuffer ( ) ; char [ ] contents ; if ( buffer != null && ( contents = buffer . getCharacters ( ) ) != null ) { BinaryType type = ( BinaryType ) getType ( ) ; BasicCompilationUnit cu = new BasicCompilationUnit ( contents , null , type . sourceFileName ( ( IBinaryType ) type . getElementInfo ( ) ) ) ; return super . codeSelect ( cu , offset , length , owner ) ; } else { return new IJavaElement [ ] { } ; } } protected Object createElementInfo ( ) { return new ClassFileInfo ( ) ; } public boolean equals ( Object o ) { if ( ! ( o instanceof ClassFile ) ) return false ; ClassFile other = ( ClassFile ) o ; return this . name . equals ( other . name ) && this . parent . equals ( other . parent ) ; } public boolean existsUsingJarTypeCache ( ) { if ( getPackageFragmentRoot ( ) . isArchive ( ) ) { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; IType type = getType ( ) ; Object info = manager . getInfo ( type ) ; if ( info == JavaModelCache . NON_EXISTING_JAR_TYPE_INFO ) return false ; else if ( info != null ) return true ; JavaElementInfo parentInfo = ( JavaElementInfo ) manager . getInfo ( getParent ( ) ) ; if ( parentInfo != null ) { IJavaElement [ ] children = parentInfo . getChildren ( ) ; for ( int i = <NUM_LIT:0> , length = children . length ; i < length ; i ++ ) { if ( this . name . equals ( ( ( ClassFile ) children [ i ] ) . name ) ) return true ; } return false ; } try { info = getJarBinaryTypeInfo ( ( PackageFragment ) getParent ( ) , true ) ; } catch ( CoreException e ) { } catch ( IOException e ) { } catch ( ClassFormatException e ) { } manager . putJarTypeInfo ( type , info == null ? JavaModelCache . NON_EXISTING_JAR_TYPE_INFO : info ) ; return info != null ; } else return exists ( ) ; } protected IJavaElement findElement ( IJavaElement elt , int position , SourceMapper mapper ) { SourceRange range = mapper . getSourceRange ( elt ) ; if ( range == null || position < range . getOffset ( ) || range . getOffset ( ) + range . getLength ( ) - <NUM_LIT:1> < position ) { return null ; } if ( elt instanceof IParent ) { try { IJavaElement [ ] children = ( ( IParent ) elt ) . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { IJavaElement match = findElement ( children [ i ] , position , mapper ) ; if ( match != null ) { return match ; } } } catch ( JavaModelException npe ) { } } return elt ; } public IType findPrimaryType ( ) { IType primaryType = getType ( ) ; if ( primaryType . exists ( ) ) { return primaryType ; } return null ; } public String getAttachedJavadoc ( IProgressMonitor monitor ) throws JavaModelException { return getType ( ) . getAttachedJavadoc ( monitor ) ; } public IBinaryType getBinaryTypeInfo ( IFile file ) throws JavaModelException { return getBinaryTypeInfo ( file , true ) ; } public IBinaryType getBinaryTypeInfo ( IFile file , boolean fullyInitialize ) throws JavaModelException { JavaElement pkg = ( JavaElement ) getParent ( ) ; if ( pkg instanceof JarPackageFragment ) { try { IBinaryType info = getJarBinaryTypeInfo ( ( PackageFragment ) pkg , fullyInitialize ) ; if ( info == null ) { throw newNotPresentException ( ) ; } return info ; } catch ( ClassFormatException cfe ) { if ( JavaCore . getPlugin ( ) . isDebugging ( ) ) { cfe . printStackTrace ( System . err ) ; } return null ; } catch ( IOException ioe ) { throw new JavaModelException ( ioe , IJavaModelStatusConstants . IO_EXCEPTION ) ; } catch ( CoreException e ) { if ( e instanceof JavaModelException ) { throw ( JavaModelException ) e ; } else { throw new JavaModelException ( e ) ; } } } else { byte [ ] contents = Util . getResourceContentsAsByteArray ( file ) ; try { return new ClassFileReader ( contents , file . getFullPath ( ) . toString ( ) . toCharArray ( ) , fullyInitialize ) ; } catch ( ClassFormatException cfe ) { return null ; } } } public byte [ ] getBytes ( ) throws JavaModelException { JavaElement pkg = ( JavaElement ) getParent ( ) ; if ( pkg instanceof JarPackageFragment ) { JarPackageFragmentRoot root = ( JarPackageFragmentRoot ) pkg . getParent ( ) ; ZipFile zip = null ; try { zip = root . getJar ( ) ; String entryName = Util . concatWith ( ( ( PackageFragment ) pkg ) . names , getElementName ( ) , '<CHAR_LIT:/>' ) ; ZipEntry ze = zip . getEntry ( entryName ) ; if ( ze != null ) { return org . eclipse . jdt . internal . compiler . util . Util . getZipEntryByteContent ( ze , zip ) ; } throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST , this ) ) ; } catch ( IOException ioe ) { throw new JavaModelException ( ioe , IJavaModelStatusConstants . IO_EXCEPTION ) ; } catch ( CoreException e ) { if ( e instanceof JavaModelException ) { throw ( JavaModelException ) e ; } else { throw new JavaModelException ( e ) ; } } finally { JavaModelManager . getJavaModelManager ( ) . closeZipFile ( zip ) ; } } else { IFile file = ( IFile ) resource ( ) ; return Util . getResourceContentsAsByteArray ( file ) ; } } private IBinaryType getJarBinaryTypeInfo ( PackageFragment pkg , boolean fullyInitialize ) throws CoreException , IOException , ClassFormatException { JarPackageFragmentRoot root = ( JarPackageFragmentRoot ) pkg . getParent ( ) ; ZipFile zip = null ; try { zip = root . getJar ( ) ; String entryName = Util . concatWith ( pkg . names , getElementName ( ) , '<CHAR_LIT:/>' ) ; ZipEntry ze = zip . getEntry ( entryName ) ; if ( ze != null ) { byte contents [ ] = org . eclipse . jdt . internal . compiler . util . Util . getZipEntryByteContent ( ze , zip ) ; String fileName = root . getHandleIdentifier ( ) + IDependent . JAR_FILE_ENTRY_SEPARATOR + entryName ; return new ClassFileReader ( contents , fileName . toCharArray ( ) , fullyInitialize ) ; } } finally { JavaModelManager . getJavaModelManager ( ) . closeZipFile ( zip ) ; } return null ; } public IBuffer getBuffer ( ) throws JavaModelException { IStatus status = validateClassFile ( ) ; if ( status . isOK ( ) ) { return super . getBuffer ( ) ; } else { Object info = ( ( ClassFile ) getClassFile ( ) ) . getBinaryTypeInfo ( ( IFile ) resource ( ) ) ; IBuffer buffer = openBuffer ( null , info ) ; if ( buffer != null && ! ( buffer instanceof NullBuffer ) ) return buffer ; switch ( status . getCode ( ) ) { case IJavaModelStatusConstants . ELEMENT_NOT_ON_CLASSPATH : case IJavaModelStatusConstants . INVALID_ELEMENT_TYPES : return null ; default : throw new JavaModelException ( ( IJavaModelStatus ) status ) ; } } } public IClassFile getClassFile ( ) { return this ; } public ITypeRoot getTypeRoot ( ) { return this ; } public IResource getCorrespondingResource ( ) throws JavaModelException { IPackageFragmentRoot root = ( IPackageFragmentRoot ) getParent ( ) . getParent ( ) ; if ( root . isArchive ( ) ) { return null ; } else { return getUnderlyingResource ( ) ; } } public IJavaElement getElementAt ( int position ) throws JavaModelException { IJavaElement parentElement = getParent ( ) ; while ( parentElement . getElementType ( ) != IJavaElement . PACKAGE_FRAGMENT_ROOT ) { parentElement = parentElement . getParent ( ) ; } PackageFragmentRoot root = ( PackageFragmentRoot ) parentElement ; SourceMapper mapper = root . getSourceMapper ( ) ; if ( mapper == null ) { return null ; } else { getBuffer ( ) ; IType type = getType ( ) ; return findElement ( type , position , mapper ) ; } } public IJavaElement getElementAtConsideringSibling ( int position ) throws JavaModelException { IPackageFragment fragment = ( IPackageFragment ) getParent ( ) ; PackageFragmentRoot root = ( PackageFragmentRoot ) fragment . getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; SourceMapper mapper = root . getSourceMapper ( ) ; if ( mapper == null ) { return null ; } else { int index = this . name . indexOf ( '<CHAR_LIT>' ) ; int prefixLength = index < <NUM_LIT:0> ? this . name . length ( ) : index ; IType type = null ; int start = - <NUM_LIT:1> ; int end = Integer . MAX_VALUE ; IJavaElement [ ] children = fragment . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { String childName = children [ i ] . getElementName ( ) ; int childIndex = childName . indexOf ( '<CHAR_LIT>' ) ; int childPrefixLength = childIndex < <NUM_LIT:0> ? childName . indexOf ( '<CHAR_LIT:.>' ) : childIndex ; if ( prefixLength == childPrefixLength && this . name . regionMatches ( <NUM_LIT:0> , childName , <NUM_LIT:0> , prefixLength ) ) { IClassFile classFile = ( IClassFile ) children [ i ] ; classFile . getBuffer ( ) ; SourceRange range = mapper . getSourceRange ( classFile . getType ( ) ) ; if ( range == SourceMapper . UNKNOWN_RANGE ) continue ; int newStart = range . getOffset ( ) ; int newEnd = newStart + range . getLength ( ) - <NUM_LIT:1> ; if ( newStart > start && newEnd < end && newStart <= position && newEnd >= position ) { type = classFile . getType ( ) ; start = newStart ; end = newEnd ; } } } if ( type != null ) { return findElement ( type , position , mapper ) ; } return null ; } } public String getElementName ( ) { return this . name + SuffixConstants . SUFFIX_STRING_class ; } public int getElementType ( ) { return CLASS_FILE ; } public IJavaElement getHandleFromMemento ( String token , MementoTokenizer memento , WorkingCopyOwner owner ) { switch ( token . charAt ( <NUM_LIT:0> ) ) { case JEM_TYPE : if ( ! memento . hasMoreTokens ( ) ) return this ; String typeName = memento . nextToken ( ) ; JavaElement type = new BinaryType ( this , typeName ) ; return type . getHandleFromMemento ( memento , owner ) ; } return null ; } protected char getHandleMementoDelimiter ( ) { return JavaElement . JEM_CLASSFILE ; } public IPath getPath ( ) { PackageFragmentRoot root = getPackageFragmentRoot ( ) ; if ( root . isArchive ( ) ) { return root . getPath ( ) ; } else { return getParent ( ) . getPath ( ) . append ( getElementName ( ) ) ; } } public IResource resource ( PackageFragmentRoot root ) { return ( ( IContainer ) ( ( Openable ) this . parent ) . resource ( root ) ) . getFile ( new Path ( getElementName ( ) ) ) ; } public String getSource ( ) throws JavaModelException { IBuffer buffer = getBuffer ( ) ; if ( buffer == null ) { return null ; } return buffer . getContents ( ) ; } public ISourceRange getSourceRange ( ) throws JavaModelException { IBuffer buffer = getBuffer ( ) ; if ( buffer != null ) { String contents = buffer . getContents ( ) ; if ( contents == null ) return null ; return new SourceRange ( <NUM_LIT:0> , contents . length ( ) ) ; } else { return null ; } } public String getTopLevelTypeName ( ) { String topLevelTypeName = getElementName ( ) ; int firstDollar = topLevelTypeName . indexOf ( '<CHAR_LIT>' ) ; if ( firstDollar != - <NUM_LIT:1> ) { topLevelTypeName = topLevelTypeName . substring ( <NUM_LIT:0> , firstDollar ) ; } else { topLevelTypeName = topLevelTypeName . substring ( <NUM_LIT:0> , topLevelTypeName . length ( ) - SUFFIX_CLASS . length ) ; } return topLevelTypeName ; } public IType getType ( ) { if ( this . binaryType == null ) { this . binaryType = new BinaryType ( this , getTypeName ( ) ) ; } return this . binaryType ; } public String getTypeName ( ) { int lastDollar = this . name . lastIndexOf ( '<CHAR_LIT>' ) ; return lastDollar > - <NUM_LIT:1> ? Util . localTypeName ( this . name , lastDollar , this . name . length ( ) ) : this . name ; } public ICompilationUnit getWorkingCopy ( WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException { CompilationUnit workingCopy = new ClassFileWorkingCopy ( this , owner == null ? DefaultWorkingCopyOwner . PRIMARY : owner ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; JavaModelManager . PerWorkingCopyInfo perWorkingCopyInfo = manager . getPerWorkingCopyInfo ( workingCopy , false , true , null ) ; if ( perWorkingCopyInfo != null ) { return perWorkingCopyInfo . getWorkingCopy ( ) ; } BecomeWorkingCopyOperation op = new BecomeWorkingCopyOperation ( workingCopy , null ) ; op . runOperation ( monitor ) ; return workingCopy ; } public IJavaElement getWorkingCopy ( IProgressMonitor monitor , org . eclipse . jdt . core . IBufferFactory factory ) throws JavaModelException { return getWorkingCopy ( BufferFactoryWrapper . create ( factory ) , monitor ) ; } protected boolean hasBuffer ( ) { return true ; } public int hashCode ( ) { return Util . combineHashCodes ( this . name . hashCode ( ) , this . parent . hashCode ( ) ) ; } public boolean isClass ( ) throws JavaModelException { return getType ( ) . isClass ( ) ; } public boolean isInterface ( ) throws JavaModelException { return getType ( ) . isInterface ( ) ; } public boolean isReadOnly ( ) { return true ; } private IStatus validateClassFile ( ) { IPackageFragmentRoot root = getPackageFragmentRoot ( ) ; try { if ( root . getKind ( ) != IPackageFragmentRoot . K_BINARY ) return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_ELEMENT_TYPES , root ) ; } catch ( JavaModelException e ) { return e . getJavaModelStatus ( ) ; } IJavaProject project = getJavaProject ( ) ; return JavaConventions . validateClassFileName ( getElementName ( ) , project . getOption ( JavaCore . COMPILER_SOURCE , true ) , project . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ) ; } protected IBuffer openBuffer ( IProgressMonitor pm , Object info ) throws JavaModelException { IType outerMostEnclosingType = getOuterMostEnclosingType ( ) ; IBuffer buffer = getBufferManager ( ) . getBuffer ( outerMostEnclosingType . getClassFile ( ) ) ; if ( buffer == null ) { SourceMapper mapper = getSourceMapper ( ) ; IBinaryType typeInfo = info instanceof IBinaryType ? ( IBinaryType ) info : null ; if ( mapper != null ) { buffer = mapSource ( mapper , typeInfo , outerMostEnclosingType . getClassFile ( ) ) ; } } return buffer ; } private IBuffer mapSource ( SourceMapper mapper , IBinaryType info , IClassFile bufferOwner ) { char [ ] contents = mapper . findSource ( getType ( ) , info ) ; if ( contents != null ) { IBuffer buffer = BufferManager . createBuffer ( bufferOwner ) ; if ( buffer == null ) return null ; BufferManager bufManager = getBufferManager ( ) ; bufManager . addBuffer ( buffer ) ; if ( buffer . getCharacters ( ) == null ) { buffer . setContents ( contents ) ; } buffer . addBufferChangedListener ( this ) ; mapper . mapSource ( getOuterMostEnclosingType ( ) , contents , info ) ; return buffer ; } else { IBuffer buffer = BufferManager . createNullBuffer ( bufferOwner ) ; if ( buffer == null ) return null ; BufferManager bufManager = getBufferManager ( ) ; bufManager . addBuffer ( buffer ) ; buffer . addBufferChangedListener ( this ) ; return buffer ; } } static String simpleName ( char [ ] className ) { if ( className == null ) return null ; String simpleName = new String ( unqualifiedName ( className ) ) ; int lastDollar = simpleName . lastIndexOf ( '<CHAR_LIT>' ) ; if ( lastDollar != - <NUM_LIT:1> ) return Util . localTypeName ( simpleName , lastDollar , simpleName . length ( ) ) ; else return simpleName ; } private IType getOuterMostEnclosingType ( ) { IType type = getType ( ) ; IType enclosingType = type . getDeclaringType ( ) ; while ( enclosingType != null ) { type = enclosingType ; enclosingType = type . getDeclaringType ( ) ; } return type ; } public static char [ ] translatedName ( char [ ] name ) { if ( name == null ) return null ; int nameLength = name . length ; char [ ] newName = new char [ nameLength ] ; for ( int i = <NUM_LIT:0> ; i < nameLength ; i ++ ) { if ( name [ i ] == '<CHAR_LIT:/>' ) { newName [ i ] = '<CHAR_LIT:.>' ; } else { newName [ i ] = name [ i ] ; } } return newName ; } static char [ ] [ ] translatedNames ( char [ ] [ ] names ) { if ( names == null ) return null ; int length = names . length ; char [ ] [ ] newNames = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { newNames [ i ] = translatedName ( names [ i ] ) ; } return newNames ; } static char [ ] unqualifiedName ( char [ ] className ) { if ( className == null ) return null ; int count = <NUM_LIT:0> ; for ( int i = className . length - <NUM_LIT:1> ; i > - <NUM_LIT:1> ; i -- ) { if ( className [ i ] == '<CHAR_LIT:/>' ) { char [ ] name = new char [ count ] ; System . arraycopy ( className , i + <NUM_LIT:1> , name , <NUM_LIT:0> , count ) ; return name ; } count ++ ; } return className ; } public void codeComplete ( int offset , final org . eclipse . jdt . core . ICodeCompletionRequestor requestor ) throws JavaModelException { if ( requestor == null ) { codeComplete ( offset , ( ICompletionRequestor ) null ) ; return ; } codeComplete ( offset , new ICompletionRequestor ( ) { public void acceptAnonymousType ( char [ ] superTypePackageName , char [ ] superTypeName , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] [ ] parameterNames , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) { } public void acceptClass ( char [ ] packageName , char [ ] className , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) { requestor . acceptClass ( packageName , className , completionName , modifiers , completionStart , completionEnd ) ; } public void acceptError ( IProblem error ) { } public void acceptField ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] fieldName , char [ ] typePackageName , char [ ] typeName , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) { requestor . acceptField ( declaringTypePackageName , declaringTypeName , fieldName , typePackageName , typeName , completionName , modifiers , completionStart , completionEnd ) ; } public void acceptInterface ( char [ ] packageName , char [ ] interfaceName , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) { requestor . acceptInterface ( packageName , interfaceName , completionName , modifiers , completionStart , completionEnd ) ; } public void acceptKeyword ( char [ ] keywordName , int completionStart , int completionEnd , int relevance ) { requestor . acceptKeyword ( keywordName , completionStart , completionEnd ) ; } public void acceptLabel ( char [ ] labelName , int completionStart , int completionEnd , int relevance ) { requestor . acceptLabel ( labelName , completionStart , completionEnd ) ; } public void acceptLocalVariable ( char [ ] localVarName , char [ ] typePackageName , char [ ] typeName , int modifiers , int completionStart , int completionEnd , int relevance ) { } public void acceptMethod ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] selector , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] [ ] parameterNames , char [ ] returnTypePackageName , char [ ] returnTypeName , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) { requestor . acceptMethod ( declaringTypePackageName , declaringTypeName , selector , parameterPackageNames , parameterTypeNames , returnTypePackageName , returnTypeName , completionName , modifiers , completionStart , completionEnd ) ; } public void acceptMethodDeclaration ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] selector , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] [ ] parameterNames , char [ ] returnTypePackageName , char [ ] returnTypeName , char [ ] completionName , int modifiers , int completionStart , int completionEnd , int relevance ) { } public void acceptModifier ( char [ ] modifierName , int completionStart , int completionEnd , int relevance ) { requestor . acceptModifier ( modifierName , completionStart , completionEnd ) ; } public void acceptPackage ( char [ ] packageName , char [ ] completionName , int completionStart , int completionEnd , int relevance ) { requestor . acceptPackage ( packageName , completionName , completionStart , completionEnd ) ; } public void acceptType ( char [ ] packageName , char [ ] typeName , char [ ] completionName , int completionStart , int completionEnd , int relevance ) { requestor . acceptType ( packageName , typeName , completionName , completionStart , completionEnd ) ; } public void acceptVariableName ( char [ ] typePackageName , char [ ] typeName , char [ ] varName , char [ ] completionName , int completionStart , int completionEnd , int relevance ) { } } ) ; } protected IStatus validateExistence ( IResource underlyingResource ) { IStatus status = validateClassFile ( ) ; if ( ! status . isOK ( ) ) return status ; if ( underlyingResource != null ) { if ( ! underlyingResource . isAccessible ( ) ) return newDoesNotExistStatus ( ) ; PackageFragmentRoot root ; if ( ( underlyingResource instanceof IFolder ) && ( root = getPackageFragmentRoot ( ) ) . isArchive ( ) ) { return root . newDoesNotExistStatus ( ) ; } } return JavaModelStatus . VERIFIED_OK ; } public ISourceRange getNameRange ( ) { return null ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IJavaElement ; public class SourceFieldWithChildrenInfo extends SourceFieldElementInfo { protected IJavaElement [ ] children ; public SourceFieldWithChildrenInfo ( IJavaElement [ ] children ) { this . children = children ; } public IJavaElement [ ] getChildren ( ) { return this . children ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . zip . ZipFile ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . core . runtime . PlatformObject ; import org . eclipse . jdt . core . IJarEntryResource ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . internal . core . util . Util ; public abstract class JarEntryResource extends PlatformObject implements IJarEntryResource { protected Object parent ; protected String simpleName ; public JarEntryResource ( String simpleName ) { this . simpleName = simpleName ; } public abstract JarEntryResource clone ( Object newParent ) ; public boolean equals ( Object obj ) { if ( ! ( obj instanceof JarEntryResource ) ) return false ; JarEntryResource other = ( JarEntryResource ) obj ; return this . parent . equals ( other . parent ) && this . simpleName . equals ( other . simpleName ) ; } protected String getEntryName ( ) { String parentEntryName ; if ( this . parent instanceof IPackageFragment ) { String elementName = ( ( IPackageFragment ) this . parent ) . getElementName ( ) ; parentEntryName = elementName . length ( ) == <NUM_LIT:0> ? "<STR_LIT>" : elementName . replace ( '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) + '<CHAR_LIT:/>' ; } else if ( this . parent instanceof IPackageFragmentRoot ) { parentEntryName = "<STR_LIT>" ; } else { parentEntryName = ( ( JarEntryDirectory ) this . parent ) . getEntryName ( ) + '<CHAR_LIT:/>' ; } return parentEntryName + this . simpleName ; } public IPath getFullPath ( ) { return new Path ( getEntryName ( ) ) . makeAbsolute ( ) ; } public String getName ( ) { return this . simpleName ; } public Object getParent ( ) { return this . parent ; } public IPackageFragmentRoot getPackageFragmentRoot ( ) { if ( this . parent instanceof IPackageFragment ) { return ( IPackageFragmentRoot ) ( ( IPackageFragment ) this . parent ) . getParent ( ) ; } else if ( this . parent instanceof IPackageFragmentRoot ) { return ( IPackageFragmentRoot ) this . parent ; } else { return ( ( JarEntryDirectory ) this . parent ) . getPackageFragmentRoot ( ) ; } } protected ZipFile getZipFile ( ) throws CoreException { if ( this . parent instanceof IPackageFragment ) { JarPackageFragmentRoot root = ( JarPackageFragmentRoot ) ( ( IPackageFragment ) this . parent ) . getParent ( ) ; return root . getJar ( ) ; } else if ( this . parent instanceof JarPackageFragmentRoot ) { return ( ( JarPackageFragmentRoot ) this . parent ) . getJar ( ) ; } else return ( ( JarEntryDirectory ) this . parent ) . getZipFile ( ) ; } public int hashCode ( ) { return Util . combineHashCodes ( this . simpleName . hashCode ( ) , this . parent . hashCode ( ) ) ; } public boolean isReadOnly ( ) { return true ; } public void setParent ( Object parent ) { this . parent = parent ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . internal . core . util . Messages ; public class MoveElementsOperation extends CopyElementsOperation { public MoveElementsOperation ( IJavaElement [ ] elementsToMove , IJavaElement [ ] destContainers , boolean force ) { super ( elementsToMove , destContainers , force ) ; } protected String getMainTaskName ( ) { return Messages . operation_moveElementProgress ; } protected boolean isMove ( ) { return true ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IBuffer ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . WorkingCopyOwner ; public class BufferFactoryWrapper extends WorkingCopyOwner { public org . eclipse . jdt . core . IBufferFactory factory ; private BufferFactoryWrapper ( org . eclipse . jdt . core . IBufferFactory factory ) { this . factory = factory ; } public static WorkingCopyOwner create ( org . eclipse . jdt . core . IBufferFactory factory ) { return new BufferFactoryWrapper ( factory ) ; } public IBuffer createBuffer ( ICompilationUnit workingCopy ) { if ( this . factory == null ) return super . createBuffer ( workingCopy ) ; return this . factory . createBuffer ( workingCopy ) ; } public boolean equals ( Object obj ) { if ( ! ( obj instanceof BufferFactoryWrapper ) ) return false ; BufferFactoryWrapper other = ( BufferFactoryWrapper ) obj ; if ( this . factory == null ) return other . factory == null ; return this . factory . equals ( other . factory ) ; } public int hashCode ( ) { if ( this . factory == null ) return <NUM_LIT:0> ; return this . factory . hashCode ( ) ; } public String toString ( ) { return "<STR_LIT>" + this . factory ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . HashMap ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . internal . core . util . DOMFinder ; import org . eclipse . jdt . internal . core . util . MementoTokenizer ; import org . eclipse . jdt . internal . core . util . Messages ; public abstract class SourceRefElement extends JavaElement implements ISourceReference { public int occurrenceCount = <NUM_LIT:1> ; protected SourceRefElement ( JavaElement parent ) { super ( parent ) ; } protected void closing ( Object info ) throws JavaModelException { } protected Object createElementInfo ( ) { return null ; } public void copy ( IJavaElement container , IJavaElement sibling , String rename , boolean force , IProgressMonitor monitor ) throws JavaModelException { if ( container == null ) { throw new IllegalArgumentException ( Messages . operation_nullContainer ) ; } IJavaElement [ ] elements = new IJavaElement [ ] { this } ; IJavaElement [ ] containers = new IJavaElement [ ] { container } ; IJavaElement [ ] siblings = null ; if ( sibling != null ) { siblings = new IJavaElement [ ] { sibling } ; } String [ ] renamings = null ; if ( rename != null ) { renamings = new String [ ] { rename } ; } getJavaModel ( ) . copy ( elements , containers , siblings , renamings , force , monitor ) ; } public void delete ( boolean force , IProgressMonitor monitor ) throws JavaModelException { IJavaElement [ ] elements = new IJavaElement [ ] { this } ; getJavaModel ( ) . delete ( elements , force , monitor ) ; } public boolean equals ( Object o ) { if ( ! ( o instanceof SourceRefElement ) ) return false ; return this . occurrenceCount == ( ( SourceRefElement ) o ) . occurrenceCount && super . equals ( o ) ; } public ASTNode findNode ( CompilationUnit ast ) { DOMFinder finder = new DOMFinder ( ast , this , false ) ; try { return finder . search ( ) ; } catch ( JavaModelException e ) { return null ; } } protected void generateInfos ( Object info , HashMap newElements , IProgressMonitor pm ) throws JavaModelException { Openable openableParent = ( Openable ) getOpenableParent ( ) ; if ( openableParent == null ) return ; JavaElementInfo openableParentInfo = ( JavaElementInfo ) JavaModelManager . getJavaModelManager ( ) . getInfo ( openableParent ) ; if ( openableParentInfo == null ) { openableParent . generateInfos ( openableParent . createElementInfo ( ) , newElements , pm ) ; } } public IAnnotation getAnnotation ( String name ) { return new Annotation ( this , name ) ; } public IAnnotation [ ] getAnnotations ( ) throws JavaModelException { AnnotatableInfo info = ( AnnotatableInfo ) getElementInfo ( ) ; return info . annotations ; } public ICompilationUnit getCompilationUnit ( ) { return ( ICompilationUnit ) getAncestor ( COMPILATION_UNIT ) ; } public IResource getCorrespondingResource ( ) throws JavaModelException { if ( ! exists ( ) ) throw newNotPresentException ( ) ; return null ; } public IJavaElement getHandleFromMemento ( String token , MementoTokenizer memento , WorkingCopyOwner workingCopyOwner ) { switch ( token . charAt ( <NUM_LIT:0> ) ) { case JEM_COUNT : return getHandleUpdatingCountFromMemento ( memento , workingCopyOwner ) ; } return this ; } protected void getHandleMemento ( StringBuffer buff ) { super . getHandleMemento ( buff ) ; if ( this . occurrenceCount > <NUM_LIT:1> ) { buff . append ( JEM_COUNT ) ; buff . append ( this . occurrenceCount ) ; } } public IJavaElement getHandleUpdatingCountFromMemento ( MementoTokenizer memento , WorkingCopyOwner owner ) { if ( ! memento . hasMoreTokens ( ) ) return this ; this . occurrenceCount = Integer . parseInt ( memento . nextToken ( ) ) ; if ( ! memento . hasMoreTokens ( ) ) return this ; String token = memento . nextToken ( ) ; return getHandleFromMemento ( token , memento , owner ) ; } public int getOccurrenceCount ( ) { return this . occurrenceCount ; } public IOpenable getOpenableParent ( ) { IJavaElement current = getParent ( ) ; while ( current != null ) { if ( current instanceof IOpenable ) { return ( IOpenable ) current ; } current = current . getParent ( ) ; } return null ; } public IPath getPath ( ) { return getParent ( ) . getPath ( ) ; } public IResource resource ( ) { return this . parent . resource ( ) ; } public String getSource ( ) throws JavaModelException { IOpenable openable = getOpenableParent ( ) ; IBuffer buffer = openable . getBuffer ( ) ; if ( buffer == null ) { return null ; } ISourceRange range = getSourceRange ( ) ; int offset = range . getOffset ( ) ; int length = range . getLength ( ) ; if ( offset == - <NUM_LIT:1> || length == <NUM_LIT:0> ) { return null ; } try { return buffer . getText ( offset , length ) ; } catch ( RuntimeException e ) { return null ; } } public ISourceRange getSourceRange ( ) throws JavaModelException { SourceRefElementInfo info = ( SourceRefElementInfo ) getElementInfo ( ) ; return info . getSourceRange ( ) ; } public IResource getUnderlyingResource ( ) throws JavaModelException { if ( ! exists ( ) ) throw newNotPresentException ( ) ; return getParent ( ) . getUnderlyingResource ( ) ; } public boolean hasChildren ( ) throws JavaModelException { return getChildren ( ) . length > <NUM_LIT:0> ; } public boolean isStructureKnown ( ) throws JavaModelException { return true ; } public void move ( IJavaElement container , IJavaElement sibling , String rename , boolean force , IProgressMonitor monitor ) throws JavaModelException { if ( container == null ) { throw new IllegalArgumentException ( Messages . operation_nullContainer ) ; } IJavaElement [ ] elements = new IJavaElement [ ] { this } ; IJavaElement [ ] containers = new IJavaElement [ ] { container } ; IJavaElement [ ] siblings = null ; if ( sibling != null ) { siblings = new IJavaElement [ ] { sibling } ; } String [ ] renamings = null ; if ( rename != null ) { renamings = new String [ ] { rename } ; } getJavaModel ( ) . move ( elements , containers , siblings , renamings , force , monitor ) ; } public void rename ( String newName , boolean force , IProgressMonitor monitor ) throws JavaModelException { if ( newName == null ) { throw new IllegalArgumentException ( Messages . element_nullName ) ; } IJavaElement [ ] elements = new IJavaElement [ ] { this } ; IJavaElement [ ] dests = new IJavaElement [ ] { getParent ( ) } ; String [ ] renamings = new String [ ] { newName } ; getJavaModel ( ) . rename ( elements , dests , renamings , force , monitor ) ; } protected void toStringName ( StringBuffer buffer ) { super . toStringName ( buffer ) ; if ( this . occurrenceCount > <NUM_LIT:1> ) { buffer . append ( "<STR_LIT:#>" ) ; buffer . append ( this . occurrenceCount ) ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . ArrayList ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IParent ; import org . eclipse . jdt . core . IRegion ; public class Region implements IRegion { protected ArrayList rootElements ; public Region ( ) { this . rootElements = new ArrayList ( <NUM_LIT:1> ) ; } public void add ( IJavaElement element ) { if ( ! contains ( element ) ) { removeAllChildren ( element ) ; this . rootElements . add ( element ) ; this . rootElements . trimToSize ( ) ; } } public boolean contains ( IJavaElement element ) { int size = this . rootElements . size ( ) ; ArrayList parents = getAncestors ( element ) ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { IJavaElement aTop = ( IJavaElement ) this . rootElements . get ( i ) ; if ( aTop . equals ( element ) ) { return true ; } for ( int j = <NUM_LIT:0> , pSize = parents . size ( ) ; j < pSize ; j ++ ) { if ( aTop . equals ( parents . get ( j ) ) ) { return true ; } } } return false ; } private ArrayList getAncestors ( IJavaElement element ) { ArrayList parents = new ArrayList ( ) ; IJavaElement parent = element . getParent ( ) ; while ( parent != null ) { parents . add ( parent ) ; parent = parent . getParent ( ) ; } parents . trimToSize ( ) ; return parents ; } public IJavaElement [ ] getElements ( ) { int size = this . rootElements . size ( ) ; IJavaElement [ ] roots = new IJavaElement [ size ] ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { roots [ i ] = ( IJavaElement ) this . rootElements . get ( i ) ; } return roots ; } public boolean remove ( IJavaElement element ) { removeAllChildren ( element ) ; return this . rootElements . remove ( element ) ; } protected void removeAllChildren ( IJavaElement element ) { if ( element instanceof IParent ) { ArrayList newRootElements = new ArrayList ( ) ; for ( int i = <NUM_LIT:0> , size = this . rootElements . size ( ) ; i < size ; i ++ ) { IJavaElement currentRoot = ( IJavaElement ) this . rootElements . get ( i ) ; IJavaElement parent = currentRoot . getParent ( ) ; boolean isChild = false ; while ( parent != null ) { if ( parent . equals ( element ) ) { isChild = true ; break ; } parent = parent . getParent ( ) ; } if ( ! isChild ) { newRootElements . add ( currentRoot ) ; } } this . rootElements = newRootElements ; } } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; IJavaElement [ ] roots = getElements ( ) ; buffer . append ( '<CHAR_LIT:[>' ) ; for ( int i = <NUM_LIT:0> ; i < roots . length ; i ++ ) { buffer . append ( roots [ i ] . getElementName ( ) ) ; if ( i < ( roots . length - <NUM_LIT:1> ) ) { buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } buffer . append ( '<CHAR_LIT:]>' ) ; return buffer . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . ByteArrayInputStream ; import java . io . UnsupportedEncodingException ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IWorkspace ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . jobs . ISchedulingRule ; import org . eclipse . jdt . core . IBuffer ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModelStatus ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; public class CommitWorkingCopyOperation extends JavaModelOperation { public CommitWorkingCopyOperation ( ICompilationUnit element , boolean force ) { super ( new IJavaElement [ ] { element } , force ) ; } protected void executeOperation ( ) throws JavaModelException { try { beginTask ( Messages . workingCopy_commit , <NUM_LIT:2> ) ; CompilationUnit workingCopy = getCompilationUnit ( ) ; if ( ExternalJavaProject . EXTERNAL_PROJECT_NAME . equals ( workingCopy . getJavaProject ( ) . getElementName ( ) ) ) { workingCopy . getBuffer ( ) . save ( this . progressMonitor , this . force ) ; return ; } ICompilationUnit primary = workingCopy . getPrimary ( ) ; boolean isPrimary = workingCopy . isPrimary ( ) ; JavaElementDeltaBuilder deltaBuilder = null ; PackageFragmentRoot root = ( PackageFragmentRoot ) workingCopy . getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; boolean isIncluded = ! Util . isExcluded ( workingCopy ) ; IFile resource = ( IFile ) workingCopy . getResource ( ) ; IJavaProject project = root . getJavaProject ( ) ; if ( isPrimary || ( root . validateOnClasspath ( ) . isOK ( ) && isIncluded && resource . isAccessible ( ) && Util . isValidCompilationUnitName ( workingCopy . getElementName ( ) , project . getOption ( JavaCore . COMPILER_SOURCE , true ) , project . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ) ) ) { if ( ! isPrimary && ! primary . isOpen ( ) ) { primary . open ( null ) ; } if ( isIncluded && ( ! isPrimary || ! workingCopy . isConsistent ( ) ) ) { deltaBuilder = new JavaElementDeltaBuilder ( primary ) ; } IBuffer primaryBuffer = primary . getBuffer ( ) ; if ( ! isPrimary ) { if ( primaryBuffer == null ) return ; char [ ] primaryContents = primaryBuffer . getCharacters ( ) ; boolean hasSaved = false ; try { IBuffer workingCopyBuffer = workingCopy . getBuffer ( ) ; if ( workingCopyBuffer == null ) return ; primaryBuffer . setContents ( workingCopyBuffer . getCharacters ( ) ) ; primaryBuffer . save ( this . progressMonitor , this . force ) ; primary . makeConsistent ( this ) ; hasSaved = true ; } finally { if ( ! hasSaved ) { primaryBuffer . setContents ( primaryContents ) ; } } } else { primaryBuffer . save ( this . progressMonitor , this . force ) ; primary . makeConsistent ( this ) ; } } else { String encoding = null ; try { encoding = resource . getCharset ( ) ; } catch ( CoreException ce ) { } String contents = workingCopy . getSource ( ) ; if ( contents == null ) return ; try { byte [ ] bytes = encoding == null ? contents . getBytes ( ) : contents . getBytes ( encoding ) ; ByteArrayInputStream stream = new ByteArrayInputStream ( bytes ) ; if ( resource . exists ( ) ) { resource . setContents ( stream , this . force ? IResource . FORCE | IResource . KEEP_HISTORY : IResource . KEEP_HISTORY , null ) ; } else { resource . create ( stream , this . force , this . progressMonitor ) ; } } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } catch ( UnsupportedEncodingException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . IO_EXCEPTION ) ; } } setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; workingCopy . updateTimeStamp ( ( CompilationUnit ) primary ) ; workingCopy . makeConsistent ( this ) ; worked ( <NUM_LIT:1> ) ; if ( deltaBuilder != null ) { deltaBuilder . buildDeltas ( ) ; if ( deltaBuilder . delta != null ) { addDelta ( deltaBuilder . delta ) ; } } worked ( <NUM_LIT:1> ) ; } finally { done ( ) ; } } protected CompilationUnit getCompilationUnit ( ) { return ( CompilationUnit ) getElementToProcess ( ) ; } protected ISchedulingRule getSchedulingRule ( ) { IResource resource = getElementToProcess ( ) . getResource ( ) ; if ( resource == null ) return null ; IWorkspace workspace = resource . getWorkspace ( ) ; if ( resource . exists ( ) ) { return workspace . getRuleFactory ( ) . modifyRule ( resource ) ; } else { return workspace . getRuleFactory ( ) . createRule ( resource ) ; } } public IJavaModelStatus verify ( ) { CompilationUnit cu = getCompilationUnit ( ) ; if ( ! cu . isWorkingCopy ( ) ) { return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_ELEMENT_TYPES , cu ) ; } if ( cu . hasResourceChanged ( ) && ! this . force ) { return new JavaModelStatus ( IJavaModelStatusConstants . UPDATE_CONFLICT ) ; } return JavaModelStatus . VERIFIED_OK ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . IResourceRuleFactory ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . jobs . ISchedulingRule ; import org . eclipse . core . runtime . jobs . MultiRule ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModelStatus ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . JavaModelManager . PerProjectInfo ; public class SetClasspathOperation extends ChangeClasspathOperation { IClasspathEntry [ ] newRawClasspath ; IClasspathEntry [ ] referencedEntries ; IPath newOutputLocation ; JavaProject project ; public SetClasspathOperation ( JavaProject project , IClasspathEntry [ ] newRawClasspath , IPath newOutputLocation , boolean canChangeResource ) { this ( project , newRawClasspath , null , newOutputLocation , canChangeResource ) ; } public SetClasspathOperation ( JavaProject project , IClasspathEntry [ ] newRawClasspath , IClasspathEntry [ ] referencedEntries , IPath newOutputLocation , boolean canChangeResource ) { super ( new IJavaElement [ ] { project } , canChangeResource ) ; this . project = project ; this . newRawClasspath = newRawClasspath ; this . referencedEntries = referencedEntries ; this . newOutputLocation = newOutputLocation ; } protected void executeOperation ( ) throws JavaModelException { checkCanceled ( ) ; try { PerProjectInfo perProjectInfo = this . project . getPerProjectInfo ( ) ; ClasspathChange classpathChange = perProjectInfo . setRawClasspath ( this . newRawClasspath , this . referencedEntries , this . newOutputLocation , JavaModelStatus . VERIFIED_OK ) ; classpathChanged ( classpathChange , true ) ; if ( this . canChangeResources && perProjectInfo . writeAndCacheClasspath ( this . project , this . newRawClasspath , this . newOutputLocation ) ) setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; } finally { done ( ) ; } } protected ISchedulingRule getSchedulingRule ( ) { if ( this . canChangeResources ) { IResourceRuleFactory ruleFactory = ResourcesPlugin . getWorkspace ( ) . getRuleFactory ( ) ; return new MultiRule ( new ISchedulingRule [ ] { ruleFactory . modifyRule ( this . project . getProject ( ) ) , ruleFactory . modifyRule ( JavaModelManager . getExternalManager ( ) . getExternalFoldersProject ( ) ) } ) ; } return super . getSchedulingRule ( ) ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( <NUM_LIT:20> ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT:{>" ) ; for ( int i = <NUM_LIT:0> ; i < this . newRawClasspath . length ; i ++ ) { if ( i > <NUM_LIT:0> ) buffer . append ( "<STR_LIT:U+002C>" ) ; IClasspathEntry element = this . newRawClasspath [ i ] ; buffer . append ( "<STR_LIT:U+0020>" ) . append ( element . toString ( ) ) ; } buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . newOutputLocation . toString ( ) ) ; return buffer . toString ( ) ; } public IJavaModelStatus verify ( ) { IJavaModelStatus status = super . verify ( ) ; if ( ! status . isOK ( ) ) return status ; this . project . flushClasspathProblemMarkers ( false , false , true ) ; return ClasspathEntry . validateClasspath ( this . project , this . newRawClasspath , this . newOutputLocation ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . File ; import java . io . IOException ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . util . Util ; public class BasicCompilationUnit implements ICompilationUnit { protected char [ ] contents ; protected char [ ] fileName ; protected char [ ] [ ] packageName ; protected char [ ] mainTypeName ; protected String encoding ; public BasicCompilationUnit ( char [ ] contents , char [ ] [ ] packageName , String fileName ) { this . contents = contents ; this . fileName = fileName . toCharArray ( ) ; this . packageName = packageName ; } public BasicCompilationUnit ( char [ ] contents , char [ ] [ ] packageName , String fileName , String encoding ) { this ( contents , packageName , fileName ) ; this . encoding = encoding ; } public BasicCompilationUnit ( char [ ] contents , char [ ] [ ] packageName , String fileName , IJavaElement javaElement ) { this ( contents , packageName , fileName ) ; initEncoding ( javaElement ) ; } private void initEncoding ( IJavaElement javaElement ) { if ( javaElement != null ) { try { IJavaProject javaProject = javaElement . getJavaProject ( ) ; switch ( javaElement . getElementType ( ) ) { case IJavaElement . COMPILATION_UNIT : IFile file = ( IFile ) javaElement . getResource ( ) ; if ( file != null ) { this . encoding = file . getCharset ( ) ; break ; } default : IProject project = ( IProject ) javaProject . getResource ( ) ; if ( project != null ) { this . encoding = project . getDefaultCharset ( ) ; } break ; } } catch ( CoreException e1 ) { this . encoding = null ; } } else { this . encoding = null ; } } public char [ ] getContents ( ) { if ( this . contents != null ) return this . contents ; try { return Util . getFileCharContent ( new File ( new String ( this . fileName ) ) , this . encoding ) ; } catch ( IOException e ) { } return CharOperation . NO_CHAR ; } public char [ ] getFileName ( ) { return this . fileName ; } public char [ ] getMainTypeName ( ) { if ( this . mainTypeName == null ) { int start = CharOperation . lastIndexOf ( '<CHAR_LIT:/>' , this . fileName ) + <NUM_LIT:1> ; if ( start == <NUM_LIT:0> || start < CharOperation . lastIndexOf ( '<STR_LIT:\\>' , this . fileName ) ) start = CharOperation . lastIndexOf ( '<STR_LIT:\\>' , this . fileName ) + <NUM_LIT:1> ; int separator = CharOperation . indexOf ( '<CHAR_LIT>' , this . fileName ) + <NUM_LIT:1> ; if ( separator > start ) start = separator ; int end = CharOperation . lastIndexOf ( '<CHAR_LIT>' , this . fileName ) ; if ( end == - <NUM_LIT:1> || ! Util . isClassFileName ( this . fileName ) ) { end = CharOperation . lastIndexOf ( '<CHAR_LIT:.>' , this . fileName ) ; if ( end == - <NUM_LIT:1> ) end = this . fileName . length ; } this . mainTypeName = CharOperation . subarray ( this . fileName , start , end ) ; } return this . mainTypeName ; } public char [ ] [ ] getPackageName ( ) { return this . packageName ; } public String toString ( ) { return "<STR_LIT>" + new String ( this . fileName ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . ByteArrayInputStream ; import java . io . IOException ; import java . util . ArrayList ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IResourceStatus ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . ISafeRunnable ; import org . eclipse . core . runtime . SafeRunner ; import org . eclipse . core . runtime . content . IContentDescription ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . internal . core . util . Util ; public class Buffer implements IBuffer { protected IFile file ; protected int flags ; protected char [ ] contents ; protected ArrayList changeListeners ; protected IOpenable owner ; protected int gapStart = - <NUM_LIT:1> ; protected int gapEnd = - <NUM_LIT:1> ; protected Object lock = new Object ( ) ; protected static final int F_HAS_UNSAVED_CHANGES = <NUM_LIT:1> ; protected static final int F_IS_READ_ONLY = <NUM_LIT:2> ; protected static final int F_IS_CLOSED = <NUM_LIT:4> ; protected Buffer ( IFile file , IOpenable owner , boolean readOnly ) { this . file = file ; this . owner = owner ; if ( file == null ) { setReadOnly ( readOnly ) ; } } public synchronized void addBufferChangedListener ( IBufferChangedListener listener ) { if ( this . changeListeners == null ) { this . changeListeners = new ArrayList ( <NUM_LIT:5> ) ; } if ( ! this . changeListeners . contains ( listener ) ) { this . changeListeners . add ( listener ) ; } } public void append ( char [ ] text ) { if ( ! isReadOnly ( ) ) { if ( text == null || text . length == <NUM_LIT:0> ) { return ; } int length = getLength ( ) ; synchronized ( this . lock ) { if ( this . contents == null ) return ; moveAndResizeGap ( length , text . length ) ; System . arraycopy ( text , <NUM_LIT:0> , this . contents , length , text . length ) ; this . gapStart += text . length ; this . flags |= F_HAS_UNSAVED_CHANGES ; } notifyChanged ( new BufferChangedEvent ( this , length , <NUM_LIT:0> , new String ( text ) ) ) ; } } public void append ( String text ) { if ( text == null ) { return ; } this . append ( text . toCharArray ( ) ) ; } public void close ( ) { BufferChangedEvent event = null ; synchronized ( this . lock ) { if ( isClosed ( ) ) return ; event = new BufferChangedEvent ( this , <NUM_LIT:0> , <NUM_LIT:0> , null ) ; this . contents = null ; this . flags |= F_IS_CLOSED ; } notifyChanged ( event ) ; synchronized ( this ) { this . changeListeners = null ; } } public char getChar ( int position ) { synchronized ( this . lock ) { if ( this . contents == null ) return Character . MIN_VALUE ; if ( position < this . gapStart ) { return this . contents [ position ] ; } int gapLength = this . gapEnd - this . gapStart ; return this . contents [ position + gapLength ] ; } } public char [ ] getCharacters ( ) { synchronized ( this . lock ) { if ( this . contents == null ) return null ; if ( this . gapStart < <NUM_LIT:0> ) { return this . contents ; } int length = this . contents . length ; char [ ] newContents = new char [ length - this . gapEnd + this . gapStart ] ; System . arraycopy ( this . contents , <NUM_LIT:0> , newContents , <NUM_LIT:0> , this . gapStart ) ; System . arraycopy ( this . contents , this . gapEnd , newContents , this . gapStart , length - this . gapEnd ) ; return newContents ; } } public String getContents ( ) { char [ ] chars = getCharacters ( ) ; if ( chars == null ) return null ; return new String ( chars ) ; } public int getLength ( ) { synchronized ( this . lock ) { if ( this . contents == null ) return - <NUM_LIT:1> ; int length = this . gapEnd - this . gapStart ; return ( this . contents . length - length ) ; } } public IOpenable getOwner ( ) { return this . owner ; } public String getText ( int offset , int length ) { synchronized ( this . lock ) { if ( this . contents == null ) return "<STR_LIT>" ; if ( offset + length < this . gapStart ) return new String ( this . contents , offset , length ) ; if ( this . gapStart < offset ) { int gapLength = this . gapEnd - this . gapStart ; return new String ( this . contents , offset + gapLength , length ) ; } StringBuffer buf = new StringBuffer ( ) ; buf . append ( this . contents , offset , this . gapStart - offset ) ; buf . append ( this . contents , this . gapEnd , offset + length - this . gapStart ) ; return buf . toString ( ) ; } } public IResource getUnderlyingResource ( ) { return this . file ; } public boolean hasUnsavedChanges ( ) { return ( this . flags & F_HAS_UNSAVED_CHANGES ) != <NUM_LIT:0> ; } public boolean isClosed ( ) { return ( this . flags & F_IS_CLOSED ) != <NUM_LIT:0> ; } public boolean isReadOnly ( ) { return ( this . flags & F_IS_READ_ONLY ) != <NUM_LIT:0> ; } protected void moveAndResizeGap ( int position , int size ) { char [ ] content = null ; int oldSize = this . gapEnd - this . gapStart ; if ( size < <NUM_LIT:0> ) { if ( oldSize > <NUM_LIT:0> ) { content = new char [ this . contents . length - oldSize ] ; System . arraycopy ( this . contents , <NUM_LIT:0> , content , <NUM_LIT:0> , this . gapStart ) ; System . arraycopy ( this . contents , this . gapEnd , content , this . gapStart , content . length - this . gapStart ) ; this . contents = content ; } this . gapStart = this . gapEnd = position ; return ; } content = new char [ this . contents . length + ( size - oldSize ) ] ; int newGapStart = position ; int newGapEnd = newGapStart + size ; if ( oldSize == <NUM_LIT:0> ) { System . arraycopy ( this . contents , <NUM_LIT:0> , content , <NUM_LIT:0> , newGapStart ) ; System . arraycopy ( this . contents , newGapStart , content , newGapEnd , content . length - newGapEnd ) ; } else if ( newGapStart < this . gapStart ) { int delta = this . gapStart - newGapStart ; System . arraycopy ( this . contents , <NUM_LIT:0> , content , <NUM_LIT:0> , newGapStart ) ; System . arraycopy ( this . contents , newGapStart , content , newGapEnd , delta ) ; System . arraycopy ( this . contents , this . gapEnd , content , newGapEnd + delta , this . contents . length - this . gapEnd ) ; } else { int delta = newGapStart - this . gapStart ; System . arraycopy ( this . contents , <NUM_LIT:0> , content , <NUM_LIT:0> , this . gapStart ) ; System . arraycopy ( this . contents , this . gapEnd , content , this . gapStart , delta ) ; System . arraycopy ( this . contents , this . gapEnd + delta , content , newGapEnd , content . length - newGapEnd ) ; } this . contents = content ; this . gapStart = newGapStart ; this . gapEnd = newGapEnd ; } protected void notifyChanged ( final BufferChangedEvent event ) { ArrayList listeners = this . changeListeners ; if ( listeners != null ) { for ( int i = <NUM_LIT:0> , size = listeners . size ( ) ; i < size ; ++ i ) { final IBufferChangedListener listener = ( IBufferChangedListener ) listeners . get ( i ) ; SafeRunner . run ( new ISafeRunnable ( ) { public void handleException ( Throwable exception ) { Util . log ( exception , "<STR_LIT>" ) ; } public void run ( ) throws Exception { listener . bufferChanged ( event ) ; } } ) ; } } } public synchronized void removeBufferChangedListener ( IBufferChangedListener listener ) { if ( this . changeListeners != null ) { this . changeListeners . remove ( listener ) ; if ( this . changeListeners . size ( ) == <NUM_LIT:0> ) { this . changeListeners = null ; } } } public void replace ( int position , int length , char [ ] text ) { if ( ! isReadOnly ( ) ) { int textLength = text == null ? <NUM_LIT:0> : text . length ; synchronized ( this . lock ) { if ( this . contents == null ) return ; moveAndResizeGap ( position + length , textLength - length ) ; int min = Math . min ( textLength , length ) ; if ( min > <NUM_LIT:0> ) { System . arraycopy ( text , <NUM_LIT:0> , this . contents , position , min ) ; } if ( length > textLength ) { this . gapStart -= length - textLength ; } else if ( textLength > length ) { this . gapStart += textLength - length ; System . arraycopy ( text , <NUM_LIT:0> , this . contents , position , textLength ) ; } this . flags |= F_HAS_UNSAVED_CHANGES ; } String string = null ; if ( textLength > <NUM_LIT:0> ) { string = new String ( text ) ; } notifyChanged ( new BufferChangedEvent ( this , position , length , string ) ) ; } } public void replace ( int position , int length , String text ) { this . replace ( position , length , text == null ? null : text . toCharArray ( ) ) ; } public void save ( IProgressMonitor progress , boolean force ) throws JavaModelException { if ( isReadOnly ( ) || this . file == null ) { return ; } if ( ! hasUnsavedChanges ( ) ) return ; try { String stringContents = getContents ( ) ; if ( stringContents == null ) return ; String encoding = null ; try { encoding = this . file . getCharset ( ) ; } catch ( CoreException ce ) { } byte [ ] bytes = encoding == null ? stringContents . getBytes ( ) : stringContents . getBytes ( encoding ) ; if ( encoding != null && encoding . equals ( org . eclipse . jdt . internal . compiler . util . Util . UTF_8 ) ) { IContentDescription description ; try { description = this . file . getContentDescription ( ) ; } catch ( CoreException e ) { if ( e . getStatus ( ) . getCode ( ) != IResourceStatus . RESOURCE_NOT_FOUND ) throw e ; description = null ; } if ( description != null && description . getProperty ( IContentDescription . BYTE_ORDER_MARK ) != null ) { int bomLength = IContentDescription . BOM_UTF_8 . length ; byte [ ] bytesWithBOM = new byte [ bytes . length + bomLength ] ; System . arraycopy ( IContentDescription . BOM_UTF_8 , <NUM_LIT:0> , bytesWithBOM , <NUM_LIT:0> , bomLength ) ; System . arraycopy ( bytes , <NUM_LIT:0> , bytesWithBOM , bomLength , bytes . length ) ; bytes = bytesWithBOM ; } } ByteArrayInputStream stream = new ByteArrayInputStream ( bytes ) ; if ( this . file . exists ( ) ) { this . file . setContents ( stream , force ? IResource . FORCE | IResource . KEEP_HISTORY : IResource . KEEP_HISTORY , null ) ; } else { this . file . create ( stream , force , null ) ; } } catch ( IOException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . IO_EXCEPTION ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } this . flags &= ~ ( F_HAS_UNSAVED_CHANGES ) ; } public void setContents ( char [ ] newContents ) { if ( this . contents == null ) { synchronized ( this . lock ) { this . contents = newContents ; this . flags &= ~ ( F_HAS_UNSAVED_CHANGES ) ; } return ; } if ( ! isReadOnly ( ) ) { String string = null ; if ( newContents != null ) { string = new String ( newContents ) ; } synchronized ( this . lock ) { if ( this . contents == null ) return ; this . contents = newContents ; this . flags |= F_HAS_UNSAVED_CHANGES ; this . gapStart = - <NUM_LIT:1> ; this . gapEnd = - <NUM_LIT:1> ; } BufferChangedEvent event = new BufferChangedEvent ( this , <NUM_LIT:0> , getLength ( ) , string ) ; notifyChanged ( event ) ; } } public void setContents ( String newContents ) { this . setContents ( newContents . toCharArray ( ) ) ; } protected void setReadOnly ( boolean readOnly ) { if ( readOnly ) { this . flags |= F_IS_READ_ONLY ; } else { this . flags &= ~ ( F_IS_READ_ONLY ) ; } } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( "<STR_LIT>" + ( ( JavaElement ) this . owner ) . toStringWithAncestors ( ) ) ; buffer . append ( "<STR_LIT>" + hasUnsavedChanges ( ) ) ; buffer . append ( "<STR_LIT>" + isReadOnly ( ) ) ; buffer . append ( "<STR_LIT>" + isClosed ( ) ) ; buffer . append ( "<STR_LIT>" ) ; char [ ] charContents = getCharacters ( ) ; if ( charContents == null ) { buffer . append ( "<STR_LIT>" ) ; } else { int length = charContents . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char c = charContents [ i ] ; switch ( c ) { case '<STR_LIT:\n>' : buffer . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : if ( i < length - <NUM_LIT:1> && this . contents [ i + <NUM_LIT:1> ] == '<STR_LIT:\n>' ) { buffer . append ( "<STR_LIT>" ) ; i ++ ; } else { buffer . append ( "<STR_LIT>" ) ; } break ; default : buffer . append ( c ) ; break ; } } } return buffer . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . Iterator ; import java . util . Map ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . IClassFile ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJarEntryResource ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . util . Util ; class JarPackageFragment extends PackageFragment { protected JarPackageFragment ( PackageFragmentRoot root , String [ ] names ) { super ( root , names ) ; } protected boolean buildStructure ( OpenableElementInfo info , IProgressMonitor pm , Map newElements , IResource underlyingResource ) throws JavaModelException { JarPackageFragmentRoot root = ( JarPackageFragmentRoot ) getParent ( ) ; JarPackageFragmentRootInfo parentInfo = ( JarPackageFragmentRootInfo ) root . getElementInfo ( ) ; ArrayList [ ] entries = ( ArrayList [ ] ) parentInfo . rawPackageInfo . get ( this . names ) ; if ( entries == null ) throw newNotPresentException ( ) ; JarPackageFragmentInfo fragInfo = ( JarPackageFragmentInfo ) info ; fragInfo . setChildren ( computeChildren ( entries [ <NUM_LIT:0> ] ) ) ; fragInfo . setNonJavaResources ( computeNonJavaResources ( entries [ <NUM_LIT:1> ] ) ) ; newElements . put ( this , fragInfo ) ; return true ; } private IJavaElement [ ] computeChildren ( ArrayList namesWithoutExtension ) { int size = namesWithoutExtension . size ( ) ; if ( size == <NUM_LIT:0> ) return NO_ELEMENTS ; IJavaElement [ ] children = new IJavaElement [ size ] ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { String nameWithoutExtension = ( String ) namesWithoutExtension . get ( i ) ; children [ i ] = new ClassFile ( this , nameWithoutExtension ) ; } return children ; } private Object [ ] computeNonJavaResources ( ArrayList entryNames ) { int length = entryNames . size ( ) ; if ( length == <NUM_LIT:0> ) return JavaElementInfo . NO_NON_JAVA_RESOURCES ; HashMap jarEntries = new HashMap ( ) ; HashMap childrenMap = new HashMap ( ) ; boolean isInteresting = LanguageSupportFactory . isInterestingProject ( this . getJavaProject ( ) . getProject ( ) ) ; ArrayList topJarEntries = new ArrayList ( ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { String resName = ( String ) entryNames . get ( i ) ; if ( ( ! Util . isJavaLikeFileName ( resName ) || ( isInteresting && LanguageSupportFactory . isInterestingSourceFile ( resName ) ) ) ) { IPath filePath = new Path ( resName ) ; IPath childPath = filePath . removeFirstSegments ( this . names . length ) ; if ( jarEntries . containsKey ( childPath ) ) { continue ; } JarEntryFile file = new JarEntryFile ( filePath . lastSegment ( ) ) ; jarEntries . put ( childPath , file ) ; if ( childPath . segmentCount ( ) == <NUM_LIT:1> ) { file . setParent ( this ) ; topJarEntries . add ( file ) ; } else { IPath parentPath = childPath . removeLastSegments ( <NUM_LIT:1> ) ; while ( parentPath . segmentCount ( ) > <NUM_LIT:0> ) { ArrayList parentChildren = ( ArrayList ) childrenMap . get ( parentPath ) ; if ( parentChildren == null ) { Object dir = new JarEntryDirectory ( parentPath . lastSegment ( ) ) ; jarEntries . put ( parentPath , dir ) ; childrenMap . put ( parentPath , parentChildren = new ArrayList ( ) ) ; parentChildren . add ( childPath ) ; if ( parentPath . segmentCount ( ) == <NUM_LIT:1> ) { topJarEntries . add ( dir ) ; break ; } childPath = parentPath ; parentPath = childPath . removeLastSegments ( <NUM_LIT:1> ) ; } else { parentChildren . add ( childPath ) ; break ; } } } } } Iterator entries = childrenMap . entrySet ( ) . iterator ( ) ; while ( entries . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) entries . next ( ) ; IPath entryPath = ( IPath ) entry . getKey ( ) ; ArrayList entryValue = ( ArrayList ) entry . getValue ( ) ; JarEntryDirectory jarEntryDirectory = ( JarEntryDirectory ) jarEntries . get ( entryPath ) ; int size = entryValue . size ( ) ; IJarEntryResource [ ] children = new IJarEntryResource [ size ] ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { JarEntryResource child = ( JarEntryResource ) jarEntries . get ( entryValue . get ( i ) ) ; child . setParent ( jarEntryDirectory ) ; children [ i ] = child ; } jarEntryDirectory . setChildren ( children ) ; if ( entryPath . segmentCount ( ) == <NUM_LIT:1> ) { jarEntryDirectory . setParent ( this ) ; } } return topJarEntries . toArray ( new Object [ topJarEntries . size ( ) ] ) ; } public boolean containsJavaResources ( ) throws JavaModelException { return ( ( JarPackageFragmentInfo ) getElementInfo ( ) ) . containsJavaResources ( ) ; } public ICompilationUnit createCompilationUnit ( String cuName , String contents , boolean force , IProgressMonitor monitor ) throws JavaModelException { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . READ_ONLY , this ) ) ; } protected Object createElementInfo ( ) { return new JarPackageFragmentInfo ( ) ; } public IClassFile [ ] getClassFiles ( ) throws JavaModelException { ArrayList list = getChildrenOfType ( CLASS_FILE ) ; IClassFile [ ] array = new IClassFile [ list . size ( ) ] ; list . toArray ( array ) ; return array ; } public ICompilationUnit [ ] getCompilationUnits ( ) { return NO_COMPILATION_UNITS ; } public IResource getCorrespondingResource ( ) { return null ; } public Object [ ] getNonJavaResources ( ) throws JavaModelException { if ( isDefaultPackage ( ) ) { return JavaElementInfo . NO_NON_JAVA_RESOURCES ; } else { return storedNonJavaResources ( ) ; } } public boolean isReadOnly ( ) { return true ; } protected Object [ ] storedNonJavaResources ( ) throws JavaModelException { return ( ( JarPackageFragmentInfo ) getElementInfo ( ) ) . getNonJavaResources ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModelStatus ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IRegion ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . ITypeHierarchy ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . internal . core . hierarchy . RegionBasedTypeHierarchy ; import org . eclipse . jdt . internal . core . hierarchy . TypeHierarchy ; public class CreateTypeHierarchyOperation extends JavaModelOperation { protected TypeHierarchy typeHierarchy ; public CreateTypeHierarchyOperation ( IRegion region , ICompilationUnit [ ] workingCopies , IType element , boolean computeSubtypes ) { super ( element ) ; this . typeHierarchy = new RegionBasedTypeHierarchy ( region , workingCopies , element , computeSubtypes ) ; } public CreateTypeHierarchyOperation ( IType element , ICompilationUnit [ ] workingCopies , IJavaSearchScope scope , boolean computeSubtypes ) { super ( element ) ; ICompilationUnit [ ] copies ; if ( workingCopies != null ) { int length = workingCopies . length ; copies = new ICompilationUnit [ length ] ; System . arraycopy ( workingCopies , <NUM_LIT:0> , copies , <NUM_LIT:0> , length ) ; } else { copies = null ; } this . typeHierarchy = new TypeHierarchy ( element , copies , scope , computeSubtypes ) ; } public CreateTypeHierarchyOperation ( IType element , ICompilationUnit [ ] workingCopies , IJavaProject project , boolean computeSubtypes ) { super ( element ) ; ICompilationUnit [ ] copies ; if ( workingCopies != null ) { int length = workingCopies . length ; copies = new ICompilationUnit [ length ] ; System . arraycopy ( workingCopies , <NUM_LIT:0> , copies , <NUM_LIT:0> , length ) ; } else { copies = null ; } this . typeHierarchy = new TypeHierarchy ( element , copies , project , computeSubtypes ) ; } protected void executeOperation ( ) throws JavaModelException { this . typeHierarchy . refresh ( this ) ; } public ITypeHierarchy getResult ( ) { return this . typeHierarchy ; } public boolean isReadOnly ( ) { return true ; } public IJavaModelStatus verify ( ) { IJavaElement elementToProcess = getElementToProcess ( ) ; if ( elementToProcess == null && ! ( this . typeHierarchy instanceof RegionBasedTypeHierarchy ) ) { return new JavaModelStatus ( IJavaModelStatusConstants . NO_ELEMENTS_TO_PROCESS ) ; } if ( elementToProcess != null && ! elementToProcess . exists ( ) ) { return new JavaModelStatus ( IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST , elementToProcess ) ; } IJavaProject project = this . typeHierarchy . javaProject ( ) ; if ( project != null && ! project . exists ( ) ) { return new JavaModelStatus ( IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST , project ) ; } return JavaModelStatus . VERIFIED_OK ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . IBuffer ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . ToolFactory ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . util . ClassFileBytesDisassembler ; import org . eclipse . jdt . core . util . IClassFileReader ; import org . eclipse . jdt . internal . core . util . Disassembler ; import org . eclipse . jdt . internal . core . util . Util ; public class ClassFileWorkingCopy extends CompilationUnit { public ClassFile classFile ; public ClassFileWorkingCopy ( ClassFile classFile , WorkingCopyOwner owner ) { super ( ( PackageFragment ) classFile . getParent ( ) , ( ( BinaryType ) classFile . getType ( ) ) . getSourceFileName ( null ) , owner ) ; this . classFile = classFile ; } public void commitWorkingCopy ( boolean force , IProgressMonitor monitor ) throws JavaModelException { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_ELEMENT_TYPES , this ) ) ; } public IBuffer getBuffer ( ) throws JavaModelException { if ( isWorkingCopy ( ) ) return super . getBuffer ( ) ; else return this . classFile . getBuffer ( ) ; } public char [ ] getContents ( ) { try { IBuffer buffer = getBuffer ( ) ; if ( buffer == null ) return CharOperation . NO_CHAR ; char [ ] characters = buffer . getCharacters ( ) ; if ( characters == null ) return CharOperation . NO_CHAR ; return characters ; } catch ( JavaModelException e ) { return CharOperation . NO_CHAR ; } } public IPath getPath ( ) { return this . classFile . getPath ( ) ; } public IJavaElement getPrimaryElement ( boolean checkOwner ) { if ( checkOwner && isPrimary ( ) ) return this ; return new ClassFileWorkingCopy ( this . classFile , DefaultWorkingCopyOwner . PRIMARY ) ; } public IResource resource ( PackageFragmentRoot root ) { if ( root . isArchive ( ) ) return root . resource ( root ) ; return this . classFile . resource ( root ) ; } protected IBuffer openBuffer ( IProgressMonitor pm , Object info ) throws JavaModelException { IBuffer buffer = this . owner . createBuffer ( this ) ; if ( buffer == null ) return null ; if ( buffer . getCharacters ( ) == null ) { IBuffer classFileBuffer = this . classFile . getBuffer ( ) ; if ( classFileBuffer != null ) { buffer . setContents ( classFileBuffer . getCharacters ( ) ) ; } else { IClassFileReader reader = ToolFactory . createDefaultClassFileReader ( this . classFile , IClassFileReader . ALL ) ; Disassembler disassembler = new Disassembler ( ) ; String contents = disassembler . disassemble ( reader , Util . getLineSeparator ( "<STR_LIT>" , getJavaProject ( ) ) , ClassFileBytesDisassembler . WORKING_COPY ) ; buffer . setContents ( contents ) ; } } BufferManager bufManager = getBufferManager ( ) ; bufManager . addBuffer ( buffer ) ; buffer . addBufferChangedListener ( this ) ; return buffer ; } protected void toStringName ( StringBuffer buffer ) { buffer . append ( this . classFile . getElementName ( ) ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; public class SourceMethodInfo extends SourceMethodElementInfo { protected char [ ] returnType ; public boolean isAnnotationMethod ( ) { return false ; } public boolean isConstructor ( ) { return false ; } public char [ ] getReturnTypeName ( ) { return this . returnType ; } protected void setReturnType ( char [ ] type ) { this . returnType = type ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . * ; import java . net . URI ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Hashtable ; import java . util . Iterator ; import java . util . LinkedHashSet ; import java . util . List ; import java . util . Map ; import javax . xml . parsers . DocumentBuilder ; import javax . xml . parsers . DocumentBuilderFactory ; import javax . xml . parsers . ParserConfigurationException ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . resources . ICommand ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IFolder ; import org . eclipse . core . resources . IMarker ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . resources . IProjectDescription ; import org . eclipse . core . resources . IProjectNature ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IWorkspace ; import org . eclipse . core . resources . IWorkspaceRoot ; import org . eclipse . core . resources . ProjectScope ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . Path ; import org . eclipse . core . runtime . Platform ; import org . eclipse . core . runtime . QualifiedName ; import org . eclipse . core . runtime . content . IContentDescription ; import org . eclipse . core . runtime . preferences . IEclipsePreferences ; import org . eclipse . core . runtime . preferences . IScopeContext ; import org . eclipse . jdt . core . IClasspathAttribute ; import org . eclipse . jdt . core . IClasspathContainer ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModelMarker ; import org . eclipse . jdt . core . IJavaModelStatus ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . core . IRegion ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . ITypeHierarchy ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . eval . IEvaluationContext ; import org . eclipse . jdt . internal . compiler . util . ObjectVector ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . JavaModelManager . PerProjectInfo ; import org . eclipse . jdt . internal . core . JavaProjectElementInfo . ProjectCache ; import org . eclipse . jdt . internal . core . builder . JavaBuilder ; import org . eclipse . jdt . internal . core . eval . EvaluationContextWrapper ; import org . eclipse . jdt . internal . core . util . JavaElementFinder ; import org . eclipse . jdt . internal . core . util . MementoTokenizer ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; import org . eclipse . jdt . internal . eval . EvaluationContext ; import org . osgi . service . prefs . BackingStoreException ; import org . w3c . dom . Element ; import org . w3c . dom . Node ; import org . w3c . dom . NodeList ; import org . xml . sax . InputSource ; import org . xml . sax . SAXException ; public class JavaProject extends Openable implements IJavaProject , IProjectNature , SuffixConstants { public static final String CLASSPATH_FILENAME = IJavaProject . CLASSPATH_FILE_NAME ; public static final IClasspathEntry [ ] INVALID_CLASSPATH = new IClasspathEntry [ <NUM_LIT:0> ] ; protected static final boolean IS_CASE_SENSITIVE = ! new File ( "<STR_LIT>" ) . equals ( new File ( "<STR_LIT>" ) ) ; protected static final String [ ] NO_PREREQUISITES = CharOperation . NO_STRINGS ; private static final String PREF_FILENAME = "<STR_LIT>" ; public static final String DEFAULT_PREFERENCES_DIRNAME = "<STR_LIT>" ; public static final String JAVA_CORE_PREFS_FILE = JavaCore . PLUGIN_ID + "<STR_LIT>" ; private static final IClasspathEntry [ ] RESOLUTION_IN_PROGRESS = new IClasspathEntry [ <NUM_LIT:0> ] ; private static ArrayList CP_RESOLUTION_BP_LISTENERS ; public static class ClasspathResolutionBreakpointListener { public void breakpoint ( int bp ) { } } protected IProject project ; private IEclipsePreferences . INodeChangeListener preferencesNodeListener ; private IEclipsePreferences . IPreferenceChangeListener preferencesChangeListener ; public JavaProject ( ) { super ( null ) ; } public JavaProject ( IProject project , JavaElement parent ) { super ( parent ) ; this . project = project ; } public static synchronized void addCPResolutionBPListener ( ClasspathResolutionBreakpointListener listener ) { if ( CP_RESOLUTION_BP_LISTENERS == null ) CP_RESOLUTION_BP_LISTENERS = new ArrayList ( ) ; CP_RESOLUTION_BP_LISTENERS . add ( listener ) ; } public static synchronized void removeCPResolutionBPListener ( ClasspathResolutionBreakpointListener listener ) { if ( CP_RESOLUTION_BP_LISTENERS == null ) return ; CP_RESOLUTION_BP_LISTENERS . remove ( listener ) ; if ( CP_RESOLUTION_BP_LISTENERS . size ( ) == <NUM_LIT:0> ) CP_RESOLUTION_BP_LISTENERS = null ; } private static synchronized ClasspathResolutionBreakpointListener [ ] getBPListeners ( ) { if ( CP_RESOLUTION_BP_LISTENERS == null ) return null ; return ( ClasspathResolutionBreakpointListener [ ] ) CP_RESOLUTION_BP_LISTENERS . toArray ( new ClasspathResolutionBreakpointListener [ CP_RESOLUTION_BP_LISTENERS . size ( ) ] ) ; } private static void breakpoint ( int bp , JavaProject project ) { ClasspathResolutionBreakpointListener [ ] listeners = getBPListeners ( ) ; if ( listeners == null ) return ; for ( int j = <NUM_LIT:0> , length = listeners . length ; j < length ; j ++ ) { listeners [ j ] . breakpoint ( bp ) ; } } public static boolean areClasspathsEqual ( IClasspathEntry [ ] firstClasspath , IClasspathEntry [ ] secondClasspath , IPath firstOutputLocation , IPath secondOutputLocation ) { int length = firstClasspath . length ; if ( length != secondClasspath . length ) return false ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( ! firstClasspath [ i ] . equals ( secondClasspath [ i ] ) ) return false ; } if ( firstOutputLocation == null ) return secondOutputLocation == null ; return firstOutputLocation . equals ( secondOutputLocation ) ; } private static boolean areClasspathsEqual ( IClasspathEntry [ ] newClasspath , IPath newOutputLocation , IClasspathEntry [ ] otherClasspathWithOutput ) { if ( otherClasspathWithOutput == null || otherClasspathWithOutput . length == <NUM_LIT:0> ) return false ; int length = otherClasspathWithOutput . length ; if ( length != newClasspath . length + <NUM_LIT:1> ) return false ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) { if ( ! otherClasspathWithOutput [ i ] . equals ( newClasspath [ i ] ) ) return false ; } IClasspathEntry output = otherClasspathWithOutput [ length - <NUM_LIT:1> ] ; if ( output . getContentKind ( ) != ClasspathEntry . K_OUTPUT || ! output . getPath ( ) . equals ( newOutputLocation ) ) return false ; return true ; } private static boolean areClasspathsEqual ( IClasspathEntry [ ] first , IClasspathEntry [ ] second ) { if ( first != second ) { if ( first == null ) return false ; int length = first . length ; if ( second == null || second . length != length ) return false ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( ! first [ i ] . equals ( second [ i ] ) ) return false ; } } return true ; } public static IPath canonicalizedPath ( IPath externalPath ) { if ( externalPath == null ) return null ; if ( IS_CASE_SENSITIVE ) { return externalPath ; } IWorkspace workspace = ResourcesPlugin . getWorkspace ( ) ; if ( workspace == null ) return externalPath ; if ( workspace . getRoot ( ) . findMember ( externalPath ) != null ) { return externalPath ; } IPath canonicalPath = null ; try { canonicalPath = new Path ( new File ( externalPath . toOSString ( ) ) . getCanonicalPath ( ) ) ; } catch ( IOException e ) { return externalPath ; } IPath result ; int canonicalLength = canonicalPath . segmentCount ( ) ; if ( canonicalLength == <NUM_LIT:0> ) { return externalPath ; } else if ( externalPath . isAbsolute ( ) ) { result = canonicalPath ; } else { int externalLength = externalPath . segmentCount ( ) ; if ( canonicalLength >= externalLength ) { result = canonicalPath . removeFirstSegments ( canonicalLength - externalLength ) ; } else { return externalPath ; } } if ( externalPath . getDevice ( ) == null ) { result = result . setDevice ( null ) ; } if ( externalPath . hasTrailingSeparator ( ) ) { result = result . addTrailingSeparator ( ) ; } return result ; } public static boolean hasJavaNature ( IProject project ) { try { return project . hasNature ( JavaCore . NATURE_ID ) ; } catch ( CoreException e ) { if ( ExternalJavaProject . EXTERNAL_PROJECT_NAME . equals ( project . getName ( ) ) ) return true ; } return false ; } public static void validateCycles ( Map preferredClasspaths ) throws JavaModelException { IWorkspaceRoot workspaceRoot = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ; IProject [ ] rscProjects = workspaceRoot . getProjects ( ) ; int length = rscProjects . length ; JavaProject [ ] projects = new JavaProject [ length ] ; LinkedHashSet cycleParticipants = new LinkedHashSet ( ) ; HashSet traversed = new HashSet ( ) ; ArrayList prereqChain = new ArrayList ( ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( hasJavaNature ( rscProjects [ i ] ) ) { JavaProject project = ( projects [ i ] = ( JavaProject ) JavaCore . create ( rscProjects [ i ] ) ) ; if ( ! traversed . contains ( project . getPath ( ) ) ) { prereqChain . clear ( ) ; project . updateCycleParticipants ( prereqChain , cycleParticipants , workspaceRoot , traversed , preferredClasspaths ) ; } } } for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { JavaProject project = projects [ i ] ; if ( project != null ) { if ( cycleParticipants . contains ( project . getPath ( ) ) ) { IMarker cycleMarker = project . getCycleMarker ( ) ; String circularCPOption = project . getOption ( JavaCore . CORE_CIRCULAR_CLASSPATH , true ) ; int circularCPSeverity = JavaCore . ERROR . equals ( circularCPOption ) ? IMarker . SEVERITY_ERROR : IMarker . SEVERITY_WARNING ; if ( cycleMarker != null ) { try { int existingSeverity = ( ( Integer ) cycleMarker . getAttribute ( IMarker . SEVERITY ) ) . intValue ( ) ; if ( existingSeverity != circularCPSeverity ) { cycleMarker . setAttribute ( IMarker . SEVERITY , circularCPSeverity ) ; } } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } else { IJavaProject [ ] projectsInCycle ; String cycleString = "<STR_LIT>" ; if ( cycleParticipants . isEmpty ( ) ) { projectsInCycle = null ; } else { projectsInCycle = new IJavaProject [ cycleParticipants . size ( ) ] ; Iterator it = cycleParticipants . iterator ( ) ; int k = <NUM_LIT:0> ; while ( it . hasNext ( ) ) { IResource member = workspaceRoot . findMember ( ( IPath ) it . next ( ) ) ; if ( member != null && member . getType ( ) == IResource . PROJECT ) { projectsInCycle [ k ] = JavaCore . create ( ( IProject ) member ) ; if ( projectsInCycle [ k ] != null ) { if ( k != <NUM_LIT:0> ) cycleString += "<STR_LIT:U+002CU+0020>" ; cycleString += projectsInCycle [ k ++ ] . getElementName ( ) ; } } } } project . createClasspathProblemMarker ( new JavaModelStatus ( IJavaModelStatusConstants . CLASSPATH_CYCLE , project , cycleString ) ) ; } } else { project . flushClasspathProblemMarkers ( true , false , false ) ; } } } } protected void addToBuildSpec ( String builderID ) throws CoreException { IProjectDescription description = this . project . getDescription ( ) ; int javaCommandIndex = getJavaCommandIndex ( description . getBuildSpec ( ) ) ; if ( javaCommandIndex == - <NUM_LIT:1> ) { ICommand command = description . newCommand ( ) ; command . setBuilderName ( builderID ) ; setJavaCommand ( description , command ) ; } } protected boolean buildStructure ( OpenableElementInfo info , IProgressMonitor pm , Map newElements , IResource underlyingResource ) throws JavaModelException { IClasspathEntry [ ] resolvedClasspath = getResolvedClasspath ( ) ; info . setChildren ( computePackageFragmentRoots ( resolvedClasspath , false , null ) ) ; return true ; } public void close ( ) throws JavaModelException { if ( JavaProject . hasJavaNature ( this . project ) ) { JavaModelManager . PerProjectInfo perProjectInfo = JavaModelManager . getJavaModelManager ( ) . getPerProjectInfo ( this . project , false ) ; if ( perProjectInfo != null && perProjectInfo . preferences != null ) { IEclipsePreferences eclipseParentPreferences = ( IEclipsePreferences ) perProjectInfo . preferences . parent ( ) ; if ( this . preferencesNodeListener != null ) { eclipseParentPreferences . removeNodeChangeListener ( this . preferencesNodeListener ) ; this . preferencesNodeListener = null ; } if ( this . preferencesChangeListener != null ) { perProjectInfo . preferences . removePreferenceChangeListener ( this . preferencesChangeListener ) ; this . preferencesChangeListener = null ; } } } LanguageSupportFactory . getEventHandler ( ) . handle ( this , "<STR_LIT>" ) ; super . close ( ) ; } private void computeExpandedClasspath ( ClasspathEntry referringEntry , HashSet rootIDs , ObjectVector accumulatedEntries ) throws JavaModelException { String projectRootId = rootID ( ) ; if ( rootIDs . contains ( projectRootId ) ) { return ; } rootIDs . add ( projectRootId ) ; IClasspathEntry [ ] resolvedClasspath = getResolvedClasspath ( ) ; IWorkspaceRoot workspaceRoot = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ; boolean isInitialProject = referringEntry == null ; for ( int i = <NUM_LIT:0> , length = resolvedClasspath . length ; i < length ; i ++ ) { ClasspathEntry entry = ( ClasspathEntry ) resolvedClasspath [ i ] ; if ( isInitialProject || entry . isExported ( ) ) { String rootID = entry . rootID ( ) ; if ( rootIDs . contains ( rootID ) ) { continue ; } ClasspathEntry combinedEntry = entry . combineWith ( referringEntry ) ; accumulatedEntries . add ( combinedEntry ) ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_PROJECT ) { IResource member = workspaceRoot . findMember ( entry . getPath ( ) ) ; if ( member != null && member . getType ( ) == IResource . PROJECT ) { IProject projRsc = ( IProject ) member ; if ( JavaProject . hasJavaNature ( projRsc ) ) { JavaProject javaProject = ( JavaProject ) JavaCore . create ( projRsc ) ; javaProject . computeExpandedClasspath ( combinedEntry , rootIDs , accumulatedEntries ) ; } } } else { rootIDs . add ( rootID ) ; } } } } public IPackageFragmentRoot [ ] computePackageFragmentRoots ( IClasspathEntry resolvedEntry ) { try { return computePackageFragmentRoots ( new IClasspathEntry [ ] { resolvedEntry } , false , null ) ; } catch ( JavaModelException e ) { return new IPackageFragmentRoot [ ] { } ; } } public void computePackageFragmentRoots ( IClasspathEntry resolvedEntry , ObjectVector accumulatedRoots , HashSet rootIDs , IClasspathEntry referringEntry , boolean retrieveExportedRoots , Map rootToResolvedEntries ) throws JavaModelException { String rootID = ( ( ClasspathEntry ) resolvedEntry ) . rootID ( ) ; if ( rootIDs . contains ( rootID ) ) return ; IPath projectPath = this . project . getFullPath ( ) ; IPath entryPath = resolvedEntry . getPath ( ) ; IWorkspaceRoot workspaceRoot = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ; IPackageFragmentRoot root = null ; switch ( resolvedEntry . getEntryKind ( ) ) { case IClasspathEntry . CPE_SOURCE : if ( projectPath . isPrefixOf ( entryPath ) ) { Object target = JavaModel . getTarget ( entryPath , true ) ; if ( target == null ) return ; if ( target instanceof IFolder || target instanceof IProject ) { root = getPackageFragmentRoot ( ( IResource ) target ) ; } } break ; case IClasspathEntry . CPE_LIBRARY : if ( referringEntry != null && ! resolvedEntry . isExported ( ) ) return ; Object target = JavaModel . getTarget ( entryPath , true ) ; if ( target == null ) return ; if ( target instanceof IResource ) { root = getPackageFragmentRoot ( ( IResource ) target , entryPath ) ; } else if ( target instanceof File ) { if ( JavaModel . isFile ( target ) ) { root = new JarPackageFragmentRoot ( entryPath , this ) ; } else if ( ( ( File ) target ) . isDirectory ( ) ) { root = new ExternalPackageFragmentRoot ( entryPath , this ) ; } } break ; case IClasspathEntry . CPE_PROJECT : if ( ! retrieveExportedRoots ) return ; if ( referringEntry != null && ! resolvedEntry . isExported ( ) ) return ; IResource member = workspaceRoot . findMember ( entryPath ) ; if ( member != null && member . getType ( ) == IResource . PROJECT ) { IProject requiredProjectRsc = ( IProject ) member ; if ( JavaProject . hasJavaNature ( requiredProjectRsc ) ) { rootIDs . add ( rootID ) ; JavaProject requiredProject = ( JavaProject ) JavaCore . create ( requiredProjectRsc ) ; requiredProject . computePackageFragmentRoots ( requiredProject . getResolvedClasspath ( ) , accumulatedRoots , rootIDs , rootToResolvedEntries == null ? resolvedEntry : ( ( ClasspathEntry ) resolvedEntry ) . combineWith ( ( ClasspathEntry ) referringEntry ) , retrieveExportedRoots , rootToResolvedEntries ) ; } break ; } } if ( root != null ) { accumulatedRoots . add ( root ) ; rootIDs . add ( rootID ) ; if ( rootToResolvedEntries != null ) rootToResolvedEntries . put ( root , ( ( ClasspathEntry ) resolvedEntry ) . combineWith ( ( ClasspathEntry ) referringEntry ) ) ; } } public IPackageFragmentRoot [ ] computePackageFragmentRoots ( IClasspathEntry [ ] resolvedClasspath , boolean retrieveExportedRoots , Map rootToResolvedEntries ) throws JavaModelException { ObjectVector accumulatedRoots = new ObjectVector ( ) ; computePackageFragmentRoots ( resolvedClasspath , accumulatedRoots , new HashSet ( <NUM_LIT:5> ) , null , retrieveExportedRoots , rootToResolvedEntries ) ; IPackageFragmentRoot [ ] rootArray = new IPackageFragmentRoot [ accumulatedRoots . size ( ) ] ; accumulatedRoots . copyInto ( rootArray ) ; return rootArray ; } public void computePackageFragmentRoots ( IClasspathEntry [ ] resolvedClasspath , ObjectVector accumulatedRoots , HashSet rootIDs , IClasspathEntry referringEntry , boolean retrieveExportedRoots , Map rootToResolvedEntries ) throws JavaModelException { if ( referringEntry == null ) { rootIDs . add ( rootID ( ) ) ; } for ( int i = <NUM_LIT:0> , length = resolvedClasspath . length ; i < length ; i ++ ) { computePackageFragmentRoots ( resolvedClasspath [ i ] , accumulatedRoots , rootIDs , referringEntry , retrieveExportedRoots , rootToResolvedEntries ) ; } } public String computeSharedPropertyFileName ( QualifiedName qName ) { return '<CHAR_LIT:.>' + qName . getLocalName ( ) ; } public void configure ( ) throws CoreException { addToBuildSpec ( JavaCore . BUILDER_ID ) ; } public boolean contains ( IResource resource ) { IClasspathEntry [ ] classpath ; IPath output ; try { classpath = getResolvedClasspath ( ) ; output = getOutputLocation ( ) ; } catch ( JavaModelException e ) { return false ; } IPath fullPath = resource . getFullPath ( ) ; IPath innerMostOutput = output . isPrefixOf ( fullPath ) ? output : null ; IClasspathEntry innerMostEntry = null ; ExternalFoldersManager foldersManager = JavaModelManager . getExternalManager ( ) ; for ( int j = <NUM_LIT:0> , cpLength = classpath . length ; j < cpLength ; j ++ ) { IClasspathEntry entry = classpath [ j ] ; IPath entryPath = entry . getPath ( ) ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_LIBRARY ) { IResource linkedFolder = foldersManager . getFolder ( entryPath ) ; if ( linkedFolder != null ) entryPath = linkedFolder . getFullPath ( ) ; } if ( ( innerMostEntry == null || innerMostEntry . getPath ( ) . isPrefixOf ( entryPath ) ) && entryPath . isPrefixOf ( fullPath ) ) { innerMostEntry = entry ; } IPath entryOutput = classpath [ j ] . getOutputLocation ( ) ; if ( entryOutput != null && entryOutput . isPrefixOf ( fullPath ) ) { innerMostOutput = entryOutput ; } } if ( innerMostEntry != null ) { if ( innerMostOutput != null && innerMostOutput . segmentCount ( ) > <NUM_LIT:1> && innerMostEntry . getPath ( ) . segmentCount ( ) == <NUM_LIT:1> ) { return false ; } if ( resource instanceof IFolder ) { return true ; } switch ( innerMostEntry . getEntryKind ( ) ) { case IClasspathEntry . CPE_SOURCE : return ! org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( fullPath . lastSegment ( ) ) ; case IClasspathEntry . CPE_LIBRARY : return ! org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( fullPath . lastSegment ( ) ) ; } } if ( innerMostOutput != null ) { return false ; } return true ; } public void createClasspathProblemMarker ( IJavaModelStatus status ) { IMarker marker = null ; int severity ; String [ ] arguments = CharOperation . NO_STRINGS ; boolean isCycleProblem = false , isClasspathFileFormatProblem = false , isOutputOverlapping = false ; switch ( status . getCode ( ) ) { case IJavaModelStatusConstants . CLASSPATH_CYCLE : isCycleProblem = true ; if ( JavaCore . ERROR . equals ( getOption ( JavaCore . CORE_CIRCULAR_CLASSPATH , true ) ) ) { severity = IMarker . SEVERITY_ERROR ; } else { severity = IMarker . SEVERITY_WARNING ; } break ; case IJavaModelStatusConstants . INVALID_CLASSPATH_FILE_FORMAT : isClasspathFileFormatProblem = true ; severity = IMarker . SEVERITY_ERROR ; break ; case IJavaModelStatusConstants . INCOMPATIBLE_JDK_LEVEL : String setting = getOption ( JavaCore . CORE_INCOMPATIBLE_JDK_LEVEL , true ) ; if ( JavaCore . ERROR . equals ( setting ) ) { severity = IMarker . SEVERITY_ERROR ; } else if ( JavaCore . WARNING . equals ( setting ) ) { severity = IMarker . SEVERITY_WARNING ; } else { return ; } break ; case IJavaModelStatusConstants . OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE : isOutputOverlapping = true ; setting = getOption ( JavaCore . CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE , true ) ; if ( JavaCore . ERROR . equals ( setting ) ) { severity = IMarker . SEVERITY_ERROR ; } else if ( JavaCore . WARNING . equals ( setting ) ) { severity = IMarker . SEVERITY_WARNING ; } else { return ; } break ; default : IPath path = status . getPath ( ) ; if ( path != null ) arguments = new String [ ] { path . toString ( ) } ; if ( JavaCore . ERROR . equals ( getOption ( JavaCore . CORE_INCOMPLETE_CLASSPATH , true ) ) && status . getSeverity ( ) != IStatus . WARNING ) { severity = IMarker . SEVERITY_ERROR ; } else { severity = IMarker . SEVERITY_WARNING ; } break ; } try { marker = this . project . createMarker ( IJavaModelMarker . BUILDPATH_PROBLEM_MARKER ) ; marker . setAttributes ( new String [ ] { IMarker . MESSAGE , IMarker . SEVERITY , IMarker . LOCATION , IJavaModelMarker . CYCLE_DETECTED , IJavaModelMarker . CLASSPATH_FILE_FORMAT , IJavaModelMarker . OUTPUT_OVERLAPPING_SOURCE , IJavaModelMarker . ID , IJavaModelMarker . ARGUMENTS , IJavaModelMarker . CATEGORY_ID , IMarker . SOURCE_ID , } , new Object [ ] { status . getMessage ( ) , new Integer ( severity ) , Messages . classpath_buildPath , isCycleProblem ? "<STR_LIT:true>" : "<STR_LIT:false>" , isClasspathFileFormatProblem ? "<STR_LIT:true>" : "<STR_LIT:false>" , isOutputOverlapping ? "<STR_LIT:true>" : "<STR_LIT:false>" , new Integer ( status . getCode ( ) ) , Util . getProblemArgumentsForMarker ( arguments ) , new Integer ( CategorizedProblem . CAT_BUILDPATH ) , JavaBuilder . SOURCE_ID , } ) ; } catch ( CoreException e ) { if ( JavaModelManager . VERBOSE ) { e . printStackTrace ( ) ; } } } protected Object createElementInfo ( ) { return new JavaProjectElementInfo ( ) ; } public IClasspathEntry [ ] [ ] decodeClasspath ( String xmlClasspath , Map unknownElements ) throws IOException , ClasspathEntry . AssertionFailedException { ArrayList paths = new ArrayList ( ) ; IClasspathEntry defaultOutput = null ; StringReader reader = new StringReader ( xmlClasspath ) ; Element cpElement ; try { DocumentBuilder parser = DocumentBuilderFactory . newInstance ( ) . newDocumentBuilder ( ) ; cpElement = parser . parse ( new InputSource ( reader ) ) . getDocumentElement ( ) ; } catch ( SAXException e ) { throw new IOException ( Messages . file_badFormat ) ; } catch ( ParserConfigurationException e ) { throw new IOException ( Messages . file_badFormat ) ; } finally { reader . close ( ) ; } if ( ! cpElement . getNodeName ( ) . equalsIgnoreCase ( "<STR_LIT>" ) ) { throw new IOException ( Messages . file_badFormat ) ; } NodeList list = cpElement . getElementsByTagName ( ClasspathEntry . TAG_CLASSPATHENTRY ) ; int length = list . getLength ( ) ; for ( int i = <NUM_LIT:0> ; i < length ; ++ i ) { Node node = list . item ( i ) ; if ( node . getNodeType ( ) == Node . ELEMENT_NODE ) { IClasspathEntry entry = ClasspathEntry . elementDecode ( ( Element ) node , this , unknownElements ) ; if ( entry != null ) { if ( entry . getContentKind ( ) == ClasspathEntry . K_OUTPUT ) { defaultOutput = entry ; } else { paths . add ( entry ) ; } } } } int pathSize = paths . size ( ) ; IClasspathEntry [ ] [ ] entries = new IClasspathEntry [ <NUM_LIT:2> ] [ ] ; entries [ <NUM_LIT:0> ] = new IClasspathEntry [ pathSize + ( defaultOutput == null ? <NUM_LIT:0> : <NUM_LIT:1> ) ] ; paths . toArray ( entries [ <NUM_LIT:0> ] ) ; if ( defaultOutput != null ) entries [ <NUM_LIT:0> ] [ pathSize ] = defaultOutput ; paths . clear ( ) ; list = cpElement . getElementsByTagName ( ClasspathEntry . TAG_REFERENCED_ENTRY ) ; length = list . getLength ( ) ; for ( int i = <NUM_LIT:0> ; i < length ; ++ i ) { Node node = list . item ( i ) ; if ( node . getNodeType ( ) == Node . ELEMENT_NODE ) { IClasspathEntry entry = ClasspathEntry . elementDecode ( ( Element ) node , this , unknownElements ) ; if ( entry != null ) { paths . add ( entry ) ; } } } entries [ <NUM_LIT:1> ] = new IClasspathEntry [ paths . size ( ) ] ; paths . toArray ( entries [ <NUM_LIT:1> ] ) ; return entries ; } public IClasspathEntry decodeClasspathEntry ( String encodedEntry ) { try { if ( encodedEntry == null ) return null ; StringReader reader = new StringReader ( encodedEntry ) ; Element node ; try { DocumentBuilder parser = DocumentBuilderFactory . newInstance ( ) . newDocumentBuilder ( ) ; node = parser . parse ( new InputSource ( reader ) ) . getDocumentElement ( ) ; } catch ( SAXException e ) { return null ; } catch ( ParserConfigurationException e ) { return null ; } finally { reader . close ( ) ; } if ( ! node . getNodeName ( ) . equalsIgnoreCase ( ClasspathEntry . TAG_CLASSPATHENTRY ) || node . getNodeType ( ) != Node . ELEMENT_NODE ) { return null ; } return ClasspathEntry . elementDecode ( node , this , null ) ; } catch ( IOException e ) { return null ; } } public void deconfigure ( ) throws CoreException { removeFromBuildSpec ( JavaCore . BUILDER_ID ) ; } protected IClasspathEntry [ ] defaultClasspath ( ) { return new IClasspathEntry [ ] { JavaCore . newSourceEntry ( this . project . getFullPath ( ) ) } ; } protected IPath defaultOutputLocation ( ) { return this . project . getFullPath ( ) . append ( "<STR_LIT>" ) ; } protected String encodeClasspath ( IClasspathEntry [ ] classpath , IClasspathEntry [ ] referencedEntries , IPath outputLocation , boolean indent , Map unknownElements ) throws JavaModelException { try { ByteArrayOutputStream s = new ByteArrayOutputStream ( ) ; OutputStreamWriter writer = new OutputStreamWriter ( s , "<STR_LIT>" ) ; XMLWriter xmlWriter = new XMLWriter ( writer , this , true ) ; xmlWriter . startTag ( ClasspathEntry . TAG_CLASSPATH , indent ) ; for ( int i = <NUM_LIT:0> ; i < classpath . length ; ++ i ) { ( ( ClasspathEntry ) classpath [ i ] ) . elementEncode ( xmlWriter , this . project . getFullPath ( ) , indent , true , unknownElements , false ) ; } if ( outputLocation != null ) { outputLocation = outputLocation . removeFirstSegments ( <NUM_LIT:1> ) ; outputLocation = outputLocation . makeRelative ( ) ; HashMap parameters = new HashMap ( ) ; parameters . put ( ClasspathEntry . TAG_KIND , ClasspathEntry . kindToString ( ClasspathEntry . K_OUTPUT ) ) ; parameters . put ( ClasspathEntry . TAG_PATH , String . valueOf ( outputLocation ) ) ; xmlWriter . printTag ( ClasspathEntry . TAG_CLASSPATHENTRY , parameters , indent , true , true ) ; } if ( referencedEntries != null ) { for ( int i = <NUM_LIT:0> ; i < referencedEntries . length ; ++ i ) { ( ( ClasspathEntry ) referencedEntries [ i ] ) . elementEncode ( xmlWriter , this . project . getFullPath ( ) , indent , true , unknownElements , true ) ; } } xmlWriter . endTag ( ClasspathEntry . TAG_CLASSPATH , indent , true ) ; writer . flush ( ) ; writer . close ( ) ; return s . toString ( "<STR_LIT>" ) ; } catch ( IOException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . IO_EXCEPTION ) ; } } public String encodeClasspathEntry ( IClasspathEntry classpathEntry ) { try { ByteArrayOutputStream s = new ByteArrayOutputStream ( ) ; OutputStreamWriter writer = new OutputStreamWriter ( s , "<STR_LIT>" ) ; XMLWriter xmlWriter = new XMLWriter ( writer , this , false ) ; ( ( ClasspathEntry ) classpathEntry ) . elementEncode ( xmlWriter , this . project . getFullPath ( ) , true , true , null , ( classpathEntry . getReferencingEntry ( ) != null ) ) ; writer . flush ( ) ; writer . close ( ) ; return s . toString ( "<STR_LIT>" ) ; } catch ( IOException e ) { return null ; } } public boolean equals ( Object o ) { if ( this == o ) return true ; if ( ! ( o instanceof JavaProject ) ) return false ; JavaProject other = ( JavaProject ) o ; return this . project . equals ( other . getProject ( ) ) ; } public IJavaElement findElement ( IPath path ) throws JavaModelException { return findElement ( path , DefaultWorkingCopyOwner . PRIMARY ) ; } public IJavaElement findElement ( IPath path , WorkingCopyOwner owner ) throws JavaModelException { if ( path == null || path . isAbsolute ( ) ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_PATH , path ) ) ; } try { String extension = path . getFileExtension ( ) ; if ( extension == null ) { String packageName = path . toString ( ) . replace ( IPath . SEPARATOR , '<CHAR_LIT:.>' ) ; return findPackageFragment ( packageName ) ; } else if ( Util . isJavaLikeFileName ( path . lastSegment ( ) ) || extension . equalsIgnoreCase ( EXTENSION_class ) ) { IPath packagePath = path . removeLastSegments ( <NUM_LIT:1> ) ; String packageName = packagePath . toString ( ) . replace ( IPath . SEPARATOR , '<CHAR_LIT:.>' ) ; String typeName = path . lastSegment ( ) ; typeName = typeName . substring ( <NUM_LIT:0> , typeName . length ( ) - extension . length ( ) - <NUM_LIT:1> ) ; String qualifiedName = null ; if ( packageName . length ( ) > <NUM_LIT:0> ) { qualifiedName = packageName + "<STR_LIT:.>" + typeName ; } else { qualifiedName = typeName ; } NameLookup lookup = newNameLookup ( owner ) ; NameLookup . Answer answer = lookup . findType ( qualifiedName , false , NameLookup . ACCEPT_ALL , true , false , false , null ) ; if ( answer != null ) { return answer . type . getParent ( ) ; } else { return null ; } } else { return null ; } } catch ( JavaModelException e ) { if ( e . getStatus ( ) . getCode ( ) == IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST ) { return null ; } else { throw e ; } } } public IJavaElement findPackageFragment ( String packageName ) throws JavaModelException { NameLookup lookup = newNameLookup ( ( WorkingCopyOwner ) null ) ; IPackageFragment [ ] pkgFragments = lookup . findPackageFragments ( packageName , false ) ; if ( pkgFragments == null ) { return null ; } else { for ( int i = <NUM_LIT:0> , length = pkgFragments . length ; i < length ; i ++ ) { IPackageFragment pkgFragment = pkgFragments [ i ] ; if ( equals ( pkgFragment . getParent ( ) . getParent ( ) ) ) { return pkgFragment ; } } return pkgFragments [ <NUM_LIT:0> ] ; } } public IJavaElement findElement ( String bindingKey , WorkingCopyOwner owner ) throws JavaModelException { JavaElementFinder elementFinder = new JavaElementFinder ( bindingKey , this , owner ) ; elementFinder . parse ( ) ; if ( elementFinder . exception != null ) throw elementFinder . exception ; return elementFinder . element ; } public IPackageFragment findPackageFragment ( IPath path ) throws JavaModelException { return findPackageFragment0 ( JavaProject . canonicalizedPath ( path ) ) ; } private IPackageFragment findPackageFragment0 ( IPath path ) throws JavaModelException { NameLookup lookup = newNameLookup ( ( WorkingCopyOwner ) null ) ; return lookup . findPackageFragment ( path ) ; } public IPackageFragmentRoot findPackageFragmentRoot ( IPath path ) throws JavaModelException { return findPackageFragmentRoot0 ( JavaProject . canonicalizedPath ( path ) ) ; } public IPackageFragmentRoot findPackageFragmentRoot0 ( IPath path ) throws JavaModelException { IPackageFragmentRoot [ ] allRoots = this . getAllPackageFragmentRoots ( ) ; if ( ! path . isAbsolute ( ) ) { throw new IllegalArgumentException ( Messages . path_mustBeAbsolute ) ; } for ( int i = <NUM_LIT:0> ; i < allRoots . length ; i ++ ) { IPackageFragmentRoot classpathRoot = allRoots [ i ] ; if ( classpathRoot . getPath ( ) . equals ( path ) ) { return classpathRoot ; } } return null ; } public IPackageFragmentRoot [ ] findPackageFragmentRoots ( IClasspathEntry entry ) { try { IClasspathEntry [ ] classpath = getRawClasspath ( ) ; for ( int i = <NUM_LIT:0> , length = classpath . length ; i < length ; i ++ ) { if ( classpath [ i ] . equals ( entry ) ) { return computePackageFragmentRoots ( resolveClasspath ( new IClasspathEntry [ ] { entry } ) , false , null ) ; } } } catch ( JavaModelException e ) { } return new IPackageFragmentRoot [ ] { } ; } public IType findType ( String fullyQualifiedName ) throws JavaModelException { return findType ( fullyQualifiedName , DefaultWorkingCopyOwner . PRIMARY ) ; } public IType findType ( String fullyQualifiedName , IProgressMonitor progressMonitor ) throws JavaModelException { return findType ( fullyQualifiedName , DefaultWorkingCopyOwner . PRIMARY , progressMonitor ) ; } IType findType ( String fullyQualifiedName , NameLookup lookup , boolean considerSecondaryTypes , IProgressMonitor progressMonitor ) throws JavaModelException { NameLookup . Answer answer = lookup . findType ( fullyQualifiedName , false , NameLookup . ACCEPT_ALL , considerSecondaryTypes , true , false , progressMonitor ) ; if ( answer == null ) { int lastDot = fullyQualifiedName . lastIndexOf ( '<CHAR_LIT:.>' ) ; if ( lastDot == - <NUM_LIT:1> ) return null ; IType type = findType ( fullyQualifiedName . substring ( <NUM_LIT:0> , lastDot ) , lookup , considerSecondaryTypes , progressMonitor ) ; if ( type != null ) { type = type . getType ( fullyQualifiedName . substring ( lastDot + <NUM_LIT:1> ) ) ; if ( ! type . exists ( ) ) { return null ; } } return type ; } return answer . type ; } public IType findType ( String packageName , String typeQualifiedName ) throws JavaModelException { return findType ( packageName , typeQualifiedName , DefaultWorkingCopyOwner . PRIMARY ) ; } public IType findType ( String packageName , String typeQualifiedName , IProgressMonitor progressMonitor ) throws JavaModelException { return findType ( packageName , typeQualifiedName , DefaultWorkingCopyOwner . PRIMARY , progressMonitor ) ; } IType findType ( String packageName , String typeQualifiedName , NameLookup lookup , boolean considerSecondaryTypes , IProgressMonitor progressMonitor ) throws JavaModelException { NameLookup . Answer answer = lookup . findType ( typeQualifiedName , packageName , false , NameLookup . ACCEPT_ALL , considerSecondaryTypes , true , false , progressMonitor ) ; return answer == null ? null : answer . type ; } public IType findType ( String packageName , String typeQualifiedName , WorkingCopyOwner owner ) throws JavaModelException { NameLookup lookup = newNameLookup ( owner ) ; return findType ( packageName , typeQualifiedName , lookup , false , null ) ; } public IType findType ( String packageName , String typeQualifiedName , WorkingCopyOwner owner , IProgressMonitor progressMonitor ) throws JavaModelException { NameLookup lookup = newNameLookup ( owner ) ; return findType ( packageName , typeQualifiedName , lookup , true , progressMonitor ) ; } public IType findType ( String fullyQualifiedName , WorkingCopyOwner owner ) throws JavaModelException { NameLookup lookup = newNameLookup ( owner ) ; return findType ( fullyQualifiedName , lookup , false , null ) ; } public IType findType ( String fullyQualifiedName , WorkingCopyOwner owner , IProgressMonitor progressMonitor ) throws JavaModelException { NameLookup lookup = newNameLookup ( owner ) ; return findType ( fullyQualifiedName , lookup , true , progressMonitor ) ; } protected void flushClasspathProblemMarkers ( boolean flushCycleMarkers , boolean flushClasspathFormatMarkers , boolean flushOverlappingOutputMarkers ) { try { if ( this . project . isAccessible ( ) ) { IMarker [ ] markers = this . project . findMarkers ( IJavaModelMarker . BUILDPATH_PROBLEM_MARKER , false , IResource . DEPTH_ZERO ) ; for ( int i = <NUM_LIT:0> , length = markers . length ; i < length ; i ++ ) { IMarker marker = markers [ i ] ; if ( flushCycleMarkers && flushClasspathFormatMarkers && flushOverlappingOutputMarkers ) { marker . delete ( ) ; } else { String cycleAttr = ( String ) marker . getAttribute ( IJavaModelMarker . CYCLE_DETECTED ) ; String classpathFileFormatAttr = ( String ) marker . getAttribute ( IJavaModelMarker . CLASSPATH_FILE_FORMAT ) ; String overlappingOutputAttr = ( String ) marker . getAttribute ( IJavaModelMarker . OUTPUT_OVERLAPPING_SOURCE ) ; if ( ( flushCycleMarkers == ( cycleAttr != null && cycleAttr . equals ( "<STR_LIT:true>" ) ) ) && ( flushOverlappingOutputMarkers == ( overlappingOutputAttr != null && overlappingOutputAttr . equals ( "<STR_LIT:true>" ) ) ) && ( flushClasspathFormatMarkers == ( classpathFileFormatAttr != null && classpathFileFormatAttr . equals ( "<STR_LIT:true>" ) ) ) ) { marker . delete ( ) ; } } } } } catch ( CoreException e ) { if ( JavaModelManager . VERBOSE ) { e . printStackTrace ( ) ; } } } public IPath [ ] getAccessRestrictions ( String optionName ) { String sequence = getOption ( optionName , true ) ; if ( sequence == null || sequence . length ( ) == <NUM_LIT:0> ) return null ; IPath [ ] rules = null ; char [ ] [ ] patterns = CharOperation . splitOn ( '<CHAR_LIT>' , sequence . toCharArray ( ) ) ; int patternCount ; if ( ( patternCount = patterns . length ) > <NUM_LIT:0> ) { rules = new IPath [ patternCount ] ; for ( int j = <NUM_LIT:0> ; j < patterns . length ; j ++ ) { rules [ j ] = new Path ( new String ( patterns [ j ] ) ) ; } } return rules ; } public IPackageFragmentRoot [ ] getAllPackageFragmentRoots ( ) throws JavaModelException { return getAllPackageFragmentRoots ( null ) ; } public IPackageFragmentRoot [ ] getAllPackageFragmentRoots ( Map rootToResolvedEntries ) throws JavaModelException { return computePackageFragmentRoots ( getResolvedClasspath ( ) , true , rootToResolvedEntries ) ; } public IClasspathEntry getClasspathEntryFor ( IPath path ) throws JavaModelException { getResolvedClasspath ( ) ; PerProjectInfo perProjectInfo = getPerProjectInfo ( ) ; if ( perProjectInfo == null ) return null ; Map rootPathToResolvedEntries = perProjectInfo . rootPathToResolvedEntries ; if ( rootPathToResolvedEntries == null ) return null ; IClasspathEntry classpathEntry = ( IClasspathEntry ) rootPathToResolvedEntries . get ( path ) ; if ( classpathEntry == null ) { path = getProject ( ) . getWorkspace ( ) . getRoot ( ) . getLocation ( ) . append ( path ) ; classpathEntry = ( IClasspathEntry ) rootPathToResolvedEntries . get ( path ) ; } return classpathEntry ; } public IMarker getCycleMarker ( ) { try { if ( this . project . isAccessible ( ) ) { IMarker [ ] markers = this . project . findMarkers ( IJavaModelMarker . BUILDPATH_PROBLEM_MARKER , false , IResource . DEPTH_ZERO ) ; for ( int i = <NUM_LIT:0> , length = markers . length ; i < length ; i ++ ) { IMarker marker = markers [ i ] ; String cycleAttr = ( String ) marker . getAttribute ( IJavaModelMarker . CYCLE_DETECTED ) ; if ( cycleAttr != null && cycleAttr . equals ( "<STR_LIT:true>" ) ) { return marker ; } } } } catch ( CoreException e ) { } return null ; } public IEclipsePreferences getEclipsePreferences ( ) { if ( ! JavaProject . hasJavaNature ( this . project ) ) return null ; JavaModelManager . PerProjectInfo perProjectInfo = JavaModelManager . getJavaModelManager ( ) . getPerProjectInfo ( this . project , true ) ; if ( perProjectInfo . preferences != null ) return perProjectInfo . preferences ; IScopeContext context = new ProjectScope ( getProject ( ) ) ; final IEclipsePreferences eclipsePreferences = context . getNode ( JavaCore . PLUGIN_ID ) ; updatePreferences ( eclipsePreferences ) ; perProjectInfo . preferences = eclipsePreferences ; final IEclipsePreferences eclipseParentPreferences = ( IEclipsePreferences ) eclipsePreferences . parent ( ) ; if ( eclipseParentPreferences != null ) { if ( this . preferencesNodeListener != null ) { eclipseParentPreferences . removeNodeChangeListener ( this . preferencesNodeListener ) ; } this . preferencesNodeListener = new IEclipsePreferences . INodeChangeListener ( ) { public void added ( IEclipsePreferences . NodeChangeEvent event ) { } public void removed ( IEclipsePreferences . NodeChangeEvent event ) { if ( event . getChild ( ) == eclipsePreferences ) { JavaModelManager . getJavaModelManager ( ) . resetProjectPreferences ( JavaProject . this ) ; } } } ; eclipseParentPreferences . addNodeChangeListener ( this . preferencesNodeListener ) ; } if ( this . preferencesChangeListener != null ) { eclipsePreferences . removePreferenceChangeListener ( this . preferencesChangeListener ) ; } this . preferencesChangeListener = new IEclipsePreferences . IPreferenceChangeListener ( ) { public void preferenceChange ( IEclipsePreferences . PreferenceChangeEvent event ) { String propertyName = event . getKey ( ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; if ( propertyName . startsWith ( JavaCore . PLUGIN_ID ) ) { if ( propertyName . equals ( JavaCore . CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER ) || propertyName . equals ( JavaCore . CORE_JAVA_BUILD_RESOURCE_COPY_FILTER ) || propertyName . equals ( JavaCore . CORE_JAVA_BUILD_DUPLICATE_RESOURCE ) || propertyName . equals ( JavaCore . CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER ) || propertyName . equals ( JavaCore . CORE_JAVA_BUILD_INVALID_CLASSPATH ) || propertyName . equals ( JavaCore . CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS ) || propertyName . equals ( JavaCore . CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS ) || propertyName . equals ( JavaCore . CORE_INCOMPLETE_CLASSPATH ) || propertyName . equals ( JavaCore . CORE_CIRCULAR_CLASSPATH ) || propertyName . equals ( JavaCore . CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE ) || propertyName . equals ( JavaCore . CORE_INCOMPATIBLE_JDK_LEVEL ) ) { manager . deltaState . addClasspathValidation ( JavaProject . this ) ; } manager . resetProjectOptions ( JavaProject . this ) ; JavaProject . this . resetCaches ( ) ; } } } ; eclipsePreferences . addPreferenceChangeListener ( this . preferencesChangeListener ) ; return eclipsePreferences ; } public String getElementName ( ) { return this . project . getName ( ) ; } public int getElementType ( ) { return JAVA_PROJECT ; } public IClasspathEntry [ ] getExpandedClasspath ( ) throws JavaModelException { ObjectVector accumulatedEntries = new ObjectVector ( ) ; computeExpandedClasspath ( null , new HashSet ( <NUM_LIT:5> ) , accumulatedEntries ) ; IClasspathEntry [ ] expandedPath = new IClasspathEntry [ accumulatedEntries . size ( ) ] ; accumulatedEntries . copyInto ( expandedPath ) ; return expandedPath ; } public IPackageFragmentRoot getFolderPackageFragmentRoot ( IPath path ) { if ( path . segmentCount ( ) == <NUM_LIT:1> ) { return getPackageFragmentRoot ( this . project ) ; } return getPackageFragmentRoot ( this . project . getWorkspace ( ) . getRoot ( ) . getFolder ( path ) ) ; } public IJavaElement getHandleFromMemento ( String token , MementoTokenizer memento , WorkingCopyOwner owner ) { switch ( token . charAt ( <NUM_LIT:0> ) ) { case JEM_PACKAGEFRAGMENTROOT : String rootPath = IPackageFragmentRoot . DEFAULT_PACKAGEROOT_PATH ; token = null ; while ( memento . hasMoreTokens ( ) ) { token = memento . nextToken ( ) ; if ( token == MementoTokenizer . PACKAGEFRAGMENT || token == MementoTokenizer . COUNT ) { break ; } rootPath += token ; } JavaElement root = ( JavaElement ) getPackageFragmentRoot ( new Path ( rootPath ) ) ; if ( token != null && token . charAt ( <NUM_LIT:0> ) == JEM_PACKAGEFRAGMENT ) { return root . getHandleFromMemento ( token , memento , owner ) ; } else { return root . getHandleFromMemento ( memento , owner ) ; } } return null ; } protected char getHandleMementoDelimiter ( ) { return JEM_JAVAPROJECT ; } private int getJavaCommandIndex ( ICommand [ ] buildSpec ) { for ( int i = <NUM_LIT:0> ; i < buildSpec . length ; ++ i ) { if ( buildSpec [ i ] . getBuilderName ( ) . equals ( JavaCore . BUILDER_ID ) ) { return i ; } } return - <NUM_LIT:1> ; } protected JavaProjectElementInfo getJavaProjectElementInfo ( ) throws JavaModelException { return ( JavaProjectElementInfo ) getElementInfo ( ) ; } public Object [ ] getNonJavaResources ( ) throws JavaModelException { return ( ( JavaProjectElementInfo ) getElementInfo ( ) ) . getNonJavaResources ( this ) ; } public String getOption ( String optionName , boolean inheritJavaCoreOptions ) { return JavaModelManager . getJavaModelManager ( ) . getOption ( optionName , inheritJavaCoreOptions , getEclipsePreferences ( ) ) ; } public Map getOptions ( boolean inheritJavaCoreOptions ) { Map options = inheritJavaCoreOptions ? JavaCore . getOptions ( ) : new Hashtable ( <NUM_LIT:5> ) ; JavaModelManager . PerProjectInfo perProjectInfo = null ; Hashtable projectOptions = null ; JavaModelManager javaModelManager = JavaModelManager . getJavaModelManager ( ) ; HashSet optionNames = javaModelManager . optionNames ; try { perProjectInfo = getPerProjectInfo ( ) ; projectOptions = perProjectInfo . options ; if ( projectOptions == null ) { IEclipsePreferences projectPreferences = getEclipsePreferences ( ) ; if ( projectPreferences == null ) return options ; String [ ] propertyNames = projectPreferences . keys ( ) ; projectOptions = new Hashtable ( propertyNames . length ) ; for ( int i = <NUM_LIT:0> ; i < propertyNames . length ; i ++ ) { String propertyName = propertyNames [ i ] ; String value = projectPreferences . get ( propertyName , null ) ; if ( value != null ) { value = value . trim ( ) ; projectOptions . put ( propertyName , value ) ; if ( ! optionNames . contains ( propertyName ) ) { String [ ] compatibleOptions = ( String [ ] ) javaModelManager . deprecatedOptions . get ( propertyName ) ; if ( compatibleOptions != null ) { for ( int co = <NUM_LIT:0> , length = compatibleOptions . length ; co < length ; co ++ ) { String compatibleOption = compatibleOptions [ co ] ; if ( ! projectOptions . containsKey ( compatibleOption ) ) projectOptions . put ( compatibleOption , value ) ; } } } } } perProjectInfo . options = projectOptions ; } } catch ( JavaModelException jme ) { projectOptions = new Hashtable ( ) ; } catch ( BackingStoreException e ) { projectOptions = new Hashtable ( ) ; } if ( inheritJavaCoreOptions ) { Iterator propertyNames = projectOptions . entrySet ( ) . iterator ( ) ; while ( propertyNames . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) propertyNames . next ( ) ; String propertyName = ( String ) entry . getKey ( ) ; String propertyValue = ( String ) entry . getValue ( ) ; if ( propertyValue != null && javaModelManager . knowsOption ( propertyName ) ) { options . put ( propertyName , propertyValue . trim ( ) ) ; } } Util . fixTaskTags ( options ) ; return options ; } Util . fixTaskTags ( projectOptions ) ; return projectOptions ; } public IPath getOutputLocation ( ) throws JavaModelException { JavaModelManager . PerProjectInfo perProjectInfo = getPerProjectInfo ( ) ; IPath outputLocation = perProjectInfo . outputLocation ; if ( outputLocation != null ) return outputLocation ; getRawClasspath ( ) ; outputLocation = perProjectInfo . outputLocation ; if ( outputLocation == null ) { return defaultOutputLocation ( ) ; } return outputLocation ; } public IPackageFragmentRoot getPackageFragmentRoot ( IPath path ) { if ( ! path . isAbsolute ( ) ) { path = getPath ( ) . append ( path ) ; } int segmentCount = path . segmentCount ( ) ; if ( segmentCount == <NUM_LIT:0> ) { return null ; } if ( path . getDevice ( ) != null || JavaModel . getExternalTarget ( path , true ) != null ) { return getPackageFragmentRoot0 ( path ) ; } IWorkspaceRoot workspaceRoot = this . project . getWorkspace ( ) . getRoot ( ) ; IResource resource = workspaceRoot . findMember ( path ) ; if ( resource == null ) { if ( path . getFileExtension ( ) != null ) { if ( ! workspaceRoot . getProject ( path . segment ( <NUM_LIT:0> ) ) . exists ( ) ) { return getPackageFragmentRoot0 ( path ) ; } else { resource = workspaceRoot . getFile ( path ) ; } } else if ( segmentCount == <NUM_LIT:1> ) { String projectName = path . segment ( <NUM_LIT:0> ) ; if ( getElementName ( ) . equals ( projectName ) ) { resource = this . project ; } else { resource = workspaceRoot . getProject ( projectName ) ; } } else { resource = workspaceRoot . getFolder ( path ) ; } } return getPackageFragmentRoot ( resource ) ; } public IPackageFragmentRoot getPackageFragmentRoot ( IResource resource ) { return getPackageFragmentRoot ( resource , null ) ; } private IPackageFragmentRoot getPackageFragmentRoot ( IResource resource , IPath entryPath ) { switch ( resource . getType ( ) ) { case IResource . FILE : return new JarPackageFragmentRoot ( resource , this ) ; case IResource . FOLDER : if ( ExternalFoldersManager . isInternalPathForExternalFolder ( resource . getFullPath ( ) ) ) return new ExternalPackageFragmentRoot ( resource , entryPath , this ) ; return new PackageFragmentRoot ( resource , this ) ; case IResource . PROJECT : return new PackageFragmentRoot ( resource , this ) ; default : return null ; } } public IPackageFragmentRoot getPackageFragmentRoot ( String externalLibraryPath ) { return getPackageFragmentRoot0 ( JavaProject . canonicalizedPath ( new Path ( externalLibraryPath ) ) ) ; } public IPackageFragmentRoot getPackageFragmentRoot0 ( IPath externalLibraryPath ) { IFolder linkedFolder = JavaModelManager . getExternalManager ( ) . getFolder ( externalLibraryPath ) ; if ( linkedFolder != null ) return new ExternalPackageFragmentRoot ( linkedFolder , externalLibraryPath , this ) ; return new JarPackageFragmentRoot ( externalLibraryPath , this ) ; } public IPackageFragmentRoot [ ] getPackageFragmentRoots ( ) throws JavaModelException { Object [ ] children ; int length ; IPackageFragmentRoot [ ] roots ; System . arraycopy ( children = getChildren ( ) , <NUM_LIT:0> , roots = new IPackageFragmentRoot [ length = children . length ] , <NUM_LIT:0> , length ) ; return roots ; } public IPackageFragmentRoot [ ] getPackageFragmentRoots ( IClasspathEntry entry ) { return findPackageFragmentRoots ( entry ) ; } public IPackageFragment [ ] getPackageFragments ( ) throws JavaModelException { IPackageFragmentRoot [ ] roots = getPackageFragmentRoots ( ) ; return getPackageFragmentsInRoots ( roots ) ; } public IPackageFragment [ ] getPackageFragmentsInRoots ( IPackageFragmentRoot [ ] roots ) { ArrayList frags = new ArrayList ( ) ; for ( int i = <NUM_LIT:0> ; i < roots . length ; i ++ ) { IPackageFragmentRoot root = roots [ i ] ; try { IJavaElement [ ] rootFragments = root . getChildren ( ) ; for ( int j = <NUM_LIT:0> ; j < rootFragments . length ; j ++ ) { frags . add ( rootFragments [ j ] ) ; } } catch ( JavaModelException e ) { } } IPackageFragment [ ] fragments = new IPackageFragment [ frags . size ( ) ] ; frags . toArray ( fragments ) ; return fragments ; } public IPath getPath ( ) { return this . project . getFullPath ( ) ; } public JavaModelManager . PerProjectInfo getPerProjectInfo ( ) throws JavaModelException { return JavaModelManager . getJavaModelManager ( ) . getPerProjectInfoCheckExistence ( this . project ) ; } private IPath getPluginWorkingLocation ( ) { return this . project . getWorkingLocation ( JavaCore . PLUGIN_ID ) ; } public IProject getProject ( ) { return this . project ; } public ProjectCache getProjectCache ( ) throws JavaModelException { return ( ( JavaProjectElementInfo ) getElementInfo ( ) ) . getProjectCache ( this ) ; } public IClasspathEntry [ ] getRawClasspath ( ) throws JavaModelException { JavaModelManager . PerProjectInfo perProjectInfo = getPerProjectInfo ( ) ; IClasspathEntry [ ] classpath = perProjectInfo . rawClasspath ; if ( classpath != null ) return classpath ; classpath = perProjectInfo . readAndCacheClasspath ( this ) [ <NUM_LIT:0> ] ; if ( classpath == JavaProject . INVALID_CLASSPATH ) return defaultClasspath ( ) ; return classpath ; } public IClasspathEntry [ ] getReferencedClasspathEntries ( ) throws JavaModelException { return getPerProjectInfo ( ) . referencedEntries ; } public String [ ] getRequiredProjectNames ( ) throws JavaModelException { return projectPrerequisites ( getResolvedClasspath ( ) ) ; } public IClasspathEntry [ ] getResolvedClasspath ( ) throws JavaModelException { PerProjectInfo perProjectInfo = getPerProjectInfo ( ) ; IClasspathEntry [ ] resolvedClasspath = perProjectInfo . getResolvedClasspath ( ) ; if ( resolvedClasspath == null ) { resolveClasspath ( perProjectInfo , false , true ) ; resolvedClasspath = perProjectInfo . getResolvedClasspath ( ) ; if ( resolvedClasspath == null ) { PerProjectInfo temporaryInfo = newTemporaryInfo ( ) ; resolveClasspath ( temporaryInfo , false , true ) ; resolvedClasspath = temporaryInfo . getResolvedClasspath ( ) ; } } return resolvedClasspath ; } public IClasspathEntry [ ] getResolvedClasspath ( boolean ignoreUnresolvedEntry ) throws JavaModelException { if ( JavaModelManager . getJavaModelManager ( ) . isClasspathBeingResolved ( this ) ) { if ( JavaModelManager . CP_RESOLVE_VERBOSE_ADVANCED ) verbose_reentering_classpath_resolution ( ) ; return RESOLUTION_IN_PROGRESS ; } PerProjectInfo perProjectInfo = getPerProjectInfo ( ) ; IClasspathEntry [ ] resolvedClasspath ; IJavaModelStatus unresolvedEntryStatus ; synchronized ( perProjectInfo ) { resolvedClasspath = perProjectInfo . getResolvedClasspath ( ) ; unresolvedEntryStatus = perProjectInfo . unresolvedEntryStatus ; } if ( resolvedClasspath == null || ( unresolvedEntryStatus != null && ! unresolvedEntryStatus . isOK ( ) ) ) { resolveClasspath ( perProjectInfo , false , true ) ; synchronized ( perProjectInfo ) { resolvedClasspath = perProjectInfo . getResolvedClasspath ( ) ; unresolvedEntryStatus = perProjectInfo . unresolvedEntryStatus ; } if ( resolvedClasspath == null ) { PerProjectInfo temporaryInfo = newTemporaryInfo ( ) ; resolveClasspath ( temporaryInfo , false , true ) ; resolvedClasspath = temporaryInfo . getResolvedClasspath ( ) ; unresolvedEntryStatus = temporaryInfo . unresolvedEntryStatus ; } } if ( ! ignoreUnresolvedEntry && unresolvedEntryStatus != null && ! unresolvedEntryStatus . isOK ( ) ) throw new JavaModelException ( unresolvedEntryStatus ) ; return resolvedClasspath ; } private void verbose_reentering_classpath_resolution ( ) { Util . verbose ( "<STR_LIT>" + "<STR_LIT>" + getElementName ( ) + '<STR_LIT:\n>' + "<STR_LIT>" ) ; new Exception ( "<STR_LIT>" ) . printStackTrace ( System . out ) ; } public IResource resource ( PackageFragmentRoot root ) { return this . project ; } public String getSharedProperty ( String key ) throws CoreException { String property = null ; IFile rscFile = this . project . getFile ( key ) ; if ( rscFile . exists ( ) ) { byte [ ] bytes = Util . getResourceContentsAsByteArray ( rscFile ) ; try { property = new String ( bytes , org . eclipse . jdt . internal . compiler . util . Util . UTF_8 ) ; } catch ( UnsupportedEncodingException e ) { Util . log ( e , "<STR_LIT>" ) ; property = new String ( bytes ) ; } } else { URI location = rscFile . getLocationURI ( ) ; if ( location != null ) { File file = Util . toLocalFile ( location , null ) ; if ( file != null && file . exists ( ) ) { byte [ ] bytes ; try { bytes = org . eclipse . jdt . internal . compiler . util . Util . getFileByteContent ( file ) ; } catch ( IOException e ) { return null ; } try { property = new String ( bytes , org . eclipse . jdt . internal . compiler . util . Util . UTF_8 ) ; } catch ( UnsupportedEncodingException e ) { Util . log ( e , "<STR_LIT>" ) ; property = new String ( bytes ) ; } } } } return property ; } public SourceMapper getSourceMapper ( ) { return null ; } public IResource getUnderlyingResource ( ) throws JavaModelException { if ( ! exists ( ) ) throw newNotPresentException ( ) ; return this . project ; } public boolean hasBuildState ( ) { return JavaModelManager . getJavaModelManager ( ) . getLastBuiltState ( this . project , null ) != null ; } public boolean hasClasspathCycle ( IClasspathEntry [ ] preferredClasspath ) { LinkedHashSet cycleParticipants = new LinkedHashSet ( ) ; HashMap preferredClasspaths = new HashMap ( <NUM_LIT:1> ) ; preferredClasspaths . put ( this , preferredClasspath ) ; updateCycleParticipants ( new ArrayList ( <NUM_LIT:2> ) , cycleParticipants , ResourcesPlugin . getWorkspace ( ) . getRoot ( ) , new HashSet ( <NUM_LIT:2> ) , preferredClasspaths ) ; return ! cycleParticipants . isEmpty ( ) ; } public boolean hasCycleMarker ( ) { return getCycleMarker ( ) != null ; } public int hashCode ( ) { return this . project . hashCode ( ) ; } private boolean hasUTF8BOM ( byte [ ] bytes ) { if ( bytes . length > IContentDescription . BOM_UTF_8 . length ) { for ( int i = <NUM_LIT:0> , length = IContentDescription . BOM_UTF_8 . length ; i < length ; i ++ ) { if ( IContentDescription . BOM_UTF_8 [ i ] != bytes [ i ] ) return false ; } return true ; } return false ; } public boolean hasSource ( ) { IClasspathEntry [ ] entries ; try { entries = getRawClasspath ( ) ; } catch ( JavaModelException e ) { return true ; } for ( int i = <NUM_LIT:0> , max = entries . length ; i < max ; i ++ ) { if ( entries [ i ] . getEntryKind ( ) == IClasspathEntry . CPE_SOURCE ) { return true ; } } return false ; } public boolean isOnClasspath ( IJavaElement element ) { IClasspathEntry [ ] rawClasspath ; try { rawClasspath = getRawClasspath ( ) ; } catch ( JavaModelException e ) { return false ; } int elementType = element . getElementType ( ) ; boolean isPackageFragmentRoot = false ; boolean isFolderPath = false ; boolean isSource = false ; switch ( elementType ) { case IJavaElement . JAVA_MODEL : return false ; case IJavaElement . JAVA_PROJECT : break ; case IJavaElement . PACKAGE_FRAGMENT_ROOT : isPackageFragmentRoot = true ; break ; case IJavaElement . PACKAGE_FRAGMENT : isFolderPath = ! ( ( IPackageFragmentRoot ) element . getParent ( ) ) . isArchive ( ) ; break ; case IJavaElement . COMPILATION_UNIT : isSource = true ; break ; default : isSource = element . getAncestor ( IJavaElement . COMPILATION_UNIT ) != null ; break ; } IPath elementPath = element . getPath ( ) ; int length = rawClasspath . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IClasspathEntry entry = rawClasspath [ i ] ; switch ( entry . getEntryKind ( ) ) { case IClasspathEntry . CPE_LIBRARY : case IClasspathEntry . CPE_PROJECT : case IClasspathEntry . CPE_SOURCE : if ( isOnClasspathEntry ( elementPath , isFolderPath , isPackageFragmentRoot , entry ) ) return true ; break ; } } if ( isSource ) return false ; IClasspathEntry [ ] resolvedClasspath = null ; try { resolvedClasspath = getResolvedClasspath ( ) ; } catch ( JavaModelException e ) { return false ; } for ( int index = <NUM_LIT:0> ; index < resolvedClasspath . length ; index ++ ) { if ( isOnClasspathEntry ( elementPath , isFolderPath , isPackageFragmentRoot , resolvedClasspath [ index ] ) ) return true ; } return false ; } public boolean isOnClasspath ( IResource resource ) { IPath exactPath = resource . getFullPath ( ) ; IPath path = exactPath ; int resourceType = resource . getType ( ) ; boolean isFolderPath = resourceType == IResource . FOLDER || resourceType == IResource . PROJECT ; IClasspathEntry [ ] classpath ; try { classpath = this . getResolvedClasspath ( ) ; } catch ( JavaModelException e ) { return false ; } for ( int i = <NUM_LIT:0> ; i < classpath . length ; i ++ ) { IClasspathEntry entry = classpath [ i ] ; IPath entryPath = entry . getPath ( ) ; if ( entryPath . equals ( exactPath ) ) { return true ; } if ( entryPath . isAbsolute ( ) && entryPath . equals ( ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getLocation ( ) . append ( exactPath ) ) ) { return true ; } if ( entryPath . isPrefixOf ( path ) && ! Util . isExcluded ( path , ( ( ClasspathEntry ) entry ) . fullInclusionPatternChars ( ) , ( ( ClasspathEntry ) entry ) . fullExclusionPatternChars ( ) , isFolderPath ) ) { return true ; } } return false ; } private boolean isOnClasspathEntry ( IPath elementPath , boolean isFolderPath , boolean isPackageFragmentRoot , IClasspathEntry entry ) { IPath entryPath = entry . getPath ( ) ; if ( isPackageFragmentRoot ) { if ( entryPath . equals ( elementPath ) ) return true ; } else { if ( entryPath . isPrefixOf ( elementPath ) && ! Util . isExcluded ( elementPath , ( ( ClasspathEntry ) entry ) . fullInclusionPatternChars ( ) , ( ( ClasspathEntry ) entry ) . fullExclusionPatternChars ( ) , isFolderPath ) ) return true ; } if ( entryPath . isAbsolute ( ) && entryPath . equals ( ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getLocation ( ) . append ( elementPath ) ) ) { return true ; } return false ; } private IEclipsePreferences loadPreferences ( ) { IEclipsePreferences preferences = null ; IPath projectMetaLocation = getPluginWorkingLocation ( ) ; if ( projectMetaLocation != null ) { File prefFile = projectMetaLocation . append ( PREF_FILENAME ) . toFile ( ) ; if ( prefFile . exists ( ) ) { InputStream in = null ; try { in = new BufferedInputStream ( new FileInputStream ( prefFile ) ) ; preferences = Platform . getPreferencesService ( ) . readPreferences ( in ) ; } catch ( CoreException e ) { } catch ( IOException e ) { } finally { if ( in != null ) { try { in . close ( ) ; } catch ( IOException e ) { } } } prefFile . delete ( ) ; return preferences ; } } return null ; } public IEvaluationContext newEvaluationContext ( ) { EvaluationContext context = new EvaluationContext ( ) ; context . setLineSeparator ( Util . getLineSeparator ( null , this ) ) ; return new EvaluationContextWrapper ( context , this ) ; } public NameLookup newNameLookup ( ICompilationUnit [ ] workingCopies ) throws JavaModelException { return getJavaProjectElementInfo ( ) . newNameLookup ( this , workingCopies ) ; } public NameLookup newNameLookup ( WorkingCopyOwner owner ) throws JavaModelException { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; ICompilationUnit [ ] workingCopies = owner == null ? null : manager . getWorkingCopies ( owner , true ) ; return newNameLookup ( workingCopies ) ; } public SearchableEnvironment newSearchableNameEnvironment ( ICompilationUnit [ ] workingCopies ) throws JavaModelException { return new SearchableEnvironment ( this , workingCopies ) ; } public SearchableEnvironment newSearchableNameEnvironment ( WorkingCopyOwner owner ) throws JavaModelException { return new SearchableEnvironment ( this , owner ) ; } public PerProjectInfo newTemporaryInfo ( ) { return new PerProjectInfo ( this . project . getProject ( ) ) { protected ClasspathChange addClasspathChange ( ) { return null ; } } ; } public ITypeHierarchy newTypeHierarchy ( IRegion region , IProgressMonitor monitor ) throws JavaModelException { return newTypeHierarchy ( region , DefaultWorkingCopyOwner . PRIMARY , monitor ) ; } public ITypeHierarchy newTypeHierarchy ( IRegion region , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException { if ( region == null ) { throw new IllegalArgumentException ( Messages . hierarchy_nullRegion ) ; } ICompilationUnit [ ] workingCopies = JavaModelManager . getJavaModelManager ( ) . getWorkingCopies ( owner , true ) ; CreateTypeHierarchyOperation op = new CreateTypeHierarchyOperation ( region , workingCopies , null , true ) ; op . runOperation ( monitor ) ; return op . getResult ( ) ; } public ITypeHierarchy newTypeHierarchy ( IType type , IRegion region , IProgressMonitor monitor ) throws JavaModelException { return newTypeHierarchy ( type , region , DefaultWorkingCopyOwner . PRIMARY , monitor ) ; } public ITypeHierarchy newTypeHierarchy ( IType type , IRegion region , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException { if ( type == null ) { throw new IllegalArgumentException ( Messages . hierarchy_nullFocusType ) ; } if ( region == null ) { throw new IllegalArgumentException ( Messages . hierarchy_nullRegion ) ; } ICompilationUnit [ ] workingCopies = JavaModelManager . getJavaModelManager ( ) . getWorkingCopies ( owner , true ) ; CreateTypeHierarchyOperation op = new CreateTypeHierarchyOperation ( region , workingCopies , type , true ) ; op . runOperation ( monitor ) ; return op . getResult ( ) ; } public String [ ] projectPrerequisites ( IClasspathEntry [ ] resolvedClasspath ) throws JavaModelException { ArrayList prerequisites = new ArrayList ( ) ; for ( int i = <NUM_LIT:0> , length = resolvedClasspath . length ; i < length ; i ++ ) { IClasspathEntry entry = resolvedClasspath [ i ] ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_PROJECT ) { prerequisites . add ( entry . getPath ( ) . lastSegment ( ) ) ; } } int size = prerequisites . size ( ) ; if ( size == <NUM_LIT:0> ) { return NO_PREREQUISITES ; } else { String [ ] result = new String [ size ] ; prerequisites . toArray ( result ) ; return result ; } } public IClasspathEntry [ ] [ ] readFileEntriesWithException ( Map unknownElements ) throws CoreException , IOException , ClasspathEntry . AssertionFailedException { IFile rscFile = this . project . getFile ( JavaProject . CLASSPATH_FILENAME ) ; byte [ ] bytes ; if ( rscFile . exists ( ) ) { bytes = Util . getResourceContentsAsByteArray ( rscFile ) ; } else { URI location = rscFile . getLocationURI ( ) ; if ( location == null ) throw new IOException ( "<STR_LIT>" + rscFile ) ; File file = Util . toLocalFile ( location , null ) ; if ( file == null ) throw new IOException ( "<STR_LIT>" + location ) ; try { bytes = org . eclipse . jdt . internal . compiler . util . Util . getFileByteContent ( file ) ; } catch ( IOException e ) { if ( ! file . exists ( ) ) return new IClasspathEntry [ ] [ ] { defaultClasspath ( ) , ClasspathEntry . NO_ENTRIES } ; throw e ; } } if ( hasUTF8BOM ( bytes ) ) { int length = bytes . length - IContentDescription . BOM_UTF_8 . length ; System . arraycopy ( bytes , IContentDescription . BOM_UTF_8 . length , bytes = new byte [ length ] , <NUM_LIT:0> , length ) ; } String xmlClasspath ; try { xmlClasspath = new String ( bytes , org . eclipse . jdt . internal . compiler . util . Util . UTF_8 ) ; } catch ( UnsupportedEncodingException e ) { Util . log ( e , "<STR_LIT>" ) ; xmlClasspath = new String ( bytes ) ; } return decodeClasspath ( xmlClasspath , unknownElements ) ; } private IClasspathEntry [ ] [ ] readFileEntries ( Map unkwownElements ) { try { return readFileEntriesWithException ( unkwownElements ) ; } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" + getPath ( ) . append ( JavaProject . CLASSPATH_FILENAME ) ) ; return new IClasspathEntry [ ] [ ] { JavaProject . INVALID_CLASSPATH , ClasspathEntry . NO_ENTRIES } ; } catch ( IOException e ) { Util . log ( e , "<STR_LIT>" + getPath ( ) . append ( JavaProject . CLASSPATH_FILENAME ) ) ; return new IClasspathEntry [ ] [ ] { JavaProject . INVALID_CLASSPATH , ClasspathEntry . NO_ENTRIES } ; } catch ( ClasspathEntry . AssertionFailedException e ) { Util . log ( e , "<STR_LIT>" + getPath ( ) . append ( JavaProject . CLASSPATH_FILENAME ) ) ; return new IClasspathEntry [ ] [ ] { JavaProject . INVALID_CLASSPATH , ClasspathEntry . NO_ENTRIES } ; } } public IPath readOutputLocation ( ) { IClasspathEntry [ ] [ ] classpath = readFileEntries ( null ) ; if ( classpath [ <NUM_LIT:0> ] == JavaProject . INVALID_CLASSPATH ) return defaultOutputLocation ( ) ; IPath outputLocation = null ; if ( classpath [ <NUM_LIT:0> ] . length > <NUM_LIT:0> ) { IClasspathEntry entry = classpath [ <NUM_LIT:0> ] [ classpath [ <NUM_LIT:0> ] . length - <NUM_LIT:1> ] ; if ( entry . getContentKind ( ) == ClasspathEntry . K_OUTPUT ) { outputLocation = entry . getPath ( ) ; } } return outputLocation ; } public IClasspathEntry [ ] readRawClasspath ( ) { IClasspathEntry [ ] [ ] classpath = readFileEntries ( null ) ; if ( classpath [ <NUM_LIT:0> ] == JavaProject . INVALID_CLASSPATH ) return defaultClasspath ( ) ; if ( classpath [ <NUM_LIT:0> ] . length > <NUM_LIT:0> ) { IClasspathEntry entry = classpath [ <NUM_LIT:0> ] [ classpath [ <NUM_LIT:0> ] . length - <NUM_LIT:1> ] ; if ( entry . getContentKind ( ) == ClasspathEntry . K_OUTPUT ) { IClasspathEntry [ ] copy = new IClasspathEntry [ classpath [ <NUM_LIT:0> ] . length - <NUM_LIT:1> ] ; System . arraycopy ( classpath [ <NUM_LIT:0> ] , <NUM_LIT:0> , copy , <NUM_LIT:0> , copy . length ) ; classpath [ <NUM_LIT:0> ] = copy ; } } return classpath [ <NUM_LIT:0> ] ; } protected void removeFromBuildSpec ( String builderID ) throws CoreException { IProjectDescription description = this . project . getDescription ( ) ; ICommand [ ] commands = description . getBuildSpec ( ) ; for ( int i = <NUM_LIT:0> ; i < commands . length ; ++ i ) { if ( commands [ i ] . getBuilderName ( ) . equals ( builderID ) ) { ICommand [ ] newCommands = new ICommand [ commands . length - <NUM_LIT:1> ] ; System . arraycopy ( commands , <NUM_LIT:0> , newCommands , <NUM_LIT:0> , i ) ; System . arraycopy ( commands , i + <NUM_LIT:1> , newCommands , i , commands . length - i - <NUM_LIT:1> ) ; description . setBuildSpec ( newCommands ) ; this . project . setDescription ( description , null ) ; return ; } } } public void resetCaches ( ) { JavaProjectElementInfo info = ( JavaProjectElementInfo ) JavaModelManager . getJavaModelManager ( ) . peekAtInfo ( this ) ; if ( info != null ) { info . resetCaches ( ) ; } } public ClasspathChange resetResolvedClasspath ( ) { try { return getPerProjectInfo ( ) . resetResolvedClasspath ( ) ; } catch ( JavaModelException e ) { return null ; } } public IClasspathEntry [ ] resolveClasspath ( IClasspathEntry [ ] rawClasspath ) throws JavaModelException { return resolveClasspath ( rawClasspath , false , true ) . resolvedClasspath ; } static class ResolvedClasspath { IClasspathEntry [ ] resolvedClasspath ; IJavaModelStatus unresolvedEntryStatus = JavaModelStatus . VERIFIED_OK ; HashMap rawReverseMap = new HashMap ( ) ; Map rootPathToResolvedEntries = new HashMap ( ) ; IClasspathEntry [ ] referencedEntries = null ; } public ResolvedClasspath resolveClasspath ( IClasspathEntry [ ] rawClasspath , boolean usePreviousSession , boolean resolveChainedLibraries ) throws JavaModelException { return resolveClasspath ( rawClasspath , null , usePreviousSession , resolveChainedLibraries ) ; } public ResolvedClasspath resolveClasspath ( IClasspathEntry [ ] rawClasspath , IClasspathEntry [ ] referencedEntries , boolean usePreviousSession , boolean resolveChainedLibraries ) throws JavaModelException { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; ExternalFoldersManager externalFoldersManager = JavaModelManager . getExternalManager ( ) ; ResolvedClasspath result = new ResolvedClasspath ( ) ; Map knownDrives = new HashMap ( ) ; Map referencedEntriesMap = new HashMap ( ) ; List rawLibrariesPath = new ArrayList ( ) ; LinkedHashSet resolvedEntries = new LinkedHashSet ( ) ; if ( resolveChainedLibraries ) { for ( int index = <NUM_LIT:0> ; index < rawClasspath . length ; index ++ ) { IClasspathEntry currentEntry = rawClasspath [ index ] ; if ( currentEntry . getEntryKind ( ) == IClasspathEntry . CPE_LIBRARY ) { rawLibrariesPath . add ( ClasspathEntry . resolveDotDot ( getProject ( ) . getLocation ( ) , currentEntry . getPath ( ) ) ) ; } } if ( referencedEntries != null ) { LinkedHashSet referencedEntriesSet = new LinkedHashSet ( ) ; for ( int index = <NUM_LIT:0> ; index < referencedEntries . length ; index ++ ) { IPath path = referencedEntries [ index ] . getPath ( ) ; if ( ! rawLibrariesPath . contains ( path ) && referencedEntriesMap . get ( path ) == null ) { referencedEntriesMap . put ( path , referencedEntries [ index ] ) ; referencedEntriesSet . add ( referencedEntries [ index ] ) ; } } if ( referencedEntriesSet . size ( ) > <NUM_LIT:0> ) { result . referencedEntries = new IClasspathEntry [ referencedEntriesSet . size ( ) ] ; referencedEntriesSet . toArray ( result . referencedEntries ) ; } } } int length = rawClasspath . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IClasspathEntry rawEntry = rawClasspath [ i ] ; IClasspathEntry resolvedEntry = rawEntry ; switch ( rawEntry . getEntryKind ( ) ) { case IClasspathEntry . CPE_VARIABLE : try { resolvedEntry = manager . resolveVariableEntry ( rawEntry , usePreviousSession ) ; } catch ( ClasspathEntry . AssertionFailedException e ) { result . unresolvedEntryStatus = new JavaModelStatus ( IJavaModelStatusConstants . INVALID_PATH , e . getMessage ( ) ) ; break ; } if ( resolvedEntry == null ) { result . unresolvedEntryStatus = new JavaModelStatus ( IJavaModelStatusConstants . CP_VARIABLE_PATH_UNBOUND , this , rawEntry . getPath ( ) ) ; } else { if ( resolveChainedLibraries && resolvedEntry . getEntryKind ( ) == IClasspathEntry . CPE_LIBRARY && result . rawReverseMap . get ( resolvedEntry . getPath ( ) ) == null ) { ClasspathEntry [ ] extraEntries = ( ( ClasspathEntry ) resolvedEntry ) . resolvedChainedLibraries ( ) ; for ( int j = <NUM_LIT:0> , length2 = extraEntries . length ; j < length2 ; j ++ ) { if ( ! rawLibrariesPath . contains ( extraEntries [ j ] . getPath ( ) ) ) { addToResult ( rawEntry , extraEntries [ j ] , result , resolvedEntries , externalFoldersManager , referencedEntriesMap , true , knownDrives ) ; } } } addToResult ( rawEntry , resolvedEntry , result , resolvedEntries , externalFoldersManager , referencedEntriesMap , false , knownDrives ) ; } break ; case IClasspathEntry . CPE_CONTAINER : IClasspathContainer container = usePreviousSession ? manager . getPreviousSessionContainer ( rawEntry . getPath ( ) , this ) : JavaCore . getClasspathContainer ( rawEntry . getPath ( ) , this ) ; if ( container == null ) { result . unresolvedEntryStatus = new JavaModelStatus ( IJavaModelStatusConstants . CP_CONTAINER_PATH_UNBOUND , this , rawEntry . getPath ( ) ) ; break ; } IClasspathEntry [ ] containerEntries = container . getClasspathEntries ( ) ; if ( containerEntries == null ) { if ( JavaModelManager . CP_RESOLVE_VERBOSE || JavaModelManager . CP_RESOLVE_VERBOSE_FAILURE ) { JavaModelManager . getJavaModelManager ( ) . verbose_missbehaving_container_null_entries ( this , rawEntry . getPath ( ) ) ; } break ; } for ( int j = <NUM_LIT:0> , containerLength = containerEntries . length ; j < containerLength ; j ++ ) { ClasspathEntry cEntry = ( ClasspathEntry ) containerEntries [ j ] ; if ( cEntry == null ) { if ( JavaModelManager . CP_RESOLVE_VERBOSE || JavaModelManager . CP_RESOLVE_VERBOSE_FAILURE ) { JavaModelManager . getJavaModelManager ( ) . verbose_missbehaving_container ( this , rawEntry . getPath ( ) , containerEntries ) ; } break ; } cEntry = cEntry . combineWith ( ( ClasspathEntry ) rawEntry ) ; if ( cEntry . getEntryKind ( ) == IClasspathEntry . CPE_LIBRARY ) { cEntry = cEntry . resolvedDotDot ( getProject ( ) . getLocation ( ) ) ; if ( resolveChainedLibraries && JavaModelManager . getJavaModelManager ( ) . resolveReferencedLibrariesForContainers && result . rawReverseMap . get ( cEntry . getPath ( ) ) == null ) { ClasspathEntry [ ] extraEntries = cEntry . resolvedChainedLibraries ( ) ; for ( int k = <NUM_LIT:0> , length2 = extraEntries . length ; k < length2 ; k ++ ) { if ( ! rawLibrariesPath . contains ( extraEntries [ k ] . getPath ( ) ) ) { addToResult ( rawEntry , extraEntries [ k ] , result , resolvedEntries , externalFoldersManager , referencedEntriesMap , false , knownDrives ) ; } } } } addToResult ( rawEntry , cEntry , result , resolvedEntries , externalFoldersManager , referencedEntriesMap , false , knownDrives ) ; } break ; case IClasspathEntry . CPE_LIBRARY : resolvedEntry = ( ( ClasspathEntry ) rawEntry ) . resolvedDotDot ( getProject ( ) . getLocation ( ) ) ; if ( resolveChainedLibraries && result . rawReverseMap . get ( resolvedEntry . getPath ( ) ) == null ) { ClasspathEntry [ ] extraEntries = ( ( ClasspathEntry ) resolvedEntry ) . resolvedChainedLibraries ( ) ; for ( int k = <NUM_LIT:0> , length2 = extraEntries . length ; k < length2 ; k ++ ) { if ( ! rawLibrariesPath . contains ( extraEntries [ k ] . getPath ( ) ) ) { addToResult ( rawEntry , extraEntries [ k ] , result , resolvedEntries , externalFoldersManager , referencedEntriesMap , true , knownDrives ) ; } } } addToResult ( rawEntry , resolvedEntry , result , resolvedEntries , externalFoldersManager , referencedEntriesMap , false , knownDrives ) ; break ; default : addToResult ( rawEntry , resolvedEntry , result , resolvedEntries , externalFoldersManager , referencedEntriesMap , false , knownDrives ) ; break ; } } result . resolvedClasspath = new IClasspathEntry [ resolvedEntries . size ( ) ] ; resolvedEntries . toArray ( result . resolvedClasspath ) ; return result ; } private void addToResult ( IClasspathEntry rawEntry , IClasspathEntry resolvedEntry , ResolvedClasspath result , LinkedHashSet resolvedEntries , ExternalFoldersManager externalFoldersManager , Map oldChainedEntriesMap , boolean addAsChainedEntry , Map knownDrives ) { IPath resolvedPath ; if ( result . rawReverseMap . get ( resolvedPath = resolvedEntry . getPath ( ) ) == null ) { result . rawReverseMap . put ( resolvedPath , rawEntry ) ; result . rootPathToResolvedEntries . put ( resolvedPath , resolvedEntry ) ; resolvedEntries . add ( resolvedEntry ) ; if ( addAsChainedEntry ) { IClasspathEntry chainedEntry = null ; chainedEntry = ( ClasspathEntry ) oldChainedEntriesMap . get ( resolvedPath ) ; if ( chainedEntry != null ) { copyFromOldChainedEntry ( ( ClasspathEntry ) resolvedEntry , ( ClasspathEntry ) chainedEntry ) ; } } } if ( resolvedEntry . getEntryKind ( ) == IClasspathEntry . CPE_LIBRARY && ExternalFoldersManager . isExternalFolderPath ( resolvedPath ) ) { externalFoldersManager . addFolder ( resolvedPath , true ) ; } IPath sourcePath = resolvedEntry . getSourceAttachmentPath ( ) ; if ( sourcePath != null && driveExists ( sourcePath , knownDrives ) && ExternalFoldersManager . isExternalFolderPath ( sourcePath ) ) { externalFoldersManager . addFolder ( sourcePath , true ) ; } } private void copyFromOldChainedEntry ( ClasspathEntry resolvedEntry , ClasspathEntry chainedEntry ) { IPath path = chainedEntry . getSourceAttachmentPath ( ) ; if ( path != null ) { resolvedEntry . sourceAttachmentPath = path ; } path = chainedEntry . getSourceAttachmentRootPath ( ) ; if ( path != null ) { resolvedEntry . sourceAttachmentRootPath = path ; } IClasspathAttribute [ ] attributes = chainedEntry . getExtraAttributes ( ) ; if ( attributes != null ) { resolvedEntry . extraAttributes = attributes ; } } private boolean driveExists ( IPath sourcePath , Map knownDrives ) { String drive = sourcePath . getDevice ( ) ; if ( drive == null ) return true ; Boolean good = ( Boolean ) knownDrives . get ( drive ) ; if ( good == null ) { if ( new File ( drive ) . exists ( ) ) { knownDrives . put ( drive , Boolean . TRUE ) ; return true ; } else { knownDrives . put ( drive , Boolean . FALSE ) ; return false ; } } return good . booleanValue ( ) ; } public void resolveClasspath ( PerProjectInfo perProjectInfo , boolean usePreviousSession , boolean addClasspathChange ) throws JavaModelException { if ( CP_RESOLUTION_BP_LISTENERS != null ) breakpoint ( <NUM_LIT:1> , this ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; boolean isClasspathBeingResolved = manager . isClasspathBeingResolved ( this ) ; try { if ( ! isClasspathBeingResolved ) { manager . setClasspathBeingResolved ( this , true ) ; } IClasspathEntry [ ] [ ] classpath = new IClasspathEntry [ <NUM_LIT:2> ] [ ] ; int timeStamp ; synchronized ( perProjectInfo ) { classpath [ <NUM_LIT:0> ] = perProjectInfo . rawClasspath ; classpath [ <NUM_LIT:1> ] = perProjectInfo . referencedEntries ; if ( classpath [ <NUM_LIT:0> ] == null ) classpath = perProjectInfo . readAndCacheClasspath ( this ) ; timeStamp = perProjectInfo . rawTimeStamp ; } ResolvedClasspath result = resolveClasspath ( classpath [ <NUM_LIT:0> ] , classpath [ <NUM_LIT:1> ] , usePreviousSession , true ) ; if ( CP_RESOLUTION_BP_LISTENERS != null ) breakpoint ( <NUM_LIT:2> , this ) ; perProjectInfo . setResolvedClasspath ( result . resolvedClasspath , result . referencedEntries , result . rawReverseMap , result . rootPathToResolvedEntries , usePreviousSession ? PerProjectInfo . NEED_RESOLUTION : result . unresolvedEntryStatus , timeStamp , addClasspathChange ) ; } finally { if ( ! isClasspathBeingResolved ) { manager . setClasspathBeingResolved ( this , false ) ; } if ( CP_RESOLUTION_BP_LISTENERS != null ) breakpoint ( <NUM_LIT:3> , this ) ; } } public String rootID ( ) { return "<STR_LIT>" + this . project . getFullPath ( ) ; } public boolean writeFileEntries ( IClasspathEntry [ ] newClasspath , IClasspathEntry [ ] referencedEntries , IPath newOutputLocation ) throws JavaModelException { if ( ! this . project . isAccessible ( ) ) return false ; Map unknownElements = new HashMap ( ) ; IClasspathEntry [ ] [ ] fileEntries = readFileEntries ( unknownElements ) ; if ( fileEntries [ <NUM_LIT:0> ] != JavaProject . INVALID_CLASSPATH && areClasspathsEqual ( newClasspath , newOutputLocation , fileEntries [ <NUM_LIT:0> ] ) && ( referencedEntries == null || areClasspathsEqual ( referencedEntries , fileEntries [ <NUM_LIT:1> ] ) ) ) { return false ; } try { setSharedProperty ( JavaProject . CLASSPATH_FILENAME , encodeClasspath ( newClasspath , referencedEntries , newOutputLocation , true , unknownElements ) ) ; return true ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } public boolean writeFileEntries ( IClasspathEntry [ ] newClasspath , IPath newOutputLocation ) throws JavaModelException { return writeFileEntries ( newClasspath , ClasspathEntry . NO_ENTRIES , newOutputLocation ) ; } private void setJavaCommand ( IProjectDescription description , ICommand newCommand ) throws CoreException { ICommand [ ] oldBuildSpec = description . getBuildSpec ( ) ; int oldJavaCommandIndex = getJavaCommandIndex ( oldBuildSpec ) ; ICommand [ ] newCommands ; if ( oldJavaCommandIndex == - <NUM_LIT:1> ) { newCommands = new ICommand [ oldBuildSpec . length + <NUM_LIT:1> ] ; System . arraycopy ( oldBuildSpec , <NUM_LIT:0> , newCommands , <NUM_LIT:1> , oldBuildSpec . length ) ; newCommands [ <NUM_LIT:0> ] = newCommand ; } else { oldBuildSpec [ oldJavaCommandIndex ] = newCommand ; newCommands = oldBuildSpec ; } description . setBuildSpec ( newCommands ) ; this . project . setDescription ( description , null ) ; } public void setOption ( String optionName , String optionValue ) { IEclipsePreferences projectPreferences = getEclipsePreferences ( ) ; boolean modified = JavaModelManager . getJavaModelManager ( ) . storePreference ( optionName , optionValue , projectPreferences ) ; if ( modified ) { try { projectPreferences . flush ( ) ; } catch ( BackingStoreException e ) { } } } public void setOptions ( Map newOptions ) { IEclipsePreferences projectPreferences = getEclipsePreferences ( ) ; if ( projectPreferences == null ) return ; try { if ( newOptions == null ) { projectPreferences . clear ( ) ; } else { Iterator entries = newOptions . entrySet ( ) . iterator ( ) ; JavaModelManager javaModelManager = JavaModelManager . getJavaModelManager ( ) ; while ( entries . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) entries . next ( ) ; String key = ( String ) entry . getKey ( ) ; String value = ( String ) entry . getValue ( ) ; javaModelManager . storePreference ( key , value , projectPreferences ) ; } String [ ] pNames = projectPreferences . keys ( ) ; int ln = pNames . length ; for ( int i = <NUM_LIT:0> ; i < ln ; i ++ ) { String key = pNames [ i ] ; if ( ! newOptions . containsKey ( key ) ) { projectPreferences . remove ( key ) ; } } } projectPreferences . flush ( ) ; try { getPerProjectInfo ( ) . options = null ; } catch ( JavaModelException e ) { } } catch ( BackingStoreException e ) { } } public void setOutputLocation ( IPath path , IProgressMonitor monitor ) throws JavaModelException { if ( path == null ) { throw new IllegalArgumentException ( Messages . path_nullPath ) ; } if ( path . equals ( getOutputLocation ( ) ) ) { return ; } setRawClasspath ( getRawClasspath ( ) , path , monitor ) ; } public void setProject ( IProject project ) { this . project = project ; this . parent = JavaModelManager . getJavaModelManager ( ) . getJavaModel ( ) ; } public void setRawClasspath ( IClasspathEntry [ ] entries , boolean canModifyResources , IProgressMonitor monitor ) throws JavaModelException { setRawClasspath ( entries , getOutputLocation ( ) , canModifyResources , monitor ) ; } public void setRawClasspath ( IClasspathEntry [ ] newRawClasspath , IPath newOutputLocation , boolean canModifyResources , IProgressMonitor monitor ) throws JavaModelException { setRawClasspath ( newRawClasspath , null , newOutputLocation , canModifyResources , monitor ) ; } public void setRawClasspath ( IClasspathEntry [ ] entries , IPath outputLocation , IProgressMonitor monitor ) throws JavaModelException { setRawClasspath ( entries , outputLocation , true , monitor ) ; } public void setRawClasspath ( IClasspathEntry [ ] entries , IClasspathEntry [ ] referencedEntries , IPath outputLocation , IProgressMonitor monitor ) throws JavaModelException { setRawClasspath ( entries , referencedEntries , outputLocation , true , monitor ) ; } protected void setRawClasspath ( IClasspathEntry [ ] newRawClasspath , IClasspathEntry [ ] referencedEntries , IPath newOutputLocation , boolean canModifyResources , IProgressMonitor monitor ) throws JavaModelException { try { if ( newRawClasspath == null ) newRawClasspath = defaultClasspath ( ) ; SetClasspathOperation op = new SetClasspathOperation ( this , newRawClasspath , referencedEntries , newOutputLocation , canModifyResources ) ; op . runOperation ( monitor ) ; } catch ( JavaModelException e ) { JavaModelManager . getJavaModelManager ( ) . getDeltaProcessor ( ) . flush ( ) ; throw e ; } } public void setRawClasspath ( IClasspathEntry [ ] entries , IProgressMonitor monitor ) throws JavaModelException { setRawClasspath ( entries , getOutputLocation ( ) , true , monitor ) ; } public void setSharedProperty ( String key , String value ) throws CoreException { IFile rscFile = this . project . getFile ( key ) ; byte [ ] bytes = null ; try { bytes = value . getBytes ( org . eclipse . jdt . internal . compiler . util . Util . UTF_8 ) ; } catch ( UnsupportedEncodingException e ) { Util . log ( e , "<STR_LIT>" ) ; bytes = value . getBytes ( ) ; } InputStream inputStream = new ByteArrayInputStream ( bytes ) ; if ( rscFile . exists ( ) ) { if ( rscFile . isReadOnly ( ) ) { ResourcesPlugin . getWorkspace ( ) . validateEdit ( new IFile [ ] { rscFile } , null ) ; } rscFile . setContents ( inputStream , IResource . FORCE , null ) ; } else { rscFile . create ( inputStream , IResource . FORCE , null ) ; } } public void updateCycleParticipants ( ArrayList prereqChain , LinkedHashSet cycleParticipants , IWorkspaceRoot workspaceRoot , HashSet traversed , Map preferredClasspaths ) { IPath path = getPath ( ) ; prereqChain . add ( path ) ; traversed . add ( path ) ; try { IClasspathEntry [ ] classpath = null ; if ( preferredClasspaths != null ) classpath = ( IClasspathEntry [ ] ) preferredClasspaths . get ( this ) ; if ( classpath == null ) classpath = getResolvedClasspath ( ) ; for ( int i = <NUM_LIT:0> , length = classpath . length ; i < length ; i ++ ) { IClasspathEntry entry = classpath [ i ] ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_PROJECT ) { IPath prereqProjectPath = entry . getPath ( ) ; int index = cycleParticipants . contains ( prereqProjectPath ) ? <NUM_LIT:0> : prereqChain . indexOf ( prereqProjectPath ) ; if ( index >= <NUM_LIT:0> ) { for ( int size = prereqChain . size ( ) ; index < size ; index ++ ) { cycleParticipants . add ( prereqChain . get ( index ) ) ; } } else { if ( ! traversed . contains ( prereqProjectPath ) ) { IResource member = workspaceRoot . findMember ( prereqProjectPath ) ; if ( member != null && member . getType ( ) == IResource . PROJECT ) { JavaProject javaProject = ( JavaProject ) JavaCore . create ( ( IProject ) member ) ; javaProject . updateCycleParticipants ( prereqChain , cycleParticipants , workspaceRoot , traversed , preferredClasspaths ) ; } } } } } } catch ( JavaModelException e ) { } prereqChain . remove ( path ) ; } private void updatePreferences ( IEclipsePreferences preferences ) { IEclipsePreferences oldPreferences = loadPreferences ( ) ; if ( oldPreferences != null ) { try { String [ ] propertyNames = oldPreferences . childrenNames ( ) ; for ( int i = <NUM_LIT:0> ; i < propertyNames . length ; i ++ ) { String propertyName = propertyNames [ i ] ; String propertyValue = oldPreferences . get ( propertyName , "<STR_LIT>" ) ; if ( ! "<STR_LIT>" . equals ( propertyValue ) ) { preferences . put ( propertyName , propertyValue ) ; } } preferences . flush ( ) ; } catch ( BackingStoreException e ) { } } } protected IStatus validateExistence ( IResource underlyingResource ) { try { if ( ! ( ( IProject ) underlyingResource ) . hasNature ( JavaCore . NATURE_ID ) ) return newDoesNotExistStatus ( ) ; } catch ( CoreException e ) { return newDoesNotExistStatus ( ) ; } return JavaModelStatus . VERIFIED_OK ; } } </s>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.