text
stringlengths 30
1.67M
|
|---|
<s> package org . eclipse . jdt . internal . core . util ; import java . net . URI ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . batch . CompilationUnit ; public class ResourceCompilationUnit extends CompilationUnit { private IFile file ; public ResourceCompilationUnit ( IFile file , URI location ) { super ( null , location == null ? file . getFullPath ( ) . toString ( ) : location . getPath ( ) , null ) ; this . file = file ; } public char [ ] getContents ( ) { if ( this . contents != null ) return this . contents ; try { return Util . getResourceContentsAsCharArray ( this . file ) ; } catch ( CoreException e ) { return CharOperation . NO_CHAR ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core . util ; import org . eclipse . jdt . core . util . ClassFormatException ; import org . eclipse . jdt . core . util . IConstantPool ; import org . eclipse . jdt . core . util . ILineNumberAttribute ; public class LineNumberAttribute extends ClassFileAttribute implements ILineNumberAttribute { private static final int [ ] [ ] NO_ENTRIES = new int [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] ; private int lineNumberTableLength ; private int [ ] [ ] lineNumberTable ; public LineNumberAttribute ( byte [ ] classFileBytes , IConstantPool constantPool , int offset ) throws ClassFormatException { super ( classFileBytes , constantPool , offset ) ; final int length = u2At ( classFileBytes , <NUM_LIT:6> , offset ) ; this . lineNumberTableLength = length ; if ( length != <NUM_LIT:0> ) { this . lineNumberTable = new int [ length ] [ <NUM_LIT:2> ] ; int readOffset = <NUM_LIT:8> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { this . lineNumberTable [ i ] [ <NUM_LIT:0> ] = u2At ( classFileBytes , readOffset , offset ) ; this . lineNumberTable [ i ] [ <NUM_LIT:1> ] = u2At ( classFileBytes , readOffset + <NUM_LIT:2> , offset ) ; readOffset += <NUM_LIT:4> ; } } else { this . lineNumberTable = NO_ENTRIES ; } } public int [ ] [ ] getLineNumberTable ( ) { return this . lineNumberTable ; } public int getLineNumberTableLength ( ) { return this . lineNumberTableLength ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . util ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . Wildcard ; public class BindingKeyParser { int keyStart ; static final char C_THROWN = '<CHAR_LIT>' ; static class Scanner { static final int PACKAGE = <NUM_LIT:0> ; static final int TYPE = <NUM_LIT:1> ; static final int FIELD = <NUM_LIT:2> ; static final int METHOD = <NUM_LIT:3> ; static final int ARRAY = <NUM_LIT:4> ; static final int LOCAL_VAR = <NUM_LIT:5> ; static final int FLAGS = <NUM_LIT:6> ; static final int WILDCARD = <NUM_LIT:7> ; static final int CAPTURE = <NUM_LIT:8> ; static final int BASE_TYPE = <NUM_LIT:9> ; static final int END = <NUM_LIT:10> ; static final int START = - <NUM_LIT:1> ; int index = <NUM_LIT:0> , start ; char [ ] source ; int token = START ; Scanner ( char [ ] source ) { this . source = source ; } char [ ] getTokenSource ( ) { int length = this . index - this . start ; char [ ] result = new char [ length ] ; System . arraycopy ( this . source , this . start , result , <NUM_LIT:0> , length ) ; return result ; } boolean isAtAnnotationStart ( ) { return this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT>' ; } boolean isAtCaptureStart ( ) { return this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT>' ; } boolean isAtFieldOrMethodStart ( ) { return this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT:.>' ; } boolean isAtLocalVariableStart ( ) { return this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT>' ; } boolean isAtMemberTypeStart ( ) { return this . index < this . source . length && ( this . source [ this . index ] == '<CHAR_LIT>' || ( this . source [ this . index ] == '<CHAR_LIT:.>' && this . source [ this . index - <NUM_LIT:1> ] == '<CHAR_LIT:>>' ) ) ; } boolean isAtParametersEnd ( ) { return this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT:>>' ; } boolean isAtParametersStart ( ) { char currentChar ; return this . index > <NUM_LIT:0> && this . index < this . source . length && ( ( currentChar = this . source [ this . index ] ) == '<CHAR_LIT>' || currentChar == '<CHAR_LIT>' ) ; } boolean isAtRawTypeEnd ( ) { return this . index > <NUM_LIT:0> && this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT:>>' ; } boolean isAtSecondaryTypeStart ( ) { return this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT>' ; } boolean isAtWildcardStart ( ) { return this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT>' ; } boolean isAtTypeParameterStart ( ) { return this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT>' ; } boolean isAtTypeArgumentStart ( ) { return this . index < this . source . length && "<STR_LIT>" . indexOf ( this . source [ this . index ] ) != - <NUM_LIT:1> ; } boolean isAtThrownStart ( ) { return this . index < this . source . length && this . source [ this . index ] == C_THROWN ; } boolean isAtTypeVariableStart ( ) { return this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT::>' ; } boolean isAtTypeWithCaptureStart ( ) { return this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT>' ; } int nextToken ( ) { int previousTokenEnd = this . index ; this . start = this . index ; int dollarIndex = - <NUM_LIT:1> ; int length = this . source . length ; while ( this . index <= length ) { char currentChar = this . index == length ? Character . MIN_VALUE : this . source [ this . index ] ; switch ( currentChar ) { case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT:Z>' : if ( this . index == previousTokenEnd && ( this . index == <NUM_LIT:0> || this . source [ this . index - <NUM_LIT:1> ] != '<CHAR_LIT:.>' ) ) { this . index ++ ; this . token = BASE_TYPE ; return this . token ; } break ; case '<CHAR_LIT>' : case '<CHAR_LIT>' : if ( this . index == previousTokenEnd && ( this . index == <NUM_LIT:0> || this . source [ this . index - <NUM_LIT:1> ] != '<CHAR_LIT:.>' ) ) { this . start = this . index + <NUM_LIT:1> ; dollarIndex = - <NUM_LIT:1> ; } break ; case '<CHAR_LIT:;>' : if ( this . index == previousTokenEnd ) { this . start = this . index + <NUM_LIT:1> ; dollarIndex = - <NUM_LIT:1> ; previousTokenEnd = this . start ; } else { if ( dollarIndex != - <NUM_LIT:1> ) this . index = dollarIndex ; this . token = TYPE ; return this . token ; } break ; case '<CHAR_LIT>' : if ( this . index == previousTokenEnd ) { this . start = this . index + <NUM_LIT:1> ; dollarIndex = - <NUM_LIT:1> ; } else { if ( dollarIndex == - <NUM_LIT:1> ) { dollarIndex = this . index ; break ; } this . index = dollarIndex ; this . token = TYPE ; return this . token ; } break ; case '<CHAR_LIT>' : if ( this . index == previousTokenEnd ) { this . start = this . index + <NUM_LIT:1> ; dollarIndex = - <NUM_LIT:1> ; } else { this . token = TYPE ; return this . token ; } break ; case '<CHAR_LIT:.>' : case '<CHAR_LIT>' : case '<CHAR_LIT::>' : case '<CHAR_LIT:>>' : case '<CHAR_LIT>' : this . start = this . index + <NUM_LIT:1> ; dollarIndex = - <NUM_LIT:1> ; previousTokenEnd = this . start ; break ; case '<CHAR_LIT:[>' : while ( this . index < length && this . source [ this . index ] == '<CHAR_LIT:[>' ) this . index ++ ; this . token = ARRAY ; return this . token ; case '<CHAR_LIT>' : if ( this . start > <NUM_LIT:0> ) { switch ( this . source [ this . start - <NUM_LIT:1> ] ) { case '<CHAR_LIT:.>' : if ( this . source [ this . start - <NUM_LIT:2> ] == '<CHAR_LIT:>>' ) { if ( dollarIndex != - <NUM_LIT:1> ) this . index = dollarIndex ; this . token = TYPE ; } else { this . token = METHOD ; } return this . token ; default : if ( this . index == previousTokenEnd ) { this . start = this . index + <NUM_LIT:1> ; dollarIndex = - <NUM_LIT:1> ; previousTokenEnd = this . start ; } else { if ( dollarIndex != - <NUM_LIT:1> ) this . index = dollarIndex ; this . token = TYPE ; return this . token ; } } } break ; case '<CHAR_LIT:(>' : this . token = METHOD ; return this . token ; case '<CHAR_LIT:)>' : if ( this . token == TYPE ) { this . token = FIELD ; return this . token ; } this . start = this . index + <NUM_LIT:1> ; dollarIndex = - <NUM_LIT:1> ; previousTokenEnd = this . start ; break ; case '<CHAR_LIT>' : if ( this . index == previousTokenEnd ) { this . start = this . index + <NUM_LIT:1> ; dollarIndex = - <NUM_LIT:1> ; previousTokenEnd = this . start ; } else { this . token = LOCAL_VAR ; return this . token ; } break ; case Character . MIN_VALUE : switch ( this . token ) { case START : this . token = PACKAGE ; break ; case METHOD : case LOCAL_VAR : this . token = LOCAL_VAR ; break ; case TYPE : if ( this . index > this . start && this . source [ this . start - <NUM_LIT:1> ] == '<CHAR_LIT:.>' ) this . token = FIELD ; else this . token = END ; break ; case WILDCARD : this . token = TYPE ; break ; default : this . token = END ; break ; } return this . token ; case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT:->' : this . index ++ ; this . token = WILDCARD ; return this . token ; case '<CHAR_LIT>' : case '<CHAR_LIT>' : this . index ++ ; this . token = CAPTURE ; return this . token ; } this . index ++ ; } this . token = END ; return this . token ; } void skipMethodSignature ( ) { this . start = this . index ; int braket = <NUM_LIT:0> ; while ( this . index < this . source . length ) { switch ( this . source [ this . index ] ) { case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case C_THROWN : return ; case '<CHAR_LIT::>' : if ( braket == <NUM_LIT:0> ) return ; break ; case '<CHAR_LIT>' : case '<CHAR_LIT:(>' : braket ++ ; break ; case '<CHAR_LIT:>>' : case '<CHAR_LIT:)>' : braket -- ; break ; } this . index ++ ; } } void skipRank ( ) { this . start = this . index ; while ( this . index < this . source . length && "<STR_LIT>" . indexOf ( this . source [ this . index ] ) != - <NUM_LIT:1> ) this . index ++ ; } void skipThrownStart ( ) { while ( this . index < this . source . length && this . source [ this . index ] == C_THROWN ) this . index ++ ; } void skipParametersStart ( ) { while ( this . index < this . source . length && ( this . source [ this . index ] == '<CHAR_LIT>' || this . source [ this . index ] == '<CHAR_LIT>' ) ) this . index ++ ; } void skipParametersEnd ( ) { while ( this . index < this . source . length && this . source [ this . index ] != '<CHAR_LIT:>>' ) this . index ++ ; this . index ++ ; } void skipTypeEnd ( ) { if ( this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT:;>' ) this . index ++ ; } void skipRankStart ( ) { if ( this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT>' ) this . index ++ ; } void skipRankEnd ( ) { if ( this . index < this . source . length && this . source [ this . index ] == '<CHAR_LIT:}>' ) this . index ++ ; this . start = this . index ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; switch ( this . token ) { case START : buffer . append ( "<STR_LIT>" ) ; break ; case PACKAGE : buffer . append ( "<STR_LIT>" ) ; break ; case TYPE : buffer . append ( "<STR_LIT>" ) ; break ; case FIELD : buffer . append ( "<STR_LIT>" ) ; break ; case METHOD : buffer . append ( "<STR_LIT>" ) ; break ; case ARRAY : buffer . append ( "<STR_LIT>" ) ; break ; case LOCAL_VAR : buffer . append ( "<STR_LIT>" ) ; break ; case FLAGS : buffer . append ( "<STR_LIT>" ) ; break ; case WILDCARD : buffer . append ( "<STR_LIT>" ) ; break ; case CAPTURE : buffer . append ( "<STR_LIT>" ) ; break ; case BASE_TYPE : buffer . append ( "<STR_LIT>" ) ; break ; case END : buffer . append ( "<STR_LIT>" ) ; break ; } if ( this . index < <NUM_LIT:0> ) { buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . source ) ; } else if ( this . index <= this . source . length ) { buffer . append ( this . source , <NUM_LIT:0> , this . start ) ; buffer . append ( '<CHAR_LIT>' ) ; if ( this . start <= this . index ) { buffer . append ( this . source , this . start , this . index - this . start ) ; buffer . append ( '<CHAR_LIT>' ) ; buffer . append ( this . source , this . index , this . source . length - this . index ) ; } else { buffer . append ( '<CHAR_LIT>' ) ; buffer . append ( this . source , this . start , this . source . length - this . start ) ; } } else { buffer . append ( this . source ) ; buffer . append ( "<STR_LIT>" ) ; } return buffer . toString ( ) ; } } private boolean parsingPaused ; private Scanner scanner ; private boolean hasTypeName = true ; private boolean isMalformed ; private boolean isParsingThrownExceptions = false ; public BindingKeyParser ( BindingKeyParser parser ) { this ( "<STR_LIT>" ) ; this . scanner = parser . scanner ; } public BindingKeyParser ( String key ) { this . scanner = new Scanner ( key . toCharArray ( ) ) ; } public void consumeAnnotation ( ) { } public void consumeArrayDimension ( char [ ] brakets ) { } public void consumeBaseType ( char [ ] baseTypeSig ) { } public void consumeCapture ( int position ) { } public void consumeException ( ) { } public void consumeField ( char [ ] fieldName ) { } public void consumeParameterizedGenericMethod ( ) { } public void consumeLocalType ( char [ ] uniqueKey ) { } public void consumeLocalVar ( char [ ] varName , int occurrenceCount ) { } public void consumeMethod ( char [ ] selector , char [ ] signature ) { } public void consumeModifiers ( char [ ] modifiers ) { } public void consumeNonGenericType ( ) { } public void consumeMemberType ( char [ ] simpleTypeName ) { } public void consumePackage ( char [ ] pkgName ) { } public void consumeParameterizedType ( char [ ] simpleTypeName , boolean isRaw ) { } public void consumeParser ( BindingKeyParser parser ) { } public void consumeRawType ( ) { } public void consumeScope ( int scopeNumber ) { } public void consumeSecondaryType ( char [ ] simpleTypeName ) { } public void consumeFullyQualifiedName ( char [ ] fullyQualifiedName ) { } public void consumeKey ( ) { } public void consumeTopLevelType ( ) { } public void consumeType ( ) { } public void consumeTypeParameter ( char [ ] typeParameterName ) { } public void consumeTypeVariable ( char [ ] position , char [ ] typeVariableName ) { } public void consumeTypeWithCapture ( ) { } public void consumeWildCard ( int kind ) { } public void consumeWildcardRank ( int rank ) { } public String getKey ( ) { return new String ( this . scanner . source ) ; } public boolean hasTypeName ( ) { return this . hasTypeName ; } public void malformedKey ( ) { this . isMalformed = true ; } public BindingKeyParser newParser ( ) { return new BindingKeyParser ( this ) ; } public void parse ( ) { parse ( false ) ; } public void parse ( boolean pauseAfterFullyQualifiedName ) { if ( ! this . parsingPaused ) { parseFullyQualifiedName ( ) ; parseSecondaryType ( ) ; if ( pauseAfterFullyQualifiedName ) { this . parsingPaused = true ; return ; } } if ( ! hasTypeName ( ) ) { consumeKey ( ) ; return ; } consumeTopLevelType ( ) ; parseInnerType ( ) ; if ( this . scanner . isAtParametersStart ( ) ) { this . scanner . skipParametersStart ( ) ; if ( this . scanner . isAtTypeParameterStart ( ) ) { parseGenericType ( ) ; this . scanner . skipParametersEnd ( ) ; parseInnerType ( ) ; } else if ( this . scanner . isAtTypeArgumentStart ( ) ) parseParameterizedType ( null , false ) ; else if ( this . scanner . isAtRawTypeEnd ( ) ) parseRawType ( ) ; } else { consumeNonGenericType ( ) ; } consumeType ( ) ; this . scanner . skipTypeEnd ( ) ; if ( this . scanner . isAtFieldOrMethodStart ( ) ) { switch ( this . scanner . nextToken ( ) ) { case Scanner . FIELD : parseField ( ) ; if ( this . scanner . isAtAnnotationStart ( ) ) { parseAnnotation ( ) ; } return ; case Scanner . METHOD : parseMethod ( ) ; if ( this . scanner . isAtLocalVariableStart ( ) ) { parseLocalVariable ( ) ; } else if ( this . scanner . isAtTypeVariableStart ( ) ) { parseTypeVariable ( ) ; } else if ( this . scanner . isAtAnnotationStart ( ) ) { parseAnnotation ( ) ; } break ; default : malformedKey ( ) ; return ; } } else if ( ! this . isParsingThrownExceptions && this . scanner . isAtTypeVariableStart ( ) ) { parseTypeVariable ( ) ; } else if ( this . scanner . isAtWildcardStart ( ) ) { parseWildcard ( ) ; } else if ( this . scanner . isAtTypeWithCaptureStart ( ) ) { parseTypeWithCapture ( ) ; } else if ( this . scanner . isAtAnnotationStart ( ) ) { parseAnnotation ( ) ; } consumeKey ( ) ; } private void parseFullyQualifiedName ( ) { if ( this . scanner . isAtCaptureStart ( ) ) { parseCapture ( ) ; this . hasTypeName = false ; return ; } switch ( this . scanner . nextToken ( ) ) { case Scanner . PACKAGE : this . keyStart = <NUM_LIT:0> ; consumePackage ( this . scanner . getTokenSource ( ) ) ; this . hasTypeName = false ; return ; case Scanner . TYPE : this . keyStart = this . scanner . start - <NUM_LIT:1> ; consumeFullyQualifiedName ( this . scanner . getTokenSource ( ) ) ; break ; case Scanner . BASE_TYPE : this . keyStart = this . scanner . start - <NUM_LIT:1> ; consumeBaseType ( this . scanner . getTokenSource ( ) ) ; this . hasTypeName = false ; break ; case Scanner . ARRAY : this . keyStart = this . scanner . start ; consumeArrayDimension ( this . scanner . getTokenSource ( ) ) ; switch ( this . scanner . nextToken ( ) ) { case Scanner . TYPE : consumeFullyQualifiedName ( this . scanner . getTokenSource ( ) ) ; break ; case Scanner . BASE_TYPE : consumeBaseType ( this . scanner . getTokenSource ( ) ) ; this . hasTypeName = false ; break ; default : malformedKey ( ) ; return ; } break ; default : malformedKey ( ) ; return ; } } private void parseParameterizedMethod ( ) { this . scanner . skipParametersStart ( ) ; while ( ! this . scanner . isAtParametersEnd ( ) && ! this . isMalformed ) { parseTypeArgument ( ) ; } consumeParameterizedGenericMethod ( ) ; } private void parseGenericType ( ) { while ( ! this . scanner . isAtParametersEnd ( ) && ! this . isMalformed ) { if ( this . scanner . nextToken ( ) != Scanner . TYPE ) { malformedKey ( ) ; return ; } consumeTypeParameter ( this . scanner . getTokenSource ( ) ) ; this . scanner . skipTypeEnd ( ) ; } } private void parseInnerType ( ) { if ( ! this . scanner . isAtMemberTypeStart ( ) || this . scanner . nextToken ( ) != Scanner . TYPE ) return ; char [ ] typeName = this . scanner . getTokenSource ( ) ; if ( typeName . length == <NUM_LIT:0> ) return ; if ( Character . isDigit ( typeName [ <NUM_LIT:0> ] ) ) { int nextToken = Scanner . TYPE ; while ( this . scanner . isAtMemberTypeStart ( ) && ! this . isMalformed ) nextToken = this . scanner . nextToken ( ) ; typeName = nextToken == Scanner . END ? this . scanner . source : CharOperation . subarray ( this . scanner . source , this . keyStart , this . scanner . index + <NUM_LIT:1> ) ; consumeLocalType ( typeName ) ; } else { consumeMemberType ( typeName ) ; parseInnerType ( ) ; } } private void parseLocalVariable ( ) { if ( this . scanner . nextToken ( ) != Scanner . LOCAL_VAR ) { malformedKey ( ) ; return ; } char [ ] varName = this . scanner . getTokenSource ( ) ; if ( Character . isDigit ( varName [ <NUM_LIT:0> ] ) ) { int index = Integer . parseInt ( new String ( varName ) ) ; consumeScope ( index ) ; if ( ! this . scanner . isAtLocalVariableStart ( ) ) { malformedKey ( ) ; return ; } parseLocalVariable ( ) ; } else { int occurrenceCount = <NUM_LIT:0> ; if ( this . scanner . isAtLocalVariableStart ( ) ) { if ( this . scanner . nextToken ( ) != Scanner . LOCAL_VAR ) { malformedKey ( ) ; return ; } char [ ] occurrence = this . scanner . getTokenSource ( ) ; occurrenceCount = Integer . parseInt ( new String ( occurrence ) ) ; } consumeLocalVar ( varName , occurrenceCount ) ; } } private void parseMethod ( ) { char [ ] selector = this . scanner . getTokenSource ( ) ; this . scanner . skipMethodSignature ( ) ; char [ ] signature = this . scanner . getTokenSource ( ) ; consumeMethod ( selector , signature ) ; if ( this . scanner . isAtThrownStart ( ) ) { parseThrownExceptions ( ) ; } if ( this . scanner . isAtParametersStart ( ) ) parseParameterizedMethod ( ) ; } private void parseAnnotation ( ) { int token = this . scanner . token ; BindingKeyParser parser = newParser ( ) ; parser . parse ( ) ; consumeParser ( parser ) ; consumeAnnotation ( ) ; this . isMalformed = parser . isMalformed ; this . scanner . token = token ; } private void parseCapture ( ) { if ( this . scanner . nextToken ( ) != Scanner . CAPTURE ) return ; parseCaptureWildcard ( ) ; if ( this . scanner . nextToken ( ) != Scanner . TYPE ) { malformedKey ( ) ; return ; } char [ ] positionChars = this . scanner . getTokenSource ( ) ; int position = Integer . parseInt ( new String ( positionChars ) ) ; consumeCapture ( position ) ; this . scanner . skipTypeEnd ( ) ; } private void parseCaptureWildcard ( ) { int token = this . scanner . token ; BindingKeyParser parser = newParser ( ) ; parser . parse ( ) ; consumeParser ( parser ) ; this . isMalformed = parser . isMalformed ; this . scanner . token = token ; } private void parseField ( ) { char [ ] fieldName = this . scanner . getTokenSource ( ) ; parseReturnType ( ) ; consumeField ( fieldName ) ; } private void parseThrownExceptions ( ) { int token = this . scanner . token ; while ( this . scanner . isAtThrownStart ( ) && ! this . isMalformed ) { this . scanner . skipThrownStart ( ) ; BindingKeyParser parser = newParser ( ) ; parser . isParsingThrownExceptions = true ; parser . parse ( ) ; consumeParser ( parser ) ; consumeException ( ) ; this . isMalformed = parser . isMalformed ; } this . scanner . token = token ; } private void parseParameterizedType ( char [ ] typeName , boolean isRaw ) { if ( ! isRaw ) { while ( ! this . scanner . isAtParametersEnd ( ) && ! this . isMalformed ) { parseTypeArgument ( ) ; } } this . scanner . skipParametersEnd ( ) ; consumeParameterizedType ( typeName , isRaw ) ; this . scanner . skipTypeEnd ( ) ; if ( this . scanner . isAtMemberTypeStart ( ) && this . scanner . nextToken ( ) == Scanner . TYPE ) { typeName = this . scanner . getTokenSource ( ) ; if ( this . scanner . isAtParametersStart ( ) ) { this . scanner . skipParametersStart ( ) ; parseParameterizedType ( typeName , this . scanner . isAtRawTypeEnd ( ) ) ; } else consumeParameterizedType ( typeName , true ) ; } } private void parseRawType ( ) { this . scanner . skipParametersEnd ( ) ; consumeRawType ( ) ; this . scanner . skipTypeEnd ( ) ; if ( this . scanner . isAtMemberTypeStart ( ) && this . scanner . nextToken ( ) == Scanner . TYPE ) { char [ ] typeName = this . scanner . getTokenSource ( ) ; if ( this . scanner . isAtParametersStart ( ) ) { this . scanner . skipParametersStart ( ) ; parseParameterizedType ( typeName , this . scanner . isAtRawTypeEnd ( ) ) ; } else consumeParameterizedType ( typeName , true ) ; } } private void parseReturnType ( ) { this . scanner . index ++ ; int token = this . scanner . token ; BindingKeyParser parser = newParser ( ) ; parser . parse ( ) ; consumeParser ( parser ) ; this . isMalformed = parser . isMalformed ; this . scanner . token = token ; } private void parseSecondaryType ( ) { if ( ! this . scanner . isAtSecondaryTypeStart ( ) || this . scanner . nextToken ( ) != Scanner . TYPE ) return ; consumeSecondaryType ( this . scanner . getTokenSource ( ) ) ; } private void parseTypeArgument ( ) { int token = this . scanner . token ; BindingKeyParser parser = newParser ( ) ; parser . parse ( ) ; consumeParser ( parser ) ; this . isMalformed = parser . isMalformed ; this . scanner . token = token ; } private void parseTypeWithCapture ( ) { if ( this . scanner . nextToken ( ) != Scanner . CAPTURE ) return ; int token = this . scanner . token ; BindingKeyParser parser = newParser ( ) ; parser . parse ( ) ; consumeParser ( parser ) ; consumeTypeWithCapture ( ) ; this . isMalformed = parser . isMalformed ; this . scanner . token = token ; } private void parseTypeVariable ( ) { if ( this . scanner . nextToken ( ) != Scanner . TYPE ) { malformedKey ( ) ; return ; } char [ ] typeVariableName = this . scanner . getTokenSource ( ) ; char [ ] position ; int length = typeVariableName . length ; if ( length > <NUM_LIT:0> && Character . isDigit ( typeVariableName [ <NUM_LIT:0> ] ) ) { int firstT = CharOperation . indexOf ( '<CHAR_LIT>' , typeVariableName ) ; position = CharOperation . subarray ( typeVariableName , <NUM_LIT:0> , firstT ) ; typeVariableName = CharOperation . subarray ( typeVariableName , firstT + <NUM_LIT:1> , typeVariableName . length ) ; } else { position = CharOperation . NO_CHAR ; } consumeTypeVariable ( position , typeVariableName ) ; this . scanner . skipTypeEnd ( ) ; } private void parseWildcard ( ) { parseWildcardRank ( ) ; if ( this . scanner . nextToken ( ) != Scanner . WILDCARD ) return ; char [ ] source = this . scanner . getTokenSource ( ) ; if ( source . length == <NUM_LIT:0> ) { malformedKey ( ) ; return ; } int kind = - <NUM_LIT:1> ; switch ( source [ <NUM_LIT:0> ] ) { case '<CHAR_LIT>' : kind = Wildcard . UNBOUND ; break ; case '<CHAR_LIT>' : kind = Wildcard . EXTENDS ; break ; case '<CHAR_LIT:->' : kind = Wildcard . SUPER ; break ; } if ( kind == - <NUM_LIT:1> ) { malformedKey ( ) ; return ; } if ( kind != Wildcard . UNBOUND ) parseWildcardBound ( ) ; consumeWildCard ( kind ) ; } private void parseWildcardRank ( ) { this . scanner . skipRankStart ( ) ; this . scanner . skipRank ( ) ; char [ ] source = this . scanner . getTokenSource ( ) ; consumeWildcardRank ( Integer . parseInt ( new String ( source ) ) ) ; this . scanner . skipRankEnd ( ) ; } private void parseWildcardBound ( ) { int token = this . scanner . token ; BindingKeyParser parser = newParser ( ) ; parser . parse ( ) ; consumeParser ( parser ) ; this . isMalformed = parser . isMalformed ; this . scanner . token = token ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . util ; import org . eclipse . jdt . core . util . ClassFormatException ; import org . eclipse . jdt . core . util . IAnnotation ; import org . eclipse . jdt . core . util . IConstantPool ; import org . eclipse . jdt . core . util . IParameterAnnotation ; public class ParameterAnnotation extends ClassFileStruct implements IParameterAnnotation { private static final IAnnotation [ ] NO_ENTRIES = new IAnnotation [ <NUM_LIT:0> ] ; private int annotationsNumber ; private IAnnotation [ ] annotations ; private int readOffset ; public ParameterAnnotation ( byte [ ] classFileBytes , IConstantPool constantPool , int offset ) throws ClassFormatException { final int length = u2At ( classFileBytes , <NUM_LIT:0> , offset ) ; this . readOffset = <NUM_LIT:2> ; this . annotationsNumber = length ; if ( length != <NUM_LIT:0> ) { this . annotations = new IAnnotation [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { Annotation annotation = new Annotation ( classFileBytes , constantPool , offset + this . readOffset ) ; this . annotations [ i ] = annotation ; this . readOffset += annotation . sizeInBytes ( ) ; } } else { this . annotations = NO_ENTRIES ; } } int sizeInBytes ( ) { return this . readOffset ; } public IAnnotation [ ] getAnnotations ( ) { return this . annotations ; } public int getAnnotationsNumber ( ) { return this . annotationsNumber ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . util ; import java . util . HashMap ; import java . util . HashSet ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . IClassFile ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IPackageFragmentRoot ; 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 . core . search . IJavaSearchScope ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . MethodScope ; import org . eclipse . jdt . internal . compiler . lookup . Scope ; import org . eclipse . jdt . internal . core . * ; import org . eclipse . jdt . internal . core . search . AbstractJavaSearchScope ; import org . eclipse . jdt . internal . core . util . Util ; public class HandleFactory { private String lastPkgFragmentRootPath ; private PackageFragmentRoot lastPkgFragmentRoot ; private HashtableOfArrayToObject packageHandles ; private JavaModel javaModel ; public HandleFactory ( ) { this . javaModel = JavaModelManager . getJavaModelManager ( ) . getJavaModel ( ) ; } public Openable createOpenable ( String resourcePath , IJavaSearchScope scope ) { int separatorIndex ; if ( ( separatorIndex = resourcePath . indexOf ( IJavaSearchScope . JAR_FILE_ENTRY_SEPARATOR ) ) > - <NUM_LIT:1> ) { int rootPathLength ; if ( this . lastPkgFragmentRootPath == null || ( rootPathLength = this . lastPkgFragmentRootPath . length ( ) ) != resourcePath . length ( ) || ! resourcePath . regionMatches ( <NUM_LIT:0> , this . lastPkgFragmentRootPath , <NUM_LIT:0> , rootPathLength ) ) { String jarPath = resourcePath . substring ( <NUM_LIT:0> , separatorIndex ) ; PackageFragmentRoot root = getJarPkgFragmentRoot ( resourcePath , separatorIndex , jarPath , scope ) ; if ( root == null ) return null ; this . lastPkgFragmentRootPath = jarPath ; this . lastPkgFragmentRoot = root ; this . packageHandles = new HashtableOfArrayToObject ( <NUM_LIT:5> ) ; } String classFilePath = resourcePath . substring ( separatorIndex + <NUM_LIT:1> ) ; String [ ] simpleNames = new Path ( classFilePath ) . segments ( ) ; String [ ] pkgName ; int length = simpleNames . length - <NUM_LIT:1> ; if ( length > <NUM_LIT:0> ) { pkgName = new String [ length ] ; System . arraycopy ( simpleNames , <NUM_LIT:0> , pkgName , <NUM_LIT:0> , length ) ; } else { pkgName = CharOperation . NO_STRINGS ; } IPackageFragment pkgFragment = ( IPackageFragment ) this . packageHandles . get ( pkgName ) ; if ( pkgFragment == null ) { pkgFragment = this . lastPkgFragmentRoot . getPackageFragment ( pkgName ) ; this . packageHandles . put ( pkgName , pkgFragment ) ; } IClassFile classFile = pkgFragment . getClassFile ( simpleNames [ length ] ) ; return ( Openable ) classFile ; } else { int rootPathLength = - <NUM_LIT:1> ; if ( this . lastPkgFragmentRootPath == null || ! ( resourcePath . startsWith ( this . lastPkgFragmentRootPath ) && ! org . eclipse . jdt . internal . compiler . util . Util . isExcluded ( resourcePath . toCharArray ( ) , this . lastPkgFragmentRoot . fullInclusionPatternChars ( ) , this . lastPkgFragmentRoot . fullExclusionPatternChars ( ) , false ) && ( rootPathLength = this . lastPkgFragmentRootPath . length ( ) ) > <NUM_LIT:0> && resourcePath . charAt ( rootPathLength ) == '<CHAR_LIT:/>' ) ) { PackageFragmentRoot root = getPkgFragmentRoot ( resourcePath ) ; if ( root == null ) return null ; this . lastPkgFragmentRoot = root ; this . lastPkgFragmentRootPath = this . lastPkgFragmentRoot . internalPath ( ) . toString ( ) ; this . packageHandles = new HashtableOfArrayToObject ( <NUM_LIT:5> ) ; } resourcePath = resourcePath . substring ( this . lastPkgFragmentRootPath . length ( ) + <NUM_LIT:1> ) ; String [ ] simpleNames = new Path ( resourcePath ) . segments ( ) ; String [ ] pkgName ; int length = simpleNames . length - <NUM_LIT:1> ; if ( length > <NUM_LIT:0> ) { pkgName = new String [ length ] ; System . arraycopy ( simpleNames , <NUM_LIT:0> , pkgName , <NUM_LIT:0> , length ) ; } else { pkgName = CharOperation . NO_STRINGS ; } IPackageFragment pkgFragment = ( IPackageFragment ) this . packageHandles . get ( pkgName ) ; if ( pkgFragment == null ) { pkgFragment = this . lastPkgFragmentRoot . getPackageFragment ( pkgName ) ; this . packageHandles . put ( pkgName , pkgFragment ) ; } String simpleName = simpleNames [ length ] ; if ( org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( simpleName ) ) { ICompilationUnit unit = pkgFragment . getCompilationUnit ( simpleName ) ; return ( Openable ) unit ; } else if ( org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( simpleName ) ) { IClassFile classFile = pkgFragment . getClassFile ( simpleName ) ; return ( Openable ) classFile ; } return null ; } } public IJavaElement createElement ( ClassScope scope , ICompilationUnit unit , HashSet existingElements , HashMap knownScopes ) { return createElement ( scope , scope . referenceContext . sourceStart , unit , existingElements , knownScopes ) ; } private IJavaElement createElement ( Scope scope , int elementPosition , ICompilationUnit unit , HashSet existingElements , HashMap knownScopes ) { IJavaElement newElement = ( IJavaElement ) knownScopes . get ( scope ) ; if ( newElement != null ) return newElement ; switch ( scope . kind ) { case Scope . COMPILATION_UNIT_SCOPE : newElement = unit ; break ; case Scope . CLASS_SCOPE : IJavaElement parentElement = createElement ( scope . parent , elementPosition , unit , existingElements , knownScopes ) ; switch ( parentElement . getElementType ( ) ) { case IJavaElement . COMPILATION_UNIT : newElement = ( ( ICompilationUnit ) parentElement ) . getType ( new String ( scope . enclosingSourceType ( ) . sourceName ) ) ; break ; case IJavaElement . TYPE : newElement = ( ( IType ) parentElement ) . getType ( new String ( scope . enclosingSourceType ( ) . sourceName ) ) ; break ; case IJavaElement . FIELD : case IJavaElement . INITIALIZER : case IJavaElement . METHOD : IMember member = ( IMember ) parentElement ; if ( member . isBinary ( ) ) { return null ; } else { newElement = member . getType ( new String ( scope . enclosingSourceType ( ) . sourceName ) , <NUM_LIT:1> ) ; if ( newElement != null ) { while ( ! existingElements . add ( newElement ) ) ( ( SourceRefElement ) newElement ) . occurrenceCount ++ ; } } break ; } if ( newElement != null ) { knownScopes . put ( scope , newElement ) ; } break ; case Scope . METHOD_SCOPE : IType parentType = ( IType ) createElement ( scope . parent , elementPosition , unit , existingElements , knownScopes ) ; MethodScope methodScope = ( MethodScope ) scope ; if ( methodScope . isInsideInitializer ( ) ) { TypeDeclaration type = methodScope . referenceType ( ) ; int occurenceCount = <NUM_LIT:1> ; int length = type . fields == null ? <NUM_LIT:0> : type . fields . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { FieldDeclaration field = type . fields [ i ] ; if ( field . declarationSourceStart <= elementPosition && elementPosition <= field . declarationSourceEnd ) { switch ( field . getKind ( ) ) { case AbstractVariableDeclaration . FIELD : case AbstractVariableDeclaration . ENUM_CONSTANT : newElement = parentType . getField ( new String ( field . name ) ) ; break ; case AbstractVariableDeclaration . INITIALIZER : newElement = parentType . getInitializer ( occurenceCount ) ; break ; } break ; } else if ( field . getKind ( ) == AbstractVariableDeclaration . INITIALIZER ) { occurenceCount ++ ; } } } else { AbstractMethodDeclaration method = methodScope . referenceMethod ( ) ; newElement = parentType . getMethod ( new String ( method . selector ) , Util . typeParameterSignatures ( method ) ) ; if ( newElement != null ) { knownScopes . put ( scope , newElement ) ; } } break ; case Scope . BLOCK_SCOPE : newElement = createElement ( scope . parent , elementPosition , unit , existingElements , knownScopes ) ; break ; } return newElement ; } private PackageFragmentRoot getJarPkgFragmentRoot ( String resourcePathString , int jarSeparatorIndex , String jarPathString , IJavaSearchScope scope ) { IPath jarPath = new Path ( jarPathString ) ; Object target = JavaModel . getTarget ( jarPath , false ) ; if ( target instanceof IFile ) { IFile jarFile = ( IFile ) target ; JavaProject javaProject = ( JavaProject ) this . javaModel . getJavaProject ( jarFile ) ; try { IClasspathEntry entry = javaProject . getClasspathEntryFor ( jarPath ) ; if ( entry != null ) { return ( PackageFragmentRoot ) javaProject . getPackageFragmentRoot ( jarFile ) ; } } catch ( JavaModelException e ) { } } IJavaProject [ ] projects ; if ( scope != null ) { if ( scope instanceof AbstractJavaSearchScope ) { PackageFragmentRoot root = ( PackageFragmentRoot ) ( ( AbstractJavaSearchScope ) scope ) . packageFragmentRoot ( resourcePathString , jarSeparatorIndex , jarPathString ) ; if ( root != null ) return root ; } else { IPath [ ] enclosingProjectsAndJars = scope . enclosingProjectsAndJars ( ) ; int length = enclosingProjectsAndJars . length ; projects = new IJavaProject [ length ] ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IPath path = enclosingProjectsAndJars [ i ] ; if ( path . segmentCount ( ) == <NUM_LIT:1> ) { projects [ index ++ ] = this . javaModel . getJavaProject ( path . segment ( <NUM_LIT:0> ) ) ; } } if ( index < length ) { System . arraycopy ( projects , <NUM_LIT:0> , projects = new IJavaProject [ index ] , <NUM_LIT:0> , index ) ; } PackageFragmentRoot root = getJarPkgFragmentRoot ( jarPath , target , projects ) ; if ( root != null ) { return root ; } } } try { projects = this . javaModel . getJavaProjects ( ) ; } catch ( JavaModelException e ) { return null ; } return getJarPkgFragmentRoot ( jarPath , target , projects ) ; } private PackageFragmentRoot getJarPkgFragmentRoot ( IPath jarPath , Object target , IJavaProject [ ] projects ) { for ( int i = <NUM_LIT:0> , projectCount = projects . length ; i < projectCount ; i ++ ) { try { JavaProject javaProject = ( JavaProject ) projects [ i ] ; IClasspathEntry classpathEnty = javaProject . getClasspathEntryFor ( jarPath ) ; if ( classpathEnty != null ) { if ( target instanceof IFile ) { return ( PackageFragmentRoot ) javaProject . getPackageFragmentRoot ( ( IFile ) target ) ; } else { return ( PackageFragmentRoot ) javaProject . getPackageFragmentRoot0 ( jarPath ) ; } } } catch ( JavaModelException e ) { } } return null ; } private PackageFragmentRoot getPkgFragmentRoot ( String pathString ) { IPath path = new Path ( pathString ) ; IProject [ ] projects = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getProjects ( ) ; for ( int i = <NUM_LIT:0> , max = projects . length ; i < max ; i ++ ) { try { IProject project = projects [ i ] ; if ( ! project . isAccessible ( ) || ! project . hasNature ( JavaCore . NATURE_ID ) ) continue ; IJavaProject javaProject = this . javaModel . getJavaProject ( project ) ; IPackageFragmentRoot [ ] roots = javaProject . getPackageFragmentRoots ( ) ; for ( int j = <NUM_LIT:0> , rootCount = roots . length ; j < rootCount ; j ++ ) { PackageFragmentRoot root = ( PackageFragmentRoot ) roots [ j ] ; if ( root . internalPath ( ) . isPrefixOf ( path ) && ! Util . isExcluded ( path , root . fullInclusionPatternChars ( ) , root . fullExclusionPatternChars ( ) , false ) ) { return root ; } } } catch ( CoreException e ) { } } return null ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . util ; import org . eclipse . jdt . core . util . ClassFormatException ; import org . eclipse . jdt . core . util . IAttributeNamesConstants ; import org . eclipse . jdt . core . util . IClassFileAttribute ; import org . eclipse . jdt . core . util . IConstantPool ; import org . eclipse . jdt . core . util . IConstantPoolConstant ; import org . eclipse . jdt . core . util . IConstantPoolEntry ; import org . eclipse . jdt . core . util . IConstantValueAttribute ; import org . eclipse . jdt . core . util . IFieldInfo ; import org . eclipse . jdt . core . util . IModifierConstants ; public class FieldInfo extends ClassFileStruct implements IFieldInfo { private int accessFlags ; private int attributeBytes ; private IClassFileAttribute [ ] attributes ; private int attributesCount ; private IConstantValueAttribute constantValueAttribute ; private char [ ] descriptor ; private int descriptorIndex ; private boolean isDeprecated ; private boolean isSynthetic ; private char [ ] name ; private int nameIndex ; public FieldInfo ( byte classFileBytes [ ] , IConstantPool constantPool , int offset ) throws ClassFormatException { final int flags = u2At ( classFileBytes , <NUM_LIT:0> , offset ) ; this . accessFlags = flags ; if ( ( flags & IModifierConstants . ACC_SYNTHETIC ) != <NUM_LIT:0> ) { this . isSynthetic = true ; } this . nameIndex = u2At ( classFileBytes , <NUM_LIT:2> , offset ) ; IConstantPoolEntry constantPoolEntry = constantPool . decodeEntry ( this . nameIndex ) ; if ( constantPoolEntry . getKind ( ) != IConstantPoolConstant . CONSTANT_Utf8 ) { throw new ClassFormatException ( ClassFormatException . INVALID_CONSTANT_POOL_ENTRY ) ; } this . name = constantPoolEntry . getUtf8Value ( ) ; this . descriptorIndex = u2At ( classFileBytes , <NUM_LIT:4> , offset ) ; constantPoolEntry = constantPool . decodeEntry ( this . descriptorIndex ) ; if ( constantPoolEntry . getKind ( ) != IConstantPoolConstant . CONSTANT_Utf8 ) { throw new ClassFormatException ( ClassFormatException . INVALID_CONSTANT_POOL_ENTRY ) ; } this . descriptor = constantPoolEntry . getUtf8Value ( ) ; this . attributesCount = u2At ( classFileBytes , <NUM_LIT:6> , offset ) ; this . attributes = ClassFileAttribute . NO_ATTRIBUTES ; int readOffset = <NUM_LIT:8> ; if ( this . attributesCount != <NUM_LIT:0> ) { this . attributes = new IClassFileAttribute [ this . attributesCount ] ; } int attributesIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < this . attributesCount ; i ++ ) { constantPoolEntry = constantPool . decodeEntry ( u2At ( classFileBytes , readOffset , offset ) ) ; if ( constantPoolEntry . getKind ( ) != IConstantPoolConstant . CONSTANT_Utf8 ) { throw new ClassFormatException ( ClassFormatException . INVALID_CONSTANT_POOL_ENTRY ) ; } char [ ] attributeName = constantPoolEntry . getUtf8Value ( ) ; if ( equals ( attributeName , IAttributeNamesConstants . DEPRECATED ) ) { this . isDeprecated = true ; this . attributes [ attributesIndex ++ ] = new ClassFileAttribute ( classFileBytes , constantPool , offset + readOffset ) ; } else if ( equals ( attributeName , IAttributeNamesConstants . SYNTHETIC ) ) { this . isSynthetic = true ; this . attributes [ attributesIndex ++ ] = new ClassFileAttribute ( classFileBytes , constantPool , offset + readOffset ) ; } else if ( equals ( attributeName , IAttributeNamesConstants . CONSTANT_VALUE ) ) { this . constantValueAttribute = new ConstantValueAttribute ( classFileBytes , constantPool , offset + readOffset ) ; this . attributes [ attributesIndex ++ ] = this . constantValueAttribute ; } else if ( equals ( attributeName , IAttributeNamesConstants . SIGNATURE ) ) { this . attributes [ attributesIndex ++ ] = new SignatureAttribute ( classFileBytes , constantPool , offset + readOffset ) ; } else if ( equals ( attributeName , IAttributeNamesConstants . RUNTIME_VISIBLE_ANNOTATIONS ) ) { this . attributes [ attributesIndex ++ ] = new RuntimeVisibleAnnotationsAttribute ( classFileBytes , constantPool , offset + readOffset ) ; } else if ( equals ( attributeName , IAttributeNamesConstants . RUNTIME_INVISIBLE_ANNOTATIONS ) ) { this . attributes [ attributesIndex ++ ] = new RuntimeInvisibleAnnotationsAttribute ( classFileBytes , constantPool , offset + readOffset ) ; } else { this . attributes [ attributesIndex ++ ] = new ClassFileAttribute ( classFileBytes , constantPool , offset + readOffset ) ; } readOffset += ( <NUM_LIT:6> + u4At ( classFileBytes , readOffset + <NUM_LIT:2> , offset ) ) ; } this . attributeBytes = readOffset ; } public int getAccessFlags ( ) { return this . accessFlags ; } public int getAttributeCount ( ) { return this . attributesCount ; } public IClassFileAttribute [ ] getAttributes ( ) { return this . attributes ; } public IConstantValueAttribute getConstantValueAttribute ( ) { return this . constantValueAttribute ; } public char [ ] getDescriptor ( ) { return this . descriptor ; } public int getDescriptorIndex ( ) { return this . descriptorIndex ; } public char [ ] getName ( ) { return this . name ; } public int getNameIndex ( ) { return this . nameIndex ; } public boolean hasConstantValueAttribute ( ) { return this . constantValueAttribute != null ; } public boolean isDeprecated ( ) { return this . isDeprecated ; } public boolean isSynthetic ( ) { return this . isSynthetic ; } int sizeInBytes ( ) { return this . attributeBytes ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . util ; public interface ILRUCacheable { public int getCacheFootprint ( ) ; } </s>
|
<s> package org . eclipse . jdt . internal . core . util ; import java . util . ArrayList ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . Wildcard ; import org . eclipse . jdt . internal . compiler . codegen . ConstantPool ; public class KeyToSignature extends BindingKeyParser { public static final int SIGNATURE = <NUM_LIT:0> ; public static final int TYPE_ARGUMENTS = <NUM_LIT:1> ; public static final int DECLARING_TYPE = <NUM_LIT:2> ; public static final int THROWN_EXCEPTIONS = <NUM_LIT:3> ; public StringBuffer signature = new StringBuffer ( ) ; private int kind ; private ArrayList arguments = new ArrayList ( ) ; private ArrayList typeArguments = new ArrayList ( ) ; private ArrayList typeParameters = new ArrayList ( ) ; private ArrayList thrownExceptions = new ArrayList ( ) ; private int mainTypeStart = - <NUM_LIT:1> ; private int mainTypeEnd ; private int typeSigStart = - <NUM_LIT:1> ; public KeyToSignature ( BindingKeyParser parser ) { super ( parser ) ; this . kind = ( ( KeyToSignature ) parser ) . kind ; } public KeyToSignature ( String key , int kind ) { super ( key ) ; this . kind = kind ; } public void consumeArrayDimension ( char [ ] brakets ) { this . signature . append ( brakets ) ; } public void consumeBaseType ( char [ ] baseTypeSig ) { this . typeSigStart = this . signature . length ( ) ; this . signature . append ( baseTypeSig ) ; } public void consumeCapture ( int position ) { this . signature . append ( '<CHAR_LIT>' ) ; this . signature . append ( ( ( KeyToSignature ) this . arguments . get ( <NUM_LIT:0> ) ) . signature ) ; } public void consumeLocalType ( char [ ] uniqueKey ) { this . signature = new StringBuffer ( ) ; uniqueKey = CharOperation . subarray ( uniqueKey , <NUM_LIT:0> , uniqueKey . length - <NUM_LIT:1> ) ; CharOperation . replace ( uniqueKey , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; this . signature . append ( uniqueKey ) ; } public void consumeMethod ( char [ ] selector , char [ ] methodSignature ) { this . arguments = new ArrayList ( ) ; this . typeArguments = new ArrayList ( ) ; CharOperation . replace ( methodSignature , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; switch ( this . kind ) { case SIGNATURE : this . signature = new StringBuffer ( ) ; this . signature . append ( methodSignature ) ; break ; case THROWN_EXCEPTIONS : if ( CharOperation . indexOf ( '<CHAR_LIT>' , methodSignature ) > <NUM_LIT:0> ) { char [ ] [ ] types = Signature . getThrownExceptionTypes ( methodSignature ) ; int length = types . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { this . thrownExceptions . add ( new String ( types [ i ] ) ) ; } } break ; } } public void consumeMemberType ( char [ ] simpleTypeName ) { this . signature . append ( '<CHAR_LIT>' ) ; this . signature . append ( simpleTypeName ) ; } public void consumePackage ( char [ ] pkgName ) { this . signature . append ( pkgName ) ; } public void consumeParameterizedGenericMethod ( ) { this . typeArguments = this . arguments ; int typeParametersSize = this . arguments . size ( ) ; if ( typeParametersSize > <NUM_LIT:0> ) { int sigLength = this . signature . length ( ) ; char [ ] methodSignature = new char [ sigLength ] ; this . signature . getChars ( <NUM_LIT:0> , sigLength , methodSignature , <NUM_LIT:0> ) ; char [ ] [ ] typeParameterSigs = Signature . getTypeParameters ( methodSignature ) ; if ( typeParameterSigs . length != typeParametersSize ) return ; this . signature = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> ; i < typeParametersSize ; i ++ ) typeParameterSigs [ i ] = CharOperation . concat ( Signature . C_TYPE_VARIABLE , Signature . getTypeVariable ( typeParameterSigs [ i ] ) , Signature . C_SEMICOLON ) ; int paramStart = CharOperation . indexOf ( Signature . C_PARAM_START , methodSignature ) ; char [ ] typeParametersString = CharOperation . subarray ( methodSignature , <NUM_LIT:0> , paramStart ) ; this . signature . append ( typeParametersString ) ; this . signature . append ( Signature . C_PARAM_START ) ; char [ ] [ ] parameters = Signature . getParameterTypes ( methodSignature ) ; for ( int i = <NUM_LIT:0> , parametersLength = parameters . length ; i < parametersLength ; i ++ ) substitute ( parameters [ i ] , typeParameterSigs , typeParametersSize ) ; this . signature . append ( Signature . C_PARAM_END ) ; char [ ] returnType = Signature . getReturnType ( methodSignature ) ; substitute ( returnType , typeParameterSigs , typeParametersSize ) ; char [ ] [ ] exceptions = Signature . getThrownExceptionTypes ( methodSignature ) ; for ( int i = <NUM_LIT:0> , exceptionsLength = exceptions . length ; i < exceptionsLength ; i ++ ) { this . signature . append ( Signature . C_EXCEPTION_START ) ; substitute ( exceptions [ i ] , typeParameterSigs , typeParametersSize ) ; } } } private void substitute ( char [ ] parameter , char [ ] [ ] typeParameterSigs , int typeParametersLength ) { for ( int i = <NUM_LIT:0> ; i < typeParametersLength ; i ++ ) { if ( CharOperation . equals ( parameter , typeParameterSigs [ i ] ) ) { String typeArgument = ( ( KeyToSignature ) this . arguments . get ( i ) ) . signature . toString ( ) ; this . signature . append ( typeArgument ) ; return ; } } int genericStart = CharOperation . indexOf ( Signature . C_GENERIC_START , parameter ) ; if ( genericStart > - <NUM_LIT:1> ) { this . signature . append ( CharOperation . subarray ( parameter , <NUM_LIT:0> , genericStart ) ) ; char [ ] [ ] parameters = Signature . getTypeArguments ( parameter ) ; this . signature . append ( Signature . C_GENERIC_START ) ; for ( int j = <NUM_LIT:0> , paramsLength = parameters . length ; j < paramsLength ; j ++ ) substitute ( parameters [ j ] , typeParameterSigs , typeParametersLength ) ; this . signature . append ( Signature . C_GENERIC_END ) ; this . signature . append ( Signature . C_SEMICOLON ) ; } else { int index = <NUM_LIT:0> ; int length = parameter . length ; loop : while ( index < length ) { char current = parameter [ index ] ; switch ( current ) { case Signature . C_CAPTURE : case Signature . C_EXTENDS : case Signature . C_SUPER : case Signature . C_ARRAY : this . signature . append ( current ) ; index ++ ; break ; default : break loop ; } } if ( index > <NUM_LIT:0> ) substitute ( CharOperation . subarray ( parameter , index , length ) , typeParameterSigs , typeParametersLength ) ; else this . signature . append ( parameter ) ; } } public void consumeParameterizedType ( char [ ] simpleTypeName , boolean isRaw ) { if ( simpleTypeName != null ) { this . signature . append ( '<CHAR_LIT:.>' ) ; this . signature . append ( simpleTypeName ) ; } if ( ! isRaw ) { this . signature . append ( '<CHAR_LIT>' ) ; int length = this . arguments . size ( ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { this . signature . append ( ( ( KeyToSignature ) this . arguments . get ( i ) ) . signature ) ; } this . signature . append ( '<CHAR_LIT:>>' ) ; this . typeArguments = this . arguments ; this . arguments = new ArrayList ( ) ; } } public void consumeParser ( BindingKeyParser parser ) { this . arguments . add ( parser ) ; } public void consumeField ( char [ ] fieldName ) { if ( this . kind == SIGNATURE ) { this . signature = ( ( KeyToSignature ) this . arguments . get ( <NUM_LIT:0> ) ) . signature ; } } public void consumeException ( ) { int size = this . arguments . size ( ) ; if ( size > <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { this . thrownExceptions . add ( ( ( KeyToSignature ) this . arguments . get ( i ) ) . signature . toString ( ) ) ; } this . arguments = new ArrayList ( ) ; this . typeArguments = new ArrayList ( ) ; } } public void consumeFullyQualifiedName ( char [ ] fullyQualifiedName ) { this . typeSigStart = this . signature . length ( ) ; this . signature . append ( '<CHAR_LIT>' ) ; this . signature . append ( CharOperation . replaceOnCopy ( fullyQualifiedName , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ) ; } public void consumeSecondaryType ( char [ ] simpleTypeName ) { this . signature . append ( '<CHAR_LIT>' ) ; this . mainTypeStart = this . signature . lastIndexOf ( "<STR_LIT:.>" ) + <NUM_LIT:1> ; if ( this . mainTypeStart == <NUM_LIT:0> ) { this . mainTypeStart = <NUM_LIT:1> ; int i = <NUM_LIT:0> ; while ( this . signature . charAt ( i ) == Signature . C_ARRAY ) { this . mainTypeStart ++ ; i ++ ; } } this . mainTypeEnd = this . signature . length ( ) ; this . signature . append ( simpleTypeName ) ; } public void consumeType ( ) { if ( this . mainTypeStart != - <NUM_LIT:1> ) { this . signature . replace ( this . mainTypeStart , this . mainTypeEnd , "<STR_LIT>" ) ; } int length = this . typeParameters . size ( ) ; if ( length > <NUM_LIT:0> ) { StringBuffer typeParametersSig = new StringBuffer ( ) ; typeParametersSig . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char [ ] typeParameterSig = Signature . createTypeParameterSignature ( ( char [ ] ) this . typeParameters . get ( i ) , new char [ ] [ ] { ConstantPool . ObjectSignature } ) ; typeParametersSig . append ( typeParameterSig ) ; } typeParametersSig . append ( '<CHAR_LIT:>>' ) ; this . signature . insert ( this . typeSigStart , typeParametersSig . toString ( ) ) ; this . typeParameters = new ArrayList ( ) ; } this . signature . append ( '<CHAR_LIT:;>' ) ; } public void consumeTypeParameter ( char [ ] typeParameterName ) { this . typeParameters . add ( typeParameterName ) ; } public void consumeTypeVariable ( char [ ] position , char [ ] typeVariableName ) { this . signature = new StringBuffer ( ) ; this . signature . append ( '<CHAR_LIT>' ) ; this . signature . append ( typeVariableName ) ; this . signature . append ( '<CHAR_LIT:;>' ) ; } public void consumeTypeWithCapture ( ) { KeyToSignature keyToSignature = ( KeyToSignature ) this . arguments . get ( <NUM_LIT:0> ) ; this . signature = keyToSignature . signature ; this . arguments = keyToSignature . arguments ; this . typeArguments = keyToSignature . typeArguments ; this . thrownExceptions = keyToSignature . thrownExceptions ; } public void consumeWildCard ( int wildCardKind ) { this . signature = new StringBuffer ( ) ; switch ( wildCardKind ) { case Wildcard . UNBOUND : this . signature . append ( '<CHAR_LIT>' ) ; break ; case Wildcard . EXTENDS : this . signature . append ( '<CHAR_LIT>' ) ; this . signature . append ( ( ( KeyToSignature ) this . arguments . get ( <NUM_LIT:0> ) ) . signature ) ; break ; case Wildcard . SUPER : this . signature . append ( '<CHAR_LIT:->' ) ; this . signature . append ( ( ( KeyToSignature ) this . arguments . get ( <NUM_LIT:0> ) ) . signature ) ; break ; default : return ; } } public String [ ] getThrownExceptions ( ) { int length = this . thrownExceptions . size ( ) ; String [ ] result = new String [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { result [ i ] = ( String ) this . thrownExceptions . get ( i ) ; } return result ; } public String [ ] getTypeArguments ( ) { int length = this . typeArguments . size ( ) ; String [ ] result = new String [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { result [ i ] = ( ( KeyToSignature ) this . typeArguments . get ( i ) ) . signature . toString ( ) ; } return result ; } public BindingKeyParser newParser ( ) { return new KeyToSignature ( this ) ; } public String toString ( ) { return this . signature . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . util ; public final class HashtableOfArrayToObject implements Cloneable { public Object [ ] [ ] keyTable ; public Object [ ] valueTable ; public int elementSize ; int threshold ; public HashtableOfArrayToObject ( ) { this ( <NUM_LIT> ) ; } public HashtableOfArrayToObject ( int size ) { this . elementSize = <NUM_LIT:0> ; this . threshold = size ; int extraRoom = ( int ) ( size * <NUM_LIT> ) ; if ( this . threshold == extraRoom ) extraRoom ++ ; this . keyTable = new Object [ extraRoom ] [ ] ; this . valueTable = new Object [ extraRoom ] ; } public Object clone ( ) throws CloneNotSupportedException { HashtableOfArrayToObject result = ( HashtableOfArrayToObject ) super . clone ( ) ; result . elementSize = this . elementSize ; result . threshold = this . threshold ; int length = this . keyTable . length ; result . keyTable = new Object [ length ] [ ] ; System . arraycopy ( this . keyTable , <NUM_LIT:0> , result . keyTable , <NUM_LIT:0> , length ) ; length = this . valueTable . length ; result . valueTable = new Object [ length ] ; System . arraycopy ( this . valueTable , <NUM_LIT:0> , result . valueTable , <NUM_LIT:0> , length ) ; return result ; } public boolean containsKey ( Object [ ] key ) { int length = this . keyTable . length ; int index = hashCode ( key ) % length ; int keyLength = key . length ; Object [ ] currentKey ; while ( ( currentKey = this . keyTable [ index ] ) != null ) { if ( currentKey . length == keyLength && Util . equalArraysOrNull ( currentKey , key ) ) return true ; if ( ++ index == length ) { index = <NUM_LIT:0> ; } } return false ; } public Object get ( Object [ ] key ) { int length = this . keyTable . length ; int index = hashCode ( key ) % length ; int keyLength = key . length ; Object [ ] currentKey ; while ( ( currentKey = this . keyTable [ index ] ) != null ) { if ( currentKey . length == keyLength && Util . equalArraysOrNull ( currentKey , key ) ) return this . valueTable [ index ] ; if ( ++ index == length ) { index = <NUM_LIT:0> ; } } return null ; } public int getIndex ( Object [ ] key ) { int length = this . keyTable . length ; int index = hashCode ( key ) % length ; int keyLength = key . length ; Object [ ] currentKey ; while ( ( currentKey = this . keyTable [ index ] ) != null ) { if ( currentKey . length == keyLength && Util . equalArraysOrNull ( currentKey , key ) ) return index ; if ( ++ index == length ) { index = <NUM_LIT:0> ; } } return - <NUM_LIT:1> ; } public Object [ ] getKey ( Object [ ] key , int keyLength ) { int length = this . keyTable . length ; int index = hashCode ( key , keyLength ) % length ; Object [ ] currentKey ; while ( ( currentKey = this . keyTable [ index ] ) != null ) { if ( currentKey . length == keyLength && Util . equalArrays ( currentKey , key , keyLength ) ) return currentKey ; if ( ++ index == length ) { index = <NUM_LIT:0> ; } } return null ; } private int hashCode ( Object [ ] element ) { return hashCode ( element , element . length ) ; } private int hashCode ( Object [ ] element , int length ) { int hash = <NUM_LIT:0> ; for ( int i = length - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) hash = Util . combineHashCodes ( hash , element [ i ] . hashCode ( ) ) ; return hash & <NUM_LIT> ; } public Object put ( Object [ ] key , Object value ) { int length = this . keyTable . length ; int index = hashCode ( key ) % length ; int keyLength = key . length ; Object [ ] currentKey ; while ( ( currentKey = this . keyTable [ index ] ) != null ) { if ( currentKey . length == keyLength && Util . equalArraysOrNull ( currentKey , key ) ) return this . valueTable [ index ] = value ; if ( ++ index == length ) { index = <NUM_LIT:0> ; } } this . keyTable [ index ] = key ; this . valueTable [ index ] = value ; if ( ++ this . elementSize > this . threshold ) rehash ( ) ; return value ; } public Object removeKey ( Object [ ] key ) { int length = this . keyTable . length ; int index = hashCode ( key ) % length ; int keyLength = key . length ; Object [ ] currentKey ; while ( ( currentKey = this . keyTable [ index ] ) != null ) { if ( currentKey . length == keyLength && Util . equalArraysOrNull ( currentKey , key ) ) { Object value = this . valueTable [ index ] ; this . elementSize -- ; this . keyTable [ index ] = null ; this . valueTable [ index ] = null ; rehash ( ) ; return value ; } if ( ++ index == length ) { index = <NUM_LIT:0> ; } } return null ; } private void rehash ( ) { HashtableOfArrayToObject newHashtable = new HashtableOfArrayToObject ( this . elementSize * <NUM_LIT:2> ) ; Object [ ] currentKey ; for ( int i = this . keyTable . length ; -- i >= <NUM_LIT:0> ; ) if ( ( currentKey = this . keyTable [ i ] ) != null ) newHashtable . put ( currentKey , this . valueTable [ i ] ) ; this . keyTable = newHashtable . keyTable ; this . valueTable = newHashtable . valueTable ; this . threshold = newHashtable . threshold ; } public int size ( ) { return this . elementSize ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; Object [ ] element ; for ( int i = <NUM_LIT:0> , length = this . keyTable . length ; i < length ; i ++ ) if ( ( element = this . keyTable [ i ] ) != null ) { buffer . append ( '<CHAR_LIT>' ) ; for ( int j = <NUM_LIT:0> , length2 = element . length ; j < length2 ; j ++ ) { buffer . append ( element [ j ] ) ; if ( j != length2 - <NUM_LIT:1> ) buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . valueTable [ i ] ) ; if ( i != length - <NUM_LIT:1> ) buffer . append ( '<STR_LIT:\n>' ) ; } return buffer . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . util ; import java . io . * ; import java . net . URI ; import java . util . * ; import java . util . zip . ZipEntry ; import java . util . zip . ZipFile ; import org . eclipse . core . filesystem . EFS ; import org . eclipse . core . filesystem . IFileStore ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . core . runtime . content . IContentType ; import org . eclipse . core . runtime . preferences . IScopeContext ; import org . eclipse . core . runtime . preferences . InstanceScope ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . ArrayType ; import org . eclipse . jdt . core . dom . ParameterizedType ; import org . eclipse . jdt . core . dom . PrimitiveType ; import org . eclipse . jdt . core . dom . QualifiedType ; import org . eclipse . jdt . core . dom . SimpleType ; import org . eclipse . jdt . core . dom . Type ; import org . eclipse . jdt . core . dom . WildcardType ; import org . eclipse . jdt . core . util . IClassFileAttribute ; import org . eclipse . jdt . core . util . IClassFileReader ; import org . eclipse . jdt . core . util . ICodeAttribute ; import org . eclipse . jdt . core . util . IFieldInfo ; import org . eclipse . jdt . core . util . IMethodInfo ; 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 . UnionTypeReference ; import org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFormatException ; import org . eclipse . jdt . internal . compiler . env . ClassSignature ; import org . eclipse . jdt . internal . compiler . env . EnumConstantSignature ; import org . eclipse . jdt . internal . compiler . env . IBinaryAnnotation ; import org . eclipse . jdt . internal . compiler . env . IDependent ; import org . eclipse . jdt . internal . compiler . impl . Constant ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeIds ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . Annotation ; import org . eclipse . jdt . internal . core . ClassFile ; import org . eclipse . jdt . internal . core . JavaElement ; import org . eclipse . jdt . internal . core . JavaModelManager ; import org . eclipse . jdt . internal . core . Member ; import org . eclipse . jdt . internal . core . MemberValuePair ; import org . eclipse . jdt . internal . core . PackageFragment ; import org . eclipse . jdt . internal . core . PackageFragmentRoot ; import org . eclipse . jface . text . BadLocationException ; import org . eclipse . text . edits . MalformedTreeException ; import org . eclipse . text . edits . TextEdit ; public class Util { public interface Comparable { int compareTo ( Comparable c ) ; } public interface Comparer { int compare ( Object a , Object b ) ; } public static interface BindingsToNodesMap { public org . eclipse . jdt . internal . compiler . ast . ASTNode get ( Binding binding ) ; } private static final char ARGUMENTS_DELIMITER = '<CHAR_LIT>' ; private static final String EMPTY_ARGUMENT = "<STR_LIT>" ; private static char [ ] [ ] JAVA_LIKE_EXTENSIONS ; private static final char [ ] BOOLEAN = "<STR_LIT:boolean>" . toCharArray ( ) ; private static final char [ ] BYTE = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] CHAR = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] DOUBLE = "<STR_LIT:double>" . toCharArray ( ) ; private static final char [ ] FLOAT = "<STR_LIT:float>" . toCharArray ( ) ; private static final char [ ] INT = "<STR_LIT:int>" . toCharArray ( ) ; private static final char [ ] LONG = "<STR_LIT:long>" . toCharArray ( ) ; private static final char [ ] SHORT = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] VOID = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] INIT = "<STR_LIT>" . toCharArray ( ) ; private static final String TASK_PRIORITIES_PROBLEM = "<STR_LIT>" ; private static List fgRepeatedMessages = new ArrayList ( <NUM_LIT:5> ) ; private Util ( ) { } public static final String [ ] arrayConcat ( String [ ] first , String second ) { if ( second == null ) return first ; if ( first == null ) return new String [ ] { second } ; int length = first . length ; if ( first . length == <NUM_LIT:0> ) { return new String [ ] { second } ; } String [ ] result = new String [ length + <NUM_LIT:1> ] ; System . arraycopy ( first , <NUM_LIT:0> , result , <NUM_LIT:0> , length ) ; result [ length ] = second ; return result ; } private static int checkTypeSignature ( String sig , int start , int end , boolean allowVoid ) { if ( start >= end ) return - <NUM_LIT:1> ; int i = start ; char c = sig . charAt ( i ++ ) ; int nestingDepth = <NUM_LIT:0> ; while ( c == '<CHAR_LIT:[>' ) { ++ nestingDepth ; if ( i >= end ) return - <NUM_LIT:1> ; c = sig . charAt ( i ++ ) ; } switch ( c ) { case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT:Z>' : break ; case '<CHAR_LIT>' : if ( ! allowVoid ) return - <NUM_LIT:1> ; if ( nestingDepth != <NUM_LIT:0> ) return - <NUM_LIT:1> ; break ; case '<CHAR_LIT>' : int semicolon = sig . indexOf ( '<CHAR_LIT:;>' , i ) ; if ( semicolon <= i || semicolon >= end ) return - <NUM_LIT:1> ; i = semicolon + <NUM_LIT:1> ; break ; default : return - <NUM_LIT:1> ; } return i ; } public static int combineHashCodes ( int hashCode1 , int hashCode2 ) { return hashCode1 * <NUM_LIT> + hashCode2 ; } public static int compare ( byte [ ] a , byte [ ] b ) { if ( a == b ) return <NUM_LIT:0> ; if ( a == null ) return - <NUM_LIT:1> ; if ( b == null ) return <NUM_LIT:1> ; int len = Math . min ( a . length , b . length ) ; for ( int i = <NUM_LIT:0> ; i < len ; ++ i ) { int diff = a [ i ] - b [ i ] ; if ( diff != <NUM_LIT:0> ) return diff ; } if ( a . length > len ) return <NUM_LIT:1> ; if ( b . length > len ) return - <NUM_LIT:1> ; return <NUM_LIT:0> ; } public static int compare ( char [ ] str1 , char [ ] str2 ) { int len1 = str1 . length ; int len2 = str2 . length ; int n = Math . min ( len1 , len2 ) ; int i = <NUM_LIT:0> ; while ( n -- != <NUM_LIT:0> ) { char c1 = str1 [ i ] ; char c2 = str2 [ i ++ ] ; if ( c1 != c2 ) { return c1 - c2 ; } } return len1 - len2 ; } public static char [ ] concatCompoundNameToCharArray ( String [ ] compoundName ) { if ( compoundName == null ) return null ; int length = compoundName . length ; if ( length == <NUM_LIT:0> ) return new char [ <NUM_LIT:0> ] ; int size = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { size += compoundName [ i ] . length ( ) ; } char [ ] compoundChars = new char [ size + length - <NUM_LIT:1> ] ; int pos = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { String name = compoundName [ i ] ; if ( i > <NUM_LIT:0> ) compoundChars [ pos ++ ] = '<CHAR_LIT:.>' ; int nameLength = name . length ( ) ; name . getChars ( <NUM_LIT:0> , nameLength , compoundChars , pos ) ; pos += nameLength ; } return compoundChars ; } public static String concatenateName ( String name1 , String name2 , char separator ) { StringBuffer buf = new StringBuffer ( ) ; if ( name1 != null && name1 . length ( ) > <NUM_LIT:0> ) { buf . append ( name1 ) ; } if ( name2 != null && name2 . length ( ) > <NUM_LIT:0> ) { if ( buf . length ( ) > <NUM_LIT:0> ) { buf . append ( separator ) ; } buf . append ( name2 ) ; } return buf . toString ( ) ; } public static final String concatWith ( String [ ] array , char separator ) { StringBuffer buffer = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> , length = array . length ; i < length ; i ++ ) { buffer . append ( array [ i ] ) ; if ( i < length - <NUM_LIT:1> ) buffer . append ( separator ) ; } return buffer . toString ( ) ; } public static final String concatWith ( String [ ] array , String name , char separator ) { if ( array == null || array . length == <NUM_LIT:0> ) return name ; if ( name == null || name . length ( ) == <NUM_LIT:0> ) return concatWith ( array , separator ) ; StringBuffer buffer = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> , length = array . length ; i < length ; i ++ ) { buffer . append ( array [ i ] ) ; buffer . append ( separator ) ; } buffer . append ( name ) ; return buffer . toString ( ) ; } public static String convertTypeSignature ( char [ ] sig , int start , int length ) { return new String ( sig , start , length ) . replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; } public static String defaultJavaExtension ( ) { return SuffixConstants . SUFFIX_STRING_java ; } public final static String editedString ( String original , TextEdit edit ) { if ( edit == null ) { return original ; } SimpleDocument document = new SimpleDocument ( original ) ; try { edit . apply ( document , TextEdit . NONE ) ; return document . get ( ) ; } catch ( MalformedTreeException e ) { e . printStackTrace ( ) ; } catch ( BadLocationException e ) { e . printStackTrace ( ) ; } return original ; } public final static boolean endsWithIgnoreCase ( String str , String end ) { int strLength = str == null ? <NUM_LIT:0> : str . length ( ) ; int endLength = end == null ? <NUM_LIT:0> : end . length ( ) ; if ( endLength > strLength ) return false ; for ( int i = <NUM_LIT:1> ; i <= endLength ; i ++ ) { if ( ScannerHelper . toLowerCase ( end . charAt ( endLength - i ) ) != ScannerHelper . toLowerCase ( str . charAt ( strLength - i ) ) ) return false ; } return true ; } public static boolean equalArrays ( Object [ ] a , Object [ ] b , int len ) { if ( a == b ) return true ; if ( a . length < len || b . length < len ) return false ; for ( int i = <NUM_LIT:0> ; i < len ; ++ i ) { if ( a [ i ] == null ) { if ( b [ i ] != null ) return false ; } else { if ( ! a [ i ] . equals ( b [ i ] ) ) return false ; } } return true ; } public static boolean equalArraysOrNull ( int [ ] a , int [ ] b ) { if ( a == b ) return true ; if ( a == null || b == null ) return false ; int len = a . length ; if ( len != b . length ) return false ; for ( int i = <NUM_LIT:0> ; i < len ; ++ i ) { if ( a [ i ] != b [ i ] ) return false ; } return true ; } public static boolean equalArraysOrNull ( Object [ ] a , Object [ ] b ) { if ( a == b ) return true ; if ( a == null || b == null ) return false ; int len = a . length ; if ( len != b . length ) return false ; for ( int i = len - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { if ( a [ i ] == null ) { if ( b [ i ] != null ) return false ; } else { if ( ! a [ i ] . equals ( b [ i ] ) ) return false ; } } return true ; } public static boolean equalArraysOrNullSortFirst ( Comparable [ ] a , Comparable [ ] b ) { if ( a == b ) return true ; if ( a == null || b == null ) return false ; int len = a . length ; if ( len != b . length ) return false ; if ( len >= <NUM_LIT:2> ) { a = sortCopy ( a ) ; b = sortCopy ( b ) ; } for ( int i = <NUM_LIT:0> ; i < len ; ++ i ) { if ( ! a [ i ] . equals ( b [ i ] ) ) return false ; } return true ; } public static boolean equalArraysOrNullSortFirst ( String [ ] a , String [ ] b ) { if ( a == b ) return true ; if ( a == null || b == null ) return false ; int len = a . length ; if ( len != b . length ) return false ; if ( len >= <NUM_LIT:2> ) { a = sortCopy ( a ) ; b = sortCopy ( b ) ; } for ( int i = <NUM_LIT:0> ; i < len ; ++ i ) { if ( ! a [ i ] . equals ( b [ i ] ) ) return false ; } return true ; } public static boolean equalOrNull ( Object a , Object b ) { if ( a == b ) { return true ; } if ( a == null || b == null ) { return false ; } return a . equals ( b ) ; } public static boolean equalsIgnoreJavaLikeExtension ( String fileName , String string ) { int fileNameLength = fileName . length ( ) ; int stringLength = string . length ( ) ; if ( fileNameLength < stringLength ) return false ; for ( int i = <NUM_LIT:0> ; i < stringLength ; i ++ ) { if ( fileName . charAt ( i ) != string . charAt ( i ) ) { return false ; } } char [ ] [ ] javaLikeExtensions = getJavaLikeExtensions ( ) ; suffixes : for ( int i = <NUM_LIT:0> , length = javaLikeExtensions . length ; i < length ; i ++ ) { char [ ] suffix = javaLikeExtensions [ i ] ; int extensionStart = stringLength + <NUM_LIT:1> ; if ( extensionStart + suffix . length != fileNameLength ) continue ; if ( fileName . charAt ( stringLength ) != '<CHAR_LIT:.>' ) continue ; for ( int j = extensionStart ; j < fileNameLength ; j ++ ) { if ( fileName . charAt ( j ) != suffix [ j - extensionStart ] ) continue suffixes ; } return true ; } return false ; } public static String extractLastName ( String qualifiedName ) { int i = qualifiedName . lastIndexOf ( '<CHAR_LIT:.>' ) ; if ( i == - <NUM_LIT:1> ) return qualifiedName ; return qualifiedName . substring ( i + <NUM_LIT:1> ) ; } public static String [ ] extractParameterTypes ( char [ ] sig ) { int count = getParameterCount ( sig ) ; String [ ] result = new String [ count ] ; if ( count == <NUM_LIT:0> ) return result ; int i = CharOperation . indexOf ( '<CHAR_LIT:(>' , sig ) + <NUM_LIT:1> ; count = <NUM_LIT:0> ; int len = sig . length ; int start = i ; for ( ; ; ) { if ( i == len ) break ; char c = sig [ i ] ; if ( c == '<CHAR_LIT:)>' ) break ; if ( c == '<CHAR_LIT:[>' ) { ++ i ; } else if ( c == '<CHAR_LIT>' ) { i = CharOperation . indexOf ( '<CHAR_LIT:;>' , sig , i + <NUM_LIT:1> ) + <NUM_LIT:1> ; Assert . isTrue ( i != <NUM_LIT:0> ) ; result [ count ++ ] = convertTypeSignature ( sig , start , i - start ) ; start = i ; } else { ++ i ; result [ count ++ ] = convertTypeSignature ( sig , start , i - start ) ; start = i ; } } return result ; } public static String extractReturnType ( String sig ) { int i = sig . lastIndexOf ( '<CHAR_LIT:)>' ) ; Assert . isTrue ( i != - <NUM_LIT:1> ) ; return sig . substring ( i + <NUM_LIT:1> ) ; } private static IFile findFirstClassFile ( IFolder folder ) { try { IResource [ ] members = folder . members ( ) ; for ( int i = <NUM_LIT:0> , max = members . length ; i < max ; i ++ ) { IResource member = members [ i ] ; if ( member . getType ( ) == IResource . FOLDER ) { return findFirstClassFile ( ( IFolder ) member ) ; } else if ( org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( member . getName ( ) ) ) { return ( IFile ) member ; } } } catch ( CoreException e ) { } return null ; } public static String findLineSeparator ( char [ ] text ) { int length = text . length ; if ( length > <NUM_LIT:0> ) { char nextChar = text [ <NUM_LIT:0> ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char currentChar = nextChar ; nextChar = i < length - <NUM_LIT:1> ? text [ i + <NUM_LIT:1> ] : '<CHAR_LIT:U+0020>' ; switch ( currentChar ) { case '<STR_LIT:\n>' : return "<STR_LIT:n>" ; case '<STR_LIT>' : return nextChar == '<STR_LIT:\n>' ? "<STR_LIT>" : "<STR_LIT:r>" ; } } } return null ; } public static IClassFileAttribute getAttribute ( IClassFileReader classFileReader , char [ ] attributeName ) { IClassFileAttribute [ ] attributes = classFileReader . getAttributes ( ) ; for ( int i = <NUM_LIT:0> , max = attributes . length ; i < max ; i ++ ) { if ( CharOperation . equals ( attributes [ i ] . getAttributeName ( ) , attributeName ) ) { return attributes [ i ] ; } } return null ; } public static IClassFileAttribute getAttribute ( ICodeAttribute codeAttribute , char [ ] attributeName ) { IClassFileAttribute [ ] attributes = codeAttribute . getAttributes ( ) ; for ( int i = <NUM_LIT:0> , max = attributes . length ; i < max ; i ++ ) { if ( CharOperation . equals ( attributes [ i ] . getAttributeName ( ) , attributeName ) ) { return attributes [ i ] ; } } return null ; } public static IClassFileAttribute getAttribute ( IFieldInfo fieldInfo , char [ ] attributeName ) { IClassFileAttribute [ ] attributes = fieldInfo . getAttributes ( ) ; for ( int i = <NUM_LIT:0> , max = attributes . length ; i < max ; i ++ ) { if ( CharOperation . equals ( attributes [ i ] . getAttributeName ( ) , attributeName ) ) { return attributes [ i ] ; } } return null ; } public static IClassFileAttribute getAttribute ( IMethodInfo methodInfo , char [ ] attributeName ) { IClassFileAttribute [ ] attributes = methodInfo . getAttributes ( ) ; for ( int i = <NUM_LIT:0> , max = attributes . length ; i < max ; i ++ ) { if ( CharOperation . equals ( attributes [ i ] . getAttributeName ( ) , attributeName ) ) { return attributes [ i ] ; } } return null ; } private static IClassFile getClassFile ( char [ ] fileName ) { int jarSeparator = CharOperation . indexOf ( IDependent . JAR_FILE_ENTRY_SEPARATOR , fileName ) ; int pkgEnd = CharOperation . lastIndexOf ( '<CHAR_LIT:/>' , fileName ) ; if ( pkgEnd == - <NUM_LIT:1> ) pkgEnd = CharOperation . lastIndexOf ( File . separatorChar , fileName ) ; if ( jarSeparator != - <NUM_LIT:1> && pkgEnd < jarSeparator ) pkgEnd = jarSeparator ; if ( pkgEnd == - <NUM_LIT:1> ) return null ; IPackageFragment pkg = getPackageFragment ( fileName , pkgEnd , jarSeparator ) ; if ( pkg == null ) return null ; int start ; return pkg . getClassFile ( new String ( fileName , start = pkgEnd + <NUM_LIT:1> , fileName . length - start ) ) ; } private static ICompilationUnit getCompilationUnit ( char [ ] fileName , WorkingCopyOwner workingCopyOwner ) { char [ ] slashSeparatedFileName = CharOperation . replaceOnCopy ( fileName , File . separatorChar , '<CHAR_LIT:/>' ) ; int pkgEnd = CharOperation . lastIndexOf ( '<CHAR_LIT:/>' , slashSeparatedFileName ) ; if ( pkgEnd == - <NUM_LIT:1> ) return null ; IPackageFragment pkg = getPackageFragment ( slashSeparatedFileName , pkgEnd , - <NUM_LIT:1> ) ; if ( pkg == null ) return null ; int start ; ICompilationUnit cu = pkg . getCompilationUnit ( new String ( slashSeparatedFileName , start = pkgEnd + <NUM_LIT:1> , slashSeparatedFileName . length - start ) ) ; if ( workingCopyOwner != null ) { ICompilationUnit workingCopy = cu . findWorkingCopy ( workingCopyOwner ) ; if ( workingCopy != null ) return workingCopy ; } return cu ; } public static char [ ] [ ] getJavaLikeExtensions ( ) { if ( JAVA_LIKE_EXTENSIONS == null ) { IContentType javaContentType = Platform . getContentTypeManager ( ) . getContentType ( JavaCore . JAVA_SOURCE_CONTENT_TYPE ) ; HashSet fileExtensions = new HashSet ( ) ; IContentType [ ] contentTypes = Platform . getContentTypeManager ( ) . getAllContentTypes ( ) ; for ( int i = <NUM_LIT:0> , length = contentTypes . length ; i < length ; i ++ ) { if ( contentTypes [ i ] . isKindOf ( javaContentType ) ) { String [ ] fileExtension = contentTypes [ i ] . getFileSpecs ( IContentType . FILE_EXTENSION_SPEC ) ; for ( int j = <NUM_LIT:0> , length2 = fileExtension . length ; j < length2 ; j ++ ) { fileExtensions . add ( fileExtension [ j ] ) ; } } } int length = fileExtensions . size ( ) ; char [ ] [ ] extensions = new char [ length ] [ ] ; extensions [ <NUM_LIT:0> ] = SuffixConstants . EXTENSION_java . toCharArray ( ) ; int index = <NUM_LIT:1> ; Iterator iterator = fileExtensions . iterator ( ) ; while ( iterator . hasNext ( ) ) { String fileExtension = ( String ) iterator . next ( ) ; if ( SuffixConstants . EXTENSION_java . equals ( fileExtension ) ) continue ; extensions [ index ++ ] = fileExtension . toCharArray ( ) ; } JAVA_LIKE_EXTENSIONS = extensions ; } return JAVA_LIKE_EXTENSIONS ; } public static long getJdkLevel ( Object targetLibrary ) { try { ClassFileReader reader = null ; if ( targetLibrary instanceof IFolder ) { IFile classFile = findFirstClassFile ( ( IFolder ) targetLibrary ) ; if ( classFile != null ) reader = Util . newClassFileReader ( classFile ) ; } else { ZipFile jar = null ; try { IPath path = null ; if ( targetLibrary instanceof IResource ) { path = ( ( IResource ) targetLibrary ) . getFullPath ( ) ; } else if ( targetLibrary instanceof File ) { File f = ( File ) targetLibrary ; if ( ! f . isDirectory ( ) ) { path = new Path ( ( ( File ) targetLibrary ) . getPath ( ) ) ; } } if ( path != null ) { jar = JavaModelManager . getJavaModelManager ( ) . getZipFile ( path ) ; for ( Enumeration e = jar . entries ( ) ; e . hasMoreElements ( ) ; ) { ZipEntry member = ( ZipEntry ) e . nextElement ( ) ; String entryName = member . getName ( ) ; if ( org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( entryName ) ) { reader = ClassFileReader . read ( jar , entryName ) ; break ; } } } } catch ( CoreException e ) { } finally { JavaModelManager . getJavaModelManager ( ) . closeZipFile ( jar ) ; } } if ( reader != null ) { return reader . getVersion ( ) ; } } catch ( CoreException e ) { } catch ( ClassFormatException e ) { } catch ( IOException e ) { } return <NUM_LIT:0> ; } public static String getNameWithoutJavaLikeExtension ( String fileName ) { int index = indexOfJavaLikeExtension ( fileName ) ; if ( index == - <NUM_LIT:1> ) return fileName ; return fileName . substring ( <NUM_LIT:0> , index ) ; } public static String getLineSeparator ( String text , IJavaProject project ) { String lineSeparator = null ; if ( text != null && text . length ( ) != <NUM_LIT:0> ) { lineSeparator = findLineSeparator ( text . toCharArray ( ) ) ; if ( lineSeparator != null ) return lineSeparator ; } if ( Platform . isRunning ( ) ) { IScopeContext [ ] scopeContext ; if ( project != null ) { scopeContext = new IScopeContext [ ] { new ProjectScope ( project . getProject ( ) ) } ; lineSeparator = Platform . getPreferencesService ( ) . getString ( Platform . PI_RUNTIME , Platform . PREF_LINE_SEPARATOR , null , scopeContext ) ; if ( lineSeparator != null ) return lineSeparator ; } scopeContext = new IScopeContext [ ] { InstanceScope . INSTANCE } ; lineSeparator = Platform . getPreferencesService ( ) . getString ( Platform . PI_RUNTIME , Platform . PREF_LINE_SEPARATOR , null , scopeContext ) ; if ( lineSeparator != null ) return lineSeparator ; } return org . eclipse . jdt . internal . compiler . util . Util . LINE_SEPARATOR ; } private static String getLineSeparator ( char [ ] text , char [ ] buffer ) { String lineSeparator = findLineSeparator ( buffer ) ; if ( lineSeparator == null ) { lineSeparator = findLineSeparator ( text ) ; if ( lineSeparator == null ) { return getLineSeparator ( ( String ) null , ( IJavaProject ) null ) ; } } return lineSeparator ; } public static IPackageFragment getPackageFragment ( char [ ] fileName , int pkgEnd , int jarSeparator ) { if ( jarSeparator != - <NUM_LIT:1> ) { String jarMemento = new String ( fileName , <NUM_LIT:0> , jarSeparator ) ; PackageFragmentRoot root = ( PackageFragmentRoot ) JavaCore . create ( jarMemento ) ; if ( pkgEnd == jarSeparator ) return root . getPackageFragment ( CharOperation . NO_STRINGS ) ; char [ ] pkgName = CharOperation . subarray ( fileName , jarSeparator + <NUM_LIT:1> , pkgEnd ) ; char [ ] [ ] compoundName = CharOperation . splitOn ( '<CHAR_LIT:/>' , pkgName ) ; return root . getPackageFragment ( CharOperation . toStrings ( compoundName ) ) ; } else { Path path = new Path ( new String ( fileName , <NUM_LIT:0> , pkgEnd ) ) ; IWorkspaceRoot workspaceRoot = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ; IContainer folder = path . segmentCount ( ) == <NUM_LIT:1> ? workspaceRoot . getProject ( path . lastSegment ( ) ) : ( IContainer ) workspaceRoot . getFolder ( path ) ; IJavaElement element = JavaCore . create ( folder ) ; if ( element == null ) return null ; switch ( element . getElementType ( ) ) { case IJavaElement . PACKAGE_FRAGMENT : return ( IPackageFragment ) element ; case IJavaElement . PACKAGE_FRAGMENT_ROOT : return ( ( PackageFragmentRoot ) element ) . getPackageFragment ( CharOperation . NO_STRINGS ) ; case IJavaElement . JAVA_PROJECT : PackageFragmentRoot root = ( PackageFragmentRoot ) ( ( IJavaProject ) element ) . getPackageFragmentRoot ( folder ) ; if ( root == null ) return null ; return root . getPackageFragment ( CharOperation . NO_STRINGS ) ; } return null ; } } public static int getParameterCount ( char [ ] sig ) { int i = CharOperation . indexOf ( '<CHAR_LIT:(>' , sig ) + <NUM_LIT:1> ; Assert . isTrue ( i != <NUM_LIT:0> ) ; int count = <NUM_LIT:0> ; int len = sig . length ; for ( ; ; ) { if ( i == len ) break ; char c = sig [ i ] ; if ( c == '<CHAR_LIT:)>' ) break ; if ( c == '<CHAR_LIT:[>' ) { ++ i ; } else if ( c == '<CHAR_LIT>' ) { ++ count ; i = CharOperation . indexOf ( '<CHAR_LIT:;>' , sig , i + <NUM_LIT:1> ) + <NUM_LIT:1> ; Assert . isTrue ( i != <NUM_LIT:0> ) ; } else { ++ count ; ++ i ; } } return count ; } public static String getProblemArgumentsForMarker ( String [ ] arguments ) { StringBuffer args = new StringBuffer ( <NUM_LIT:10> ) ; args . append ( arguments . length ) ; args . append ( '<CHAR_LIT::>' ) ; for ( int j = <NUM_LIT:0> ; j < arguments . length ; j ++ ) { if ( j != <NUM_LIT:0> ) args . append ( ARGUMENTS_DELIMITER ) ; if ( arguments [ j ] . length ( ) == <NUM_LIT:0> ) { args . append ( EMPTY_ARGUMENT ) ; } else { encodeArgument ( arguments [ j ] , args ) ; } } return args . toString ( ) ; } private static void encodeArgument ( String argument , StringBuffer buffer ) { for ( int i = <NUM_LIT:0> , max = argument . length ( ) ; i < max ; i ++ ) { char charAt = argument . charAt ( i ) ; switch ( charAt ) { case ARGUMENTS_DELIMITER : buffer . append ( ARGUMENTS_DELIMITER ) . append ( ARGUMENTS_DELIMITER ) ; break ; default : buffer . append ( charAt ) ; } } } public static String [ ] getProblemArgumentsFromMarker ( String argumentsString ) { if ( argumentsString == null ) { return null ; } int index = argumentsString . indexOf ( '<CHAR_LIT::>' ) ; if ( index == - <NUM_LIT:1> ) return null ; int length = argumentsString . length ( ) ; int numberOfArg = <NUM_LIT:0> ; try { numberOfArg = Integer . parseInt ( argumentsString . substring ( <NUM_LIT:0> , index ) ) ; } catch ( NumberFormatException e ) { return null ; } argumentsString = argumentsString . substring ( index + <NUM_LIT:1> , length ) ; return decodeArgumentString ( numberOfArg , argumentsString ) ; } private static String [ ] decodeArgumentString ( int length , String argumentsString ) { if ( length == <NUM_LIT:0> ) { if ( argumentsString . length ( ) != <NUM_LIT:0> ) { return null ; } return CharOperation . NO_STRINGS ; } String [ ] result = new String [ length ] ; int count = <NUM_LIT:0> ; StringBuffer buffer = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> , max = argumentsString . length ( ) ; i < max ; i ++ ) { char current = argumentsString . charAt ( i ) ; switch ( current ) { case ARGUMENTS_DELIMITER : if ( ( i + <NUM_LIT:1> ) == max ) { return null ; } char next = argumentsString . charAt ( i + <NUM_LIT:1> ) ; if ( next == ARGUMENTS_DELIMITER ) { buffer . append ( ARGUMENTS_DELIMITER ) ; i ++ ; } else { String currentArgumentContents = String . valueOf ( buffer ) ; if ( EMPTY_ARGUMENT . equals ( currentArgumentContents ) ) { currentArgumentContents = org . eclipse . jdt . internal . compiler . util . Util . EMPTY_STRING ; } result [ count ++ ] = currentArgumentContents ; if ( count > length ) { return null ; } buffer . delete ( <NUM_LIT:0> , buffer . length ( ) ) ; } break ; default : buffer . append ( current ) ; } } String currentArgumentContents = String . valueOf ( buffer ) ; if ( EMPTY_ARGUMENT . equals ( currentArgumentContents ) ) { currentArgumentContents = org . eclipse . jdt . internal . compiler . util . Util . EMPTY_STRING ; } result [ count ++ ] = currentArgumentContents ; if ( count > length ) { return null ; } buffer . delete ( <NUM_LIT:0> , buffer . length ( ) ) ; return result ; } public static byte [ ] getResourceContentsAsByteArray ( IFile file ) throws JavaModelException { InputStream stream = null ; try { stream = file . getContents ( true ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } try { return org . eclipse . jdt . internal . compiler . util . Util . getInputStreamAsByteArray ( stream , - <NUM_LIT:1> ) ; } catch ( IOException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . IO_EXCEPTION ) ; } finally { try { stream . close ( ) ; } catch ( IOException e ) { } } } public static char [ ] getResourceContentsAsCharArray ( IFile file ) throws JavaModelException { String encoding ; try { encoding = file . getCharset ( ) ; } catch ( CoreException ce ) { encoding = null ; } return getResourceContentsAsCharArray ( file , encoding ) ; } public static char [ ] getResourceContentsAsCharArray ( IFile file , String encoding ) throws JavaModelException { IPath location = file . getLocation ( ) ; long length ; if ( location == null ) { try { URI locationURI = file . getLocationURI ( ) ; if ( locationURI == null ) throw new CoreException ( new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , Messages . bind ( Messages . file_notFound , file . getFullPath ( ) . toString ( ) ) ) ) ; length = EFS . getStore ( locationURI ) . fetchInfo ( ) . getLength ( ) ; } catch ( CoreException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST ) ; } } else { length = location . toFile ( ) . length ( ) ; } InputStream stream = null ; try { stream = file . getContents ( true ) ; } catch ( CoreException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST ) ; } try { return org . eclipse . jdt . internal . compiler . util . Util . getInputStreamAsCharArray ( stream , ( int ) length , encoding ) ; } catch ( IOException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . IO_EXCEPTION ) ; } finally { try { stream . close ( ) ; } catch ( IOException e ) { } } } public static String getSignature ( Type type ) { StringBuffer buffer = new StringBuffer ( ) ; getFullyQualifiedName ( type , buffer ) ; return Signature . createTypeSignature ( buffer . toString ( ) , false ) ; } public static String getSourceAttachmentProperty ( IPath path ) throws JavaModelException { Map rootPathToAttachments = JavaModelManager . getJavaModelManager ( ) . rootPathToAttachments ; String property = ( String ) rootPathToAttachments . get ( path ) ; if ( property == null ) { try { property = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getPersistentProperty ( getSourceAttachmentPropertyName ( path ) ) ; if ( property == null ) { rootPathToAttachments . put ( path , PackageFragmentRoot . NO_SOURCE_ATTACHMENT ) ; return null ; } rootPathToAttachments . put ( path , property ) ; return property ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } else if ( property . equals ( PackageFragmentRoot . NO_SOURCE_ATTACHMENT ) ) { return null ; } else return property ; } private static QualifiedName getSourceAttachmentPropertyName ( IPath path ) { return new QualifiedName ( JavaCore . PLUGIN_ID , "<STR_LIT>" + path . toOSString ( ) ) ; } public static void setSourceAttachmentProperty ( IPath path , String property ) { if ( property == null ) { JavaModelManager . getJavaModelManager ( ) . rootPathToAttachments . put ( path , PackageFragmentRoot . NO_SOURCE_ATTACHMENT ) ; } else { JavaModelManager . getJavaModelManager ( ) . rootPathToAttachments . put ( path , property ) ; } try { ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . setPersistentProperty ( getSourceAttachmentPropertyName ( path ) , property ) ; } catch ( CoreException e ) { e . printStackTrace ( ) ; } } public static String getDeclaringTypeSignature ( String key ) { KeyToSignature keyToSignature = new KeyToSignature ( key , KeyToSignature . DECLARING_TYPE ) ; keyToSignature . parse ( ) ; return keyToSignature . signature . toString ( ) ; } private static void getFullyQualifiedName ( Type type , StringBuffer buffer ) { switch ( type . getNodeType ( ) ) { case ASTNode . ARRAY_TYPE : ArrayType arrayType = ( ArrayType ) type ; getFullyQualifiedName ( arrayType . getElementType ( ) , buffer ) ; for ( int i = <NUM_LIT:0> , length = arrayType . getDimensions ( ) ; i < length ; i ++ ) { buffer . append ( '<CHAR_LIT:[>' ) ; buffer . append ( '<CHAR_LIT:]>' ) ; } break ; case ASTNode . PARAMETERIZED_TYPE : ParameterizedType parameterizedType = ( ParameterizedType ) type ; getFullyQualifiedName ( parameterizedType . getType ( ) , buffer ) ; buffer . append ( '<CHAR_LIT>' ) ; Iterator iterator = parameterizedType . typeArguments ( ) . iterator ( ) ; boolean isFirst = true ; while ( iterator . hasNext ( ) ) { if ( ! isFirst ) buffer . append ( '<CHAR_LIT:U+002C>' ) ; else isFirst = false ; Type typeArgument = ( Type ) iterator . next ( ) ; getFullyQualifiedName ( typeArgument , buffer ) ; } buffer . append ( '<CHAR_LIT:>>' ) ; break ; case ASTNode . PRIMITIVE_TYPE : buffer . append ( ( ( PrimitiveType ) type ) . getPrimitiveTypeCode ( ) . toString ( ) ) ; break ; case ASTNode . QUALIFIED_TYPE : buffer . append ( ( ( QualifiedType ) type ) . getName ( ) . getFullyQualifiedName ( ) ) ; break ; case ASTNode . SIMPLE_TYPE : buffer . append ( ( ( SimpleType ) type ) . getName ( ) . getFullyQualifiedName ( ) ) ; break ; case ASTNode . WILDCARD_TYPE : buffer . append ( '<CHAR_LIT>' ) ; WildcardType wildcardType = ( WildcardType ) type ; Type bound = wildcardType . getBound ( ) ; if ( bound == null ) return ; if ( wildcardType . isUpperBound ( ) ) { buffer . append ( "<STR_LIT>" ) ; } else { buffer . append ( "<STR_LIT>" ) ; } getFullyQualifiedName ( bound , buffer ) ; break ; } } public static String [ ] getTrimmedSimpleNames ( String name ) { String [ ] result = Signature . getSimpleNames ( name ) ; for ( int i = <NUM_LIT:0> , length = result . length ; i < length ; i ++ ) { result [ i ] = result [ i ] . trim ( ) ; } return result ; } public static JavaElement getUnresolvedJavaElement ( FieldBinding binding , WorkingCopyOwner workingCopyOwner , BindingsToNodesMap bindingsToNodes ) { if ( binding . declaringClass == null ) return null ; JavaElement unresolvedJavaElement = getUnresolvedJavaElement ( binding . declaringClass , workingCopyOwner , bindingsToNodes ) ; if ( unresolvedJavaElement == null || unresolvedJavaElement . getElementType ( ) != IJavaElement . TYPE ) { return null ; } return ( JavaElement ) ( ( IType ) unresolvedJavaElement ) . getField ( String . valueOf ( binding . name ) ) ; } public static JavaElement getUnresolvedJavaElement ( int localSourceStart , int localSourceEnd , JavaElement type ) { try { if ( ! ( type instanceof IType ) ) return null ; IInitializer [ ] initializers = ( ( IType ) type ) . getInitializers ( ) ; for ( int i = <NUM_LIT:0> ; i < initializers . length ; i ++ ) { IInitializer initializer = initializers [ i ] ; ISourceRange sourceRange = initializer . getSourceRange ( ) ; if ( sourceRange != null ) { int initializerStart = sourceRange . getOffset ( ) ; int initializerEnd = initializerStart + sourceRange . getLength ( ) ; if ( initializerStart <= localSourceStart && localSourceEnd <= initializerEnd ) { return ( JavaElement ) initializer ; } } } return null ; } catch ( JavaModelException e ) { return null ; } } public static JavaElement getUnresolvedJavaElement ( MethodBinding methodBinding , WorkingCopyOwner workingCopyOwner , BindingsToNodesMap bindingsToNodes ) { JavaElement unresolvedJavaElement = getUnresolvedJavaElement ( methodBinding . declaringClass , workingCopyOwner , bindingsToNodes ) ; if ( unresolvedJavaElement == null || unresolvedJavaElement . getElementType ( ) != IJavaElement . TYPE ) { return null ; } IType declaringType = ( IType ) unresolvedJavaElement ; org . eclipse . jdt . internal . compiler . ast . ASTNode node = bindingsToNodes == null ? null : bindingsToNodes . get ( methodBinding ) ; if ( node != null && ! declaringType . isBinary ( ) ) { if ( node instanceof AnnotationMethodDeclaration ) { AnnotationMethodDeclaration typeMemberDeclaration = ( AnnotationMethodDeclaration ) node ; return ( JavaElement ) declaringType . getMethod ( String . valueOf ( typeMemberDeclaration . selector ) , CharOperation . NO_STRINGS ) ; } else { MethodDeclaration methodDeclaration = ( MethodDeclaration ) node ; Argument [ ] arguments = methodDeclaration . arguments ; String [ ] parameterSignatures ; if ( arguments != null ) { parameterSignatures = new String [ arguments . length ] ; for ( int i = <NUM_LIT:0> ; i < arguments . length ; i ++ ) { Argument argument = arguments [ i ] ; TypeReference typeReference = argument . type ; int arrayDim = typeReference . dimensions ( ) ; String typeSig = Signature . createTypeSignature ( CharOperation . concatWith ( typeReference . getTypeName ( ) , '<CHAR_LIT:.>' ) , false ) ; if ( arrayDim > <NUM_LIT:0> ) { typeSig = Signature . createArraySignature ( typeSig , arrayDim ) ; } parameterSignatures [ i ] = typeSig ; } } else { parameterSignatures = CharOperation . NO_STRINGS ; } return ( JavaElement ) declaringType . getMethod ( String . valueOf ( methodDeclaration . selector ) , parameterSignatures ) ; } } else { org . eclipse . jdt . internal . compiler . lookup . MethodBinding original = methodBinding . original ( ) ; String selector = original . isConstructor ( ) ? declaringType . getElementName ( ) : new String ( original . selector ) ; boolean isBinary = declaringType . isBinary ( ) ; ReferenceBinding enclosingType = original . declaringClass . enclosingType ( ) ; boolean isInnerBinaryTypeConstructor = isBinary && original . isConstructor ( ) && enclosingType != null ; TypeBinding [ ] parameters = original . parameters ; int length = parameters == null ? <NUM_LIT:0> : parameters . length ; int declaringIndex = isInnerBinaryTypeConstructor ? <NUM_LIT:1> : <NUM_LIT:0> ; String [ ] parameterSignatures = new String [ declaringIndex + length ] ; if ( isInnerBinaryTypeConstructor ) parameterSignatures [ <NUM_LIT:0> ] = new String ( enclosingType . genericTypeSignature ( ) ) . replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char [ ] signature = parameters [ i ] . genericTypeSignature ( ) ; if ( isBinary ) { signature = CharOperation . replaceOnCopy ( signature , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; } else { signature = toUnresolvedTypeSignature ( signature ) ; } parameterSignatures [ declaringIndex + i ] = new String ( signature ) ; } IMethod result = declaringType . getMethod ( selector , parameterSignatures ) ; if ( isBinary ) return ( JavaElement ) result ; if ( result . exists ( ) ) return ( JavaElement ) result ; IMethod [ ] methods = null ; try { methods = declaringType . getMethods ( ) ; } catch ( JavaModelException e ) { return null ; } IMethod [ ] candidates = Member . findMethods ( result , methods ) ; if ( candidates == null || candidates . length == <NUM_LIT:0> ) return null ; return ( JavaElement ) candidates [ <NUM_LIT:0> ] ; } } public static JavaElement getUnresolvedJavaElement ( TypeBinding typeBinding , WorkingCopyOwner workingCopyOwner , BindingsToNodesMap bindingsToNodes ) { if ( typeBinding == null ) return null ; switch ( typeBinding . kind ( ) ) { case Binding . ARRAY_TYPE : typeBinding = ( ( org . eclipse . jdt . internal . compiler . lookup . ArrayBinding ) typeBinding ) . leafComponentType ( ) ; return getUnresolvedJavaElement ( typeBinding , workingCopyOwner , bindingsToNodes ) ; case Binding . BASE_TYPE : case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : return null ; default : if ( typeBinding . isCapture ( ) ) return null ; } ReferenceBinding referenceBinding ; if ( typeBinding . isParameterizedType ( ) || typeBinding . isRawType ( ) ) referenceBinding = ( ReferenceBinding ) typeBinding . erasure ( ) ; else referenceBinding = ( ReferenceBinding ) typeBinding ; char [ ] fileName = referenceBinding . getFileName ( ) ; if ( referenceBinding . isLocalType ( ) || referenceBinding . isAnonymousType ( ) ) { if ( org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( fileName ) ) { int jarSeparator = CharOperation . indexOf ( IDependent . JAR_FILE_ENTRY_SEPARATOR , fileName ) ; int pkgEnd = CharOperation . lastIndexOf ( '<CHAR_LIT:/>' , fileName ) ; if ( pkgEnd == - <NUM_LIT:1> ) pkgEnd = CharOperation . lastIndexOf ( File . separatorChar , fileName ) ; if ( jarSeparator != - <NUM_LIT:1> && pkgEnd < jarSeparator ) pkgEnd = jarSeparator ; if ( pkgEnd == - <NUM_LIT:1> ) return null ; IPackageFragment pkg = getPackageFragment ( fileName , pkgEnd , jarSeparator ) ; char [ ] constantPoolName = referenceBinding . constantPoolName ( ) ; if ( constantPoolName == null ) { ClassFile classFile = ( ClassFile ) getClassFile ( fileName ) ; return classFile == null ? null : ( JavaElement ) classFile . getType ( ) ; } pkgEnd = CharOperation . lastIndexOf ( '<CHAR_LIT:/>' , constantPoolName ) ; char [ ] classFileName = CharOperation . subarray ( constantPoolName , pkgEnd + <NUM_LIT:1> , constantPoolName . length ) ; ClassFile classFile = ( ClassFile ) pkg . getClassFile ( new String ( classFileName ) + SuffixConstants . SUFFIX_STRING_class ) ; return ( JavaElement ) classFile . getType ( ) ; } ICompilationUnit cu = getCompilationUnit ( fileName , workingCopyOwner ) ; if ( cu == null ) return null ; try { int sourceStart = ( ( org . eclipse . jdt . internal . compiler . lookup . LocalTypeBinding ) referenceBinding ) . sourceStart ; return ( JavaElement ) cu . getElementAt ( sourceStart ) ; } catch ( JavaModelException e ) { return null ; } } else if ( referenceBinding . isTypeVariable ( ) ) { final String typeVariableName = new String ( referenceBinding . sourceName ( ) ) ; org . eclipse . jdt . internal . compiler . lookup . Binding declaringElement = ( ( org . eclipse . jdt . internal . compiler . lookup . TypeVariableBinding ) referenceBinding ) . declaringElement ; if ( declaringElement instanceof MethodBinding ) { IMethod declaringMethod = ( IMethod ) getUnresolvedJavaElement ( ( MethodBinding ) declaringElement , workingCopyOwner , bindingsToNodes ) ; return ( JavaElement ) declaringMethod . getTypeParameter ( typeVariableName ) ; } else { IType declaringType = ( IType ) getUnresolvedJavaElement ( ( TypeBinding ) declaringElement , workingCopyOwner , bindingsToNodes ) ; return ( JavaElement ) declaringType . getTypeParameter ( typeVariableName ) ; } } else { if ( fileName == null ) return null ; TypeBinding declaringTypeBinding = typeBinding . enclosingType ( ) ; if ( declaringTypeBinding == null ) { if ( org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( fileName ) ) { ClassFile classFile = ( ClassFile ) getClassFile ( fileName ) ; if ( classFile == null ) return null ; return ( JavaElement ) classFile . getType ( ) ; } ICompilationUnit cu = getCompilationUnit ( fileName , workingCopyOwner ) ; if ( cu == null ) return null ; return ( JavaElement ) cu . getType ( new String ( referenceBinding . sourceName ( ) ) ) ; } else { IType declaringType = ( IType ) getUnresolvedJavaElement ( declaringTypeBinding , workingCopyOwner , bindingsToNodes ) ; if ( declaringType == null ) return null ; return ( JavaElement ) declaringType . getType ( new String ( referenceBinding . sourceName ( ) ) ) ; } } } public static int indexOfEnclosingPath ( IPath checkedPath , IPath [ ] paths , int pathCount ) { int bestMatch = - <NUM_LIT:1> , bestLength = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < pathCount ; i ++ ) { if ( paths [ i ] . equals ( checkedPath ) ) continue ; if ( paths [ i ] . isPrefixOf ( checkedPath ) ) { int currentLength = paths [ i ] . segmentCount ( ) ; if ( currentLength > bestLength ) { bestLength = currentLength ; bestMatch = i ; } } } return bestMatch ; } public static int indexOfJavaLikeExtension ( String fileName ) { int fileNameLength = fileName . length ( ) ; char [ ] [ ] javaLikeExtensions = getJavaLikeExtensions ( ) ; extensions : for ( int i = <NUM_LIT:0> , length = javaLikeExtensions . length ; i < length ; i ++ ) { char [ ] extension = javaLikeExtensions [ i ] ; int extensionLength = extension . length ; int extensionStart = fileNameLength - extensionLength ; int dotIndex = extensionStart - <NUM_LIT:1> ; if ( dotIndex < <NUM_LIT:0> ) continue ; if ( fileName . charAt ( dotIndex ) != '<CHAR_LIT:.>' ) continue ; for ( int j = <NUM_LIT:0> ; j < extensionLength ; j ++ ) { if ( fileName . charAt ( extensionStart + j ) != extension [ j ] ) continue extensions ; } return dotIndex ; } return - <NUM_LIT:1> ; } public static int indexOfMatchingPath ( IPath checkedPath , IPath [ ] paths , int pathCount ) { for ( int i = <NUM_LIT:0> ; i < pathCount ; i ++ ) { if ( paths [ i ] . equals ( checkedPath ) ) return i ; } return - <NUM_LIT:1> ; } public static int indexOfNestedPath ( IPath checkedPath , IPath [ ] paths , int pathCount ) { for ( int i = <NUM_LIT:0> ; i < pathCount ; i ++ ) { if ( checkedPath . equals ( paths [ i ] ) ) continue ; if ( checkedPath . isPrefixOf ( paths [ i ] ) ) return i ; } return - <NUM_LIT:1> ; } protected static boolean isAttributeSupported ( int attribute ) { return ( EFS . getLocalFileSystem ( ) . attributes ( ) & attribute ) != <NUM_LIT:0> ; } public static boolean isReadOnly ( IResource resource ) { if ( isReadOnlySupported ( ) ) { ResourceAttributes resourceAttributes = resource . getResourceAttributes ( ) ; if ( resourceAttributes == null ) return false ; return resourceAttributes . isReadOnly ( ) ; } return false ; } public static boolean isReadOnlySupported ( ) { return isAttributeSupported ( EFS . ATTRIBUTE_READ_ONLY ) ; } public static final boolean isExcluded ( IJavaElement element ) { int elementType = element . getElementType ( ) ; switch ( elementType ) { case IJavaElement . JAVA_MODEL : case IJavaElement . JAVA_PROJECT : case IJavaElement . PACKAGE_FRAGMENT_ROOT : return false ; case IJavaElement . PACKAGE_FRAGMENT : PackageFragmentRoot root = ( PackageFragmentRoot ) element . getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; IResource resource = ( ( PackageFragment ) element ) . resource ( ) ; return resource != null && isExcluded ( resource , root . fullInclusionPatternChars ( ) , root . fullExclusionPatternChars ( ) ) ; case IJavaElement . COMPILATION_UNIT : root = ( PackageFragmentRoot ) element . getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; resource = element . getResource ( ) ; if ( resource == null ) return false ; if ( isExcluded ( resource , root . fullInclusionPatternChars ( ) , root . fullExclusionPatternChars ( ) ) ) return true ; return isExcluded ( element . getParent ( ) ) ; default : IJavaElement cu = element . getAncestor ( IJavaElement . COMPILATION_UNIT ) ; return cu != null && isExcluded ( cu ) ; } } public final static boolean isExcluded ( IPath resourcePath , char [ ] [ ] inclusionPatterns , char [ ] [ ] exclusionPatterns , boolean isFolderPath ) { if ( inclusionPatterns == null && exclusionPatterns == null ) return false ; return org . eclipse . jdt . internal . compiler . util . Util . isExcluded ( resourcePath . toString ( ) . toCharArray ( ) , inclusionPatterns , exclusionPatterns , isFolderPath ) ; } public final static boolean isExcluded ( IResource resource , char [ ] [ ] inclusionPatterns , char [ ] [ ] exclusionPatterns ) { IPath path = resource . getFullPath ( ) ; int resourceType = resource . getType ( ) ; return isExcluded ( path , inclusionPatterns , exclusionPatterns , resourceType == IResource . FOLDER || resourceType == IResource . PROJECT ) ; } public static boolean isValidClassFileName ( String name , String sourceLevel , String complianceLevel ) { return JavaConventions . validateClassFileName ( name , sourceLevel , complianceLevel ) . getSeverity ( ) != IStatus . ERROR ; } public static boolean isValidCompilationUnitName ( String name , String sourceLevel , String complianceLevel ) { return JavaConventions . validateCompilationUnitName ( name , sourceLevel , complianceLevel ) . getSeverity ( ) != IStatus . ERROR ; } public static boolean isValidFolderNameForPackage ( String folderName , String sourceLevel , String complianceLevel ) { return JavaConventions . validateIdentifier ( folderName , sourceLevel , complianceLevel ) . getSeverity ( ) != IStatus . ERROR ; } public static boolean isValidMethodSignature ( String sig ) { int len = sig . length ( ) ; if ( len == <NUM_LIT:0> ) return false ; int i = <NUM_LIT:0> ; char c = sig . charAt ( i ++ ) ; if ( c != '<CHAR_LIT:(>' ) return false ; if ( i >= len ) return false ; while ( sig . charAt ( i ) != '<CHAR_LIT:)>' ) { i = checkTypeSignature ( sig , i , len , false ) ; if ( i == - <NUM_LIT:1> ) return false ; if ( i >= len ) return false ; } ++ i ; i = checkTypeSignature ( sig , i , len , true ) ; return i == len ; } public static boolean isValidTypeSignature ( String sig , boolean allowVoid ) { int len = sig . length ( ) ; return checkTypeSignature ( sig , <NUM_LIT:0> , len , allowVoid ) == len ; } public static String localTypeName ( String binaryTypeName , int lastDollar , int end ) { if ( lastDollar > <NUM_LIT:0> && binaryTypeName . charAt ( lastDollar - <NUM_LIT:1> ) == '<CHAR_LIT>' ) return binaryTypeName ; int nameStart = lastDollar + <NUM_LIT:1> ; while ( nameStart < end && Character . isDigit ( binaryTypeName . charAt ( nameStart ) ) ) nameStart ++ ; return binaryTypeName . substring ( nameStart , end ) ; } public static void log ( Throwable e , String message ) { Throwable nestedException ; if ( e instanceof JavaModelException && ( nestedException = ( ( JavaModelException ) e ) . getException ( ) ) != null ) { e = nestedException ; } log ( new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , IStatus . ERROR , message , e ) ) ; } public static void logRepeatedMessage ( String key , Exception e ) { if ( key == null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } if ( fgRepeatedMessages . contains ( key ) ) { return ; } fgRepeatedMessages . add ( key ) ; log ( e ) ; } public static void logRepeatedMessage ( String key , int statusErrorID , String message ) { if ( key == null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } if ( fgRepeatedMessages . contains ( key ) ) { return ; } fgRepeatedMessages . add ( key ) ; log ( statusErrorID , message ) ; } public static void log ( int statusErrorID , String message ) { log ( new Status ( statusErrorID , JavaCore . PLUGIN_ID , message ) ) ; } public static void log ( IStatus status ) { JavaCore . getPlugin ( ) . getLog ( ) . log ( status ) ; } public static void log ( Throwable e ) { log ( new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , Messages . code_assist_internal_error , e ) ) ; } public static ClassFileReader newClassFileReader ( IResource resource ) throws CoreException , ClassFormatException , IOException { InputStream in = null ; try { in = ( ( IFile ) resource ) . getContents ( true ) ; return ClassFileReader . read ( in , resource . getFullPath ( ) . toString ( ) ) ; } finally { if ( in != null ) in . close ( ) ; } } public static char [ ] normalizeCRs ( char [ ] text , char [ ] buffer ) { CharArrayBuffer result = new CharArrayBuffer ( ) ; int lineStart = <NUM_LIT:0> ; int length = text . length ; if ( length == <NUM_LIT:0> ) return text ; String lineSeparator = getLineSeparator ( text , buffer ) ; char nextChar = text [ <NUM_LIT:0> ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char currentChar = nextChar ; nextChar = i < length - <NUM_LIT:1> ? text [ i + <NUM_LIT:1> ] : '<CHAR_LIT:U+0020>' ; switch ( currentChar ) { case '<STR_LIT:\n>' : int lineLength = i - lineStart ; char [ ] line = new char [ lineLength ] ; System . arraycopy ( text , lineStart , line , <NUM_LIT:0> , lineLength ) ; result . append ( line ) ; result . append ( lineSeparator ) ; lineStart = i + <NUM_LIT:1> ; break ; case '<STR_LIT>' : lineLength = i - lineStart ; if ( lineLength >= <NUM_LIT:0> ) { line = new char [ lineLength ] ; System . arraycopy ( text , lineStart , line , <NUM_LIT:0> , lineLength ) ; result . append ( line ) ; result . append ( lineSeparator ) ; if ( nextChar == '<STR_LIT:\n>' ) { nextChar = '<CHAR_LIT:U+0020>' ; lineStart = i + <NUM_LIT:2> ; } else { lineStart = i + <NUM_LIT:1> ; } } else { lineStart = i + <NUM_LIT:1> ; } break ; } } char [ ] lastLine ; if ( lineStart > <NUM_LIT:0> ) { int lastLineLength = length - lineStart ; if ( lastLineLength > <NUM_LIT:0> ) { lastLine = new char [ lastLineLength ] ; System . arraycopy ( text , lineStart , lastLine , <NUM_LIT:0> , lastLineLength ) ; result . append ( lastLine ) ; } return result . getContents ( ) ; } return text ; } public static String normalizeCRs ( String text , String buffer ) { return new String ( normalizeCRs ( text . toCharArray ( ) , buffer . toCharArray ( ) ) ) ; } public static String packageName ( IPath pkgPath , String sourceLevel , String complianceLevel ) { StringBuffer pkgName = new StringBuffer ( IPackageFragment . DEFAULT_PACKAGE_NAME ) ; for ( int j = <NUM_LIT:0> , max = pkgPath . segmentCount ( ) ; j < max ; j ++ ) { String segment = pkgPath . segment ( j ) ; if ( ! isValidFolderNameForPackage ( segment , sourceLevel , complianceLevel ) ) { return null ; } pkgName . append ( segment ) ; if ( j < pkgPath . segmentCount ( ) - <NUM_LIT:1> ) { pkgName . append ( "<STR_LIT:.>" ) ; } } return pkgName . toString ( ) ; } public static int prefixLength ( char [ ] s1 , char [ ] s2 ) { int len = <NUM_LIT:0> ; int max = Math . min ( s1 . length , s2 . length ) ; for ( int i = <NUM_LIT:0> ; i < max && s1 [ i ] == s2 [ i ] ; ++ i ) ++ len ; return len ; } public static int prefixLength ( String s1 , String s2 ) { int len = <NUM_LIT:0> ; int max = Math . min ( s1 . length ( ) , s2 . length ( ) ) ; for ( int i = <NUM_LIT:0> ; i < max && s1 . charAt ( i ) == s2 . charAt ( i ) ; ++ i ) ++ len ; return len ; } private static void quickSort ( char [ ] [ ] list , int left , int right ) { int original_left = left ; int original_right = right ; char [ ] mid = list [ left + ( right - left ) / <NUM_LIT:2> ] ; do { while ( compare ( list [ left ] , mid ) < <NUM_LIT:0> ) { left ++ ; } while ( compare ( mid , list [ right ] ) < <NUM_LIT:0> ) { right -- ; } if ( left <= right ) { char [ ] tmp = list [ left ] ; list [ left ] = list [ right ] ; list [ right ] = tmp ; left ++ ; right -- ; } } while ( left <= right ) ; if ( original_left < right ) { quickSort ( list , original_left , right ) ; } if ( left < original_right ) { quickSort ( list , left , original_right ) ; } } private static void quickSort ( Comparable [ ] sortedCollection , int left , int right ) { int original_left = left ; int original_right = right ; Comparable mid = sortedCollection [ left + ( right - left ) / <NUM_LIT:2> ] ; do { while ( sortedCollection [ left ] . compareTo ( mid ) < <NUM_LIT:0> ) { left ++ ; } while ( mid . compareTo ( sortedCollection [ right ] ) < <NUM_LIT:0> ) { right -- ; } if ( left <= right ) { Comparable tmp = sortedCollection [ left ] ; sortedCollection [ left ] = sortedCollection [ right ] ; sortedCollection [ right ] = tmp ; left ++ ; right -- ; } } while ( left <= right ) ; if ( original_left < right ) { quickSort ( sortedCollection , original_left , right ) ; } if ( left < original_right ) { quickSort ( sortedCollection , left , original_right ) ; } } private static void quickSort ( int [ ] list , int left , int right ) { int original_left = left ; int original_right = right ; int mid = list [ left + ( right - left ) / <NUM_LIT:2> ] ; do { while ( list [ left ] < mid ) { left ++ ; } while ( mid < list [ right ] ) { right -- ; } if ( left <= right ) { int tmp = list [ left ] ; list [ left ] = list [ right ] ; list [ right ] = tmp ; left ++ ; right -- ; } } while ( left <= right ) ; if ( original_left < right ) { quickSort ( list , original_left , right ) ; } if ( left < original_right ) { quickSort ( list , left , original_right ) ; } } private static void quickSort ( Object [ ] sortedCollection , int left , int right , Comparer comparer ) { int original_left = left ; int original_right = right ; Object mid = sortedCollection [ left + ( right - left ) / <NUM_LIT:2> ] ; do { while ( comparer . compare ( sortedCollection [ left ] , mid ) < <NUM_LIT:0> ) { left ++ ; } while ( comparer . compare ( mid , sortedCollection [ right ] ) < <NUM_LIT:0> ) { right -- ; } if ( left <= right ) { Object tmp = sortedCollection [ left ] ; sortedCollection [ left ] = sortedCollection [ right ] ; sortedCollection [ right ] = tmp ; left ++ ; right -- ; } } while ( left <= right ) ; if ( original_left < right ) { quickSort ( sortedCollection , original_left , right , comparer ) ; } if ( left < original_right ) { quickSort ( sortedCollection , left , original_right , comparer ) ; } } private static void quickSort ( String [ ] sortedCollection , int left , int right ) { int original_left = left ; int original_right = right ; String mid = sortedCollection [ left + ( right - left ) / <NUM_LIT:2> ] ; do { while ( sortedCollection [ left ] . compareTo ( mid ) < <NUM_LIT:0> ) { left ++ ; } while ( mid . compareTo ( sortedCollection [ right ] ) < <NUM_LIT:0> ) { right -- ; } if ( left <= right ) { String tmp = sortedCollection [ left ] ; sortedCollection [ left ] = sortedCollection [ right ] ; sortedCollection [ right ] = tmp ; left ++ ; right -- ; } } while ( left <= right ) ; if ( original_left < right ) { quickSort ( sortedCollection , original_left , right ) ; } if ( left < original_right ) { quickSort ( sortedCollection , left , original_right ) ; } } public static String relativePath ( IPath fullPath , int skipSegmentCount ) { boolean hasTrailingSeparator = fullPath . hasTrailingSeparator ( ) ; String [ ] segments = fullPath . segments ( ) ; int length = <NUM_LIT:0> ; int max = segments . length ; if ( max > skipSegmentCount ) { for ( int i1 = skipSegmentCount ; i1 < max ; i1 ++ ) { length += segments [ i1 ] . length ( ) ; } length += max - skipSegmentCount - <NUM_LIT:1> ; } if ( hasTrailingSeparator ) length ++ ; char [ ] result = new char [ length ] ; int offset = <NUM_LIT:0> ; int len = segments . length - <NUM_LIT:1> ; if ( len >= skipSegmentCount ) { for ( int i = skipSegmentCount ; i < len ; i ++ ) { int size = segments [ i ] . length ( ) ; segments [ i ] . getChars ( <NUM_LIT:0> , size , result , offset ) ; offset += size ; result [ offset ++ ] = '<CHAR_LIT:/>' ; } int size = segments [ len ] . length ( ) ; segments [ len ] . getChars ( <NUM_LIT:0> , size , result , offset ) ; offset += size ; } if ( hasTrailingSeparator ) result [ offset ++ ] = '<CHAR_LIT:/>' ; return new String ( result ) ; } public static void resetJavaLikeExtensions ( ) { JAVA_LIKE_EXTENSIONS = null ; } public static int scanTypeSignature ( char [ ] string , int start ) { return org . eclipse . jdt . internal . compiler . util . Util . scanTypeSignature ( string , start ) ; } public static final String [ ] splitOn ( char divider , String string , int start , int end ) { int length = string == null ? <NUM_LIT:0> : string . length ( ) ; if ( length == <NUM_LIT:0> || start > end ) return CharOperation . NO_STRINGS ; int wordCount = <NUM_LIT:1> ; for ( int i = start ; i < end ; i ++ ) if ( string . charAt ( i ) == divider ) wordCount ++ ; String [ ] split = new String [ wordCount ] ; int last = start , currentWord = <NUM_LIT:0> ; for ( int i = start ; i < end ; i ++ ) { if ( string . charAt ( i ) == divider ) { split [ currentWord ++ ] = string . substring ( last , i ) ; last = i + <NUM_LIT:1> ; } } split [ currentWord ] = string . substring ( last , end ) ; return split ; } public static void setReadOnly ( IResource resource , boolean readOnly ) { if ( isReadOnlySupported ( ) ) { ResourceAttributes resourceAttributes = resource . getResourceAttributes ( ) ; if ( resourceAttributes == null ) return ; resourceAttributes . setReadOnly ( readOnly ) ; try { resource . setResourceAttributes ( resourceAttributes ) ; } catch ( CoreException e ) { } } } public static void sort ( char [ ] [ ] list ) { if ( list . length > <NUM_LIT:1> ) quickSort ( list , <NUM_LIT:0> , list . length - <NUM_LIT:1> ) ; } public static void sort ( Comparable [ ] objects ) { if ( objects . length > <NUM_LIT:1> ) quickSort ( objects , <NUM_LIT:0> , objects . length - <NUM_LIT:1> ) ; } public static void sort ( int [ ] list ) { if ( list . length > <NUM_LIT:1> ) quickSort ( list , <NUM_LIT:0> , list . length - <NUM_LIT:1> ) ; } public static void sort ( Object [ ] objects , Comparer comparer ) { if ( objects . length > <NUM_LIT:1> ) quickSort ( objects , <NUM_LIT:0> , objects . length - <NUM_LIT:1> , comparer ) ; } public static void sort ( String [ ] strings ) { if ( strings . length > <NUM_LIT:1> ) quickSort ( strings , <NUM_LIT:0> , strings . length - <NUM_LIT:1> ) ; } public static Comparable [ ] sortCopy ( Comparable [ ] objects ) { int len = objects . length ; Comparable [ ] copy = new Comparable [ len ] ; System . arraycopy ( objects , <NUM_LIT:0> , copy , <NUM_LIT:0> , len ) ; sort ( copy ) ; return copy ; } public static IJavaElement [ ] sortCopy ( IJavaElement [ ] elements ) { int len = elements . length ; IJavaElement [ ] copy = new IJavaElement [ len ] ; System . arraycopy ( elements , <NUM_LIT:0> , copy , <NUM_LIT:0> , len ) ; sort ( copy , new Comparer ( ) { public int compare ( Object a , Object b ) { return ( ( JavaElement ) a ) . toStringWithAncestors ( ) . compareTo ( ( ( JavaElement ) b ) . toStringWithAncestors ( ) ) ; } } ) ; return copy ; } public static Object [ ] sortCopy ( Object [ ] objects , Comparer comparer ) { int len = objects . length ; Object [ ] copy = new Object [ len ] ; System . arraycopy ( objects , <NUM_LIT:0> , copy , <NUM_LIT:0> , len ) ; sort ( copy , comparer ) ; return copy ; } public static String [ ] sortCopy ( String [ ] objects ) { int len = objects . length ; String [ ] copy = new String [ len ] ; System . arraycopy ( objects , <NUM_LIT:0> , copy , <NUM_LIT:0> , len ) ; sort ( copy ) ; return copy ; } public static boolean startsWithIgnoreCase ( String [ ] compoundName , String [ ] prefix , boolean partialMatch ) { int prefixLength = prefix . length ; int nameLength = compoundName . length ; if ( prefixLength > nameLength ) return false ; for ( int i = <NUM_LIT:0> ; i < prefixLength - <NUM_LIT:1> ; i ++ ) { if ( ! compoundName [ i ] . equalsIgnoreCase ( prefix [ i ] ) ) return false ; } return ( partialMatch || prefixLength == nameLength ) && compoundName [ prefixLength - <NUM_LIT:1> ] . toLowerCase ( ) . startsWith ( prefix [ prefixLength - <NUM_LIT:1> ] . toLowerCase ( ) ) ; } public static char [ ] [ ] toCharArrays ( String [ ] a ) { int len = a . length ; if ( len == <NUM_LIT:0> ) return CharOperation . NO_CHAR_CHAR ; char [ ] [ ] result = new char [ len ] [ ] ; for ( int i = <NUM_LIT:0> ; i < len ; ++ i ) { result [ i ] = a [ i ] . toCharArray ( ) ; } return result ; } public static char [ ] [ ] toCompoundChars ( String s ) { int len = s . length ( ) ; if ( len == <NUM_LIT:0> ) { return CharOperation . NO_CHAR_CHAR ; } int segCount = <NUM_LIT:1> ; for ( int off = s . indexOf ( '<CHAR_LIT:.>' ) ; off != - <NUM_LIT:1> ; off = s . indexOf ( '<CHAR_LIT:.>' , off + <NUM_LIT:1> ) ) { ++ segCount ; } char [ ] [ ] segs = new char [ segCount ] [ ] ; int start = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < segCount ; ++ i ) { int dot = s . indexOf ( '<CHAR_LIT:.>' , start ) ; int end = ( dot == - <NUM_LIT:1> ? s . length ( ) : dot ) ; segs [ i ] = new char [ end - start ] ; s . getChars ( start , end , segs [ i ] , <NUM_LIT:0> ) ; start = end + <NUM_LIT:1> ; } return segs ; } public static File toLocalFile ( URI uri , IProgressMonitor monitor ) throws CoreException { IFileStore fileStore = EFS . getStore ( uri ) ; File localFile = fileStore . toLocalFile ( EFS . NONE , monitor ) ; if ( localFile == null ) localFile = fileStore . toLocalFile ( EFS . CACHE , monitor ) ; return localFile ; } public static String toString ( char [ ] [ ] c ) { StringBuffer sb = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> , max = c . length ; i < max ; ++ i ) { if ( i != <NUM_LIT:0> ) sb . append ( '<CHAR_LIT:.>' ) ; sb . append ( c [ i ] ) ; } return sb . toString ( ) ; } public static String toString ( char [ ] [ ] c , char [ ] d ) { if ( c == null ) return new String ( d ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> , max = c . length ; i < max ; ++ i ) { sb . append ( c [ i ] ) ; sb . append ( '<CHAR_LIT:.>' ) ; } sb . append ( d ) ; return sb . toString ( ) ; } public static String [ ] toStrings ( char [ ] [ ] a ) { int len = a . length ; String [ ] result = new String [ len ] ; for ( int i = <NUM_LIT:0> ; i < len ; ++ i ) { result [ i ] = new String ( a [ i ] ) ; } return result ; } private static char [ ] toUnresolvedTypeSignature ( char [ ] signature ) { int length = signature . length ; if ( length <= <NUM_LIT:1> ) return signature ; StringBuffer buffer = new StringBuffer ( length ) ; toUnresolvedTypeSignature ( signature , <NUM_LIT:0> , length , buffer ) ; int bufferLength = buffer . length ( ) ; char [ ] result = new char [ bufferLength ] ; buffer . getChars ( <NUM_LIT:0> , bufferLength , result , <NUM_LIT:0> ) ; return result ; } private static int toUnresolvedTypeSignature ( char [ ] signature , int start , int length , StringBuffer buffer ) { if ( signature [ start ] == Signature . C_RESOLVED ) buffer . append ( Signature . C_UNRESOLVED ) ; else buffer . append ( signature [ start ] ) ; for ( int i = start + <NUM_LIT:1> ; i < length ; i ++ ) { char c = signature [ i ] ; switch ( c ) { case '<CHAR_LIT:/>' : case Signature . C_DOLLAR : buffer . append ( Signature . C_DOT ) ; break ; case Signature . C_GENERIC_START : buffer . append ( Signature . C_GENERIC_START ) ; i = toUnresolvedTypeSignature ( signature , i + <NUM_LIT:1> , length , buffer ) ; break ; case Signature . C_GENERIC_END : buffer . append ( Signature . C_GENERIC_END ) ; return i ; default : buffer . append ( c ) ; break ; } } return length ; } private static void appendArrayTypeSignature ( char [ ] string , int start , StringBuffer buffer , boolean compact ) { int length = string . length ; if ( start >= length - <NUM_LIT:1> ) { throw new IllegalArgumentException ( ) ; } char c = string [ start ] ; if ( c != Signature . C_ARRAY ) { throw new IllegalArgumentException ( ) ; } int index = start ; c = string [ ++ index ] ; while ( c == Signature . C_ARRAY ) { if ( index >= length - <NUM_LIT:1> ) { throw new IllegalArgumentException ( ) ; } c = string [ ++ index ] ; } appendTypeSignature ( string , index , buffer , compact ) ; for ( int i = <NUM_LIT:0> , dims = index - start ; i < dims ; i ++ ) { buffer . append ( '<CHAR_LIT:[>' ) . append ( '<CHAR_LIT:]>' ) ; } } private static void appendClassTypeSignature ( char [ ] string , int start , StringBuffer buffer , boolean compact ) { char c = string [ start ] ; if ( c != Signature . C_RESOLVED ) { return ; } int p = start + <NUM_LIT:1> ; int checkpoint = buffer . length ( ) ; while ( true ) { c = string [ p ] ; switch ( c ) { case Signature . C_SEMICOLON : return ; case Signature . C_DOT : case '<CHAR_LIT:/>' : if ( compact ) { buffer . setLength ( checkpoint ) ; } else { buffer . append ( '<CHAR_LIT:.>' ) ; } break ; case Signature . C_DOLLAR : buffer . append ( '<CHAR_LIT:.>' ) ; break ; default : buffer . append ( c ) ; } p ++ ; } } static void appendTypeSignature ( char [ ] string , int start , StringBuffer buffer , boolean compact ) { char c = string [ start ] ; switch ( c ) { case Signature . C_ARRAY : appendArrayTypeSignature ( string , start , buffer , compact ) ; break ; case Signature . C_RESOLVED : appendClassTypeSignature ( string , start , buffer , compact ) ; break ; case Signature . C_TYPE_VARIABLE : int e = org . eclipse . jdt . internal . compiler . util . Util . scanTypeVariableSignature ( string , start ) ; buffer . append ( string , start + <NUM_LIT:1> , e - start - <NUM_LIT:1> ) ; break ; case Signature . C_BOOLEAN : buffer . append ( BOOLEAN ) ; break ; case Signature . C_BYTE : buffer . append ( BYTE ) ; break ; case Signature . C_CHAR : buffer . append ( CHAR ) ; break ; case Signature . C_DOUBLE : buffer . append ( DOUBLE ) ; break ; case Signature . C_FLOAT : buffer . append ( FLOAT ) ; break ; case Signature . C_INT : buffer . append ( INT ) ; break ; case Signature . C_LONG : buffer . append ( LONG ) ; break ; case Signature . C_SHORT : buffer . append ( SHORT ) ; break ; case Signature . C_VOID : buffer . append ( VOID ) ; break ; } } public static String toString ( char [ ] declaringClass , char [ ] methodName , char [ ] methodSignature , boolean includeReturnType , boolean compact ) { final boolean isConstructor = CharOperation . equals ( methodName , INIT ) ; int firstParen = CharOperation . indexOf ( Signature . C_PARAM_START , methodSignature ) ; if ( firstParen == - <NUM_LIT:1> ) { return "<STR_LIT>" ; } StringBuffer buffer = new StringBuffer ( methodSignature . length + <NUM_LIT:10> ) ; if ( declaringClass != null && declaringClass . length > <NUM_LIT:0> ) { char [ ] declaringClassSignature = null ; if ( declaringClass [ <NUM_LIT:0> ] == Signature . C_ARRAY ) { CharOperation . replace ( declaringClass , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; declaringClassSignature = Signature . toCharArray ( declaringClass ) ; } else { CharOperation . replace ( declaringClass , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; declaringClassSignature = declaringClass ; } int lastIndexOfSlash = CharOperation . lastIndexOf ( '<CHAR_LIT:.>' , declaringClassSignature ) ; if ( compact && lastIndexOfSlash != - <NUM_LIT:1> ) { buffer . append ( declaringClassSignature , lastIndexOfSlash + <NUM_LIT:1> , declaringClassSignature . length - lastIndexOfSlash - <NUM_LIT:1> ) ; } else { buffer . append ( declaringClassSignature ) ; } if ( ! isConstructor ) { buffer . append ( '<CHAR_LIT:.>' ) ; } } if ( ! isConstructor && methodName != null ) { buffer . append ( methodName ) ; } buffer . append ( '<CHAR_LIT:(>' ) ; char [ ] [ ] pts = Signature . getParameterTypes ( methodSignature ) ; for ( int i = <NUM_LIT:0> , max = pts . length ; i < max ; i ++ ) { appendTypeSignature ( pts [ i ] , <NUM_LIT:0> , buffer , compact ) ; if ( i != pts . length - <NUM_LIT:1> ) { buffer . append ( '<CHAR_LIT:U+002C>' ) ; buffer . append ( '<CHAR_LIT:U+0020>' ) ; } } buffer . append ( '<CHAR_LIT:)>' ) ; if ( ! isConstructor ) { buffer . append ( "<STR_LIT:U+0020:U+0020>" ) ; if ( includeReturnType ) { char [ ] rts = Signature . getReturnType ( methodSignature ) ; appendTypeSignature ( rts , <NUM_LIT:0> , buffer , compact ) ; } } return String . valueOf ( buffer ) ; } public static String [ ] typeParameterSignatures ( AbstractMethodDeclaration method ) { Argument [ ] args = method . arguments ; if ( args != null ) { int length = args . length ; String [ ] signatures = new String [ length ] ; for ( int i = <NUM_LIT:0> ; i < args . length ; i ++ ) { Argument arg = args [ i ] ; signatures [ i ] = typeSignature ( arg . type ) ; } return signatures ; } return CharOperation . NO_STRINGS ; } public static String typeSignature ( TypeReference type ) { String signature = null ; if ( ( type . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . IsUnionType ) != <NUM_LIT:0> ) { UnionTypeReference unionTypeReference = ( UnionTypeReference ) type ; TypeReference [ ] typeReferences = unionTypeReference . typeReferences ; int length = typeReferences . length ; String [ ] typeSignatures = new String [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char [ ] [ ] compoundName = typeReferences [ i ] . getParameterizedTypeName ( ) ; char [ ] typeName = CharOperation . concatWith ( compoundName , '<CHAR_LIT:.>' ) ; typeSignatures [ i ] = Signature . createTypeSignature ( typeName , false ) ; } signature = Signature . createIntersectionTypeSignature ( typeSignatures ) ; } else { char [ ] [ ] compoundName = type . getParameterizedTypeName ( ) ; char [ ] typeName = CharOperation . concatWith ( compoundName , '<CHAR_LIT:.>' ) ; signature = Signature . createTypeSignature ( typeName , false ) ; } return signature ; } public static void validateMethodSignature ( String sig ) { Assert . isTrue ( isValidMethodSignature ( sig ) ) ; } public static void validateTypeSignature ( String sig , boolean allowVoid ) { Assert . isTrue ( isValidTypeSignature ( sig , allowVoid ) ) ; } public static void verbose ( String log ) { verbose ( log , System . out ) ; } public static synchronized void verbose ( String log , PrintStream printStream ) { int start = <NUM_LIT:0> ; do { int end = log . indexOf ( '<STR_LIT:\n>' , start ) ; printStream . print ( Thread . currentThread ( ) ) ; printStream . print ( "<STR_LIT:U+0020>" ) ; printStream . print ( log . substring ( start , end == - <NUM_LIT:1> ? log . length ( ) : end + <NUM_LIT:1> ) ) ; start = end + <NUM_LIT:1> ; } while ( start != <NUM_LIT:0> ) ; printStream . println ( ) ; } public final static boolean isJavaLikeFileName ( String name ) { if ( name == null ) return false ; return indexOfJavaLikeExtension ( name ) != - <NUM_LIT:1> ; } public final static boolean isJavaLikeFileName ( char [ ] fileName ) { if ( fileName == null ) return false ; int fileNameLength = fileName . length ; char [ ] [ ] javaLikeExtensions = getJavaLikeExtensions ( ) ; extensions : for ( int i = <NUM_LIT:0> , length = javaLikeExtensions . length ; i < length ; i ++ ) { char [ ] extension = javaLikeExtensions [ i ] ; int extensionLength = extension . length ; int extensionStart = fileNameLength - extensionLength ; if ( extensionStart - <NUM_LIT:1> < <NUM_LIT:0> ) continue ; if ( fileName [ extensionStart - <NUM_LIT:1> ] != '<CHAR_LIT:.>' ) continue ; for ( int j = <NUM_LIT:0> ; j < extensionLength ; j ++ ) { if ( fileName [ extensionStart + j ] != extension [ j ] ) continue extensions ; } return true ; } return false ; } public final static char [ ] [ ] [ ] getAllTypeArguments ( char [ ] [ ] typeSignatures ) { if ( typeSignatures == null ) return null ; int length = typeSignatures . length ; char [ ] [ ] [ ] typeArguments = new char [ length ] [ ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { typeArguments [ i ] = Signature . getTypeArguments ( typeSignatures [ i ] ) ; } return typeArguments ; } public static IAnnotation getAnnotation ( JavaElement parent , IBinaryAnnotation binaryAnnotation , String memberValuePairName ) { char [ ] typeName = org . eclipse . jdt . core . Signature . toCharArray ( CharOperation . replaceOnCopy ( binaryAnnotation . getTypeName ( ) , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ) ; return new Annotation ( parent , new String ( typeName ) , memberValuePairName ) ; } public static Object getAnnotationMemberValue ( JavaElement parent , MemberValuePair memberValuePair , Object binaryValue ) { if ( binaryValue instanceof Constant ) { return getAnnotationMemberValue ( memberValuePair , ( Constant ) binaryValue ) ; } else if ( binaryValue instanceof IBinaryAnnotation ) { memberValuePair . valueKind = IMemberValuePair . K_ANNOTATION ; return getAnnotation ( parent , ( IBinaryAnnotation ) binaryValue , memberValuePair . getMemberName ( ) ) ; } else if ( binaryValue instanceof ClassSignature ) { memberValuePair . valueKind = IMemberValuePair . K_CLASS ; char [ ] className = Signature . toCharArray ( CharOperation . replaceOnCopy ( ( ( ClassSignature ) binaryValue ) . getTypeName ( ) , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ) ; return new String ( className ) ; } else if ( binaryValue instanceof EnumConstantSignature ) { memberValuePair . valueKind = IMemberValuePair . K_QUALIFIED_NAME ; EnumConstantSignature enumConstant = ( EnumConstantSignature ) binaryValue ; char [ ] enumName = Signature . toCharArray ( CharOperation . replaceOnCopy ( enumConstant . getTypeName ( ) , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ) ; char [ ] qualifiedName = CharOperation . concat ( enumName , enumConstant . getEnumConstantName ( ) , '<CHAR_LIT:.>' ) ; return new String ( qualifiedName ) ; } else if ( binaryValue instanceof Object [ ] ) { memberValuePair . valueKind = - <NUM_LIT:1> ; Object [ ] binaryValues = ( Object [ ] ) binaryValue ; int length = binaryValues . length ; Object [ ] values = new Object [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { int previousValueKind = memberValuePair . valueKind ; Object value = getAnnotationMemberValue ( parent , memberValuePair , binaryValues [ i ] ) ; if ( previousValueKind != - <NUM_LIT:1> && memberValuePair . valueKind != previousValueKind ) { memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; } if ( value instanceof Annotation ) { Annotation annotation = ( Annotation ) value ; for ( int j = <NUM_LIT:0> ; j < i ; j ++ ) { if ( annotation . equals ( values [ j ] ) ) { annotation . occurrenceCount ++ ; } } } values [ i ] = value ; } if ( memberValuePair . valueKind == - <NUM_LIT:1> ) memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return values ; } else { memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return null ; } } public static Object getAnnotationMemberValue ( MemberValuePair memberValuePair , Constant constant ) { if ( constant == null ) { memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return null ; } switch ( constant . typeID ( ) ) { case TypeIds . T_int : memberValuePair . valueKind = IMemberValuePair . K_INT ; return new Integer ( constant . intValue ( ) ) ; case TypeIds . T_byte : memberValuePair . valueKind = IMemberValuePair . K_BYTE ; return new Byte ( constant . byteValue ( ) ) ; case TypeIds . T_short : memberValuePair . valueKind = IMemberValuePair . K_SHORT ; return new Short ( constant . shortValue ( ) ) ; case TypeIds . T_char : memberValuePair . valueKind = IMemberValuePair . K_CHAR ; return new Character ( constant . charValue ( ) ) ; case TypeIds . T_float : memberValuePair . valueKind = IMemberValuePair . K_FLOAT ; return new Float ( constant . floatValue ( ) ) ; case TypeIds . T_double : memberValuePair . valueKind = IMemberValuePair . K_DOUBLE ; return new Double ( constant . doubleValue ( ) ) ; case TypeIds . T_boolean : memberValuePair . valueKind = IMemberValuePair . K_BOOLEAN ; return Boolean . valueOf ( constant . booleanValue ( ) ) ; case TypeIds . T_long : memberValuePair . valueKind = IMemberValuePair . K_LONG ; return new Long ( constant . longValue ( ) ) ; case TypeIds . T_JavaLangString : memberValuePair . valueKind = IMemberValuePair . K_STRING ; return constant . stringValue ( ) ; default : memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return null ; } } public static Object getNegativeAnnotationMemberValue ( MemberValuePair memberValuePair , Constant constant ) { if ( constant == null ) { memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return null ; } switch ( constant . typeID ( ) ) { case TypeIds . T_int : memberValuePair . valueKind = IMemberValuePair . K_INT ; return new Integer ( constant . intValue ( ) * - <NUM_LIT:1> ) ; case TypeIds . T_float : memberValuePair . valueKind = IMemberValuePair . K_FLOAT ; return new Float ( constant . floatValue ( ) * - <NUM_LIT:1.0f> ) ; case TypeIds . T_double : memberValuePair . valueKind = IMemberValuePair . K_DOUBLE ; return new Double ( constant . doubleValue ( ) * - <NUM_LIT:1.0> ) ; case TypeIds . T_long : memberValuePair . valueKind = IMemberValuePair . K_LONG ; return new Long ( constant . longValue ( ) * - <NUM_LIT:1L> ) ; default : memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return null ; } } public final static char [ ] [ ] splitTypeLevelsSignature ( String typeSignature ) { char [ ] source = Signature . removeCapture ( typeSignature . toCharArray ( ) ) ; CharOperation . replace ( source , '<CHAR_LIT>' , '<CHAR_LIT:.>' ) ; char [ ] [ ] signatures = new char [ <NUM_LIT:10> ] [ ] ; int signaturesCount = <NUM_LIT:0> ; int paramOpening = <NUM_LIT:0> ; for ( int idx = <NUM_LIT:0> , ln = source . length ; idx < ln ; idx ++ ) { switch ( source [ idx ] ) { case '<CHAR_LIT:>>' : paramOpening -- ; if ( paramOpening == <NUM_LIT:0> ) { if ( signaturesCount == signatures . length ) { System . arraycopy ( signatures , <NUM_LIT:0> , signatures = new char [ signaturesCount + <NUM_LIT:10> ] [ ] , <NUM_LIT:0> , signaturesCount ) ; } } break ; case '<CHAR_LIT>' : paramOpening ++ ; break ; case '<CHAR_LIT:.>' : if ( paramOpening == <NUM_LIT:0> ) { if ( signaturesCount == signatures . length ) { System . arraycopy ( signatures , <NUM_LIT:0> , signatures = new char [ signaturesCount + <NUM_LIT:10> ] [ ] , <NUM_LIT:0> , signaturesCount ) ; } signatures [ signaturesCount ] = new char [ idx + <NUM_LIT:1> ] ; System . arraycopy ( source , <NUM_LIT:0> , signatures [ signaturesCount ] , <NUM_LIT:0> , idx ) ; signatures [ signaturesCount ] [ idx ] = Signature . C_SEMICOLON ; signaturesCount ++ ; } break ; case '<CHAR_LIT:/>' : source [ idx ] = '<CHAR_LIT:.>' ; break ; } } char [ ] [ ] typeSignatures = new char [ signaturesCount + <NUM_LIT:1> ] [ ] ; typeSignatures [ <NUM_LIT:0> ] = source ; for ( int i = <NUM_LIT:1> , j = signaturesCount - <NUM_LIT:1> ; i <= signaturesCount ; i ++ , j -- ) { typeSignatures [ i ] = signatures [ j ] ; } return typeSignatures ; } public static String toAnchor ( int startingIndex , char [ ] methodSignature , String methodName , boolean isVarArgs ) { try { return new String ( toAnchor ( startingIndex , methodSignature , methodName . toCharArray ( ) , isVarArgs ) ) ; } catch ( IllegalArgumentException e ) { return null ; } } public static char [ ] toAnchor ( int startingIndex , char [ ] methodSignature , char [ ] methodName , boolean isVargArgs ) { int firstParen = CharOperation . indexOf ( Signature . C_PARAM_START , methodSignature ) ; if ( firstParen == - <NUM_LIT:1> ) { throw new IllegalArgumentException ( ) ; } StringBuffer buffer = new StringBuffer ( methodSignature . length + <NUM_LIT:10> ) ; if ( methodName != null ) { buffer . append ( methodName ) ; } buffer . append ( '<CHAR_LIT:(>' ) ; char [ ] [ ] pts = Signature . getParameterTypes ( methodSignature ) ; for ( int i = startingIndex , max = pts . length ; i < max ; i ++ ) { if ( i == max - <NUM_LIT:1> ) { appendTypeSignatureForAnchor ( pts [ i ] , <NUM_LIT:0> , buffer , isVargArgs ) ; } else { appendTypeSignatureForAnchor ( pts [ i ] , <NUM_LIT:0> , buffer , false ) ; } if ( i != pts . length - <NUM_LIT:1> ) { buffer . append ( '<CHAR_LIT:U+002C>' ) ; buffer . append ( '<CHAR_LIT:U+0020>' ) ; } } buffer . append ( '<CHAR_LIT:)>' ) ; char [ ] result = new char [ buffer . length ( ) ] ; buffer . getChars ( <NUM_LIT:0> , buffer . length ( ) , result , <NUM_LIT:0> ) ; return result ; } private static int appendTypeSignatureForAnchor ( char [ ] string , int start , StringBuffer buffer , boolean isVarArgs ) { if ( start >= string . length ) { throw new IllegalArgumentException ( ) ; } char c = string [ start ] ; if ( isVarArgs ) { switch ( c ) { case Signature . C_ARRAY : return appendArrayTypeSignatureForAnchor ( string , start , buffer , true ) ; case Signature . C_RESOLVED : case Signature . C_TYPE_VARIABLE : case Signature . C_BOOLEAN : case Signature . C_BYTE : case Signature . C_CHAR : case Signature . C_DOUBLE : case Signature . C_FLOAT : case Signature . C_INT : case Signature . C_LONG : case Signature . C_SHORT : case Signature . C_VOID : case Signature . C_STAR : case Signature . C_EXTENDS : case Signature . C_SUPER : case Signature . C_CAPTURE : default : throw new IllegalArgumentException ( ) ; } } else { switch ( c ) { case Signature . C_ARRAY : return appendArrayTypeSignatureForAnchor ( string , start , buffer , false ) ; case Signature . C_RESOLVED : return appendClassTypeSignatureForAnchor ( string , start , buffer ) ; case Signature . C_TYPE_VARIABLE : int e = org . eclipse . jdt . internal . compiler . util . Util . scanTypeVariableSignature ( string , start ) ; buffer . append ( string , start + <NUM_LIT:1> , e - start - <NUM_LIT:1> ) ; return e ; case Signature . C_BOOLEAN : buffer . append ( BOOLEAN ) ; return start ; case Signature . C_BYTE : buffer . append ( BYTE ) ; return start ; case Signature . C_CHAR : buffer . append ( CHAR ) ; return start ; case Signature . C_DOUBLE : buffer . append ( DOUBLE ) ; return start ; case Signature . C_FLOAT : buffer . append ( FLOAT ) ; return start ; case Signature . C_INT : buffer . append ( INT ) ; return start ; case Signature . C_LONG : buffer . append ( LONG ) ; return start ; case Signature . C_SHORT : buffer . append ( SHORT ) ; return start ; case Signature . C_VOID : buffer . append ( VOID ) ; return start ; case Signature . C_CAPTURE : return appendCaptureTypeSignatureForAnchor ( string , start , buffer ) ; case Signature . C_STAR : case Signature . C_EXTENDS : case Signature . C_SUPER : return appendTypeArgumentSignatureForAnchor ( string , start , buffer ) ; default : throw new IllegalArgumentException ( ) ; } } } private static int appendTypeArgumentSignatureForAnchor ( char [ ] string , int start , StringBuffer buffer ) { if ( start >= string . length ) { throw new IllegalArgumentException ( ) ; } char c = string [ start ] ; switch ( c ) { case Signature . C_STAR : return start ; case Signature . C_EXTENDS : return appendTypeSignatureForAnchor ( string , start + <NUM_LIT:1> , buffer , false ) ; case Signature . C_SUPER : return appendTypeSignatureForAnchor ( string , start + <NUM_LIT:1> , buffer , false ) ; default : return appendTypeSignatureForAnchor ( string , start , buffer , false ) ; } } private static int appendCaptureTypeSignatureForAnchor ( char [ ] string , int start , StringBuffer buffer ) { if ( start >= string . length - <NUM_LIT:1> ) { throw new IllegalArgumentException ( ) ; } char c = string [ start ] ; if ( c != Signature . C_CAPTURE ) { throw new IllegalArgumentException ( ) ; } return appendTypeArgumentSignatureForAnchor ( string , start + <NUM_LIT:1> , buffer ) ; } private static int appendArrayTypeSignatureForAnchor ( char [ ] string , int start , StringBuffer buffer , boolean isVarArgs ) { int length = string . length ; if ( start >= length - <NUM_LIT:1> ) { throw new IllegalArgumentException ( ) ; } char c = string [ start ] ; if ( c != Signature . C_ARRAY ) { throw new IllegalArgumentException ( ) ; } int index = start ; c = string [ ++ index ] ; while ( c == Signature . C_ARRAY ) { if ( index >= length - <NUM_LIT:1> ) { throw new IllegalArgumentException ( ) ; } c = string [ ++ index ] ; } int e = appendTypeSignatureForAnchor ( string , index , buffer , false ) ; for ( int i = <NUM_LIT:1> , dims = index - start ; i < dims ; i ++ ) { buffer . append ( '<CHAR_LIT:[>' ) . append ( '<CHAR_LIT:]>' ) ; } if ( isVarArgs ) { buffer . append ( '<CHAR_LIT:.>' ) . append ( '<CHAR_LIT:.>' ) . append ( '<CHAR_LIT:.>' ) ; } else { buffer . append ( '<CHAR_LIT:[>' ) . append ( '<CHAR_LIT:]>' ) ; } return e ; } private static int appendClassTypeSignatureForAnchor ( char [ ] string , int start , StringBuffer buffer ) { if ( start >= string . length - <NUM_LIT:2> ) { throw new IllegalArgumentException ( ) ; } char c = string [ start ] ; if ( c != Signature . C_RESOLVED && c != Signature . C_UNRESOLVED ) { throw new IllegalArgumentException ( ) ; } int p = start + <NUM_LIT:1> ; while ( true ) { if ( p >= string . length ) { throw new IllegalArgumentException ( ) ; } c = string [ p ] ; switch ( c ) { case Signature . C_SEMICOLON : return p ; case Signature . C_GENERIC_START : int e = scanGenericEnd ( string , p + <NUM_LIT:1> ) ; p = e ; break ; case Signature . C_DOT : buffer . append ( '<CHAR_LIT:.>' ) ; break ; case '<CHAR_LIT:/>' : buffer . append ( '<CHAR_LIT:/>' ) ; break ; case Signature . C_DOLLAR : buffer . append ( '<CHAR_LIT:.>' ) ; break ; default : buffer . append ( c ) ; } p ++ ; } } private static int scanGenericEnd ( char [ ] string , int start ) { if ( string [ start ] == Signature . C_GENERIC_END ) { return start ; } int length = string . length ; int balance = <NUM_LIT:1> ; start ++ ; while ( start <= length ) { switch ( string [ start ] ) { case Signature . C_GENERIC_END : balance -- ; if ( balance == <NUM_LIT:0> ) { return start ; } break ; case Signature . C_GENERIC_START : balance ++ ; break ; } start ++ ; } return start ; } public static void fixTaskTags ( Map defaultOptionsMap ) { Object taskTagsValue = defaultOptionsMap . get ( JavaCore . COMPILER_TASK_TAGS ) ; char [ ] [ ] taskTags = null ; if ( taskTagsValue instanceof String ) { taskTags = CharOperation . splitAndTrimOn ( '<CHAR_LIT:U+002C>' , ( ( String ) taskTagsValue ) . toCharArray ( ) ) ; } Object taskPrioritiesValue = defaultOptionsMap . get ( JavaCore . COMPILER_TASK_PRIORITIES ) ; char [ ] [ ] taskPriorities = null ; if ( taskPrioritiesValue instanceof String ) { taskPriorities = CharOperation . splitAndTrimOn ( '<CHAR_LIT:U+002C>' , ( ( String ) taskPrioritiesValue ) . toCharArray ( ) ) ; } if ( taskPriorities == null ) { if ( taskTags != null ) { Util . logRepeatedMessage ( TASK_PRIORITIES_PROBLEM , IStatus . ERROR , "<STR_LIT>" ) ; defaultOptionsMap . remove ( JavaCore . COMPILER_TASK_TAGS ) ; } return ; } else if ( taskTags == null ) { Util . logRepeatedMessage ( TASK_PRIORITIES_PROBLEM , IStatus . ERROR , "<STR_LIT>" ) ; defaultOptionsMap . remove ( JavaCore . COMPILER_TASK_PRIORITIES ) ; return ; } int taskTagsLength = taskTags . length ; int taskPrioritiesLength = taskPriorities . length ; if ( taskTagsLength != taskPrioritiesLength ) { Util . logRepeatedMessage ( TASK_PRIORITIES_PROBLEM , IStatus . ERROR , "<STR_LIT>" ) ; if ( taskTagsLength > taskPrioritiesLength ) { System . arraycopy ( taskTags , <NUM_LIT:0> , ( taskTags = new char [ taskPrioritiesLength ] [ ] ) , <NUM_LIT:0> , taskPrioritiesLength ) ; defaultOptionsMap . put ( JavaCore . COMPILER_TASK_TAGS , new String ( CharOperation . concatWith ( taskTags , '<CHAR_LIT:U+002C>' ) ) ) ; } else { System . arraycopy ( taskPriorities , <NUM_LIT:0> , ( taskPriorities = new char [ taskTagsLength ] [ ] ) , <NUM_LIT:0> , taskTagsLength ) ; defaultOptionsMap . put ( JavaCore . COMPILER_TASK_PRIORITIES , new String ( CharOperation . concatWith ( taskPriorities , '<CHAR_LIT:U+002C>' ) ) ) ; } } } public static IMethod findMethod ( IType type , char [ ] selector , String [ ] paramTypeSignatures , boolean isConstructor ) throws JavaModelException { IMethod method = null ; int startingIndex = <NUM_LIT:0> ; String [ ] args ; IType enclosingType = type . getDeclaringType ( ) ; if ( enclosingType != null && isConstructor && ! Flags . isStatic ( type . getFlags ( ) ) ) { args = new String [ paramTypeSignatures . length + <NUM_LIT:1> ] ; startingIndex = <NUM_LIT:1> ; args [ <NUM_LIT:0> ] = Signature . createTypeSignature ( enclosingType . getFullyQualifiedName ( ) , true ) ; } else { args = new String [ paramTypeSignatures . length ] ; } int length = args . length ; for ( int i = startingIndex ; i < length ; i ++ ) { args [ i ] = new String ( paramTypeSignatures [ i - startingIndex ] ) ; } method = type . getMethod ( new String ( selector ) , args ) ; IMethod [ ] methods = type . findMethods ( method ) ; if ( methods != null && methods . length > <NUM_LIT:0> ) { method = methods [ <NUM_LIT:0> ] ; } return method ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . util ; import org . eclipse . jdt . core . util . ClassFormatException ; import org . eclipse . jdt . core . util . IConstantPool ; import org . eclipse . jdt . core . util . IConstantPoolConstant ; import org . eclipse . jdt . core . util . IConstantPoolEntry ; import org . eclipse . jdt . core . util . ILocalVariableTypeTableEntry ; public class LocalVariableTypeTableEntry extends ClassFileStruct implements ILocalVariableTypeTableEntry { private int startPC ; private int length ; private int nameIndex ; private int signatureIndex ; private char [ ] name ; private char [ ] signature ; private int index ; public LocalVariableTypeTableEntry ( byte [ ] classFileBytes , IConstantPool constantPool , int offset ) throws ClassFormatException { this . startPC = u2At ( classFileBytes , <NUM_LIT:0> , offset ) ; this . length = u2At ( classFileBytes , <NUM_LIT:2> , offset ) ; this . nameIndex = u2At ( classFileBytes , <NUM_LIT:4> , offset ) ; this . signatureIndex = u2At ( classFileBytes , <NUM_LIT:6> , offset ) ; this . index = u2At ( classFileBytes , <NUM_LIT:8> , offset ) ; IConstantPoolEntry constantPoolEntry = constantPool . decodeEntry ( this . nameIndex ) ; if ( constantPoolEntry . getKind ( ) != IConstantPoolConstant . CONSTANT_Utf8 ) { throw new ClassFormatException ( ClassFormatException . INVALID_CONSTANT_POOL_ENTRY ) ; } this . name = constantPoolEntry . getUtf8Value ( ) ; constantPoolEntry = constantPool . decodeEntry ( this . signatureIndex ) ; if ( constantPoolEntry . getKind ( ) != IConstantPoolConstant . CONSTANT_Utf8 ) { throw new ClassFormatException ( ClassFormatException . INVALID_CONSTANT_POOL_ENTRY ) ; } this . signature = constantPoolEntry . getUtf8Value ( ) ; } public int getStartPC ( ) { return this . startPC ; } public int getLength ( ) { return this . length ; } public int getNameIndex ( ) { return this . nameIndex ; } public int getSignatureIndex ( ) { return this . signatureIndex ; } public int getIndex ( ) { return this . index ; } public char [ ] getName ( ) { return this . name ; } public char [ ] getSignature ( ) { return this . signature ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . util ; import org . eclipse . jdt . core . util . ClassFormatException ; import org . eclipse . jdt . core . util . IAnnotationComponentValue ; import org . eclipse . jdt . core . util . IAnnotationDefaultAttribute ; import org . eclipse . jdt . core . util . IConstantPool ; public class AnnotationDefaultAttribute extends ClassFileAttribute implements IAnnotationDefaultAttribute { private IAnnotationComponentValue memberValue ; public AnnotationDefaultAttribute ( byte [ ] classFileBytes , IConstantPool constantPool , int offset ) throws ClassFormatException { super ( classFileBytes , constantPool , offset ) ; this . memberValue = new AnnotationComponentValue ( classFileBytes , constantPool , offset + <NUM_LIT:6> ) ; } public IAnnotationComponentValue getMemberValue ( ) { return this . memberValue ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IType ; public final class TypeVector { static int INITIAL_SIZE = <NUM_LIT:10> ; public int size ; int maxSize ; IType [ ] elements ; public final static IType [ ] NoElements = new IType [ <NUM_LIT:0> ] ; public TypeVector ( ) { this . maxSize = INITIAL_SIZE ; this . size = <NUM_LIT:0> ; this . elements = new IType [ this . maxSize ] ; } public TypeVector ( IType [ ] types ) { this . size = types . length ; this . maxSize = this . size + <NUM_LIT:1> ; this . elements = new IType [ this . maxSize ] ; System . arraycopy ( types , <NUM_LIT:0> , this . elements , <NUM_LIT:0> , this . size ) ; } public TypeVector ( IType type ) { this . maxSize = INITIAL_SIZE ; this . size = <NUM_LIT:1> ; this . elements = new IType [ this . maxSize ] ; this . elements [ <NUM_LIT:0> ] = type ; } public void add ( IType newElement ) { if ( this . size == this . maxSize ) System . arraycopy ( this . elements , <NUM_LIT:0> , ( this . elements = new IType [ this . maxSize *= <NUM_LIT:2> ] ) , <NUM_LIT:0> , this . size ) ; this . elements [ this . size ++ ] = newElement ; } public void addAll ( IType [ ] newElements ) { if ( this . size + newElements . length >= this . maxSize ) { this . maxSize = this . size + newElements . length ; System . arraycopy ( this . elements , <NUM_LIT:0> , ( this . elements = new IType [ this . maxSize ] ) , <NUM_LIT:0> , this . size ) ; } System . arraycopy ( newElements , <NUM_LIT:0> , this . elements , this . size , newElements . length ) ; this . size += newElements . length ; } public boolean contains ( IType element ) { for ( int i = this . size ; -- i >= <NUM_LIT:0> ; ) if ( element . equals ( this . elements [ i ] ) ) return true ; return false ; } public TypeVector copy ( ) { TypeVector clone = new TypeVector ( ) ; int length = this . elements . length ; System . arraycopy ( this . elements , <NUM_LIT:0> , clone . elements = new IType [ length ] , <NUM_LIT:0> , length ) ; clone . size = this . size ; clone . maxSize = this . maxSize ; return clone ; } public IType elementAt ( int index ) { return this . elements [ index ] ; } public IType [ ] elements ( ) { if ( this . size == <NUM_LIT:0> ) return NoElements ; if ( this . size < this . maxSize ) { this . maxSize = this . size ; System . arraycopy ( this . elements , <NUM_LIT:0> , ( this . elements = new IType [ this . maxSize ] ) , <NUM_LIT:0> , this . size ) ; } return this . elements ; } public IType find ( IType element ) { for ( int i = this . size ; -- i >= <NUM_LIT:0> ; ) if ( element == this . elements [ i ] ) return this . elements [ i ] ; return null ; } public IType remove ( IType element ) { for ( int i = this . size ; -- i >= <NUM_LIT:0> ; ) if ( element == this . elements [ i ] ) { System . arraycopy ( this . elements , i + <NUM_LIT:1> , this . elements , i , -- this . size - i ) ; this . elements [ this . size ] = null ; return element ; } return null ; } public void removeAll ( ) { for ( int i = this . size ; -- i >= <NUM_LIT:0> ; ) this . elements [ i ] = null ; this . size = <NUM_LIT:0> ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( "<STR_LIT:[>" ) ; for ( int i = <NUM_LIT:0> ; i < this . size ; i ++ ) { buffer . append ( "<STR_LIT:n>" ) ; buffer . append ( this . elements [ i ] ) ; } buffer . append ( "<STR_LIT>" ) ; return buffer . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IJavaElement ; public class SourceConstructorWithChildrenInfo extends SourceConstructorInfo { protected IJavaElement [ ] children ; public SourceConstructorWithChildrenInfo ( IJavaElement [ ] children ) { this . children = children ; } public IJavaElement [ ] getChildren ( ) { return this . children ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IContainer ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . internal . core . util . Util ; class PackageFragmentRootInfo extends OpenableElementInfo { protected SourceMapper sourceMapper = null ; protected int rootKind = IPackageFragmentRoot . K_SOURCE ; protected Object [ ] nonJavaResources ; private boolean ignoreOptionalProblems ; private boolean initialized ; public PackageFragmentRootInfo ( ) { this . nonJavaResources = null ; this . initialized = false ; } static Object [ ] computeFolderNonJavaResources ( IPackageFragmentRoot root , IContainer folder , char [ ] [ ] inclusionPatterns , char [ ] [ ] exclusionPatterns ) throws JavaModelException { IResource [ ] nonJavaResources = new IResource [ <NUM_LIT:5> ] ; int nonJavaResourcesCounter = <NUM_LIT:0> ; JavaProject project = ( JavaProject ) root . getJavaProject ( ) ; try { boolean isInterestingPackageRoot = LanguageSupportFactory . isInterestingProject ( project . getProject ( ) ) && root . getRawClasspathEntry ( ) . getEntryKind ( ) != IClasspathEntry . CPE_SOURCE ; IClasspathEntry [ ] classpath = project . getResolvedClasspath ( ) ; IResource [ ] members = folder . members ( ) ; int length = members . length ; if ( length > <NUM_LIT:0> ) { String sourceLevel = project . getOption ( JavaCore . COMPILER_SOURCE , true ) ; String complianceLevel = project . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ; nextResource : for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IResource member = members [ i ] ; switch ( member . getType ( ) ) { case IResource . FILE : String fileName = member . getName ( ) ; if ( ( Util . isValidCompilationUnitName ( fileName , sourceLevel , complianceLevel ) && ! Util . isExcluded ( member , inclusionPatterns , exclusionPatterns ) ) && ! ( isInterestingPackageRoot && LanguageSupportFactory . isInterestingSourceFile ( fileName ) ) ) continue nextResource ; if ( Util . isValidClassFileName ( fileName , sourceLevel , complianceLevel ) ) continue nextResource ; if ( isClasspathEntry ( member . getFullPath ( ) , classpath ) ) continue nextResource ; break ; case IResource . FOLDER : if ( Util . isValidFolderNameForPackage ( member . getName ( ) , sourceLevel , complianceLevel ) && ( ! Util . isExcluded ( member , inclusionPatterns , exclusionPatterns ) || isClasspathEntry ( member . getFullPath ( ) , classpath ) ) ) continue nextResource ; break ; } if ( nonJavaResources . length == nonJavaResourcesCounter ) { System . arraycopy ( nonJavaResources , <NUM_LIT:0> , ( nonJavaResources = new IResource [ nonJavaResourcesCounter * <NUM_LIT:2> ] ) , <NUM_LIT:0> , nonJavaResourcesCounter ) ; } nonJavaResources [ nonJavaResourcesCounter ++ ] = member ; } } if ( ExternalFoldersManager . isInternalPathForExternalFolder ( folder . getFullPath ( ) ) ) { IJarEntryResource [ ] jarEntryResources = new IJarEntryResource [ nonJavaResourcesCounter ] ; for ( int i = <NUM_LIT:0> ; i < nonJavaResourcesCounter ; i ++ ) { jarEntryResources [ i ] = new NonJavaResource ( root , nonJavaResources [ i ] ) ; } return jarEntryResources ; } else if ( nonJavaResources . length != nonJavaResourcesCounter ) { System . arraycopy ( nonJavaResources , <NUM_LIT:0> , ( nonJavaResources = new IResource [ nonJavaResourcesCounter ] ) , <NUM_LIT:0> , nonJavaResourcesCounter ) ; } return nonJavaResources ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } private Object [ ] computeNonJavaResources ( IResource underlyingResource , PackageFragmentRoot handle ) { Object [ ] resources = NO_NON_JAVA_RESOURCES ; try { if ( underlyingResource . getType ( ) == IResource . FOLDER || underlyingResource . getType ( ) == IResource . PROJECT ) { resources = computeFolderNonJavaResources ( handle , ( IContainer ) underlyingResource , handle . fullInclusionPatternChars ( ) , handle . fullExclusionPatternChars ( ) ) ; } } catch ( JavaModelException e ) { } return resources ; } synchronized Object [ ] getNonJavaResources ( IJavaProject project , IResource underlyingResource , PackageFragmentRoot handle ) { Object [ ] resources = this . nonJavaResources ; if ( resources == null ) { resources = computeNonJavaResources ( underlyingResource , handle ) ; this . nonJavaResources = resources ; } return resources ; } public int getRootKind ( ) { return this . rootKind ; } protected SourceMapper getSourceMapper ( ) { return this . sourceMapper ; } boolean ignoreOptionalProblems ( PackageFragmentRoot packageFragmentRoot ) throws JavaModelException { if ( this . initialized == false ) { this . ignoreOptionalProblems = ( ( ClasspathEntry ) packageFragmentRoot . getRawClasspathEntry ( ) ) . ignoreOptionalProblems ( ) ; this . initialized = true ; } return this . ignoreOptionalProblems ; } private static boolean isClasspathEntry ( IPath path , IClasspathEntry [ ] resolvedClasspath ) { for ( int i = <NUM_LIT:0> , length = resolvedClasspath . length ; i < length ; i ++ ) { IClasspathEntry entry = resolvedClasspath [ i ] ; if ( entry . getPath ( ) . equals ( path ) ) { return true ; } } return false ; } void setNonJavaResources ( Object [ ] resources ) { this . nonJavaResources = resources ; } protected void setRootKind ( int newRootKind ) { this . rootKind = newRootKind ; } protected void setSourceMapper ( SourceMapper mapper ) { this . sourceMapper = mapper ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . IResourceStatus ; import org . eclipse . core . resources . IWorkspaceRunnable ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . jdt . core . IJavaModelStatus ; import org . eclipse . jdt . core . JavaModelException ; public class BatchOperation extends JavaModelOperation { protected IWorkspaceRunnable runnable ; public BatchOperation ( IWorkspaceRunnable runnable ) { this . runnable = runnable ; } protected boolean canModifyRoots ( ) { return true ; } protected void executeOperation ( ) throws JavaModelException { try { this . runnable . run ( this . progressMonitor ) ; } catch ( CoreException ce ) { if ( ce instanceof JavaModelException ) { throw ( JavaModelException ) ce ; } else { if ( ce . getStatus ( ) . getCode ( ) == IResourceStatus . OPERATION_FAILED ) { Throwable e = ce . getStatus ( ) . getException ( ) ; if ( e instanceof JavaModelException ) { throw ( JavaModelException ) e ; } } throw new JavaModelException ( ce ) ; } } } protected IJavaModelStatus verify ( ) { return JavaModelStatus . VERIFIED_OK ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . BufferedInputStream ; import java . io . File ; import java . io . FileOutputStream ; import java . io . IOException ; import java . util . ArrayList ; import java . util . Collection ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Iterator ; import java . util . Map ; import java . util . Set ; import java . util . Vector ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IFolder ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . resources . IProjectDescription ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IResourceStatus ; 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 . Platform ; import org . eclipse . core . runtime . Status ; import org . eclipse . core . runtime . jobs . Job ; import org . eclipse . jdt . core . IClasspathEntry ; 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 ExternalFoldersManager { private static final String EXTERNAL_PROJECT_NAME = "<STR_LIT>" ; private static final String LINKED_FOLDER_NAME = "<STR_LIT>" ; private Map folders ; private Set pendingFolders ; private int counter = <NUM_LIT:0> ; private static ExternalFoldersManager MANAGER ; private ExternalFoldersManager ( ) { if ( Platform . isRunning ( ) ) { getFolders ( ) ; } } public static synchronized ExternalFoldersManager getExternalFoldersManager ( ) { if ( MANAGER == null ) { MANAGER = new ExternalFoldersManager ( ) ; } return MANAGER ; } public static HashSet getExternalFolders ( IClasspathEntry [ ] classpath ) { if ( classpath == null ) return null ; HashSet folders = null ; for ( int i = <NUM_LIT:0> ; i < classpath . length ; i ++ ) { IClasspathEntry entry = classpath [ i ] ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_LIBRARY ) { IPath entryPath = entry . getPath ( ) ; if ( isExternalFolderPath ( entryPath ) ) { if ( folders == null ) folders = new HashSet ( ) ; folders . add ( entryPath ) ; } IPath attachmentPath = entry . getSourceAttachmentPath ( ) ; if ( isExternalFolderPath ( attachmentPath ) ) { if ( folders == null ) folders = new HashSet ( ) ; folders . add ( attachmentPath ) ; } } } return folders ; } public static boolean isExternalFolderPath ( IPath externalPath ) { if ( externalPath == null ) return false ; String firstSegment = externalPath . segment ( <NUM_LIT:0> ) ; if ( firstSegment != null && ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getProject ( firstSegment ) . exists ( ) ) return false ; File externalFolder = externalPath . toFile ( ) ; if ( externalFolder . isFile ( ) ) return false ; if ( externalPath . getFileExtension ( ) != null && ! externalFolder . exists ( ) ) return false ; return true ; } public static boolean isInternalPathForExternalFolder ( IPath resourcePath ) { return EXTERNAL_PROJECT_NAME . equals ( resourcePath . segment ( <NUM_LIT:0> ) ) ; } public IFolder addFolder ( IPath externalFolderPath , boolean scheduleForCreation ) { return addFolder ( externalFolderPath , getExternalFoldersProject ( ) , scheduleForCreation ) ; } private IFolder addFolder ( IPath externalFolderPath , IProject externalFoldersProject , boolean scheduleForCreation ) { Map knownFolders = getFolders ( ) ; Object existing = knownFolders . get ( externalFolderPath ) ; if ( existing != null ) { return ( IFolder ) existing ; } IFolder result ; do { result = externalFoldersProject . getFolder ( LINKED_FOLDER_NAME + this . counter ++ ) ; } while ( result . exists ( ) ) ; if ( scheduleForCreation ) { synchronized ( this ) { if ( this . pendingFolders == null ) this . pendingFolders = Collections . synchronizedSet ( new HashSet ( ) ) ; } this . pendingFolders . add ( externalFolderPath ) ; } knownFolders . put ( externalFolderPath , result ) ; return result ; } public synchronized boolean removePendingFolder ( Object externalPath ) { if ( this . pendingFolders == null ) return false ; return this . pendingFolders . remove ( externalPath ) ; } public IFolder createLinkFolder ( IPath externalFolderPath , boolean refreshIfExistAlready , IProgressMonitor monitor ) throws CoreException { IProject externalFoldersProject = createExternalFoldersProject ( monitor ) ; return createLinkFolder ( externalFolderPath , refreshIfExistAlready , externalFoldersProject , monitor ) ; } private IFolder createLinkFolder ( IPath externalFolderPath , boolean refreshIfExistAlready , IProject externalFoldersProject , IProgressMonitor monitor ) throws CoreException { IFolder result = addFolder ( externalFolderPath , externalFoldersProject , false ) ; try { if ( ! result . exists ( ) ) result . createLink ( externalFolderPath , IResource . ALLOW_MISSING_LOCAL , monitor ) ; else if ( refreshIfExistAlready ) result . refreshLocal ( IResource . DEPTH_INFINITE , monitor ) ; } catch ( IllegalArgumentException e ) { if ( System . getProperty ( "<STR_LIT>" ) != null ) { System . out . println ( "<STR_LIT>" ) ; System . out . println ( "<STR_LIT>" ) ; System . out . println ( "<STR_LIT>" + externalFolderPath ) ; System . out . println ( "<STR_LIT>" + result . toString ( ) ) ; File externalFile = new File ( externalFolderPath . toOSString ( ) ) ; System . out . println ( externalFile . exists ( ) ? "<STR_LIT>" : "<STR_LIT>" ) ; System . out . println ( result . exists ( ) ? "<STR_LIT>" : "<STR_LIT>" ) ; IProject externalFolderProject = getExternalFoldersProject ( ) ; IFile externalProjectFile = externalFolderProject . getFile ( IProjectDescription . DESCRIPTION_FILE_NAME ) ; if ( externalProjectFile . exists ( ) ) { System . out . println ( "<STR_LIT>" ) ; BufferedInputStream bs = new BufferedInputStream ( externalProjectFile . getContents ( ) ) ; int available = <NUM_LIT:0> ; try { while ( ( available = bs . available ( ) ) > <NUM_LIT:0> ) { byte [ ] contents = new byte [ available ] ; bs . read ( contents ) ; System . out . println ( new String ( contents ) ) ; } bs . close ( ) ; } catch ( IOException e1 ) { System . out . println ( "<STR_LIT>" ) ; e1 . printStackTrace ( ) ; } } else { System . out . println ( "<STR_LIT>" ) ; } System . out . println ( "<STR_LIT>" ) ; } throw e ; } return result ; } public void createPendingFolders ( IProgressMonitor monitor ) throws JavaModelException { synchronized ( this ) { if ( this . pendingFolders == null || this . pendingFolders . isEmpty ( ) ) return ; } IProject externalFoldersProject = null ; try { externalFoldersProject = createExternalFoldersProject ( monitor ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } Object [ ] arrayOfFolders = null ; synchronized ( this . pendingFolders ) { arrayOfFolders = this . pendingFolders . toArray ( ) ; this . pendingFolders . clear ( ) ; } for ( int i = <NUM_LIT:0> ; i < arrayOfFolders . length ; i ++ ) { try { createLinkFolder ( ( IPath ) arrayOfFolders [ i ] , false , externalFoldersProject , monitor ) ; } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" + arrayOfFolders [ i ] ) ; } } } public void cleanUp ( IProgressMonitor monitor ) throws CoreException { ArrayList toDelete = getFoldersToCleanUp ( monitor ) ; if ( toDelete == null ) return ; for ( Iterator iterator = toDelete . iterator ( ) ; iterator . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) iterator . next ( ) ; IFolder folder = ( IFolder ) entry . getValue ( ) ; folder . delete ( true , monitor ) ; IPath key = ( IPath ) entry . getKey ( ) ; this . folders . remove ( key ) ; } IProject project = getExternalFoldersProject ( ) ; if ( project . isAccessible ( ) && project . members ( ) . length == <NUM_LIT:1> ) project . delete ( true , monitor ) ; } private ArrayList getFoldersToCleanUp ( IProgressMonitor monitor ) throws CoreException { DeltaProcessingState state = JavaModelManager . getDeltaState ( ) ; HashMap roots = state . roots ; HashMap sourceAttachments = state . sourceAttachments ; if ( roots == null && sourceAttachments == null ) return null ; Map knownFolders = getFolders ( ) ; ArrayList result = null ; synchronized ( knownFolders ) { Iterator iterator = knownFolders . entrySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) iterator . next ( ) ; IPath path = ( IPath ) entry . getKey ( ) ; if ( ( roots != null && ! roots . containsKey ( path ) ) && ( sourceAttachments != null && ! sourceAttachments . containsKey ( path ) ) ) { if ( entry . getValue ( ) != null ) { if ( result == null ) result = new ArrayList ( ) ; result . add ( entry ) ; } } } } return result ; } public IProject getExternalFoldersProject ( ) { return ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getProject ( EXTERNAL_PROJECT_NAME ) ; } public IProject createExternalFoldersProject ( IProgressMonitor monitor ) throws CoreException { IProject project = getExternalFoldersProject ( ) ; if ( ! project . isAccessible ( ) ) { if ( ! project . exists ( ) ) { createExternalFoldersProject ( project , monitor ) ; } openExternalFoldersProject ( project , monitor ) ; } return project ; } private void openExternalFoldersProject ( IProject project , IProgressMonitor monitor ) throws CoreException { try { project . open ( monitor ) ; } catch ( CoreException e1 ) { if ( e1 . getStatus ( ) . getCode ( ) == IResourceStatus . FAILED_READ_METADATA ) { project . delete ( false , true , monitor ) ; createExternalFoldersProject ( project , monitor ) ; } else { IPath stateLocation = JavaCore . getPlugin ( ) . getStateLocation ( ) ; IPath projectPath = stateLocation . append ( EXTERNAL_PROJECT_NAME ) ; projectPath . toFile ( ) . mkdirs ( ) ; try { FileOutputStream output = new FileOutputStream ( projectPath . append ( "<STR_LIT>" ) . toOSString ( ) ) ; try { output . write ( ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + EXTERNAL_PROJECT_NAME + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" ) . getBytes ( ) ) ; } finally { output . close ( ) ; } } catch ( IOException e ) { project . delete ( false , true , monitor ) ; createExternalFoldersProject ( project , monitor ) ; } } project . open ( monitor ) ; } } private void createExternalFoldersProject ( IProject project , IProgressMonitor monitor ) throws CoreException { IProjectDescription desc = project . getWorkspace ( ) . newProjectDescription ( project . getName ( ) ) ; IPath stateLocation = JavaCore . getPlugin ( ) . getStateLocation ( ) ; desc . setLocation ( stateLocation . append ( EXTERNAL_PROJECT_NAME ) ) ; project . create ( desc , IResource . HIDDEN , monitor ) ; } public IFolder getFolder ( IPath externalFolderPath ) { return ( IFolder ) getFolders ( ) . get ( externalFolderPath ) ; } private Map getFolders ( ) { if ( this . folders == null ) { Map tempFolders = new HashMap ( ) ; IProject project = getExternalFoldersProject ( ) ; try { if ( ! project . isAccessible ( ) ) { if ( project . exists ( ) ) { openExternalFoldersProject ( project , null ) ; } else { return this . folders = Collections . synchronizedMap ( tempFolders ) ; } } IResource [ ] members = project . members ( ) ; for ( int i = <NUM_LIT:0> , length = members . length ; i < length ; i ++ ) { IResource member = members [ i ] ; if ( member . getType ( ) == IResource . FOLDER && member . isLinked ( ) && member . getName ( ) . startsWith ( LINKED_FOLDER_NAME ) ) { IPath externalFolderPath = member . getLocation ( ) ; tempFolders . put ( externalFolderPath , member ) ; } } } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" ) ; } this . folders = Collections . synchronizedMap ( tempFolders ) ; } return this . folders ; } private void runRefreshJob ( Collection paths ) { Job [ ] jobs = Job . getJobManager ( ) . find ( ResourcesPlugin . FAMILY_MANUAL_REFRESH ) ; RefreshJob refreshJob = null ; if ( jobs != null ) { for ( int index = <NUM_LIT:0> ; index < jobs . length ; index ++ ) { if ( jobs [ index ] instanceof RefreshJob ) { refreshJob = ( RefreshJob ) jobs [ index ] ; refreshJob . addFoldersToRefresh ( paths ) ; if ( refreshJob . getState ( ) == Job . NONE ) { refreshJob . schedule ( ) ; } break ; } } } if ( refreshJob == null ) { refreshJob = new RefreshJob ( new Vector ( paths ) ) ; refreshJob . schedule ( ) ; } } public void refreshReferences ( final IProject [ ] sourceProjects , IProgressMonitor monitor ) { IProject externalProject = getExternalFoldersProject ( ) ; try { HashSet externalFolders = null ; for ( int index = <NUM_LIT:0> ; index < sourceProjects . length ; index ++ ) { if ( sourceProjects [ index ] . equals ( externalProject ) ) continue ; if ( ! JavaProject . hasJavaNature ( sourceProjects [ index ] ) ) continue ; HashSet foldersInProject = getExternalFolders ( ( ( JavaProject ) JavaCore . create ( sourceProjects [ index ] ) ) . getResolvedClasspath ( ) ) ; if ( foldersInProject == null || foldersInProject . size ( ) == <NUM_LIT:0> ) continue ; if ( externalFolders == null ) externalFolders = new HashSet ( ) ; externalFolders . addAll ( foldersInProject ) ; } if ( externalFolders == null ) return ; runRefreshJob ( externalFolders ) ; } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" ) ; } return ; } public void refreshReferences ( IProject source , IProgressMonitor monitor ) { IProject externalProject = getExternalFoldersProject ( ) ; if ( source . equals ( externalProject ) ) return ; if ( ! JavaProject . hasJavaNature ( source ) ) return ; try { HashSet externalFolders = getExternalFolders ( ( ( JavaProject ) JavaCore . create ( source ) ) . getResolvedClasspath ( ) ) ; if ( externalFolders == null ) return ; runRefreshJob ( externalFolders ) ; } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" ) ; } return ; } public IFolder removeFolder ( IPath externalFolderPath ) { return ( IFolder ) getFolders ( ) . remove ( externalFolderPath ) ; } class RefreshJob extends Job { Vector externalFolders = null ; RefreshJob ( Vector externalFolders ) { super ( Messages . refreshing_external_folders ) ; this . externalFolders = externalFolders ; } public boolean belongsTo ( Object family ) { return family == ResourcesPlugin . FAMILY_MANUAL_REFRESH ; } public void addFoldersToRefresh ( Collection paths ) { if ( ! paths . isEmpty ( ) && this . externalFolders == null ) { this . externalFolders = new Vector ( ) ; } Iterator it = paths . iterator ( ) ; while ( it . hasNext ( ) ) { Object path = it . next ( ) ; if ( ! this . externalFolders . contains ( path ) ) { this . externalFolders . add ( path ) ; } } } protected IStatus run ( IProgressMonitor pm ) { try { if ( this . externalFolders == null ) return Status . OK_STATUS ; IPath externalPath = null ; for ( int index = <NUM_LIT:0> ; index < this . externalFolders . size ( ) ; index ++ ) { if ( ( externalPath = ( IPath ) this . externalFolders . get ( index ) ) != null ) { IFolder folder = getFolder ( externalPath ) ; if ( folder != null ) folder . refreshLocal ( IResource . DEPTH_INFINITE , pm ) ; } this . externalFolders . setElementAt ( null , index ) ; } } catch ( CoreException e ) { return e . getStatus ( ) ; } return Status . OK_STATUS ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . HashMap ; import org . eclipse . jdt . core . dom . CompilationUnit ; public class ASTHolderCUInfo extends CompilationUnitElementInfo { int astLevel ; boolean resolveBindings ; int reconcileFlags ; HashMap problems = null ; CompilationUnit ast ; } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . ISourceRange ; import org . eclipse . jdt . core . SourceRange ; public class AnnotatableInfo extends MemberElementInfo { protected IAnnotation [ ] annotations = Annotation . NO_ANNOTATIONS ; protected int nameStart = - <NUM_LIT:1> ; protected int nameEnd = - <NUM_LIT:1> ; public int getNameSourceEnd ( ) { return this . nameEnd ; } public int getNameSourceStart ( ) { return this . nameStart ; } protected void setNameSourceEnd ( int end ) { this . nameEnd = end ; } protected void setNameSourceStart ( int start ) { this . nameStart = start ; } protected ISourceRange getNameRange ( ) { return new SourceRange ( this . nameStart , this . nameEnd - this . nameStart + <NUM_LIT:1> ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . ArrayList ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModelStatusConstants ; import org . eclipse . jdt . core . ISourceRange ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . env . IBinaryAnnotation ; import org . eclipse . jdt . internal . compiler . lookup . TagBits ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . core . util . Util ; public abstract class BinaryMember extends NamedMember { protected BinaryMember ( JavaElement parent , String name ) { super ( parent , name ) ; } public void copy ( IJavaElement container , IJavaElement sibling , String rename , boolean force , IProgressMonitor monitor ) throws JavaModelException { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . READ_ONLY , this ) ) ; } protected IAnnotation [ ] getAnnotations ( IBinaryAnnotation [ ] binaryAnnotations , long tagBits ) { IAnnotation [ ] standardAnnotations = getStandardAnnotations ( tagBits ) ; if ( binaryAnnotations == null ) return standardAnnotations ; int length = binaryAnnotations . length ; int standardLength = standardAnnotations . length ; int fullLength = length + standardLength ; if ( fullLength == <NUM_LIT:0> ) { return Annotation . NO_ANNOTATIONS ; } IAnnotation [ ] annotations = new IAnnotation [ fullLength ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { annotations [ i ] = Util . getAnnotation ( this , binaryAnnotations [ i ] , null ) ; } System . arraycopy ( standardAnnotations , <NUM_LIT:0> , annotations , length , standardLength ) ; return annotations ; } private IAnnotation getAnnotation ( char [ ] [ ] annotationName ) { return new Annotation ( this , new String ( CharOperation . concatWith ( annotationName , '<CHAR_LIT:.>' ) ) ) ; } protected IAnnotation [ ] getStandardAnnotations ( long tagBits ) { if ( ( tagBits & TagBits . AllStandardAnnotationsMask ) == <NUM_LIT:0> ) return Annotation . NO_ANNOTATIONS ; ArrayList annotations = new ArrayList ( ) ; if ( ( tagBits & TagBits . AnnotationTargetMASK ) != <NUM_LIT:0> ) { annotations . add ( getAnnotation ( TypeConstants . JAVA_LANG_ANNOTATION_TARGET ) ) ; } if ( ( tagBits & TagBits . AnnotationRetentionMASK ) != <NUM_LIT:0> ) { annotations . add ( getAnnotation ( TypeConstants . JAVA_LANG_ANNOTATION_RETENTION ) ) ; } if ( ( tagBits & TagBits . AnnotationDeprecated ) != <NUM_LIT:0> ) { annotations . add ( getAnnotation ( TypeConstants . JAVA_LANG_DEPRECATED ) ) ; } if ( ( tagBits & TagBits . AnnotationDocumented ) != <NUM_LIT:0> ) { annotations . add ( getAnnotation ( TypeConstants . JAVA_LANG_ANNOTATION_DOCUMENTED ) ) ; } if ( ( tagBits & TagBits . AnnotationInherited ) != <NUM_LIT:0> ) { annotations . add ( getAnnotation ( TypeConstants . JAVA_LANG_ANNOTATION_INHERITED ) ) ; } if ( ( tagBits & TagBits . AnnotationPolymorphicSignature ) != <NUM_LIT:0> ) { annotations . add ( getAnnotation ( TypeConstants . JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE ) ) ; } if ( ( tagBits & TagBits . AnnotationSafeVarargs ) != <NUM_LIT:0> ) { annotations . add ( getAnnotation ( TypeConstants . JAVA_LANG_SAFEVARARGS ) ) ; } return ( IAnnotation [ ] ) annotations . toArray ( new IAnnotation [ annotations . size ( ) ] ) ; } public String [ ] getCategories ( ) throws JavaModelException { SourceMapper mapper = getSourceMapper ( ) ; if ( mapper != null ) { ( ( ClassFile ) getClassFile ( ) ) . getBuffer ( ) ; if ( mapper . categories != null ) { String [ ] categories = ( String [ ] ) mapper . categories . get ( this ) ; if ( categories != null ) return categories ; } } return CharOperation . NO_STRINGS ; } public String getKey ( ) { try { return getKey ( false ) ; } catch ( JavaModelException e ) { return null ; } } public abstract String getKey ( boolean forceOpen ) throws JavaModelException ; public ISourceRange getNameRange ( ) throws JavaModelException { SourceMapper mapper = getSourceMapper ( ) ; if ( mapper != null ) { ( ( ClassFile ) getClassFile ( ) ) . getBuffer ( ) ; return mapper . getNameRange ( this ) ; } else { return SourceMapper . UNKNOWN_RANGE ; } } public ISourceRange getSourceRange ( ) throws JavaModelException { SourceMapper mapper = getSourceMapper ( ) ; if ( mapper != null ) { ( ( ClassFile ) getClassFile ( ) ) . getBuffer ( ) ; return mapper . getSourceRange ( this ) ; } else { return SourceMapper . UNKNOWN_RANGE ; } } public boolean isBinary ( ) { return true ; } public boolean isStructureKnown ( ) throws JavaModelException { return ( ( IJavaElement ) getOpenableParent ( ) ) . isStructureKnown ( ) ; } public void move ( IJavaElement container , IJavaElement sibling , String rename , boolean force , IProgressMonitor monitor ) throws JavaModelException { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . READ_ONLY , this ) ) ; } public void rename ( String newName , boolean force , IProgressMonitor monitor ) throws JavaModelException { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . READ_ONLY , this ) ) ; } public void setContents ( String contents , IProgressMonitor monitor ) throws JavaModelException { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . READ_ONLY , this ) ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . File ; import java . util . * ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IPackageFragmentRoot ; 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 . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . env . AccessRestriction ; import org . eclipse . jdt . internal . compiler . env . AccessRuleSet ; import org . eclipse . jdt . internal . compiler . env . IBinaryType ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObjectToInt ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . util . HashtableOfArrayToObject ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; public class NameLookup implements SuffixConstants { public static class Answer { public IType type ; AccessRestriction restriction ; Answer ( IType type , AccessRestriction restriction ) { this . type = type ; this . restriction = restriction ; } public boolean ignoreIfBetter ( ) { return this . restriction != null && this . restriction . ignoreIfBetter ( ) ; } public boolean isBetter ( Answer otherAnswer ) { if ( otherAnswer == null ) return true ; if ( this . restriction == null ) return true ; return otherAnswer . restriction != null && this . restriction . getProblemId ( ) < otherAnswer . restriction . getProblemId ( ) ; } } public static final int ACCEPT_CLASSES = ASTNode . Bit2 ; public static final int ACCEPT_INTERFACES = ASTNode . Bit3 ; public static final int ACCEPT_ENUMS = ASTNode . Bit4 ; public static final int ACCEPT_ANNOTATIONS = ASTNode . Bit5 ; public static final int ACCEPT_ALL = ACCEPT_CLASSES | ACCEPT_INTERFACES | ACCEPT_ENUMS | ACCEPT_ANNOTATIONS ; public static boolean VERBOSE = false ; private static final IType [ ] NO_TYPES = { } ; protected IPackageFragmentRoot [ ] packageFragmentRoots ; protected HashtableOfArrayToObject packageFragments ; protected Map rootToResolvedEntries ; protected HashMap typesInWorkingCopies ; public long timeSpentInSeekTypesInSourcePackage = <NUM_LIT:0> ; public long timeSpentInSeekTypesInBinaryPackage = <NUM_LIT:0> ; public NameLookup ( IPackageFragmentRoot [ ] packageFragmentRoots , HashtableOfArrayToObject packageFragments , ICompilationUnit [ ] workingCopies , Map rootToResolvedEntries ) { long start = - <NUM_LIT:1> ; if ( VERBOSE ) { Util . verbose ( "<STR_LIT>" ) ; Util . verbose ( "<STR_LIT>" + ( packageFragmentRoots == null ? <NUM_LIT:0> : packageFragmentRoots . length ) ) ; Util . verbose ( "<STR_LIT>" + ( packageFragments == null ? <NUM_LIT:0> : packageFragments . size ( ) ) ) ; Util . verbose ( "<STR_LIT>" + ( workingCopies == null ? <NUM_LIT:0> : workingCopies . length ) ) ; start = System . currentTimeMillis ( ) ; } this . packageFragmentRoots = packageFragmentRoots ; if ( workingCopies == null ) { this . packageFragments = packageFragments ; } else { try { this . packageFragments = ( HashtableOfArrayToObject ) packageFragments . clone ( ) ; } catch ( CloneNotSupportedException e1 ) { } this . typesInWorkingCopies = new HashMap ( ) ; HashtableOfObjectToInt rootPositions = new HashtableOfObjectToInt ( ) ; for ( int i = <NUM_LIT:0> , length = packageFragmentRoots . length ; i < length ; i ++ ) { rootPositions . put ( packageFragmentRoots [ i ] , i ) ; } for ( int i = <NUM_LIT:0> , length = workingCopies . length ; i < length ; i ++ ) { ICompilationUnit workingCopy = workingCopies [ i ] ; PackageFragment pkg = ( PackageFragment ) workingCopy . getParent ( ) ; IPackageFragmentRoot root = ( IPackageFragmentRoot ) pkg . getParent ( ) ; int rootPosition = rootPositions . get ( root ) ; if ( rootPosition == - <NUM_LIT:1> ) continue ; HashMap typeMap = ( HashMap ) this . typesInWorkingCopies . get ( pkg ) ; if ( typeMap == null ) { typeMap = new HashMap ( ) ; this . typesInWorkingCopies . put ( pkg , typeMap ) ; } try { IType [ ] types = workingCopy . getTypes ( ) ; int typeLength = types . length ; if ( typeLength == <NUM_LIT:0> ) { String typeName = Util . getNameWithoutJavaLikeExtension ( workingCopy . getElementName ( ) ) ; typeMap . put ( typeName , NO_TYPES ) ; } else { for ( int j = <NUM_LIT:0> ; j < typeLength ; j ++ ) { IType type = types [ j ] ; String typeName = type . getElementName ( ) ; Object existing = typeMap . get ( typeName ) ; if ( existing == null ) { typeMap . put ( typeName , type ) ; } else if ( existing instanceof IType ) { typeMap . put ( typeName , new IType [ ] { ( IType ) existing , type } ) ; } else { IType [ ] existingTypes = ( IType [ ] ) existing ; int existingTypeLength = existingTypes . length ; System . arraycopy ( existingTypes , <NUM_LIT:0> , existingTypes = new IType [ existingTypeLength + <NUM_LIT:1> ] , <NUM_LIT:0> , existingTypeLength ) ; existingTypes [ existingTypeLength ] = type ; typeMap . put ( typeName , existingTypes ) ; } } } } catch ( JavaModelException e ) { } String [ ] pkgName = pkg . names ; Object existing = this . packageFragments . get ( pkgName ) ; if ( existing == null || existing == JavaProjectElementInfo . NO_ROOTS ) { this . packageFragments . put ( pkgName , root ) ; JavaProjectElementInfo . addSuperPackageNames ( pkgName , this . packageFragments ) ; } else { if ( existing instanceof PackageFragmentRoot ) { int exisitingPosition = rootPositions . get ( existing ) ; if ( rootPosition != exisitingPosition ) { this . packageFragments . put ( pkgName , exisitingPosition < rootPosition ? new IPackageFragmentRoot [ ] { ( PackageFragmentRoot ) existing , root } : new IPackageFragmentRoot [ ] { root , ( PackageFragmentRoot ) existing } ) ; } } else { IPackageFragmentRoot [ ] roots = ( IPackageFragmentRoot [ ] ) existing ; int rootLength = roots . length ; int insertionIndex = <NUM_LIT:0> ; for ( int j = <NUM_LIT:0> ; j < rootLength ; j ++ ) { int existingPosition = rootPositions . get ( roots [ j ] ) ; if ( rootPosition > existingPosition ) { insertionIndex = j ; } else if ( rootPosition == existingPosition ) { insertionIndex = - <NUM_LIT:1> ; break ; } else if ( rootPosition < existingPosition ) { break ; } } if ( insertionIndex != - <NUM_LIT:1> ) { IPackageFragmentRoot [ ] newRoots = new IPackageFragmentRoot [ rootLength + <NUM_LIT:1> ] ; System . arraycopy ( roots , <NUM_LIT:0> , newRoots , <NUM_LIT:0> , insertionIndex ) ; newRoots [ insertionIndex ] = root ; System . arraycopy ( roots , insertionIndex , newRoots , insertionIndex + <NUM_LIT:1> , rootLength - insertionIndex ) ; this . packageFragments . put ( pkgName , newRoots ) ; } } } } } this . rootToResolvedEntries = rootToResolvedEntries ; if ( VERBOSE ) { Util . verbose ( "<STR_LIT>" + ( System . currentTimeMillis ( ) - start ) + "<STR_LIT>" ) ; } } protected boolean acceptType ( IType type , int acceptFlags , boolean isSourceType ) { if ( acceptFlags == <NUM_LIT:0> || acceptFlags == ACCEPT_ALL ) return true ; try { int kind = isSourceType ? TypeDeclaration . kind ( ( ( SourceTypeElementInfo ) ( ( SourceType ) type ) . getElementInfo ( ) ) . getModifiers ( ) ) : TypeDeclaration . kind ( ( ( IBinaryType ) ( ( BinaryType ) type ) . getElementInfo ( ) ) . getModifiers ( ) ) ; switch ( kind ) { case TypeDeclaration . CLASS_DECL : return ( acceptFlags & ACCEPT_CLASSES ) != <NUM_LIT:0> ; case TypeDeclaration . INTERFACE_DECL : return ( acceptFlags & ACCEPT_INTERFACES ) != <NUM_LIT:0> ; case TypeDeclaration . ENUM_DECL : return ( acceptFlags & ACCEPT_ENUMS ) != <NUM_LIT:0> ; default : return ( acceptFlags & ACCEPT_ANNOTATIONS ) != <NUM_LIT:0> ; } } catch ( JavaModelException npe ) { return false ; } } private void findAllTypes ( String prefix , boolean partialMatch , int acceptFlags , IJavaElementRequestor requestor ) { int count = this . packageFragmentRoots . length ; for ( int i = <NUM_LIT:0> ; i < count ; i ++ ) { if ( requestor . isCanceled ( ) ) return ; IPackageFragmentRoot root = this . packageFragmentRoots [ i ] ; IJavaElement [ ] packages = null ; try { packages = root . getChildren ( ) ; } catch ( JavaModelException npe ) { continue ; } if ( packages != null ) { for ( int j = <NUM_LIT:0> , packageCount = packages . length ; j < packageCount ; j ++ ) { if ( requestor . isCanceled ( ) ) return ; seekTypes ( prefix , ( IPackageFragment ) packages [ j ] , partialMatch , acceptFlags , requestor ) ; } } } } public ICompilationUnit findCompilationUnit ( String qualifiedTypeName ) { String [ ] pkgName = CharOperation . NO_STRINGS ; String cuName = qualifiedTypeName ; int index = qualifiedTypeName . lastIndexOf ( '<CHAR_LIT:.>' ) ; if ( index != - <NUM_LIT:1> ) { pkgName = Util . splitOn ( '<CHAR_LIT:.>' , qualifiedTypeName , <NUM_LIT:0> , index ) ; cuName = qualifiedTypeName . substring ( index + <NUM_LIT:1> ) ; } index = cuName . indexOf ( '<CHAR_LIT>' ) ; if ( index != - <NUM_LIT:1> ) { cuName = cuName . substring ( <NUM_LIT:0> , index ) ; } int pkgIndex = this . packageFragments . getIndex ( pkgName ) ; if ( pkgIndex != - <NUM_LIT:1> ) { Object value = this . packageFragments . valueTable [ pkgIndex ] ; pkgName = ( String [ ] ) this . packageFragments . keyTable [ pkgIndex ] ; if ( value instanceof PackageFragmentRoot ) { return findCompilationUnit ( pkgName , cuName , ( PackageFragmentRoot ) value ) ; } else { IPackageFragmentRoot [ ] roots = ( IPackageFragmentRoot [ ] ) value ; for ( int i = <NUM_LIT:0> ; i < roots . length ; i ++ ) { PackageFragmentRoot root = ( PackageFragmentRoot ) roots [ i ] ; ICompilationUnit cu = findCompilationUnit ( pkgName , cuName , root ) ; if ( cu != null ) return cu ; } } } return null ; } private ICompilationUnit findCompilationUnit ( String [ ] pkgName , String cuName , PackageFragmentRoot root ) { if ( ! root . isArchive ( ) ) { IPackageFragment pkg = root . getPackageFragment ( pkgName ) ; try { ICompilationUnit [ ] cus = pkg . getCompilationUnits ( ) ; for ( int j = <NUM_LIT:0> , length = cus . length ; j < length ; j ++ ) { ICompilationUnit cu = cus [ j ] ; if ( Util . equalsIgnoreJavaLikeExtension ( cu . getElementName ( ) , cuName ) ) return cu ; } } catch ( JavaModelException e ) { } } return null ; } public IPackageFragment findPackageFragment ( IPath path ) { if ( ! path . isAbsolute ( ) ) { throw new IllegalArgumentException ( Messages . path_mustBeAbsolute ) ; } IResource possibleFragment = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . findMember ( path ) ; if ( possibleFragment == null ) { for ( int i = <NUM_LIT:0> ; i < this . packageFragmentRoots . length ; i ++ ) { IPackageFragmentRoot root = this . packageFragmentRoots [ i ] ; if ( ! root . isExternal ( ) ) { continue ; } IPath rootPath = root . getPath ( ) ; if ( rootPath . isPrefixOf ( path ) ) { String name = path . toOSString ( ) ; name = name . substring ( rootPath . toOSString ( ) . length ( ) + <NUM_LIT:1> , name . length ( ) ) ; name = name . replace ( File . separatorChar , '<CHAR_LIT:.>' ) ; IJavaElement [ ] list = null ; try { list = root . getChildren ( ) ; } catch ( JavaModelException npe ) { continue ; } int elementCount = list . length ; for ( int j = <NUM_LIT:0> ; j < elementCount ; j ++ ) { IPackageFragment packageFragment = ( IPackageFragment ) list [ j ] ; if ( nameMatches ( name , packageFragment , false ) ) { return packageFragment ; } } } } } else { IJavaElement fromFactory = JavaCore . create ( possibleFragment ) ; if ( fromFactory == null ) { return null ; } switch ( fromFactory . getElementType ( ) ) { case IJavaElement . PACKAGE_FRAGMENT : return ( IPackageFragment ) fromFactory ; case IJavaElement . JAVA_PROJECT : JavaProject project = ( JavaProject ) fromFactory ; try { IClasspathEntry entry = project . getClasspathEntryFor ( path ) ; if ( entry != null ) { IPackageFragmentRoot root = project . getPackageFragmentRoot ( project . getResource ( ) ) ; Object defaultPkgRoot = this . packageFragments . get ( CharOperation . NO_STRINGS ) ; if ( defaultPkgRoot == null ) { return null ; } if ( defaultPkgRoot instanceof PackageFragmentRoot && defaultPkgRoot . equals ( root ) ) return ( ( PackageFragmentRoot ) root ) . getPackageFragment ( CharOperation . NO_STRINGS ) ; else { IPackageFragmentRoot [ ] roots = ( IPackageFragmentRoot [ ] ) defaultPkgRoot ; for ( int i = <NUM_LIT:0> ; i < roots . length ; i ++ ) { if ( roots [ i ] . equals ( root ) ) { return ( ( PackageFragmentRoot ) root ) . getPackageFragment ( CharOperation . NO_STRINGS ) ; } } } } } catch ( JavaModelException e ) { return null ; } return null ; case IJavaElement . PACKAGE_FRAGMENT_ROOT : return ( ( PackageFragmentRoot ) fromFactory ) . getPackageFragment ( CharOperation . NO_STRINGS ) ; } } return null ; } public IPackageFragment [ ] findPackageFragments ( String name , boolean partialMatch ) { return findPackageFragments ( name , partialMatch , false ) ; } public IPackageFragment [ ] findPackageFragments ( String name , boolean partialMatch , boolean patternMatch ) { boolean isStarPattern = name . equals ( "<STR_LIT:*>" ) ; boolean hasPatternChars = isStarPattern || ( patternMatch && ( name . indexOf ( '<CHAR_LIT>' ) >= <NUM_LIT:0> || name . indexOf ( '<CHAR_LIT>' ) >= <NUM_LIT:0> ) ) ; if ( partialMatch || hasPatternChars ) { String [ ] splittedName = Util . splitOn ( '<CHAR_LIT:.>' , name , <NUM_LIT:0> , name . length ( ) ) ; IPackageFragment [ ] oneFragment = null ; ArrayList pkgs = null ; char [ ] lowercaseName = hasPatternChars && ! isStarPattern ? name . toLowerCase ( ) . toCharArray ( ) : null ; Object [ ] [ ] keys = this . packageFragments . keyTable ; for ( int i = <NUM_LIT:0> , length = keys . length ; i < length ; i ++ ) { String [ ] pkgName = ( String [ ] ) keys [ i ] ; if ( pkgName != null ) { boolean match = isStarPattern || ( hasPatternChars ? CharOperation . match ( lowercaseName , Util . concatCompoundNameToCharArray ( pkgName ) , false ) : Util . startsWithIgnoreCase ( pkgName , splittedName , partialMatch ) ) ; if ( match ) { Object value = this . packageFragments . valueTable [ i ] ; if ( value instanceof PackageFragmentRoot ) { IPackageFragment pkg = ( ( PackageFragmentRoot ) value ) . getPackageFragment ( pkgName ) ; if ( oneFragment == null ) { oneFragment = new IPackageFragment [ ] { pkg } ; } else { if ( pkgs == null ) { pkgs = new ArrayList ( ) ; pkgs . add ( oneFragment [ <NUM_LIT:0> ] ) ; } pkgs . add ( pkg ) ; } } else { IPackageFragmentRoot [ ] roots = ( IPackageFragmentRoot [ ] ) value ; for ( int j = <NUM_LIT:0> , length2 = roots . length ; j < length2 ; j ++ ) { PackageFragmentRoot root = ( PackageFragmentRoot ) roots [ j ] ; IPackageFragment pkg = root . getPackageFragment ( pkgName ) ; if ( oneFragment == null ) { oneFragment = new IPackageFragment [ ] { pkg } ; } else { if ( pkgs == null ) { pkgs = new ArrayList ( ) ; pkgs . add ( oneFragment [ <NUM_LIT:0> ] ) ; } pkgs . add ( pkg ) ; } } } } } } if ( pkgs == null ) return oneFragment ; int resultLength = pkgs . size ( ) ; IPackageFragment [ ] result = new IPackageFragment [ resultLength ] ; pkgs . toArray ( result ) ; return result ; } else { String [ ] splittedName = Util . splitOn ( '<CHAR_LIT:.>' , name , <NUM_LIT:0> , name . length ( ) ) ; int pkgIndex = this . packageFragments . getIndex ( splittedName ) ; if ( pkgIndex == - <NUM_LIT:1> ) return null ; Object value = this . packageFragments . valueTable [ pkgIndex ] ; String [ ] pkgName = ( String [ ] ) this . packageFragments . keyTable [ pkgIndex ] ; if ( value instanceof PackageFragmentRoot ) { return new IPackageFragment [ ] { ( ( PackageFragmentRoot ) value ) . getPackageFragment ( pkgName ) } ; } else { IPackageFragmentRoot [ ] roots = ( IPackageFragmentRoot [ ] ) value ; IPackageFragment [ ] result = new IPackageFragment [ roots . length ] ; for ( int i = <NUM_LIT:0> ; i < roots . length ; i ++ ) { result [ i ] = ( ( PackageFragmentRoot ) roots [ i ] ) . getPackageFragment ( pkgName ) ; } return result ; } } } private IType findSecondaryType ( String packageName , String typeName , IJavaProject project , boolean waitForIndexes , IProgressMonitor monitor ) { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; try { IJavaProject javaProject = project ; Map secondaryTypePaths = manager . secondaryTypes ( javaProject , waitForIndexes , monitor ) ; if ( secondaryTypePaths . size ( ) > <NUM_LIT:0> ) { Map types = ( Map ) secondaryTypePaths . get ( packageName == null ? "<STR_LIT>" : packageName ) ; if ( types != null && types . size ( ) > <NUM_LIT:0> ) { IType type = ( IType ) types . get ( typeName ) ; if ( type != null ) { if ( JavaModelManager . VERBOSE ) { Util . verbose ( "<STR_LIT>" ) ; Util . verbose ( "<STR_LIT>" + packageName ) ; Util . verbose ( "<STR_LIT>" + typeName ) ; Util . verbose ( "<STR_LIT>" + project . getElementName ( ) ) ; Util . verbose ( "<STR_LIT>" + type . getElementName ( ) ) ; } return type ; } } } } catch ( JavaModelException jme ) { } return null ; } public Answer findType ( String typeName , String packageName , boolean partialMatch , int acceptFlags , boolean checkRestrictions ) { return findType ( typeName , packageName , partialMatch , acceptFlags , true , false , checkRestrictions , null ) ; } public Answer findType ( String typeName , String packageName , boolean partialMatch , int acceptFlags , boolean considerSecondaryTypes , boolean waitForIndexes , boolean checkRestrictions , IProgressMonitor monitor ) { if ( packageName == null || packageName . length ( ) == <NUM_LIT:0> ) { packageName = IPackageFragment . DEFAULT_PACKAGE_NAME ; } else if ( typeName . length ( ) > <NUM_LIT:0> && ScannerHelper . isLowerCase ( typeName . charAt ( <NUM_LIT:0> ) ) ) { if ( findPackageFragments ( packageName + "<STR_LIT:.>" + typeName , false ) != null ) return null ; } JavaElementRequestor elementRequestor = new JavaElementRequestor ( ) ; seekPackageFragments ( packageName , false , elementRequestor ) ; IPackageFragment [ ] packages = elementRequestor . getPackageFragments ( ) ; IType type = null ; int length = packages . length ; HashSet projects = null ; IJavaProject javaProject = null ; Answer suggestedAnswer = null ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { type = findType ( typeName , packages [ i ] , partialMatch , acceptFlags ) ; if ( type != null ) { AccessRestriction accessRestriction = null ; if ( checkRestrictions ) { accessRestriction = getViolatedRestriction ( typeName , packageName , type , accessRestriction ) ; } Answer answer = new Answer ( type , accessRestriction ) ; if ( ! answer . ignoreIfBetter ( ) ) { if ( answer . isBetter ( suggestedAnswer ) ) return answer ; } else if ( answer . isBetter ( suggestedAnswer ) ) suggestedAnswer = answer ; } else if ( suggestedAnswer == null && considerSecondaryTypes ) { if ( javaProject == null ) { javaProject = packages [ i ] . getJavaProject ( ) ; } else if ( projects == null ) { if ( ! javaProject . equals ( packages [ i ] . getJavaProject ( ) ) ) { projects = new HashSet ( <NUM_LIT:3> ) ; projects . add ( javaProject ) ; projects . add ( packages [ i ] . getJavaProject ( ) ) ; } } else { projects . add ( packages [ i ] . getJavaProject ( ) ) ; } } } if ( suggestedAnswer != null ) return suggestedAnswer ; if ( considerSecondaryTypes && javaProject != null ) { if ( projects == null ) { type = findSecondaryType ( packageName , typeName , javaProject , waitForIndexes , monitor ) ; } else { Iterator allProjects = projects . iterator ( ) ; while ( type == null && allProjects . hasNext ( ) ) { type = findSecondaryType ( packageName , typeName , ( IJavaProject ) allProjects . next ( ) , waitForIndexes , monitor ) ; } } } return type == null ? null : new Answer ( type , null ) ; } private AccessRestriction getViolatedRestriction ( String typeName , String packageName , IType type , AccessRestriction accessRestriction ) { PackageFragmentRoot root = ( PackageFragmentRoot ) type . getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; ClasspathEntry entry = ( ClasspathEntry ) this . rootToResolvedEntries . get ( root ) ; if ( entry != null ) { AccessRuleSet accessRuleSet = entry . getAccessRuleSet ( ) ; if ( accessRuleSet != null ) { char [ ] [ ] packageChars = CharOperation . splitOn ( '<CHAR_LIT:.>' , packageName . toCharArray ( ) ) ; char [ ] typeChars = typeName . toCharArray ( ) ; accessRestriction = accessRuleSet . getViolatedRestriction ( CharOperation . concatWith ( packageChars , typeChars , '<CHAR_LIT:/>' ) ) ; } } return accessRestriction ; } public IType findType ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags , boolean considerSecondaryTypes ) { IType type = findType ( name , pkg , partialMatch , acceptFlags ) ; if ( type == null && considerSecondaryTypes ) { type = findSecondaryType ( pkg . getElementName ( ) , name , pkg . getJavaProject ( ) , false , null ) ; } return type ; } public IType findType ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags ) { if ( pkg == null ) return null ; SingleTypeRequestor typeRequestor = new SingleTypeRequestor ( ) ; seekTypes ( name , pkg , partialMatch , acceptFlags , typeRequestor ) ; return typeRequestor . getType ( ) ; } public IType findType ( String name , boolean partialMatch , int acceptFlags ) { NameLookup . Answer answer = findType ( name , partialMatch , acceptFlags , false ) ; return answer == null ? null : answer . type ; } public Answer findType ( String name , boolean partialMatch , int acceptFlags , boolean checkRestrictions ) { return findType ( name , partialMatch , acceptFlags , true , true , checkRestrictions , null ) ; } public Answer findType ( String name , boolean partialMatch , int acceptFlags , boolean considerSecondaryTypes , boolean waitForIndexes , boolean checkRestrictions , IProgressMonitor monitor ) { int index = name . lastIndexOf ( '<CHAR_LIT:.>' ) ; String className = null , packageName = null ; if ( index == - <NUM_LIT:1> ) { packageName = IPackageFragment . DEFAULT_PACKAGE_NAME ; className = name ; } else { packageName = name . substring ( <NUM_LIT:0> , index ) ; className = name . substring ( index + <NUM_LIT:1> ) ; } return findType ( className , packageName , partialMatch , acceptFlags , considerSecondaryTypes , waitForIndexes , checkRestrictions , monitor ) ; } private IType getMemberType ( IType type , String name , int dot ) { while ( dot != - <NUM_LIT:1> ) { int start = dot + <NUM_LIT:1> ; dot = name . indexOf ( '<CHAR_LIT:.>' , start ) ; String typeName = name . substring ( start , dot == - <NUM_LIT:1> ? name . length ( ) : dot ) ; type = type . getType ( typeName ) ; } return type ; } public boolean isPackage ( String [ ] pkgName ) { return this . packageFragments . get ( pkgName ) != null ; } protected boolean nameMatches ( String searchName , IJavaElement element , boolean partialMatch ) { if ( partialMatch ) { return element . getElementName ( ) . toLowerCase ( ) . startsWith ( searchName ) ; } else { return element . getElementName ( ) . equals ( searchName ) ; } } protected boolean nameMatches ( String searchName , ICompilationUnit cu , boolean partialMatch ) { if ( partialMatch ) { return cu . getElementName ( ) . toLowerCase ( ) . startsWith ( searchName ) ; } else { return Util . equalsIgnoreJavaLikeExtension ( cu . getElementName ( ) , searchName ) ; } } public void seekPackageFragments ( String name , boolean partialMatch , IJavaElementRequestor requestor ) { if ( partialMatch ) { String [ ] splittedName = Util . splitOn ( '<CHAR_LIT:.>' , name , <NUM_LIT:0> , name . length ( ) ) ; Object [ ] [ ] keys = this . packageFragments . keyTable ; for ( int i = <NUM_LIT:0> , length = keys . length ; i < length ; i ++ ) { if ( requestor . isCanceled ( ) ) return ; String [ ] pkgName = ( String [ ] ) keys [ i ] ; if ( pkgName != null && Util . startsWithIgnoreCase ( pkgName , splittedName , partialMatch ) ) { Object value = this . packageFragments . valueTable [ i ] ; if ( value instanceof PackageFragmentRoot ) { PackageFragmentRoot root = ( PackageFragmentRoot ) value ; requestor . acceptPackageFragment ( root . getPackageFragment ( pkgName ) ) ; } else { IPackageFragmentRoot [ ] roots = ( IPackageFragmentRoot [ ] ) value ; for ( int j = <NUM_LIT:0> , length2 = roots . length ; j < length2 ; j ++ ) { if ( requestor . isCanceled ( ) ) return ; PackageFragmentRoot root = ( PackageFragmentRoot ) roots [ j ] ; requestor . acceptPackageFragment ( root . getPackageFragment ( pkgName ) ) ; } } } } } else { String [ ] splittedName = Util . splitOn ( '<CHAR_LIT:.>' , name , <NUM_LIT:0> , name . length ( ) ) ; int pkgIndex = this . packageFragments . getIndex ( splittedName ) ; if ( pkgIndex != - <NUM_LIT:1> ) { Object value = this . packageFragments . valueTable [ pkgIndex ] ; String [ ] pkgName = ( String [ ] ) this . packageFragments . keyTable [ pkgIndex ] ; if ( value instanceof PackageFragmentRoot ) { requestor . acceptPackageFragment ( ( ( PackageFragmentRoot ) value ) . getPackageFragment ( pkgName ) ) ; } else { IPackageFragmentRoot [ ] roots = ( IPackageFragmentRoot [ ] ) value ; if ( roots != null ) { for ( int i = <NUM_LIT:0> , length = roots . length ; i < length ; i ++ ) { if ( requestor . isCanceled ( ) ) return ; PackageFragmentRoot root = ( PackageFragmentRoot ) roots [ i ] ; requestor . acceptPackageFragment ( root . getPackageFragment ( pkgName ) ) ; } } } } } } public void seekTypes ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags , IJavaElementRequestor requestor ) { String matchName = partialMatch ? name . toLowerCase ( ) : name ; if ( pkg == null ) { findAllTypes ( matchName , partialMatch , acceptFlags , requestor ) ; return ; } PackageFragmentRoot root = ( PackageFragmentRoot ) pkg . getParent ( ) ; try { int firstDot = - <NUM_LIT:1> ; String topLevelTypeName = null ; int packageFlavor = root . internalKind ( ) ; if ( this . typesInWorkingCopies != null || packageFlavor == IPackageFragmentRoot . K_SOURCE ) { firstDot = matchName . indexOf ( '<CHAR_LIT:.>' ) ; if ( ! partialMatch ) topLevelTypeName = firstDot == - <NUM_LIT:1> ? matchName : matchName . substring ( <NUM_LIT:0> , firstDot ) ; } if ( this . typesInWorkingCopies != null ) { if ( seekTypesInWorkingCopies ( matchName , pkg , firstDot , partialMatch , topLevelTypeName , acceptFlags , requestor ) ) return ; } switch ( packageFlavor ) { case IPackageFragmentRoot . K_BINARY : matchName = matchName . replace ( '<CHAR_LIT:.>' , '<CHAR_LIT>' ) ; seekTypesInBinaryPackage ( matchName , pkg , partialMatch , acceptFlags , requestor ) ; break ; case IPackageFragmentRoot . K_SOURCE : seekTypesInSourcePackage ( matchName , pkg , firstDot , partialMatch , topLevelTypeName , acceptFlags , requestor ) ; if ( matchName . indexOf ( '<CHAR_LIT>' ) != - <NUM_LIT:1> ) { matchName = matchName . replace ( '<CHAR_LIT>' , '<CHAR_LIT:.>' ) ; firstDot = matchName . indexOf ( '<CHAR_LIT:.>' ) ; if ( ! partialMatch ) topLevelTypeName = firstDot == - <NUM_LIT:1> ? matchName : matchName . substring ( <NUM_LIT:0> , firstDot ) ; seekTypesInSourcePackage ( matchName , pkg , firstDot , partialMatch , topLevelTypeName , acceptFlags , requestor ) ; } break ; default : return ; } } catch ( JavaModelException e ) { return ; } } protected void seekTypesInBinaryPackage ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags , IJavaElementRequestor requestor ) { long start = - <NUM_LIT:1> ; if ( VERBOSE ) start = System . currentTimeMillis ( ) ; try { if ( ! partialMatch ) { if ( requestor . isCanceled ( ) ) return ; ClassFile classFile = new ClassFile ( ( PackageFragment ) pkg , name ) ; if ( classFile . existsUsingJarTypeCache ( ) ) { IType type = classFile . getType ( ) ; if ( acceptType ( type , acceptFlags , false ) ) { requestor . acceptType ( type ) ; } } } else { IJavaElement [ ] classFiles = null ; try { classFiles = pkg . getChildren ( ) ; } catch ( JavaModelException npe ) { return ; } int length = classFiles . length ; String unqualifiedName = name ; int index = name . lastIndexOf ( '<CHAR_LIT>' ) ; if ( index != - <NUM_LIT:1> ) { unqualifiedName = Util . localTypeName ( name , index , name . length ( ) ) ; } int matchLength = name . length ( ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( requestor . isCanceled ( ) ) return ; IJavaElement classFile = classFiles [ i ] ; String elementName = classFile . getElementName ( ) ; if ( elementName . regionMatches ( true , <NUM_LIT:0> , name , <NUM_LIT:0> , matchLength ) ) { IType type = ( ( ClassFile ) classFile ) . getType ( ) ; String typeName = type . getElementName ( ) ; if ( typeName . length ( ) > <NUM_LIT:0> && ! Character . isDigit ( typeName . charAt ( <NUM_LIT:0> ) ) ) { if ( nameMatches ( unqualifiedName , type , true ) && acceptType ( type , acceptFlags , false ) ) requestor . acceptType ( type ) ; } } } } } finally { if ( VERBOSE ) this . timeSpentInSeekTypesInBinaryPackage += System . currentTimeMillis ( ) - start ; } } protected void seekTypesInSourcePackage ( String name , IPackageFragment pkg , int firstDot , boolean partialMatch , String topLevelTypeName , int acceptFlags , IJavaElementRequestor requestor ) { long start = - <NUM_LIT:1> ; if ( VERBOSE ) start = System . currentTimeMillis ( ) ; try { if ( ! partialMatch ) { try { IJavaElement [ ] compilationUnits = pkg . getChildren ( ) ; for ( int i = <NUM_LIT:0> , length = compilationUnits . length ; i < length ; i ++ ) { if ( requestor . isCanceled ( ) ) return ; IJavaElement cu = compilationUnits [ i ] ; String cuName = cu . getElementName ( ) ; int lastDot = cuName . lastIndexOf ( '<CHAR_LIT:.>' ) ; if ( lastDot != topLevelTypeName . length ( ) || ! topLevelTypeName . regionMatches ( <NUM_LIT:0> , cuName , <NUM_LIT:0> , lastDot ) ) continue ; if ( ! ( cu instanceof ICompilationUnit ) ) continue ; IType type = ( ( ICompilationUnit ) cu ) . getType ( topLevelTypeName ) ; type = getMemberType ( type , name , firstDot ) ; if ( acceptType ( type , acceptFlags , true ) ) { requestor . acceptType ( type ) ; break ; } } } catch ( JavaModelException e ) { } } else { try { String cuPrefix = firstDot == - <NUM_LIT:1> ? name : name . substring ( <NUM_LIT:0> , firstDot ) ; IJavaElement [ ] compilationUnits = pkg . getChildren ( ) ; for ( int i = <NUM_LIT:0> , length = compilationUnits . length ; i < length ; i ++ ) { if ( requestor . isCanceled ( ) ) return ; IJavaElement cu = compilationUnits [ i ] ; if ( ! cu . getElementName ( ) . toLowerCase ( ) . startsWith ( cuPrefix ) ) continue ; try { IType [ ] types = ( ( ICompilationUnit ) cu ) . getTypes ( ) ; for ( int j = <NUM_LIT:0> , typeLength = types . length ; j < typeLength ; j ++ ) seekTypesInTopLevelType ( name , firstDot , types [ j ] , requestor , acceptFlags ) ; } catch ( JavaModelException e ) { } } } catch ( JavaModelException e ) { } } } finally { if ( VERBOSE ) this . timeSpentInSeekTypesInSourcePackage += System . currentTimeMillis ( ) - start ; } } protected boolean seekTypesInType ( String prefix , int firstDot , IType type , IJavaElementRequestor requestor , int acceptFlags ) { IType [ ] types = null ; try { types = type . getTypes ( ) ; } catch ( JavaModelException npe ) { return false ; } int length = types . length ; if ( length == <NUM_LIT:0> ) return false ; String memberPrefix = prefix ; boolean isMemberTypePrefix = false ; if ( firstDot != - <NUM_LIT:1> ) { memberPrefix = prefix . substring ( <NUM_LIT:0> , firstDot ) ; isMemberTypePrefix = true ; } for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( requestor . isCanceled ( ) ) return false ; IType memberType = types [ i ] ; if ( memberType . getElementName ( ) . toLowerCase ( ) . startsWith ( memberPrefix ) ) if ( isMemberTypePrefix ) { String subPrefix = prefix . substring ( firstDot + <NUM_LIT:1> , prefix . length ( ) ) ; return seekTypesInType ( subPrefix , subPrefix . indexOf ( '<CHAR_LIT:.>' ) , memberType , requestor , acceptFlags ) ; } else { if ( acceptType ( memberType , acceptFlags , true ) ) { requestor . acceptMemberType ( memberType ) ; return true ; } } } return false ; } protected boolean seekTypesInTopLevelType ( String prefix , int firstDot , IType topLevelType , IJavaElementRequestor requestor , int acceptFlags ) { if ( ! topLevelType . getElementName ( ) . toLowerCase ( ) . startsWith ( prefix ) ) return false ; if ( firstDot == - <NUM_LIT:1> ) { if ( acceptType ( topLevelType , acceptFlags , true ) ) { requestor . acceptType ( topLevelType ) ; return true ; } } else { return seekTypesInType ( prefix , firstDot , topLevelType , requestor , acceptFlags ) ; } return false ; } protected boolean seekTypesInWorkingCopies ( String name , IPackageFragment pkg , int firstDot , boolean partialMatch , String topLevelTypeName , int acceptFlags , IJavaElementRequestor requestor ) { if ( ! partialMatch ) { HashMap typeMap = ( HashMap ) ( this . typesInWorkingCopies == null ? null : this . typesInWorkingCopies . get ( pkg ) ) ; if ( typeMap != null ) { Object object = typeMap . get ( topLevelTypeName ) ; if ( object instanceof IType ) { IType type = getMemberType ( ( IType ) object , name , firstDot ) ; if ( acceptType ( type , acceptFlags , true ) ) { requestor . acceptType ( type ) ; return true ; } } else if ( object instanceof IType [ ] ) { if ( object == NO_TYPES ) { String packageInfoName = String . valueOf ( TypeConstants . PACKAGE_INFO_NAME ) ; if ( packageInfoName . equals ( name ) ) requestor . acceptType ( pkg . getCompilationUnit ( packageInfoName . concat ( SUFFIX_STRING_java ) ) . getType ( name ) ) ; return true ; } IType [ ] topLevelTypes = ( IType [ ] ) object ; for ( int i = <NUM_LIT:0> , length = topLevelTypes . length ; i < length ; i ++ ) { if ( requestor . isCanceled ( ) ) return false ; IType type = getMemberType ( topLevelTypes [ i ] , name , firstDot ) ; if ( acceptType ( type , acceptFlags , true ) ) { requestor . acceptType ( type ) ; return true ; } } } } } else { HashMap typeMap = ( HashMap ) ( this . typesInWorkingCopies == null ? null : this . typesInWorkingCopies . get ( pkg ) ) ; if ( typeMap != null ) { Iterator iterator = typeMap . values ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { if ( requestor . isCanceled ( ) ) return false ; Object object = iterator . next ( ) ; if ( object instanceof IType ) { seekTypesInTopLevelType ( name , firstDot , ( IType ) object , requestor , acceptFlags ) ; } else if ( object instanceof IType [ ] ) { IType [ ] topLevelTypes = ( IType [ ] ) object ; for ( int i = <NUM_LIT:0> , length = topLevelTypes . length ; i < length ; i ++ ) seekTypesInTopLevelType ( name , firstDot , topLevelTypes [ i ] , requestor , acceptFlags ) ; } } } } return false ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . InputStream ; import java . util . ArrayList ; import java . util . HashMap ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . core . runtime . jobs . ISchedulingRule ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jface . text . BadLocationException ; import org . eclipse . jface . text . IDocument ; import org . eclipse . text . edits . TextEdit ; public abstract class JavaModelOperation implements IWorkspaceRunnable , IProgressMonitor { protected interface IPostAction { String getID ( ) ; void run ( ) throws JavaModelException ; } protected static final int APPEND = <NUM_LIT:1> ; protected static final int REMOVEALL_APPEND = <NUM_LIT:2> ; protected static final int KEEP_EXISTING = <NUM_LIT:3> ; protected static boolean POST_ACTION_VERBOSE ; protected IPostAction [ ] actions ; protected int actionsStart = <NUM_LIT:0> ; protected int actionsEnd = - <NUM_LIT:1> ; protected HashMap attributes ; public static final String HAS_MODIFIED_RESOURCE_ATTR = "<STR_LIT>" ; public static final String TRUE = JavaModelManager . TRUE ; protected IJavaElement [ ] elementsToProcess ; protected IJavaElement [ ] parentElements ; protected static final IJavaElement [ ] NO_ELEMENTS = new IJavaElement [ ] { } ; protected IJavaElement [ ] resultElements = NO_ELEMENTS ; public IProgressMonitor progressMonitor = null ; protected boolean isNested = false ; protected boolean force = false ; protected static final ThreadLocal OPERATION_STACKS = new ThreadLocal ( ) ; protected JavaModelOperation ( ) { } protected JavaModelOperation ( IJavaElement [ ] elements ) { this . elementsToProcess = elements ; } protected JavaModelOperation ( IJavaElement [ ] elementsToProcess , IJavaElement [ ] parentElements ) { this . elementsToProcess = elementsToProcess ; this . parentElements = parentElements ; } protected JavaModelOperation ( IJavaElement [ ] elementsToProcess , IJavaElement [ ] parentElements , boolean force ) { this . elementsToProcess = elementsToProcess ; this . parentElements = parentElements ; this . force = force ; } protected JavaModelOperation ( IJavaElement [ ] elements , boolean force ) { this . elementsToProcess = elements ; this . force = force ; } protected JavaModelOperation ( IJavaElement element ) { this . elementsToProcess = new IJavaElement [ ] { element } ; } protected void addAction ( IPostAction action ) { int length = this . actions . length ; if ( length == ++ this . actionsEnd ) { System . arraycopy ( this . actions , <NUM_LIT:0> , this . actions = new IPostAction [ length * <NUM_LIT:2> ] , <NUM_LIT:0> , length ) ; } this . actions [ this . actionsEnd ] = action ; } protected void addDelta ( IJavaElementDelta delta ) { JavaModelManager . getJavaModelManager ( ) . getDeltaProcessor ( ) . registerJavaModelDelta ( delta ) ; } protected void addReconcileDelta ( ICompilationUnit workingCopy , IJavaElementDelta delta ) { HashMap reconcileDeltas = JavaModelManager . getJavaModelManager ( ) . getDeltaProcessor ( ) . reconcileDeltas ; JavaElementDelta previousDelta = ( JavaElementDelta ) reconcileDeltas . get ( workingCopy ) ; if ( previousDelta != null ) { IJavaElementDelta [ ] children = delta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> , length = children . length ; i < length ; i ++ ) { JavaElementDelta child = ( JavaElementDelta ) children [ i ] ; previousDelta . insertDeltaTree ( child . getElement ( ) , child ) ; } if ( ( delta . getFlags ( ) & IJavaElementDelta . F_AST_AFFECTED ) != <NUM_LIT:0> ) { previousDelta . changedAST ( delta . getCompilationUnitAST ( ) ) ; } } else { reconcileDeltas . put ( workingCopy , delta ) ; } } protected void removeReconcileDelta ( ICompilationUnit workingCopy ) { JavaModelManager . getJavaModelManager ( ) . getDeltaProcessor ( ) . reconcileDeltas . remove ( workingCopy ) ; } protected void applyTextEdit ( ICompilationUnit cu , TextEdit edits ) throws JavaModelException { try { edits . apply ( getDocument ( cu ) ) ; } catch ( BadLocationException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . INVALID_CONTENTS ) ; } } public void beginTask ( String name , int totalWork ) { if ( this . progressMonitor != null ) { this . progressMonitor . beginTask ( name , totalWork ) ; } } protected boolean canModifyRoots ( ) { return false ; } protected void checkCanceled ( ) { if ( isCanceled ( ) ) { throw new OperationCanceledException ( Messages . operation_cancelled ) ; } } protected IJavaModelStatus commonVerify ( ) { if ( this . elementsToProcess == null || this . elementsToProcess . length == <NUM_LIT:0> ) { return new JavaModelStatus ( IJavaModelStatusConstants . NO_ELEMENTS_TO_PROCESS ) ; } for ( int i = <NUM_LIT:0> ; i < this . elementsToProcess . length ; i ++ ) { if ( this . elementsToProcess [ i ] == null ) { return new JavaModelStatus ( IJavaModelStatusConstants . NO_ELEMENTS_TO_PROCESS ) ; } } return JavaModelStatus . VERIFIED_OK ; } protected void copyResources ( IResource [ ] resources , IPath container ) throws JavaModelException { IProgressMonitor subProgressMonitor = getSubProgressMonitor ( resources . length ) ; IWorkspaceRoot root = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ; try { for ( int i = <NUM_LIT:0> , length = resources . length ; i < length ; i ++ ) { IResource resource = resources [ i ] ; IPath destination = container . append ( resource . getName ( ) ) ; if ( root . findMember ( destination ) == null ) { resource . copy ( destination , false , subProgressMonitor ) ; } } setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } protected void createFile ( IContainer folder , String name , InputStream contents , boolean forceFlag ) throws JavaModelException { IFile file = folder . getFile ( new Path ( name ) ) ; try { file . create ( contents , forceFlag ? IResource . FORCE | IResource . KEEP_HISTORY : IResource . KEEP_HISTORY , getSubProgressMonitor ( <NUM_LIT:1> ) ) ; setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } protected void createFolder ( IContainer parentFolder , String name , boolean forceFlag ) throws JavaModelException { IFolder folder = parentFolder . getFolder ( new Path ( name ) ) ; try { folder . create ( forceFlag ? IResource . FORCE | IResource . KEEP_HISTORY : IResource . KEEP_HISTORY , true , getSubProgressMonitor ( <NUM_LIT:1> ) ) ; setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } protected void deleteEmptyPackageFragment ( IPackageFragment fragment , boolean forceFlag , IResource rootResource ) throws JavaModelException { IContainer resource = ( IContainer ) ( ( JavaElement ) fragment ) . resource ( ) ; try { resource . delete ( forceFlag ? IResource . FORCE | IResource . KEEP_HISTORY : IResource . KEEP_HISTORY , getSubProgressMonitor ( <NUM_LIT:1> ) ) ; setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; while ( resource instanceof IFolder ) { resource = resource . getParent ( ) ; if ( ! resource . equals ( rootResource ) && resource . members ( ) . length == <NUM_LIT:0> ) { resource . delete ( forceFlag ? IResource . FORCE | IResource . KEEP_HISTORY : IResource . KEEP_HISTORY , getSubProgressMonitor ( <NUM_LIT:1> ) ) ; setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; } } } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } protected void deleteResource ( IResource resource , int flags ) throws JavaModelException { try { resource . delete ( flags , getSubProgressMonitor ( <NUM_LIT:1> ) ) ; setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } protected void deleteResources ( IResource [ ] resources , boolean forceFlag ) throws JavaModelException { if ( resources == null || resources . length == <NUM_LIT:0> ) return ; IProgressMonitor subProgressMonitor = getSubProgressMonitor ( resources . length ) ; IWorkspace workspace = resources [ <NUM_LIT:0> ] . getWorkspace ( ) ; try { workspace . delete ( resources , forceFlag ? IResource . FORCE | IResource . KEEP_HISTORY : IResource . KEEP_HISTORY , subProgressMonitor ) ; setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } public void done ( ) { if ( this . progressMonitor != null ) { this . progressMonitor . done ( ) ; } } protected boolean equalsOneOf ( IPath path , IPath [ ] otherPaths ) { for ( int i = <NUM_LIT:0> , length = otherPaths . length ; i < length ; i ++ ) { if ( path . equals ( otherPaths [ i ] ) ) { return true ; } } return false ; } public void executeNestedOperation ( JavaModelOperation operation , int subWorkAmount ) throws JavaModelException { IJavaModelStatus status = operation . verify ( ) ; if ( ! status . isOK ( ) ) { throw new JavaModelException ( status ) ; } IProgressMonitor subProgressMonitor = getSubProgressMonitor ( subWorkAmount ) ; try { operation . setNested ( true ) ; operation . run ( subProgressMonitor ) ; } catch ( CoreException ce ) { if ( ce instanceof JavaModelException ) { throw ( JavaModelException ) ce ; } else { if ( ce . getStatus ( ) . getCode ( ) == IResourceStatus . OPERATION_FAILED ) { Throwable e = ce . getStatus ( ) . getException ( ) ; if ( e instanceof JavaModelException ) { throw ( JavaModelException ) e ; } } throw new JavaModelException ( ce ) ; } } } protected abstract void executeOperation ( ) throws JavaModelException ; protected static Object getAttribute ( Object key ) { ArrayList stack = getCurrentOperationStack ( ) ; if ( stack . size ( ) == <NUM_LIT:0> ) return null ; JavaModelOperation topLevelOp = ( JavaModelOperation ) stack . get ( <NUM_LIT:0> ) ; if ( topLevelOp . attributes == null ) { return null ; } else { return topLevelOp . attributes . get ( key ) ; } } protected ICompilationUnit getCompilationUnitFor ( IJavaElement element ) { return ( ( JavaElement ) element ) . getCompilationUnit ( ) ; } protected static ArrayList getCurrentOperationStack ( ) { ArrayList stack = ( ArrayList ) OPERATION_STACKS . get ( ) ; if ( stack == null ) { stack = new ArrayList ( ) ; OPERATION_STACKS . set ( stack ) ; } return stack ; } protected IDocument getDocument ( ICompilationUnit cu ) throws JavaModelException { IBuffer buffer = cu . getBuffer ( ) ; if ( buffer instanceof IDocument ) return ( IDocument ) buffer ; return new DocumentAdapter ( buffer ) ; } protected IJavaElement getElementToProcess ( ) { if ( this . elementsToProcess == null || this . elementsToProcess . length == <NUM_LIT:0> ) { return null ; } return this . elementsToProcess [ <NUM_LIT:0> ] ; } public IJavaModel getJavaModel ( ) { return JavaModelManager . getJavaModelManager ( ) . getJavaModel ( ) ; } protected IPath [ ] getNestedFolders ( IPackageFragmentRoot root ) throws JavaModelException { IPath rootPath = root . getPath ( ) ; IClasspathEntry [ ] classpath = root . getJavaProject ( ) . getRawClasspath ( ) ; int length = classpath . length ; IPath [ ] result = new IPath [ length ] ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IPath path = classpath [ i ] . getPath ( ) ; if ( rootPath . isPrefixOf ( path ) && ! rootPath . equals ( path ) ) { result [ index ++ ] = path ; } } if ( index < length ) { System . arraycopy ( result , <NUM_LIT:0> , result = new IPath [ index ] , <NUM_LIT:0> , index ) ; } return result ; } protected IJavaElement getParentElement ( ) { if ( this . parentElements == null || this . parentElements . length == <NUM_LIT:0> ) { return null ; } return this . parentElements [ <NUM_LIT:0> ] ; } protected IJavaElement [ ] getParentElements ( ) { return this . parentElements ; } public IJavaElement [ ] getResultElements ( ) { return this . resultElements ; } protected ISchedulingRule getSchedulingRule ( ) { return ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ; } protected IProgressMonitor getSubProgressMonitor ( int workAmount ) { IProgressMonitor sub = null ; if ( this . progressMonitor != null ) { sub = new SubProgressMonitor ( this . progressMonitor , workAmount , SubProgressMonitor . PREPEND_MAIN_LABEL_TO_SUBTASK ) ; } return sub ; } public boolean hasModifiedResource ( ) { return ! isReadOnly ( ) && getAttribute ( HAS_MODIFIED_RESOURCE_ATTR ) == TRUE ; } public void internalWorked ( double work ) { if ( this . progressMonitor != null ) { this . progressMonitor . internalWorked ( work ) ; } } public boolean isCanceled ( ) { if ( this . progressMonitor != null ) { return this . progressMonitor . isCanceled ( ) ; } return false ; } public boolean isReadOnly ( ) { return false ; } protected boolean isTopLevelOperation ( ) { ArrayList stack ; return ( stack = getCurrentOperationStack ( ) ) . size ( ) > <NUM_LIT:0> && stack . get ( <NUM_LIT:0> ) == this ; } protected int firstActionWithID ( String id , int start ) { for ( int i = start ; i <= this . actionsEnd ; i ++ ) { if ( this . actions [ i ] . getID ( ) . equals ( id ) ) { return i ; } } return - <NUM_LIT:1> ; } protected void moveResources ( IResource [ ] resources , IPath container ) throws JavaModelException { IProgressMonitor subProgressMonitor = null ; if ( this . progressMonitor != null ) { subProgressMonitor = new SubProgressMonitor ( this . progressMonitor , resources . length , SubProgressMonitor . PREPEND_MAIN_LABEL_TO_SUBTASK ) ; } IWorkspaceRoot root = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ; try { for ( int i = <NUM_LIT:0> , length = resources . length ; i < length ; i ++ ) { IResource resource = resources [ i ] ; IPath destination = container . append ( resource . getName ( ) ) ; if ( root . findMember ( destination ) == null ) { resource . move ( destination , false , subProgressMonitor ) ; } } setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } public JavaElementDelta newJavaElementDelta ( ) { return new JavaElementDelta ( getJavaModel ( ) ) ; } protected JavaModelOperation popOperation ( ) { ArrayList stack = getCurrentOperationStack ( ) ; int size = stack . size ( ) ; if ( size > <NUM_LIT:0> ) { if ( size == <NUM_LIT:1> ) { OPERATION_STACKS . set ( null ) ; } return ( JavaModelOperation ) stack . remove ( size - <NUM_LIT:1> ) ; } else { return null ; } } protected void postAction ( IPostAction action , int insertionMode ) { if ( POST_ACTION_VERBOSE ) { System . out . print ( "<STR_LIT:(>" + Thread . currentThread ( ) + "<STR_LIT>" + action . getID ( ) ) ; switch ( insertionMode ) { case REMOVEALL_APPEND : System . out . println ( "<STR_LIT>" ) ; break ; case KEEP_EXISTING : System . out . println ( "<STR_LIT>" ) ; break ; case APPEND : System . out . println ( "<STR_LIT>" ) ; break ; } } JavaModelOperation topLevelOp = ( JavaModelOperation ) getCurrentOperationStack ( ) . get ( <NUM_LIT:0> ) ; IPostAction [ ] postActions = topLevelOp . actions ; if ( postActions == null ) { topLevelOp . actions = postActions = new IPostAction [ <NUM_LIT:1> ] ; postActions [ <NUM_LIT:0> ] = action ; topLevelOp . actionsEnd = <NUM_LIT:0> ; } else { String id = action . getID ( ) ; switch ( insertionMode ) { case REMOVEALL_APPEND : int index = this . actionsStart - <NUM_LIT:1> ; while ( ( index = topLevelOp . firstActionWithID ( id , index + <NUM_LIT:1> ) ) >= <NUM_LIT:0> ) { System . arraycopy ( postActions , index + <NUM_LIT:1> , postActions , index , topLevelOp . actionsEnd - index ) ; postActions [ topLevelOp . actionsEnd -- ] = null ; } topLevelOp . addAction ( action ) ; break ; case KEEP_EXISTING : if ( topLevelOp . firstActionWithID ( id , <NUM_LIT:0> ) < <NUM_LIT:0> ) { topLevelOp . addAction ( action ) ; } break ; case APPEND : topLevelOp . addAction ( action ) ; break ; } } } protected boolean prefixesOneOf ( IPath path , IPath [ ] otherPaths ) { for ( int i = <NUM_LIT:0> , length = otherPaths . length ; i < length ; i ++ ) { if ( path . isPrefixOf ( otherPaths [ i ] ) ) { return true ; } } return false ; } protected void pushOperation ( JavaModelOperation operation ) { getCurrentOperationStack ( ) . add ( operation ) ; } protected void removeAllPostAction ( String actionID ) { if ( POST_ACTION_VERBOSE ) { System . out . println ( "<STR_LIT:(>" + Thread . currentThread ( ) + "<STR_LIT>" + actionID ) ; } JavaModelOperation topLevelOp = ( JavaModelOperation ) getCurrentOperationStack ( ) . get ( <NUM_LIT:0> ) ; IPostAction [ ] postActions = topLevelOp . actions ; if ( postActions == null ) return ; int index = this . actionsStart - <NUM_LIT:1> ; while ( ( index = topLevelOp . firstActionWithID ( actionID , index + <NUM_LIT:1> ) ) >= <NUM_LIT:0> ) { System . arraycopy ( postActions , index + <NUM_LIT:1> , postActions , index , topLevelOp . actionsEnd - index ) ; postActions [ topLevelOp . actionsEnd -- ] = null ; } } public void run ( IProgressMonitor monitor ) throws CoreException { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; DeltaProcessor deltaProcessor = manager . getDeltaProcessor ( ) ; int previousDeltaCount = deltaProcessor . javaModelDeltas . size ( ) ; try { this . progressMonitor = monitor ; pushOperation ( this ) ; try { if ( canModifyRoots ( ) ) { JavaModelManager . getDeltaState ( ) . initializeRoots ( false ) ; } executeOperation ( ) ; } finally { if ( isTopLevelOperation ( ) ) { runPostActions ( ) ; } } } finally { try { deltaProcessor = manager . getDeltaProcessor ( ) ; for ( int i = previousDeltaCount , size = deltaProcessor . javaModelDeltas . size ( ) ; i < size ; i ++ ) { deltaProcessor . updateJavaModel ( ( IJavaElementDelta ) deltaProcessor . javaModelDeltas . get ( i ) ) ; } for ( int i = <NUM_LIT:0> , length = this . resultElements . length ; i < length ; i ++ ) { IJavaElement element = this . resultElements [ i ] ; Openable openable = ( Openable ) element . getOpenable ( ) ; if ( ! ( openable instanceof CompilationUnit ) || ! ( ( CompilationUnit ) openable ) . isWorkingCopy ( ) ) { ( ( JavaElement ) openable . getParent ( ) ) . close ( ) ; } switch ( element . getElementType ( ) ) { case IJavaElement . PACKAGE_FRAGMENT_ROOT : case IJavaElement . PACKAGE_FRAGMENT : deltaProcessor . projectCachesToReset . add ( element . getJavaProject ( ) ) ; break ; } } deltaProcessor . resetProjectCaches ( ) ; if ( isTopLevelOperation ( ) ) { if ( ( deltaProcessor . javaModelDeltas . size ( ) > previousDeltaCount || ! deltaProcessor . reconcileDeltas . isEmpty ( ) ) && ! hasModifiedResource ( ) ) { deltaProcessor . fire ( null , DeltaProcessor . DEFAULT_CHANGE_EVENT ) ; } } } finally { popOperation ( ) ; } } } public void runOperation ( IProgressMonitor monitor ) throws JavaModelException { IJavaModelStatus status = verify ( ) ; if ( ! status . isOK ( ) ) { throw new JavaModelException ( status ) ; } try { if ( isReadOnly ( ) ) { run ( monitor ) ; } else { ResourcesPlugin . getWorkspace ( ) . run ( this , getSchedulingRule ( ) , IWorkspace . AVOID_UPDATE , monitor ) ; } } catch ( CoreException ce ) { if ( ce instanceof JavaModelException ) { throw ( JavaModelException ) ce ; } else { if ( ce . getStatus ( ) . getCode ( ) == IResourceStatus . OPERATION_FAILED ) { Throwable e = ce . getStatus ( ) . getException ( ) ; if ( e instanceof JavaModelException ) { throw ( JavaModelException ) e ; } } throw new JavaModelException ( ce ) ; } } } protected void runPostActions ( ) throws JavaModelException { while ( this . actionsStart <= this . actionsEnd ) { IPostAction postAction = this . actions [ this . actionsStart ++ ] ; if ( POST_ACTION_VERBOSE ) { System . out . println ( "<STR_LIT:(>" + Thread . currentThread ( ) + "<STR_LIT>" + postAction . getID ( ) ) ; } postAction . run ( ) ; } } protected static void setAttribute ( Object key , Object attribute ) { ArrayList operationStack = getCurrentOperationStack ( ) ; if ( operationStack . size ( ) == <NUM_LIT:0> ) return ; JavaModelOperation topLevelOp = ( JavaModelOperation ) operationStack . get ( <NUM_LIT:0> ) ; if ( topLevelOp . attributes == null ) { topLevelOp . attributes = new HashMap ( ) ; } topLevelOp . attributes . put ( key , attribute ) ; } public void setCanceled ( boolean b ) { if ( this . progressMonitor != null ) { this . progressMonitor . setCanceled ( b ) ; } } protected void setNested ( boolean nested ) { this . isNested = nested ; } public void setTaskName ( String name ) { if ( this . progressMonitor != null ) { this . progressMonitor . setTaskName ( name ) ; } } public void subTask ( String name ) { if ( this . progressMonitor != null ) { this . progressMonitor . subTask ( name ) ; } } protected IJavaModelStatus verify ( ) { return commonVerify ( ) ; } public void worked ( int work ) { if ( this . progressMonitor != null ) { this . progressMonitor . worked ( work ) ; checkCanceled ( ) ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . Flags ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . IField ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . internal . compiler . env . IBinaryAnnotation ; import org . eclipse . jdt . internal . compiler . env . IBinaryField ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; class BinaryField extends BinaryMember implements IField { protected BinaryField ( JavaElement parent , String name ) { super ( parent , name ) ; } public boolean equals ( Object o ) { if ( ! ( o instanceof BinaryField ) ) return false ; return super . equals ( o ) ; } public IAnnotation [ ] getAnnotations ( ) throws JavaModelException { IBinaryField info = ( IBinaryField ) getElementInfo ( ) ; IBinaryAnnotation [ ] binaryAnnotations = info . getAnnotations ( ) ; return getAnnotations ( binaryAnnotations , info . getTagBits ( ) ) ; } public Object getConstant ( ) throws JavaModelException { IBinaryField info = ( IBinaryField ) getElementInfo ( ) ; return convertConstant ( info . getConstant ( ) ) ; } public int getFlags ( ) throws JavaModelException { IBinaryField info = ( IBinaryField ) getElementInfo ( ) ; return info . getModifiers ( ) ; } public int getElementType ( ) { return FIELD ; } protected char getHandleMementoDelimiter ( ) { return JavaElement . JEM_FIELD ; } public String getKey ( boolean forceOpen ) throws JavaModelException { return getKey ( this , forceOpen ) ; } public String getTypeSignature ( ) throws JavaModelException { IBinaryField info = ( IBinaryField ) getElementInfo ( ) ; char [ ] genericSignature = info . getGenericSignature ( ) ; if ( genericSignature != null ) { return new String ( ClassFile . translatedName ( genericSignature ) ) ; } return new String ( ClassFile . translatedName ( info . getTypeName ( ) ) ) ; } public boolean isEnumConstant ( ) throws JavaModelException { return Flags . isEnum ( getFlags ( ) ) ; } public boolean isResolved ( ) { return false ; } public JavaElement resolved ( Binding binding ) { SourceRefElement resolvedHandle = new ResolvedBinaryField ( this . parent , this . name , new String ( binding . computeUniqueKey ( ) ) ) ; resolvedHandle . occurrenceCount = this . occurrenceCount ; return resolvedHandle ; } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { buffer . append ( tabString ( tab ) ) ; if ( info == null ) { toStringName ( buffer ) ; buffer . append ( "<STR_LIT>" ) ; } else if ( info == NO_INFO ) { toStringName ( buffer ) ; } else { try { buffer . append ( Signature . toString ( getTypeSignature ( ) ) ) ; buffer . append ( "<STR_LIT:U+0020>" ) ; toStringName ( buffer ) ; } catch ( JavaModelException e ) { buffer . append ( "<STR_LIT>" + getElementName ( ) ) ; } } } public String getAttachedJavadoc ( IProgressMonitor monitor ) throws JavaModelException { JavadocContents javadocContents = ( ( BinaryType ) this . getDeclaringType ( ) ) . getJavadocContents ( monitor ) ; if ( javadocContents == null ) return null ; return javadocContents . getFieldDoc ( this ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . ArrayList ; import org . eclipse . core . resources . IResourceDelta ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaElementDelta ; import org . eclipse . jdt . core . dom . CompilationUnit ; public class JavaElementDelta extends SimpleDelta implements IJavaElementDelta { IJavaElementDelta [ ] affectedChildren = EMPTY_DELTA ; CompilationUnit ast = null ; IJavaElement changedElement ; IResourceDelta [ ] resourceDeltas = null ; int resourceDeltasCounter ; IJavaElement movedFromHandle = null ; IJavaElement movedToHandle = null ; IJavaElementDelta [ ] annotationDeltas = EMPTY_DELTA ; static IJavaElementDelta [ ] EMPTY_DELTA = new IJavaElementDelta [ ] { } ; public JavaElementDelta ( IJavaElement element ) { this . changedElement = element ; } protected void addAffectedChild ( JavaElementDelta child ) { switch ( this . kind ) { case ADDED : case REMOVED : return ; case CHANGED : this . changeFlags |= F_CHILDREN ; break ; default : this . kind = CHANGED ; this . changeFlags |= F_CHILDREN ; } if ( this . changedElement . getElementType ( ) >= IJavaElement . COMPILATION_UNIT ) { fineGrained ( ) ; } if ( this . affectedChildren == null || this . affectedChildren . length == <NUM_LIT:0> ) { this . affectedChildren = new IJavaElementDelta [ ] { child } ; return ; } JavaElementDelta existingChild = null ; int existingChildIndex = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < this . affectedChildren . length ; i ++ ) { if ( equalsAndSameParent ( this . affectedChildren [ i ] . getElement ( ) , child . getElement ( ) ) ) { existingChild = ( JavaElementDelta ) this . affectedChildren [ i ] ; existingChildIndex = i ; break ; } } if ( existingChild == null ) { this . affectedChildren = growAndAddToArray ( this . affectedChildren , child ) ; } else { switch ( existingChild . getKind ( ) ) { case ADDED : switch ( child . getKind ( ) ) { case ADDED : case CHANGED : return ; case REMOVED : this . affectedChildren = removeAndShrinkArray ( this . affectedChildren , existingChildIndex ) ; return ; } break ; case REMOVED : switch ( child . getKind ( ) ) { case ADDED : child . kind = CHANGED ; this . affectedChildren [ existingChildIndex ] = child ; return ; case CHANGED : case REMOVED : return ; } break ; case CHANGED : switch ( child . getKind ( ) ) { case ADDED : case REMOVED : this . affectedChildren [ existingChildIndex ] = child ; return ; case CHANGED : IJavaElementDelta [ ] children = child . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { JavaElementDelta childsChild = ( JavaElementDelta ) children [ i ] ; existingChild . addAffectedChild ( childsChild ) ; } boolean childHadContentFlag = ( child . changeFlags & F_CONTENT ) != <NUM_LIT:0> ; boolean existingChildHadChildrenFlag = ( existingChild . changeFlags & F_CHILDREN ) != <NUM_LIT:0> ; existingChild . changeFlags |= child . changeFlags ; if ( childHadContentFlag && existingChildHadChildrenFlag ) { existingChild . changeFlags &= ~ F_CONTENT ; } IResourceDelta [ ] resDeltas = child . getResourceDeltas ( ) ; if ( resDeltas != null ) { existingChild . resourceDeltas = resDeltas ; existingChild . resourceDeltasCounter = child . resourceDeltasCounter ; } return ; } break ; default : int flags = existingChild . getFlags ( ) ; this . affectedChildren [ existingChildIndex ] = child ; child . changeFlags |= flags ; } } } public void added ( IJavaElement element ) { added ( element , <NUM_LIT:0> ) ; } public void added ( IJavaElement element , int flags ) { JavaElementDelta addedDelta = new JavaElementDelta ( element ) ; addedDelta . added ( ) ; addedDelta . changeFlags |= flags ; insertDeltaTree ( element , addedDelta ) ; } protected void addResourceDelta ( IResourceDelta child ) { switch ( this . kind ) { case ADDED : case REMOVED : return ; case CHANGED : this . changeFlags |= F_CONTENT ; break ; default : this . kind = CHANGED ; this . changeFlags |= F_CONTENT ; } if ( this . resourceDeltas == null ) { this . resourceDeltas = new IResourceDelta [ <NUM_LIT:5> ] ; this . resourceDeltas [ this . resourceDeltasCounter ++ ] = child ; return ; } if ( this . resourceDeltas . length == this . resourceDeltasCounter ) { System . arraycopy ( this . resourceDeltas , <NUM_LIT:0> , ( this . resourceDeltas = new IResourceDelta [ this . resourceDeltasCounter * <NUM_LIT:2> ] ) , <NUM_LIT:0> , this . resourceDeltasCounter ) ; } this . resourceDeltas [ this . resourceDeltasCounter ++ ] = child ; } public JavaElementDelta changed ( IJavaElement element , int changeFlag ) { JavaElementDelta changedDelta = new JavaElementDelta ( element ) ; changedDelta . changed ( changeFlag ) ; insertDeltaTree ( element , changedDelta ) ; return changedDelta ; } public void changedAST ( CompilationUnit changedAST ) { this . ast = changedAST ; changed ( F_AST_AFFECTED ) ; } public void contentChanged ( ) { this . changeFlags |= F_CONTENT ; } public void closed ( IJavaElement element ) { JavaElementDelta delta = new JavaElementDelta ( element ) ; delta . changed ( F_CLOSED ) ; insertDeltaTree ( element , delta ) ; } protected JavaElementDelta createDeltaTree ( IJavaElement element , JavaElementDelta delta ) { JavaElementDelta childDelta = delta ; ArrayList ancestors = getAncestors ( element ) ; if ( ancestors == null ) { if ( equalsAndSameParent ( delta . getElement ( ) , getElement ( ) ) ) { this . kind = delta . kind ; this . changeFlags = delta . changeFlags ; this . movedToHandle = delta . movedToHandle ; this . movedFromHandle = delta . movedFromHandle ; } } else { for ( int i = <NUM_LIT:0> , size = ancestors . size ( ) ; i < size ; i ++ ) { IJavaElement ancestor = ( IJavaElement ) ancestors . get ( i ) ; JavaElementDelta ancestorDelta = new JavaElementDelta ( ancestor ) ; ancestorDelta . addAffectedChild ( childDelta ) ; childDelta = ancestorDelta ; } } return childDelta ; } protected boolean equalsAndSameParent ( IJavaElement e1 , IJavaElement e2 ) { IJavaElement parent1 ; return e1 . equals ( e2 ) && ( ( parent1 = e1 . getParent ( ) ) != null ) && parent1 . equals ( e2 . getParent ( ) ) ; } protected JavaElementDelta find ( IJavaElement e ) { if ( equalsAndSameParent ( this . changedElement , e ) ) { return this ; } else { for ( int i = <NUM_LIT:0> ; i < this . affectedChildren . length ; i ++ ) { JavaElementDelta delta = ( ( JavaElementDelta ) this . affectedChildren [ i ] ) . find ( e ) ; if ( delta != null ) { return delta ; } } } return null ; } public void fineGrained ( ) { changed ( F_FINE_GRAINED ) ; } public IJavaElementDelta [ ] getAddedChildren ( ) { return getChildrenOfType ( ADDED ) ; } public IJavaElementDelta [ ] getAffectedChildren ( ) { return this . affectedChildren ; } private ArrayList getAncestors ( IJavaElement element ) { IJavaElement parent = element . getParent ( ) ; if ( parent == null ) { return null ; } ArrayList parents = new ArrayList ( ) ; while ( ! parent . equals ( this . changedElement ) ) { parents . add ( parent ) ; parent = parent . getParent ( ) ; if ( parent == null ) { return null ; } } parents . trimToSize ( ) ; return parents ; } public CompilationUnit getCompilationUnitAST ( ) { return this . ast ; } public IJavaElementDelta [ ] getAnnotationDeltas ( ) { return this . annotationDeltas ; } public IJavaElementDelta [ ] getChangedChildren ( ) { return getChildrenOfType ( CHANGED ) ; } protected IJavaElementDelta [ ] getChildrenOfType ( int type ) { int length = this . affectedChildren . length ; if ( length == <NUM_LIT:0> ) { return new IJavaElementDelta [ ] { } ; } ArrayList children = new ArrayList ( length ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( this . affectedChildren [ i ] . getKind ( ) == type ) { children . add ( this . affectedChildren [ i ] ) ; } } IJavaElementDelta [ ] childrenOfType = new IJavaElementDelta [ children . size ( ) ] ; children . toArray ( childrenOfType ) ; return childrenOfType ; } protected JavaElementDelta getDeltaFor ( IJavaElement element ) { if ( equalsAndSameParent ( getElement ( ) , element ) ) return this ; if ( this . affectedChildren . length == <NUM_LIT:0> ) return null ; int childrenCount = this . affectedChildren . length ; for ( int i = <NUM_LIT:0> ; i < childrenCount ; i ++ ) { JavaElementDelta delta = ( JavaElementDelta ) this . affectedChildren [ i ] ; if ( equalsAndSameParent ( delta . getElement ( ) , element ) ) { return delta ; } else { delta = delta . getDeltaFor ( element ) ; if ( delta != null ) return delta ; } } return null ; } public IJavaElement getElement ( ) { return this . changedElement ; } public IJavaElement getMovedFromElement ( ) { return this . movedFromHandle ; } public IJavaElement getMovedToElement ( ) { return this . movedToHandle ; } public IJavaElementDelta [ ] getRemovedChildren ( ) { return getChildrenOfType ( REMOVED ) ; } public IResourceDelta [ ] getResourceDeltas ( ) { if ( this . resourceDeltas == null ) return null ; if ( this . resourceDeltas . length != this . resourceDeltasCounter ) { System . arraycopy ( this . resourceDeltas , <NUM_LIT:0> , this . resourceDeltas = new IResourceDelta [ this . resourceDeltasCounter ] , <NUM_LIT:0> , this . resourceDeltasCounter ) ; } return this . resourceDeltas ; } protected IJavaElementDelta [ ] growAndAddToArray ( IJavaElementDelta [ ] array , IJavaElementDelta addition ) { IJavaElementDelta [ ] old = array ; array = new IJavaElementDelta [ old . length + <NUM_LIT:1> ] ; System . arraycopy ( old , <NUM_LIT:0> , array , <NUM_LIT:0> , old . length ) ; array [ old . length ] = addition ; return array ; } protected void insertDeltaTree ( IJavaElement element , JavaElementDelta delta ) { JavaElementDelta childDelta = createDeltaTree ( element , delta ) ; if ( ! equalsAndSameParent ( element , getElement ( ) ) ) { addAffectedChild ( childDelta ) ; } } public void movedFrom ( IJavaElement movedFromElement , IJavaElement movedToElement ) { JavaElementDelta removedDelta = new JavaElementDelta ( movedFromElement ) ; removedDelta . kind = REMOVED ; removedDelta . changeFlags |= F_MOVED_TO ; removedDelta . movedToHandle = movedToElement ; insertDeltaTree ( movedFromElement , removedDelta ) ; } public void movedTo ( IJavaElement movedToElement , IJavaElement movedFromElement ) { JavaElementDelta addedDelta = new JavaElementDelta ( movedToElement ) ; addedDelta . kind = ADDED ; addedDelta . changeFlags |= F_MOVED_FROM ; addedDelta . movedFromHandle = movedFromElement ; insertDeltaTree ( movedToElement , addedDelta ) ; } public void opened ( IJavaElement element ) { JavaElementDelta delta = new JavaElementDelta ( element ) ; delta . changed ( F_OPENED ) ; insertDeltaTree ( element , delta ) ; } protected void removeAffectedChild ( JavaElementDelta child ) { int index = - <NUM_LIT:1> ; if ( this . affectedChildren != null ) { for ( int i = <NUM_LIT:0> ; i < this . affectedChildren . length ; i ++ ) { if ( equalsAndSameParent ( this . affectedChildren [ i ] . getElement ( ) , child . getElement ( ) ) ) { index = i ; break ; } } } if ( index >= <NUM_LIT:0> ) { this . affectedChildren = removeAndShrinkArray ( this . affectedChildren , index ) ; } } protected IJavaElementDelta [ ] removeAndShrinkArray ( IJavaElementDelta [ ] old , int index ) { IJavaElementDelta [ ] array = new IJavaElementDelta [ old . length - <NUM_LIT:1> ] ; if ( index > <NUM_LIT:0> ) System . arraycopy ( old , <NUM_LIT:0> , array , <NUM_LIT:0> , index ) ; int rest = old . length - index - <NUM_LIT:1> ; if ( rest > <NUM_LIT:0> ) System . arraycopy ( old , index + <NUM_LIT:1> , array , index , rest ) ; return array ; } public void removed ( IJavaElement element ) { removed ( element , <NUM_LIT:0> ) ; } public void removed ( IJavaElement element , int flags ) { JavaElementDelta removedDelta = new JavaElementDelta ( element ) ; insertDeltaTree ( element , removedDelta ) ; JavaElementDelta actualDelta = getDeltaFor ( element ) ; if ( actualDelta != null ) { actualDelta . removed ( ) ; actualDelta . changeFlags |= flags ; actualDelta . affectedChildren = EMPTY_DELTA ; } } public void sourceAttached ( IJavaElement element ) { JavaElementDelta attachedDelta = new JavaElementDelta ( element ) ; attachedDelta . changed ( F_SOURCEATTACHED ) ; insertDeltaTree ( element , attachedDelta ) ; } public void sourceDetached ( IJavaElement element ) { JavaElementDelta detachedDelta = new JavaElementDelta ( element ) ; detachedDelta . changed ( F_SOURCEDETACHED ) ; insertDeltaTree ( element , detachedDelta ) ; } public String toDebugString ( int depth ) { StringBuffer buffer = new StringBuffer ( ) ; for ( int i = <NUM_LIT:0> ; i < depth ; i ++ ) { buffer . append ( '<STR_LIT:\t>' ) ; } buffer . append ( ( ( JavaElement ) getElement ( ) ) . toDebugString ( ) ) ; toDebugString ( buffer ) ; IJavaElementDelta [ ] children = getAffectedChildren ( ) ; if ( children != null ) { for ( int i = <NUM_LIT:0> ; i < children . length ; ++ i ) { buffer . append ( "<STR_LIT:n>" ) ; buffer . append ( ( ( JavaElementDelta ) children [ i ] ) . toDebugString ( depth + <NUM_LIT:1> ) ) ; } } for ( int i = <NUM_LIT:0> ; i < this . resourceDeltasCounter ; i ++ ) { buffer . append ( "<STR_LIT:n>" ) ; for ( int j = <NUM_LIT:0> ; j < depth + <NUM_LIT:1> ; j ++ ) { buffer . append ( '<STR_LIT:\t>' ) ; } IResourceDelta resourceDelta = this . resourceDeltas [ i ] ; buffer . append ( resourceDelta . toString ( ) ) ; buffer . append ( "<STR_LIT:[>" ) ; switch ( resourceDelta . getKind ( ) ) { case IResourceDelta . ADDED : buffer . append ( '<CHAR_LIT>' ) ; break ; case IResourceDelta . REMOVED : buffer . append ( '<CHAR_LIT:->' ) ; break ; case IResourceDelta . CHANGED : buffer . append ( '<CHAR_LIT>' ) ; break ; default : buffer . append ( '<CHAR_LIT>' ) ; break ; } buffer . append ( "<STR_LIT:]>" ) ; } IJavaElementDelta [ ] annotations = getAnnotationDeltas ( ) ; if ( annotations != null ) { for ( int i = <NUM_LIT:0> ; i < annotations . length ; ++ i ) { buffer . append ( "<STR_LIT:n>" ) ; buffer . append ( ( ( JavaElementDelta ) annotations [ i ] ) . toDebugString ( depth + <NUM_LIT:1> ) ) ; } } return buffer . toString ( ) ; } protected boolean toDebugString ( StringBuffer buffer , int flags ) { boolean prev = super . toDebugString ( buffer , flags ) ; if ( ( flags & IJavaElementDelta . F_CHILDREN ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_CONTENT ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_MOVED_FROM ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" + ( ( JavaElement ) getMovedFromElement ( ) ) . toStringWithAncestors ( ) + "<STR_LIT:)>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_MOVED_TO ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" + ( ( JavaElement ) getMovedToElement ( ) ) . toStringWithAncestors ( ) + "<STR_LIT:)>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_ADDED_TO_CLASSPATH ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_REMOVED_FROM_CLASSPATH ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_REORDER ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_ARCHIVE_CONTENT_CHANGED ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_SOURCEATTACHED ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_SOURCEDETACHED ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_FINE_GRAINED ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_PRIMARY_WORKING_COPY ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_CLASSPATH_CHANGED ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_RESOLVED_CLASSPATH_CHANGED ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_PRIMARY_RESOURCE ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_OPENED ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_CLOSED ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_AST_AFFECTED ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_CATEGORIES ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } if ( ( flags & IJavaElementDelta . F_ANNOTATIONS ) != <NUM_LIT:0> ) { if ( prev ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; prev = true ; } return prev ; } public String toString ( ) { return toDebugString ( <NUM_LIT:0> ) ; } } </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 . IClasspathContainer ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . internal . core . util . Util ; public class UserLibraryClasspathContainer implements IClasspathContainer { private String name ; public UserLibraryClasspathContainer ( String name ) { this . name = name ; } public IClasspathEntry [ ] getClasspathEntries ( ) { UserLibrary library = getUserLibrary ( ) ; if ( library != null ) { return library . getEntries ( ) ; } return new IClasspathEntry [ <NUM_LIT:0> ] ; } public String getDescription ( ) { return this . name ; } public int getKind ( ) { UserLibrary library = getUserLibrary ( ) ; if ( library != null && library . isSystemLibrary ( ) ) { return K_SYSTEM ; } return K_APPLICATION ; } public IPath getPath ( ) { return new Path ( JavaCore . USER_LIBRARY_CONTAINER_ID ) . append ( this . name ) ; } private UserLibrary getUserLibrary ( ) { UserLibrary userLibrary = JavaModelManager . getUserLibraryManager ( ) . getUserLibrary ( this . name ) ; if ( userLibrary == null && ( JavaModelManager . CP_RESOLVE_VERBOSE || JavaModelManager . CP_RESOLVE_VERBOSE_FAILURE ) ) { verbose_no_user_library_found ( this . name ) ; } return userLibrary ; } private void verbose_no_user_library_found ( String userLibraryName ) { Util . verbose ( "<STR_LIT>" + "<STR_LIT>" + userLibraryName ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . HashMap ; import java . util . Map ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . util . CompilerUtils ; import org . eclipse . jdt . internal . compiler . * ; import org . eclipse . jdt . internal . compiler . Compiler ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . env . AccessRestriction ; import org . eclipse . jdt . internal . compiler . env . INameEnvironment ; import org . eclipse . jdt . internal . compiler . env . ISourceType ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . lookup . PackageBinding ; import org . eclipse . jdt . internal . compiler . parser . SourceTypeConverter ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . core . util . Util ; public class CompilationUnitProblemFinder extends Compiler { protected CompilationUnitProblemFinder ( INameEnvironment environment , IErrorHandlingPolicy policy , CompilerOptions compilerOptions , ICompilerRequestor requestor , IProblemFactory problemFactory ) { super ( environment , policy , compilerOptions , requestor , problemFactory ) ; } public void accept ( ISourceType [ ] sourceTypes , PackageBinding packageBinding , AccessRestriction accessRestriction ) { while ( sourceTypes [ <NUM_LIT:0> ] . getEnclosingType ( ) != null ) { sourceTypes [ <NUM_LIT:0> ] = sourceTypes [ <NUM_LIT:0> ] . getEnclosingType ( ) ; } CompilationResult result = new CompilationResult ( sourceTypes [ <NUM_LIT:0> ] . getFileName ( ) , <NUM_LIT:1> , <NUM_LIT:1> , this . options . maxProblemsPerUnit ) ; final long savedComplianceLevel = this . options . complianceLevel ; final long savedSourceLevel = this . options . sourceLevel ; try { IJavaProject project = ( ( SourceTypeElementInfo ) sourceTypes [ <NUM_LIT:0> ] ) . getHandle ( ) . getJavaProject ( ) ; this . options . complianceLevel = CompilerOptions . versionToJdkLevel ( project . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ) ; this . options . sourceLevel = CompilerOptions . versionToJdkLevel ( project . getOption ( JavaCore . COMPILER_SOURCE , true ) ) ; CompilationUnitDeclaration unit = SourceTypeConverter . buildCompilationUnit ( sourceTypes , SourceTypeConverter . FIELD_AND_METHOD | SourceTypeConverter . MEMBER_TYPE | SourceTypeConverter . FIELD_INITIALIZATION , this . lookupEnvironment . problemReporter , result ) ; if ( unit != null ) { this . lookupEnvironment . buildTypeBindings ( unit , accessRestriction ) ; this . lookupEnvironment . completeTypeBindings ( unit ) ; } } finally { this . options . complianceLevel = savedComplianceLevel ; this . options . sourceLevel = savedSourceLevel ; } } protected static CompilerOptions getCompilerOptions ( Map settings , boolean creatingAST , boolean statementsRecovery ) { CompilerOptions compilerOptions = new CompilerOptions ( settings ) ; compilerOptions . performMethodsFullRecovery = statementsRecovery ; compilerOptions . performStatementsRecovery = statementsRecovery ; compilerOptions . parseLiteralExpressionsAsConstants = ! creatingAST ; compilerOptions . storeAnnotations = creatingAST ; return compilerOptions ; } protected static IErrorHandlingPolicy getHandlingPolicy ( ) { return DefaultErrorHandlingPolicies . proceedWithAllProblems ( ) ; } protected static ICompilerRequestor getRequestor ( ) { return new ICompilerRequestor ( ) { public void acceptResult ( CompilationResult compilationResult ) { } } ; } public static CompilationUnitDeclaration process ( CompilationUnit unitElement , SourceElementParser parser , WorkingCopyOwner workingCopyOwner , HashMap problems , boolean creatingAST , int reconcileFlags , IProgressMonitor monitor ) throws JavaModelException { JavaProject project = ( JavaProject ) unitElement . getJavaProject ( ) ; CancelableNameEnvironment environment = null ; CancelableProblemFactory problemFactory = null ; CompilationUnitProblemFinder problemFinder = null ; CompilationUnitDeclaration unit = null ; try { environment = new CancelableNameEnvironment ( project , workingCopyOwner , monitor ) ; problemFactory = new CancelableProblemFactory ( monitor ) ; CompilerOptions compilerOptions = getCompilerOptions ( project . getOptions ( true ) , creatingAST , ( ( reconcileFlags & ICompilationUnit . ENABLE_STATEMENTS_RECOVERY ) != <NUM_LIT:0> ) ) ; boolean ignoreMethodBodies = ( reconcileFlags & ICompilationUnit . IGNORE_METHOD_BODIES ) != <NUM_LIT:0> ; compilerOptions . ignoreMethodBodies = ignoreMethodBodies ; CompilerUtils . configureOptionsBasedOnNature ( compilerOptions , project ) ; problemFinder = new CompilationUnitProblemFinder ( environment , getHandlingPolicy ( ) , compilerOptions , getRequestor ( ) , problemFactory ) ; boolean analyzeAndGenerateCode = true ; if ( ignoreMethodBodies ) { analyzeAndGenerateCode = false ; } try { if ( parser != null ) { problemFinder . parser = parser ; unit = parser . parseCompilationUnit ( unitElement , true , monitor ) ; problemFinder . resolve ( unit , unitElement , true , analyzeAndGenerateCode , analyzeAndGenerateCode ) ; } else { unit = problemFinder . resolve ( unitElement , true , analyzeAndGenerateCode , analyzeAndGenerateCode ) ; } } catch ( AbortCompilation e ) { problemFinder . handleInternalException ( e , unit ) ; } if ( unit != null ) { CompilationResult unitResult = unit . compilationResult ; CategorizedProblem [ ] unitProblems = unitResult . getCUProblems ( ) ; int length = unitProblems == null ? <NUM_LIT:0> : unitProblems . length ; if ( length > <NUM_LIT:0> ) { CategorizedProblem [ ] categorizedProblems = new CategorizedProblem [ length ] ; System . arraycopy ( unitProblems , <NUM_LIT:0> , categorizedProblems , <NUM_LIT:0> , length ) ; problems . put ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER , categorizedProblems ) ; } unitProblems = unitResult . getTasks ( ) ; length = unitProblems == null ? <NUM_LIT:0> : unitProblems . length ; if ( length > <NUM_LIT:0> ) { CategorizedProblem [ ] categorizedProblems = new CategorizedProblem [ length ] ; System . arraycopy ( unitProblems , <NUM_LIT:0> , categorizedProblems , <NUM_LIT:0> , length ) ; problems . put ( IJavaModelMarker . TASK_MARKER , categorizedProblems ) ; } if ( NameLookup . VERBOSE ) { System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInSourcePackage + "<STR_LIT>" ) ; System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInBinaryPackage + "<STR_LIT>" ) ; } } } catch ( OperationCanceledException e ) { throw e ; } catch ( RuntimeException e ) { String lineDelimiter = unitElement . findRecommendedLineSeparator ( ) ; StringBuffer message = new StringBuffer ( "<STR_LIT>" ) ; message . append ( lineDelimiter ) ; message . append ( "<STR_LIT>" ) ; message . append ( lineDelimiter ) ; message . append ( unitElement . getSource ( ) ) ; message . append ( lineDelimiter ) ; message . append ( "<STR_LIT>" ) ; Util . log ( e , message . toString ( ) ) ; throw new JavaModelException ( e , IJavaModelStatusConstants . COMPILER_FAILURE ) ; } finally { if ( environment != null ) environment . setMonitor ( null ) ; if ( problemFactory != null ) problemFactory . monitor = null ; if ( problemFinder != null && ! creatingAST ) problemFinder . lookupEnvironment . reset ( ) ; } return unit ; } public static CompilationUnitDeclaration process ( CompilationUnit unitElement , WorkingCopyOwner workingCopyOwner , HashMap problems , boolean creatingAST , int reconcileFlags , IProgressMonitor monitor ) throws JavaModelException { return process ( unitElement , null , workingCopyOwner , problems , creatingAST , reconcileFlags , monitor ) ; } public void initializeParser ( ) { this . parser = LanguageSupportFactory . getParser ( this , this . lookupEnvironment == null ? null : this . lookupEnvironment . globalOptions , this . problemReporter , this . options . parseLiteralExpressionsAsConstants , <NUM_LIT:3> ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . Enumeration ; public class LRUCacheEnumerator implements Enumeration { protected LRUEnumeratorElement elementQueue ; public static class LRUEnumeratorElement { public Object value ; public LRUEnumeratorElement next ; public LRUEnumeratorElement ( Object value ) { this . value = value ; } } public LRUCacheEnumerator ( LRUEnumeratorElement firstElement ) { this . elementQueue = firstElement ; } public boolean hasMoreElements ( ) { return this . elementQueue != null ; } public Object nextElement ( ) { Object temp = this . elementQueue . value ; this . elementQueue = this . elementQueue . next ; return temp ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . internal . core . util . HashtableOfArrayToObject ; class JarPackageFragmentRootInfo extends PackageFragmentRootInfo { HashtableOfArrayToObject rawPackageInfo ; } </s>
|
<s> package org . eclipse . jdt . internal . core ; 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 . Messages ; public class RenameResourceElementsOperation extends MoveResourceElementsOperation { public RenameResourceElementsOperation ( IJavaElement [ ] elements , IJavaElement [ ] destinations , String [ ] newNames , boolean force ) { super ( elements , destinations , force ) ; setRenamings ( newNames ) ; } protected String getMainTaskName ( ) { return Messages . operation_renameResourceProgress ; } protected boolean isRename ( ) { return true ; } protected void verify ( IJavaElement element ) throws JavaModelException { super . verify ( element ) ; int elementType = element . getElementType ( ) ; if ( ! ( elementType == IJavaElement . COMPILATION_UNIT || elementType == IJavaElement . PACKAGE_FRAGMENT ) ) { error ( IJavaModelStatusConstants . INVALID_ELEMENT_TYPES , element ) ; } if ( elementType == IJavaElement . COMPILATION_UNIT ) { CompilationUnit cu = ( CompilationUnit ) element ; if ( cu . isWorkingCopy ( ) && ! cu . isPrimary ( ) ) { error ( IJavaModelStatusConstants . INVALID_ELEMENT_TYPES , element ) ; } } verifyRenaming ( element ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . internal . core . util . MementoTokenizer ; public class ImportContainer extends SourceRefElement implements IImportContainer { protected ImportContainer ( CompilationUnit parent ) { super ( parent ) ; } public boolean equals ( Object o ) { if ( ! ( o instanceof ImportContainer ) ) return false ; return super . equals ( o ) ; } public int getElementType ( ) { return IMPORT_CONTAINER ; } public IJavaElement getHandleFromMemento ( String token , MementoTokenizer memento , WorkingCopyOwner workingCopyOwner ) { switch ( token . charAt ( <NUM_LIT:0> ) ) { case JEM_COUNT : return getHandleUpdatingCountFromMemento ( memento , workingCopyOwner ) ; case JEM_IMPORTDECLARATION : if ( memento . hasMoreTokens ( ) ) { String importName = memento . nextToken ( ) ; JavaElement importDecl = ( JavaElement ) getImport ( importName ) ; return importDecl . getHandleFromMemento ( memento , workingCopyOwner ) ; } else { return this ; } } return null ; } protected char getHandleMementoDelimiter ( ) { return JavaElement . JEM_IMPORTDECLARATION ; } public IImportDeclaration getImport ( String importName ) { int index = importName . indexOf ( "<STR_LIT>" ) ; boolean isOnDemand = index != - <NUM_LIT:1> ; if ( isOnDemand ) importName = new String ( importName . substring ( <NUM_LIT:0> , index ) ) ; return getImport ( importName , isOnDemand ) ; } protected IImportDeclaration getImport ( String importName , boolean isOnDemand ) { return new ImportDeclaration ( this , importName , isOnDemand ) ; } public IJavaElement getPrimaryElement ( boolean checkOwner ) { CompilationUnit cu = ( CompilationUnit ) this . parent ; if ( checkOwner && cu . isPrimary ( ) ) return this ; return cu . getImportContainer ( ) ; } public ISourceRange getSourceRange ( ) throws JavaModelException { IJavaElement [ ] imports = getChildren ( ) ; ISourceRange firstRange = ( ( ISourceReference ) imports [ <NUM_LIT:0> ] ) . getSourceRange ( ) ; ISourceRange lastRange = ( ( ISourceReference ) imports [ imports . length - <NUM_LIT:1> ] ) . getSourceRange ( ) ; SourceRange range = new SourceRange ( firstRange . getOffset ( ) , lastRange . getOffset ( ) + lastRange . getLength ( ) - firstRange . getOffset ( ) ) ; return range ; } public String readableName ( ) { return null ; } protected void toString ( int tab , StringBuffer buffer ) { Object info = JavaModelManager . getJavaModelManager ( ) . peekAtInfo ( this ) ; if ( info == null || ! ( info instanceof JavaElementInfo ) ) return ; IJavaElement [ ] children = ( ( JavaElementInfo ) info ) . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { if ( i > <NUM_LIT:0> ) buffer . append ( "<STR_LIT:n>" ) ; ( ( JavaElement ) children [ i ] ) . toString ( tab , buffer ) ; } } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { buffer . append ( tabString ( tab ) ) ; buffer . append ( "<STR_LIT>" ) ; if ( info == null ) { buffer . append ( "<STR_LIT>" ) ; } } public ISourceRange getNameRange ( ) { return null ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . jdt . internal . compiler . problem . DefaultProblemFactory ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import java . util . * ; public class ProblemFactory extends DefaultProblemFactory { static SimpleLookupTable factories = new SimpleLookupTable ( <NUM_LIT:5> ) ; private ProblemFactory ( Locale locale ) { super ( locale ) ; } public static ProblemFactory getProblemFactory ( Locale locale ) { ProblemFactory factory = ( ProblemFactory ) factories . get ( locale ) ; if ( factory == null ) factories . put ( locale , factory = new ProblemFactory ( locale ) ) ; return factory ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . core . * ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; import java . io . * ; import java . util . * ; public class JavaBuilder extends IncrementalProjectBuilder { IProject currentProject ; JavaProject javaProject ; IWorkspaceRoot workspaceRoot ; CompilationParticipant [ ] participants ; NameEnvironment nameEnvironment ; SimpleLookupTable binaryLocationsPerProject ; public State lastState ; BuildNotifier notifier ; char [ ] [ ] extraResourceFileFilters ; String [ ] extraResourceFolderFilters ; public static final String SOURCE_ID = "<STR_LIT>" ; public static boolean DEBUG = false ; public static boolean SHOW_STATS = false ; static ArrayList builtProjects = null ; public static IMarker [ ] getProblemsFor ( IResource resource ) { try { if ( resource != null && resource . exists ( ) ) { IMarker [ ] markers = resource . findMarkers ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER , false , IResource . DEPTH_INFINITE ) ; Set markerTypes = JavaModelManager . getJavaModelManager ( ) . compilationParticipants . managedMarkerTypes ( ) ; if ( markerTypes . isEmpty ( ) ) return markers ; ArrayList markerList = new ArrayList ( <NUM_LIT:5> ) ; for ( int i = <NUM_LIT:0> , length = markers . length ; i < length ; i ++ ) { markerList . add ( markers [ i ] ) ; } Iterator iterator = markerTypes . iterator ( ) ; while ( iterator . hasNext ( ) ) { markers = resource . findMarkers ( ( String ) iterator . next ( ) , false , IResource . DEPTH_INFINITE ) ; for ( int i = <NUM_LIT:0> , length = markers . length ; i < length ; i ++ ) { markerList . add ( markers [ i ] ) ; } } IMarker [ ] result ; markerList . toArray ( result = new IMarker [ markerList . size ( ) ] ) ; return result ; } } catch ( CoreException e ) { } return new IMarker [ <NUM_LIT:0> ] ; } public static IMarker [ ] getTasksFor ( IResource resource ) { try { if ( resource != null && resource . exists ( ) ) return resource . findMarkers ( IJavaModelMarker . TASK_MARKER , false , IResource . DEPTH_INFINITE ) ; } catch ( CoreException e ) { } return new IMarker [ <NUM_LIT:0> ] ; } public static void buildStarting ( ) { } public static void buildFinished ( ) { BuildNotifier . resetProblemCounters ( ) ; } public static void removeProblemsFor ( IResource resource ) { try { if ( resource != null && resource . exists ( ) ) { resource . deleteMarkers ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER , false , IResource . DEPTH_INFINITE ) ; Set markerTypes = JavaModelManager . getJavaModelManager ( ) . compilationParticipants . managedMarkerTypes ( ) ; if ( markerTypes . size ( ) == <NUM_LIT:0> ) return ; Iterator iterator = markerTypes . iterator ( ) ; while ( iterator . hasNext ( ) ) resource . deleteMarkers ( ( String ) iterator . next ( ) , false , IResource . DEPTH_INFINITE ) ; } } catch ( CoreException e ) { } } public static void removeTasksFor ( IResource resource ) { try { if ( resource != null && resource . exists ( ) ) resource . deleteMarkers ( IJavaModelMarker . TASK_MARKER , false , IResource . DEPTH_INFINITE ) ; } catch ( CoreException e ) { } } public static void removeProblemsAndTasksFor ( IResource resource ) { try { if ( resource != null && resource . exists ( ) ) { resource . deleteMarkers ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER , false , IResource . DEPTH_INFINITE ) ; resource . deleteMarkers ( IJavaModelMarker . TASK_MARKER , false , IResource . DEPTH_INFINITE ) ; Set markerTypes = JavaModelManager . getJavaModelManager ( ) . compilationParticipants . managedMarkerTypes ( ) ; if ( markerTypes . size ( ) == <NUM_LIT:0> ) return ; Iterator iterator = markerTypes . iterator ( ) ; while ( iterator . hasNext ( ) ) resource . deleteMarkers ( ( String ) iterator . next ( ) , false , IResource . DEPTH_INFINITE ) ; } } catch ( CoreException e ) { } } public static State readState ( IProject project , DataInputStream in ) throws IOException { return State . read ( project , in ) ; } public static void writeState ( Object state , DataOutputStream out ) throws IOException { ( ( State ) state ) . write ( out ) ; } protected IProject [ ] build ( int kind , Map ignored , IProgressMonitor monitor ) throws CoreException { this . currentProject = getProject ( ) ; if ( this . currentProject == null || ! this . currentProject . isAccessible ( ) ) return new IProject [ <NUM_LIT:0> ] ; if ( DEBUG ) System . out . println ( "<STR_LIT>" + this . currentProject . getName ( ) + "<STR_LIT>" + new Date ( System . currentTimeMillis ( ) ) ) ; this . notifier = new BuildNotifier ( monitor , this . currentProject ) ; this . notifier . begin ( ) ; boolean ok = false ; try { this . notifier . checkCancel ( ) ; kind = initializeBuilder ( kind , true ) ; if ( isWorthBuilding ( ) ) { if ( kind == FULL_BUILD ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" ) ; buildAll ( ) ; } else { if ( ( this . lastState = getLastState ( this . currentProject ) ) == null ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" ) ; buildAll ( ) ; } else if ( hasClasspathChanged ( ) ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" ) ; buildAll ( ) ; } else if ( this . nameEnvironment . sourceLocations . length > <NUM_LIT:0> ) { SimpleLookupTable deltas = findDeltas ( ) ; if ( deltas == null ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" ) ; buildAll ( ) ; } else if ( deltas . elementSize > <NUM_LIT:0> ) { buildDeltas ( deltas ) ; } else if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; } } else { if ( hasStructuralDelta ( ) ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" ) ; buildAll ( ) ; } else { if ( DEBUG ) System . out . println ( "<STR_LIT>" ) ; this . lastState . tagAsNoopBuild ( ) ; } } } ok = true ; } } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" + this . currentProject . getName ( ) ) ; createInconsistentBuildMarker ( e ) ; } catch ( ImageBuilderInternalException e ) { Util . log ( e . getThrowable ( ) , "<STR_LIT>" + this . currentProject . getName ( ) ) ; createInconsistentBuildMarker ( e . coreException ) ; } catch ( MissingSourceFileException e ) { if ( DEBUG ) System . out . println ( Messages . bind ( Messages . build_missingSourceFile , e . missingSourceFile ) ) ; removeProblemsAndTasksFor ( this . currentProject ) ; IMarker marker = this . currentProject . createMarker ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER ) ; marker . setAttributes ( new String [ ] { IMarker . MESSAGE , IMarker . SEVERITY , IMarker . SOURCE_ID } , new Object [ ] { Messages . bind ( Messages . build_missingSourceFile , e . missingSourceFile ) , new Integer ( IMarker . SEVERITY_ERROR ) , JavaBuilder . SOURCE_ID } ) ; } finally { for ( int i = <NUM_LIT:0> , l = this . participants == null ? <NUM_LIT:0> : this . participants . length ; i < l ; i ++ ) this . participants [ i ] . buildFinished ( this . javaProject ) ; if ( ! ok ) clearLastState ( ) ; this . notifier . done ( ) ; cleanup ( ) ; } IProject [ ] requiredProjects = getRequiredProjects ( true ) ; if ( DEBUG ) System . out . println ( "<STR_LIT>" + this . currentProject . getName ( ) + "<STR_LIT>" + new Date ( System . currentTimeMillis ( ) ) ) ; return requiredProjects ; } private void buildAll ( ) { this . notifier . checkCancel ( ) ; this . notifier . subTask ( Messages . bind ( Messages . build_preparingBuild , this . currentProject . getName ( ) ) ) ; if ( DEBUG && this . lastState != null ) System . out . println ( "<STR_LIT>" + this . lastState ) ; clearLastState ( ) ; BatchImageBuilder imageBuilder = new BatchImageBuilder ( this , true ) ; imageBuilder . build ( ) ; recordNewState ( imageBuilder . newState ) ; } private void buildDeltas ( SimpleLookupTable deltas ) { this . notifier . checkCancel ( ) ; this . notifier . subTask ( Messages . bind ( Messages . build_preparingBuild , this . currentProject . getName ( ) ) ) ; if ( DEBUG && this . lastState != null ) System . out . println ( "<STR_LIT>" + this . lastState ) ; clearLastState ( ) ; IncrementalImageBuilder imageBuilder = new IncrementalImageBuilder ( this ) ; if ( imageBuilder . build ( deltas ) ) { recordNewState ( imageBuilder . newState ) ; } else { if ( DEBUG ) System . out . println ( "<STR_LIT>" ) ; buildAll ( ) ; } } protected void clean ( IProgressMonitor monitor ) throws CoreException { this . currentProject = getProject ( ) ; if ( this . currentProject == null || ! this . currentProject . isAccessible ( ) ) return ; if ( DEBUG ) System . out . println ( "<STR_LIT>" + this . currentProject . getName ( ) + "<STR_LIT>" + new Date ( System . currentTimeMillis ( ) ) ) ; this . notifier = new BuildNotifier ( monitor , this . currentProject ) ; this . notifier . begin ( ) ; try { this . notifier . checkCancel ( ) ; initializeBuilder ( CLEAN_BUILD , true ) ; if ( DEBUG ) System . out . println ( "<STR_LIT>" + this . lastState ) ; clearLastState ( ) ; removeProblemsAndTasksFor ( this . currentProject ) ; new BatchImageBuilder ( this , false ) . cleanOutputFolders ( false ) ; } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" + this . currentProject . getName ( ) ) ; createInconsistentBuildMarker ( e ) ; } finally { this . notifier . done ( ) ; cleanup ( ) ; } if ( DEBUG ) System . out . println ( "<STR_LIT>" + this . currentProject . getName ( ) + "<STR_LIT>" + new Date ( System . currentTimeMillis ( ) ) ) ; } private void createInconsistentBuildMarker ( CoreException coreException ) throws CoreException { String message = null ; IStatus status = coreException . getStatus ( ) ; if ( status . isMultiStatus ( ) ) { IStatus [ ] children = status . getChildren ( ) ; if ( children != null && children . length > <NUM_LIT:0> ) message = children [ <NUM_LIT:0> ] . getMessage ( ) ; } if ( message == null ) message = coreException . getMessage ( ) ; IMarker marker = this . currentProject . createMarker ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER ) ; marker . setAttributes ( new String [ ] { IMarker . MESSAGE , IMarker . SEVERITY , IJavaModelMarker . CATEGORY_ID , IMarker . SOURCE_ID } , new Object [ ] { Messages . bind ( Messages . build_inconsistentProject , message ) , new Integer ( IMarker . SEVERITY_ERROR ) , new Integer ( CategorizedProblem . CAT_BUILDPATH ) , JavaBuilder . SOURCE_ID } ) ; } private void cleanup ( ) { this . participants = null ; this . nameEnvironment = null ; this . binaryLocationsPerProject = null ; this . lastState = null ; this . notifier = null ; this . extraResourceFileFilters = null ; this . extraResourceFolderFilters = null ; } private void clearLastState ( ) { JavaModelManager . getJavaModelManager ( ) . setLastBuiltState ( this . currentProject , null ) ; } boolean filterExtraResource ( IResource resource ) { if ( this . extraResourceFileFilters != null ) { char [ ] name = resource . getName ( ) . toCharArray ( ) ; for ( int i = <NUM_LIT:0> , l = this . extraResourceFileFilters . length ; i < l ; i ++ ) if ( CharOperation . match ( this . extraResourceFileFilters [ i ] , name , true ) ) return true ; } if ( this . extraResourceFolderFilters != null ) { IPath path = resource . getProjectRelativePath ( ) ; String pathName = path . toString ( ) ; int count = path . segmentCount ( ) ; if ( resource . getType ( ) == IResource . FILE ) count -- ; for ( int i = <NUM_LIT:0> , l = this . extraResourceFolderFilters . length ; i < l ; i ++ ) if ( pathName . indexOf ( this . extraResourceFolderFilters [ i ] ) != - <NUM_LIT:1> ) for ( int j = <NUM_LIT:0> ; j < count ; j ++ ) if ( this . extraResourceFolderFilters [ i ] . equals ( path . segment ( j ) ) ) return true ; } return false ; } private SimpleLookupTable findDeltas ( ) { this . notifier . subTask ( Messages . bind ( Messages . build_readingDelta , this . currentProject . getName ( ) ) ) ; IResourceDelta delta = getDelta ( this . currentProject ) ; SimpleLookupTable deltas = new SimpleLookupTable ( <NUM_LIT:3> ) ; if ( delta != null ) { if ( delta . getKind ( ) != IResourceDelta . NO_CHANGE ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" + this . currentProject . getName ( ) ) ; deltas . put ( this . currentProject , delta ) ; } } else { if ( DEBUG ) System . out . println ( "<STR_LIT>" + this . currentProject . getName ( ) ) ; this . notifier . subTask ( "<STR_LIT>" ) ; return null ; } Object [ ] keyTable = this . binaryLocationsPerProject . keyTable ; Object [ ] valueTable = this . binaryLocationsPerProject . valueTable ; nextProject : for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { IProject p = ( IProject ) keyTable [ i ] ; if ( p != null && p != this . currentProject ) { State s = getLastState ( p ) ; if ( ! this . lastState . wasStructurallyChanged ( p , s ) ) { if ( s . wasNoopBuild ( ) ) continue nextProject ; ClasspathLocation [ ] classFoldersAndJars = ( ClasspathLocation [ ] ) valueTable [ i ] ; boolean canSkip = true ; for ( int j = <NUM_LIT:0> , m = classFoldersAndJars . length ; j < m ; j ++ ) { if ( classFoldersAndJars [ j ] . isOutputFolder ( ) ) classFoldersAndJars [ j ] = null ; else canSkip = false ; } if ( canSkip ) continue nextProject ; } this . notifier . subTask ( Messages . bind ( Messages . build_readingDelta , p . getName ( ) ) ) ; delta = getDelta ( p ) ; if ( delta != null ) { if ( delta . getKind ( ) != IResourceDelta . NO_CHANGE ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" + p . getName ( ) ) ; deltas . put ( p , delta ) ; } } else { if ( DEBUG ) System . out . println ( "<STR_LIT>" + p . getName ( ) ) ; this . notifier . subTask ( "<STR_LIT>" ) ; return null ; } } } this . notifier . subTask ( "<STR_LIT>" ) ; return deltas ; } public State getLastState ( IProject project ) { return ( State ) JavaModelManager . getJavaModelManager ( ) . getLastBuiltState ( project , this . notifier . monitor ) ; } private IProject [ ] getRequiredProjects ( boolean includeBinaryPrerequisites ) { if ( this . javaProject == null || this . workspaceRoot == null ) return new IProject [ <NUM_LIT:0> ] ; ArrayList projects = new ArrayList ( ) ; ExternalFoldersManager externalFoldersManager = JavaModelManager . getExternalManager ( ) ; try { IClasspathEntry [ ] entries = this . javaProject . getExpandedClasspath ( ) ; for ( int i = <NUM_LIT:0> , l = entries . length ; i < l ; i ++ ) { IClasspathEntry entry = entries [ i ] ; IPath path = entry . getPath ( ) ; IProject p = null ; switch ( entry . getEntryKind ( ) ) { case IClasspathEntry . CPE_PROJECT : p = this . workspaceRoot . getProject ( path . lastSegment ( ) ) ; if ( ( ( ClasspathEntry ) entry ) . isOptional ( ) && ! JavaProject . hasJavaNature ( p ) ) p = null ; break ; case IClasspathEntry . CPE_LIBRARY : if ( includeBinaryPrerequisites && path . segmentCount ( ) > <NUM_LIT:0> ) { IResource resource = this . workspaceRoot . findMember ( path . segment ( <NUM_LIT:0> ) ) ; if ( resource instanceof IProject ) { p = ( IProject ) resource ; } else { resource = externalFoldersManager . getFolder ( path ) ; if ( resource != null ) p = resource . getProject ( ) ; } } } if ( p != null && ! projects . contains ( p ) ) projects . add ( p ) ; } } catch ( JavaModelException e ) { return new IProject [ <NUM_LIT:0> ] ; } IProject [ ] result = new IProject [ projects . size ( ) ] ; projects . toArray ( result ) ; return result ; } boolean hasBuildpathErrors ( ) throws CoreException { IMarker [ ] markers = this . currentProject . findMarkers ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER , false , IResource . DEPTH_ZERO ) ; for ( int i = <NUM_LIT:0> , l = markers . length ; i < l ; i ++ ) if ( markers [ i ] . getAttribute ( IJavaModelMarker . CATEGORY_ID , - <NUM_LIT:1> ) == CategorizedProblem . CAT_BUILDPATH ) return true ; return false ; } private boolean hasClasspathChanged ( ) { ClasspathMultiDirectory [ ] newSourceLocations = this . nameEnvironment . sourceLocations ; ClasspathMultiDirectory [ ] oldSourceLocations = this . lastState . sourceLocations ; int newLength = newSourceLocations . length ; int oldLength = oldSourceLocations . length ; int n , o ; for ( n = o = <NUM_LIT:0> ; n < newLength && o < oldLength ; n ++ , o ++ ) { if ( newSourceLocations [ n ] . equals ( oldSourceLocations [ o ] ) ) continue ; try { if ( newSourceLocations [ n ] . sourceFolder . members ( ) . length == <NUM_LIT:0> ) { o -- ; continue ; } else if ( this . lastState . isSourceFolderEmpty ( oldSourceLocations [ o ] . sourceFolder ) ) { n -- ; continue ; } } catch ( CoreException ignore ) { } if ( DEBUG ) { System . out . println ( "<STR_LIT>" + newSourceLocations [ n ] + "<STR_LIT>" + oldSourceLocations [ o ] ) ; printLocations ( newSourceLocations , oldSourceLocations ) ; } return true ; } while ( n < newLength ) { try { if ( newSourceLocations [ n ] . sourceFolder . members ( ) . length == <NUM_LIT:0> ) { n ++ ; continue ; } } catch ( CoreException ignore ) { } if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; printLocations ( newSourceLocations , oldSourceLocations ) ; } return true ; } while ( o < oldLength ) { if ( this . lastState . isSourceFolderEmpty ( oldSourceLocations [ o ] . sourceFolder ) ) { o ++ ; continue ; } if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; printLocations ( newSourceLocations , oldSourceLocations ) ; } return true ; } ClasspathLocation [ ] newBinaryLocations = this . nameEnvironment . binaryLocations ; ClasspathLocation [ ] oldBinaryLocations = this . lastState . binaryLocations ; newLength = newBinaryLocations . length ; oldLength = oldBinaryLocations . length ; for ( n = o = <NUM_LIT:0> ; n < newLength && o < oldLength ; n ++ , o ++ ) { if ( newBinaryLocations [ n ] . equals ( oldBinaryLocations [ o ] ) ) continue ; if ( DEBUG ) { System . out . println ( "<STR_LIT>" + newBinaryLocations [ n ] + "<STR_LIT>" + oldBinaryLocations [ o ] ) ; printLocations ( newBinaryLocations , oldBinaryLocations ) ; } return true ; } if ( n < newLength || o < oldLength ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; printLocations ( newBinaryLocations , oldBinaryLocations ) ; } return true ; } return false ; } private boolean hasJavaBuilder ( IProject project ) throws CoreException { ICommand [ ] buildCommands = project . getDescription ( ) . getBuildSpec ( ) ; for ( int i = <NUM_LIT:0> , l = buildCommands . length ; i < l ; i ++ ) if ( buildCommands [ i ] . getBuilderName ( ) . equals ( JavaCore . BUILDER_ID ) ) return true ; return false ; } private boolean hasStructuralDelta ( ) { IResourceDelta delta = getDelta ( this . currentProject ) ; if ( delta != null && delta . getKind ( ) != IResourceDelta . NO_CHANGE ) { ClasspathLocation [ ] classFoldersAndJars = ( ClasspathLocation [ ] ) this . binaryLocationsPerProject . get ( this . currentProject ) ; if ( classFoldersAndJars != null ) { for ( int i = <NUM_LIT:0> , l = classFoldersAndJars . length ; i < l ; i ++ ) { ClasspathLocation classFolderOrJar = classFoldersAndJars [ i ] ; if ( classFolderOrJar != null ) { IPath p = classFolderOrJar . getProjectRelativePath ( ) ; if ( p != null ) { IResourceDelta binaryDelta = delta . findMember ( p ) ; if ( binaryDelta != null && binaryDelta . getKind ( ) != IResourceDelta . NO_CHANGE ) return true ; } } } } } return false ; } private int initializeBuilder ( int kind , boolean forBuild ) throws CoreException { this . javaProject = ( JavaProject ) JavaCore . create ( this . currentProject ) ; this . workspaceRoot = this . currentProject . getWorkspace ( ) . getRoot ( ) ; if ( forBuild ) { this . participants = JavaModelManager . getJavaModelManager ( ) . compilationParticipants . getCompilationParticipants ( this . javaProject ) ; if ( this . participants != null ) for ( int i = <NUM_LIT:0> , l = this . participants . length ; i < l ; i ++ ) if ( this . participants [ i ] . aboutToBuild ( this . javaProject ) == CompilationParticipant . NEEDS_FULL_BUILD ) kind = FULL_BUILD ; String projectName = this . currentProject . getName ( ) ; if ( builtProjects == null || builtProjects . contains ( projectName ) ) { JavaModel . flushExternalFileCache ( ) ; builtProjects = new ArrayList ( ) ; } builtProjects . add ( projectName ) ; } this . binaryLocationsPerProject = new SimpleLookupTable ( <NUM_LIT:3> ) ; this . nameEnvironment = new NameEnvironment ( this . workspaceRoot , this . javaProject , this . binaryLocationsPerProject , this . notifier ) ; if ( forBuild ) { String filterSequence = this . javaProject . getOption ( JavaCore . CORE_JAVA_BUILD_RESOURCE_COPY_FILTER , true ) ; char [ ] [ ] filters = filterSequence != null && filterSequence . length ( ) > <NUM_LIT:0> ? CharOperation . splitAndTrimOn ( '<CHAR_LIT:U+002C>' , filterSequence . toCharArray ( ) ) : null ; if ( filters == null ) { this . extraResourceFileFilters = null ; this . extraResourceFolderFilters = null ; } else { int fileCount = <NUM_LIT:0> , folderCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , l = filters . length ; i < l ; i ++ ) { char [ ] f = filters [ i ] ; if ( f . length == <NUM_LIT:0> ) continue ; if ( f [ f . length - <NUM_LIT:1> ] == '<CHAR_LIT:/>' ) folderCount ++ ; else fileCount ++ ; } this . extraResourceFileFilters = new char [ fileCount ] [ ] ; this . extraResourceFolderFilters = new String [ folderCount ] ; for ( int i = <NUM_LIT:0> , l = filters . length ; i < l ; i ++ ) { char [ ] f = filters [ i ] ; if ( f . length == <NUM_LIT:0> ) continue ; if ( f [ f . length - <NUM_LIT:1> ] == '<CHAR_LIT:/>' ) this . extraResourceFolderFilters [ -- folderCount ] = new String ( f , <NUM_LIT:0> , f . length - <NUM_LIT:1> ) ; else this . extraResourceFileFilters [ -- fileCount ] = f ; } } } return kind ; } private boolean isClasspathBroken ( IClasspathEntry [ ] classpath , IProject p ) throws CoreException { IMarker [ ] markers = p . findMarkers ( IJavaModelMarker . BUILDPATH_PROBLEM_MARKER , false , IResource . DEPTH_ZERO ) ; for ( int i = <NUM_LIT:0> , l = markers . length ; i < l ; i ++ ) if ( markers [ i ] . getAttribute ( IMarker . SEVERITY , - <NUM_LIT:1> ) == IMarker . SEVERITY_ERROR ) return true ; return false ; } private boolean isWorthBuilding ( ) throws CoreException { boolean abortBuilds = JavaCore . ABORT . equals ( this . javaProject . getOption ( JavaCore . CORE_JAVA_BUILD_INVALID_CLASSPATH , true ) ) ; if ( ! abortBuilds ) return true ; if ( isClasspathBroken ( this . javaProject . getRawClasspath ( ) , this . currentProject ) ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" ) ; removeProblemsAndTasksFor ( this . currentProject ) ; IMarker marker = this . currentProject . createMarker ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER ) ; marker . setAttributes ( new String [ ] { IMarker . MESSAGE , IMarker . SEVERITY , IJavaModelMarker . CATEGORY_ID , IMarker . SOURCE_ID } , new Object [ ] { Messages . build_abortDueToClasspathProblems , new Integer ( IMarker . SEVERITY_ERROR ) , new Integer ( CategorizedProblem . CAT_BUILDPATH ) , JavaBuilder . SOURCE_ID } ) ; return false ; } if ( JavaCore . WARNING . equals ( this . javaProject . getOption ( JavaCore . CORE_INCOMPLETE_CLASSPATH , true ) ) ) return true ; IProject [ ] requiredProjects = getRequiredProjects ( false ) ; for ( int i = <NUM_LIT:0> , l = requiredProjects . length ; i < l ; i ++ ) { IProject p = requiredProjects [ i ] ; if ( getLastState ( p ) == null ) { JavaProject prereq = ( JavaProject ) JavaCore . create ( p ) ; if ( prereq . hasCycleMarker ( ) && JavaCore . WARNING . equals ( this . javaProject . getOption ( JavaCore . CORE_CIRCULAR_CLASSPATH , true ) ) ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" + p . getName ( ) + "<STR_LIT>" ) ; continue ; } if ( ! hasJavaBuilder ( p ) ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" + p . getName ( ) + "<STR_LIT>" ) ; continue ; } if ( DEBUG ) System . out . println ( "<STR_LIT>" + p . getName ( ) + "<STR_LIT>" ) ; removeProblemsAndTasksFor ( this . currentProject ) ; IMarker marker = this . currentProject . createMarker ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER ) ; marker . setAttributes ( new String [ ] { IMarker . MESSAGE , IMarker . SEVERITY , IJavaModelMarker . CATEGORY_ID , IMarker . SOURCE_ID } , new Object [ ] { isClasspathBroken ( prereq . getRawClasspath ( ) , p ) ? Messages . bind ( Messages . build_prereqProjectHasClasspathProblems , p . getName ( ) ) : Messages . bind ( Messages . build_prereqProjectMustBeRebuilt , p . getName ( ) ) , new Integer ( IMarker . SEVERITY_ERROR ) , new Integer ( CategorizedProblem . CAT_BUILDPATH ) , JavaBuilder . SOURCE_ID } ) ; return false ; } } return true ; } void mustPropagateStructuralChanges ( ) { LinkedHashSet cycleParticipants = new LinkedHashSet ( <NUM_LIT:3> ) ; this . javaProject . updateCycleParticipants ( new ArrayList ( ) , cycleParticipants , this . workspaceRoot , new HashSet ( <NUM_LIT:3> ) , null ) ; IPath currentPath = this . javaProject . getPath ( ) ; Iterator i = cycleParticipants . iterator ( ) ; while ( i . hasNext ( ) ) { IPath participantPath = ( IPath ) i . next ( ) ; if ( participantPath != currentPath ) { IProject project = this . workspaceRoot . getProject ( participantPath . segment ( <NUM_LIT:0> ) ) ; if ( hasBeenBuilt ( project ) ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" + project . getName ( ) + "<STR_LIT>" ) ; needRebuild ( ) ; return ; } } } } private void printLocations ( ClasspathLocation [ ] newLocations , ClasspathLocation [ ] oldLocations ) { System . out . println ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> , length = newLocations . length ; i < length ; i ++ ) System . out . println ( "<STR_LIT:U+0020U+0020U+0020U+0020>" + newLocations [ i ] . debugPathString ( ) ) ; System . out . println ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> , length = oldLocations . length ; i < length ; i ++ ) System . out . println ( "<STR_LIT:U+0020U+0020U+0020U+0020>" + oldLocations [ i ] . debugPathString ( ) ) ; } private void recordNewState ( State state ) { Object [ ] keyTable = this . binaryLocationsPerProject . keyTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { IProject prereqProject = ( IProject ) keyTable [ i ] ; if ( prereqProject != null && prereqProject != this . currentProject ) state . recordStructuralDependency ( prereqProject , getLastState ( prereqProject ) ) ; } if ( DEBUG ) System . out . println ( "<STR_LIT>" + state ) ; JavaModelManager . getJavaModelManager ( ) . setLastBuiltState ( this . currentProject , state ) ; } public String toString ( ) { return this . currentProject == null ? "<STR_LIT>" : "<STR_LIT>" + this . currentProject . getName ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . ClassFile ; import org . eclipse . jdt . internal . compiler . impl . CompilerStats ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; import java . util . * ; public class BatchImageBuilder extends AbstractImageBuilder { IncrementalImageBuilder incrementalBuilder ; ArrayList secondaryTypes ; StringSet typeLocatorsWithUndefinedTypes ; protected BatchImageBuilder ( JavaBuilder javaBuilder , boolean buildStarting ) { super ( javaBuilder , buildStarting , null ) ; this . nameEnvironment . isIncrementalBuild = false ; this . incrementalBuilder = null ; this . secondaryTypes = null ; this . typeLocatorsWithUndefinedTypes = null ; } public void build ( ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; try { this . notifier . subTask ( Messages . bind ( Messages . build_cleaningOutput , this . javaBuilder . currentProject . getName ( ) ) ) ; JavaBuilder . removeProblemsAndTasksFor ( this . javaBuilder . currentProject ) ; cleanOutputFolders ( true ) ; this . notifier . updateProgressDelta ( <NUM_LIT> ) ; this . notifier . subTask ( Messages . build_analyzingSources ) ; ArrayList sourceFiles = new ArrayList ( <NUM_LIT> ) ; addAllSourceFiles ( sourceFiles ) ; this . notifier . updateProgressDelta ( <NUM_LIT> ) ; if ( sourceFiles . size ( ) > <NUM_LIT:0> ) { SourceFile [ ] allSourceFiles = new SourceFile [ sourceFiles . size ( ) ] ; sourceFiles . toArray ( allSourceFiles ) ; this . notifier . setProgressPerCompilationUnit ( <NUM_LIT> / allSourceFiles . length ) ; this . workQueue . addAll ( allSourceFiles ) ; compile ( allSourceFiles ) ; if ( this . typeLocatorsWithUndefinedTypes != null ) if ( this . secondaryTypes != null && ! this . secondaryTypes . isEmpty ( ) ) rebuildTypesAffectedBySecondaryTypes ( ) ; if ( this . incrementalBuilder != null ) this . incrementalBuilder . buildAfterBatchBuild ( ) ; } if ( this . javaBuilder . javaProject . hasCycleMarker ( ) ) this . javaBuilder . mustPropagateStructuralChanges ( ) ; } catch ( CoreException e ) { throw internalException ( e ) ; } finally { if ( JavaBuilder . SHOW_STATS ) printStats ( ) ; cleanUp ( ) ; } } protected void acceptSecondaryType ( ClassFile classFile ) { if ( this . secondaryTypes != null ) this . secondaryTypes . add ( classFile . fileName ( ) ) ; } protected void cleanOutputFolders ( boolean copyBack ) throws CoreException { boolean deleteAll = JavaCore . CLEAN . equals ( this . javaBuilder . javaProject . getOption ( JavaCore . CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER , true ) ) ; if ( deleteAll ) { if ( this . javaBuilder . participants != null ) for ( int i = <NUM_LIT:0> , l = this . javaBuilder . participants . length ; i < l ; i ++ ) this . javaBuilder . participants [ i ] . cleanStarting ( this . javaBuilder . javaProject ) ; ArrayList visited = new ArrayList ( this . sourceLocations . length ) ; for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) { this . notifier . subTask ( Messages . bind ( Messages . build_cleaningOutput , this . javaBuilder . currentProject . getName ( ) ) ) ; ClasspathMultiDirectory sourceLocation = this . sourceLocations [ i ] ; if ( sourceLocation . hasIndependentOutputFolder ) { IContainer outputFolder = sourceLocation . binaryFolder ; if ( ! visited . contains ( outputFolder ) ) { visited . add ( outputFolder ) ; IResource [ ] members = outputFolder . members ( ) ; for ( int j = <NUM_LIT:0> , m = members . length ; j < m ; j ++ ) { IResource member = members [ j ] ; if ( ! member . isDerived ( ) ) { member . accept ( new IResourceVisitor ( ) { public boolean visit ( IResource resource ) throws CoreException { resource . setDerived ( true , null ) ; return resource . getType ( ) != IResource . FILE ; } } ) ; } member . delete ( IResource . FORCE , null ) ; } } this . notifier . checkCancel ( ) ; if ( copyBack ) copyExtraResourcesBack ( sourceLocation , true ) ; } else { boolean isOutputFolder = sourceLocation . sourceFolder . equals ( sourceLocation . binaryFolder ) ; final char [ ] [ ] exclusionPatterns = isOutputFolder ? sourceLocation . exclusionPatterns : null ; final char [ ] [ ] inclusionPatterns = isOutputFolder ? sourceLocation . inclusionPatterns : null ; sourceLocation . binaryFolder . accept ( new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) throws CoreException { if ( proxy . getType ( ) == IResource . FILE ) { if ( org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( proxy . getName ( ) ) ) { IResource resource = proxy . requestResource ( ) ; if ( exclusionPatterns != null || inclusionPatterns != null ) if ( Util . isExcluded ( resource . getFullPath ( ) , inclusionPatterns , exclusionPatterns , false ) ) return false ; if ( ! resource . isDerived ( ) ) resource . setDerived ( true , null ) ; resource . delete ( IResource . FORCE , null ) ; } return false ; } if ( exclusionPatterns != null && inclusionPatterns == null ) if ( Util . isExcluded ( proxy . requestFullPath ( ) , null , exclusionPatterns , true ) ) return false ; BatchImageBuilder . this . notifier . checkCancel ( ) ; return true ; } } , IResource . NONE ) ; this . notifier . checkCancel ( ) ; } this . notifier . checkCancel ( ) ; } } else if ( copyBack ) { for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) { ClasspathMultiDirectory sourceLocation = this . sourceLocations [ i ] ; if ( sourceLocation . hasIndependentOutputFolder ) copyExtraResourcesBack ( sourceLocation , false ) ; this . notifier . checkCancel ( ) ; } } LanguageSupportFactory . getEventHandler ( ) . handle ( this . javaBuilder . javaProject , "<STR_LIT>" ) ; } protected void cleanUp ( ) { this . incrementalBuilder = null ; this . secondaryTypes = null ; this . typeLocatorsWithUndefinedTypes = null ; super . cleanUp ( ) ; } protected void compile ( SourceFile [ ] units , SourceFile [ ] additionalUnits , boolean compilingFirstGroup ) { if ( additionalUnits != null && this . secondaryTypes == null ) this . secondaryTypes = new ArrayList ( <NUM_LIT:7> ) ; super . compile ( units , additionalUnits , compilingFirstGroup ) ; } protected void copyExtraResourcesBack ( ClasspathMultiDirectory sourceLocation , final boolean deletedAll ) throws CoreException { this . notifier . subTask ( Messages . build_copyingResources ) ; final int segmentCount = sourceLocation . sourceFolder . getFullPath ( ) . segmentCount ( ) ; final char [ ] [ ] exclusionPatterns = sourceLocation . exclusionPatterns ; final char [ ] [ ] inclusionPatterns = sourceLocation . inclusionPatterns ; final IContainer outputFolder = sourceLocation . binaryFolder ; final boolean isAlsoProject = sourceLocation . sourceFolder . equals ( this . javaBuilder . currentProject ) ; final boolean isInterestingProject = LanguageSupportFactory . isInterestingProject ( this . javaBuilder . getProject ( ) ) ; sourceLocation . sourceFolder . accept ( new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) throws CoreException { IResource resource = null ; switch ( proxy . getType ( ) ) { case IResource . FILE : if ( ( LanguageSupportFactory . isSourceFile ( proxy . getName ( ) , isInterestingProject ) && org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( proxy . getName ( ) ) ) || org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( proxy . getName ( ) ) ) return false ; resource = proxy . requestResource ( ) ; if ( BatchImageBuilder . this . javaBuilder . filterExtraResource ( resource ) ) return false ; if ( exclusionPatterns != null || inclusionPatterns != null ) if ( Util . isExcluded ( resource . getFullPath ( ) , inclusionPatterns , exclusionPatterns , false ) ) return false ; IPath partialPath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) ; IResource copiedResource = outputFolder . getFile ( partialPath ) ; if ( copiedResource . exists ( ) ) { if ( deletedAll ) { IResource originalResource = findOriginalResource ( partialPath ) ; String id = originalResource . getFullPath ( ) . removeFirstSegments ( <NUM_LIT:1> ) . toString ( ) ; createProblemFor ( resource , null , Messages . bind ( Messages . build_duplicateResource , id ) , BatchImageBuilder . this . javaBuilder . javaProject . getOption ( JavaCore . CORE_JAVA_BUILD_DUPLICATE_RESOURCE , true ) ) ; return false ; } copiedResource . delete ( IResource . FORCE , null ) ; } createFolder ( partialPath . removeLastSegments ( <NUM_LIT:1> ) , outputFolder ) ; copyResource ( resource , copiedResource ) ; return false ; case IResource . FOLDER : resource = proxy . requestResource ( ) ; if ( BatchImageBuilder . this . javaBuilder . filterExtraResource ( resource ) ) return false ; if ( isAlsoProject && isExcludedFromProject ( resource . getFullPath ( ) ) ) return false ; if ( exclusionPatterns != null && inclusionPatterns == null ) if ( Util . isExcluded ( resource . getFullPath ( ) , null , exclusionPatterns , true ) ) return false ; } return true ; } } , IResource . NONE ) ; } protected IResource findOriginalResource ( IPath partialPath ) { for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) { ClasspathMultiDirectory sourceLocation = this . sourceLocations [ i ] ; if ( sourceLocation . hasIndependentOutputFolder ) { IResource originalResource = sourceLocation . sourceFolder . getFile ( partialPath ) ; if ( originalResource . exists ( ) ) return originalResource ; } } return null ; } private void printStats ( ) { if ( this . compiler == null ) return ; CompilerStats compilerStats = this . compiler . stats ; long time = compilerStats . elapsedTime ( ) ; long lineCount = compilerStats . lineCount ; double speed = ( ( int ) ( lineCount * <NUM_LIT> / time ) ) / <NUM_LIT> ; System . out . println ( "<STR_LIT>" + this . javaBuilder . javaProject . getElementName ( ) ) ; System . out . println ( "<STR_LIT>" + lineCount + "<STR_LIT>" + time + "<STR_LIT>" + speed + "<STR_LIT>" ) ; System . out . print ( "<STR_LIT>" + compilerStats . parseTime + "<STR_LIT>" + ( ( int ) ( compilerStats . parseTime * <NUM_LIT> / time ) ) / <NUM_LIT> + "<STR_LIT>" ) ; System . out . print ( "<STR_LIT>" + compilerStats . resolveTime + "<STR_LIT>" + ( ( int ) ( compilerStats . resolveTime * <NUM_LIT> / time ) ) / <NUM_LIT> + "<STR_LIT>" ) ; System . out . print ( "<STR_LIT>" + compilerStats . analyzeTime + "<STR_LIT>" + ( ( int ) ( compilerStats . analyzeTime * <NUM_LIT> / time ) ) / <NUM_LIT> + "<STR_LIT>" ) ; System . out . println ( "<STR_LIT>" + compilerStats . generateTime + "<STR_LIT>" + ( ( int ) ( compilerStats . generateTime * <NUM_LIT> / time ) ) / <NUM_LIT> + "<STR_LIT>" ) ; } protected void processAnnotationResults ( CompilationParticipantResult [ ] results ) { if ( this . incrementalBuilder == null ) this . incrementalBuilder = new IncrementalImageBuilder ( this ) ; this . incrementalBuilder . processAnnotationResults ( results ) ; } protected void rebuildTypesAffectedBySecondaryTypes ( ) { if ( this . incrementalBuilder == null ) this . incrementalBuilder = new IncrementalImageBuilder ( this ) ; int count = this . secondaryTypes . size ( ) ; StringSet qualifiedNames = new StringSet ( count * <NUM_LIT:2> ) ; StringSet simpleNames = new StringSet ( count ) ; StringSet rootNames = new StringSet ( <NUM_LIT:3> ) ; while ( -- count >= <NUM_LIT:0> ) { char [ ] secondaryTypeName = ( char [ ] ) this . secondaryTypes . get ( count ) ; IPath path = new Path ( null , new String ( secondaryTypeName ) ) ; this . incrementalBuilder . addDependentsOf ( path , false , qualifiedNames , simpleNames , rootNames ) ; } this . incrementalBuilder . addAffectedSourceFiles ( qualifiedNames , simpleNames , rootNames , this . typeLocatorsWithUndefinedTypes ) ; } protected void storeProblemsFor ( SourceFile sourceFile , CategorizedProblem [ ] problems ) throws CoreException { if ( sourceFile == null || problems == null || problems . length == <NUM_LIT:0> ) return ; for ( int i = problems . length ; -- i >= <NUM_LIT:0> ; ) { CategorizedProblem problem = problems [ i ] ; if ( problem != null && problem . getID ( ) == IProblem . UndefinedType ) { if ( this . typeLocatorsWithUndefinedTypes == null ) this . typeLocatorsWithUndefinedTypes = new StringSet ( <NUM_LIT:3> ) ; this . typeLocatorsWithUndefinedTypes . add ( sourceFile . typeLocator ( ) ) ; break ; } } super . storeProblemsFor ( sourceFile , problems ) ; } public String toString ( ) { return "<STR_LIT>" + this . newState ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; public class AbortIncrementalBuildException extends RuntimeException { protected String qualifiedTypeName ; private static final long serialVersionUID = - <NUM_LIT> ; public AbortIncrementalBuildException ( String qualifiedTypeName ) { this . qualifiedTypeName = qualifiedTypeName ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; public class AdditionalTypeCollection extends ReferenceCollection { char [ ] [ ] definedTypeNames ; protected AdditionalTypeCollection ( char [ ] [ ] definedTypeNames , char [ ] [ ] [ ] qualifiedReferences , char [ ] [ ] simpleNameReferences , char [ ] [ ] rootReferences ) { super ( qualifiedReferences , simpleNameReferences , rootReferences ) ; this . definedTypeNames = definedTypeNames ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . core . util . Util ; public class SourceFile implements ICompilationUnit { public IFile resource ; ClasspathMultiDirectory sourceLocation ; String initialTypeName ; boolean updateClassFile ; public SourceFile ( IFile resource , ClasspathMultiDirectory sourceLocation ) { this . resource = resource ; this . sourceLocation = sourceLocation ; this . initialTypeName = extractTypeName ( ) ; this . updateClassFile = false ; } public SourceFile ( IFile resource , ClasspathMultiDirectory sourceLocation , boolean updateClassFile ) { this ( resource , sourceLocation ) ; this . updateClassFile = updateClassFile ; } public boolean equals ( Object o ) { if ( this == o ) return true ; if ( ! ( o instanceof SourceFile ) ) return false ; SourceFile f = ( SourceFile ) o ; return this . sourceLocation == f . sourceLocation && this . resource . getFullPath ( ) . equals ( f . resource . getFullPath ( ) ) ; } String extractTypeName ( ) { IPath fullPath = this . resource . getFullPath ( ) ; int resourceSegmentCount = fullPath . segmentCount ( ) ; int sourceFolderSegmentCount = this . sourceLocation . sourceFolder . getFullPath ( ) . segmentCount ( ) ; int charCount = ( resourceSegmentCount - sourceFolderSegmentCount - <NUM_LIT:1> ) ; resourceSegmentCount -- ; for ( int i = sourceFolderSegmentCount ; i < resourceSegmentCount ; i ++ ) charCount += fullPath . segment ( i ) . length ( ) ; String lastSegment = fullPath . segment ( resourceSegmentCount ) ; int extensionIndex = Util . indexOfJavaLikeExtension ( lastSegment ) ; charCount += extensionIndex ; char [ ] result = new char [ charCount ] ; int offset = <NUM_LIT:0> ; for ( int i = sourceFolderSegmentCount ; i < resourceSegmentCount ; i ++ ) { String segment = fullPath . segment ( i ) ; int size = segment . length ( ) ; segment . getChars ( <NUM_LIT:0> , size , result , offset ) ; offset += size ; result [ offset ++ ] = '<CHAR_LIT:/>' ; } lastSegment . getChars ( <NUM_LIT:0> , extensionIndex , result , offset ) ; return new String ( result ) ; } public char [ ] getContents ( ) { try { return Util . getResourceContentsAsCharArray ( this . resource ) ; } catch ( CoreException e ) { throw new AbortCompilation ( true , new MissingSourceFileException ( this . resource . getFullPath ( ) . toString ( ) ) ) ; } } public char [ ] getFileName ( ) { return this . resource . getFullPath ( ) . toString ( ) . toCharArray ( ) ; } public char [ ] getMainTypeName ( ) { char [ ] typeName = this . initialTypeName . toCharArray ( ) ; int lastIndex = CharOperation . lastIndexOf ( '<CHAR_LIT:/>' , typeName ) ; return CharOperation . subarray ( typeName , lastIndex + <NUM_LIT:1> , - <NUM_LIT:1> ) ; } public char [ ] [ ] getPackageName ( ) { char [ ] typeName = this . initialTypeName . toCharArray ( ) ; int lastIndex = CharOperation . lastIndexOf ( '<CHAR_LIT:/>' , typeName ) ; return CharOperation . splitOn ( '<CHAR_LIT:/>' , typeName , <NUM_LIT:0> , lastIndex ) ; } public int hashCode ( ) { return this . initialTypeName . hashCode ( ) ; } public boolean ignoreOptionalProblems ( ) { return this . sourceLocation . ignoreOptionalProblems ; } String typeLocator ( ) { return this . resource . getProjectRelativePath ( ) . toString ( ) ; } public String toString ( ) { return "<STR_LIT>" + this . resource . getFullPath ( ) + "<STR_LIT:]>" ; } public static final String LINK_TO_GRAILS_PLUGINS = "<STR_LIT>" ; public boolean isInLinkedSourceFolder ( ) { if ( this . sourceLocation != null && this . sourceLocation . sourceFolder != null ) { IPath fullPath = this . sourceLocation . sourceFolder . getFullPath ( ) ; if ( fullPath != null ) { return LINK_TO_GRAILS_PLUGINS . equals ( fullPath . segment ( <NUM_LIT:1> ) ) ; } } return false ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; public class StringSet { public String [ ] values ; public int elementSize ; public int threshold ; public StringSet ( int size ) { this . elementSize = <NUM_LIT:0> ; this . threshold = size ; int extraRoom = ( int ) ( size * <NUM_LIT> ) ; if ( this . threshold == extraRoom ) extraRoom ++ ; this . values = new String [ extraRoom ] ; } public boolean add ( String value ) { int length = this . values . length ; int index = ( value . hashCode ( ) & <NUM_LIT> ) % length ; String current ; while ( ( current = this . values [ index ] ) != null ) { if ( value . equals ( current ) ) return false ; if ( ++ index == length ) index = <NUM_LIT:0> ; } this . values [ index ] = value ; if ( ++ this . elementSize > this . threshold ) rehash ( ) ; return true ; } public void clear ( ) { for ( int i = this . values . length ; -- i >= <NUM_LIT:0> ; ) this . values [ i ] = null ; this . elementSize = <NUM_LIT:0> ; } public boolean includes ( String value ) { int length = this . values . length ; int index = ( value . hashCode ( ) & <NUM_LIT> ) % length ; String current ; while ( ( current = this . values [ index ] ) != null ) { if ( value . equals ( current ) ) return true ; if ( ++ index == length ) index = <NUM_LIT:0> ; } return false ; } private void rehash ( ) { StringSet newSet = new StringSet ( this . elementSize * <NUM_LIT:2> ) ; String current ; for ( int i = this . values . length ; -- i >= <NUM_LIT:0> ; ) if ( ( current = this . values [ i ] ) != null ) newSet . add ( current ) ; this . values = newSet . values ; this . elementSize = newSet . elementSize ; this . threshold = newSet . threshold ; } public String toString ( ) { String s = "<STR_LIT>" ; String value ; for ( int i = <NUM_LIT:0> , l = this . values . length ; i < l ; i ++ ) if ( ( value = this . values [ i ] ) != null ) s += value + "<STR_LIT:n>" ; return s ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . resources . IFile ; import org . eclipse . jdt . core . compiler . * ; public class CompilationParticipantResult extends BuildContext { protected SourceFile sourceFile ; protected boolean hasAnnotations ; protected IFile [ ] addedFiles ; protected IFile [ ] deletedFiles ; protected CategorizedProblem [ ] problems ; protected String [ ] dependencies ; protected CompilationParticipantResult ( SourceFile sourceFile ) { this . sourceFile = sourceFile ; this . hasAnnotations = false ; this . addedFiles = null ; this . deletedFiles = null ; this . problems = null ; this . dependencies = null ; } public char [ ] getContents ( ) { return this . sourceFile . getContents ( ) ; } public IFile getFile ( ) { return this . sourceFile . resource ; } public boolean hasAnnotations ( ) { return this . hasAnnotations ; } public void recordAddedGeneratedFiles ( IFile [ ] addedGeneratedFiles ) { int length2 = addedGeneratedFiles . length ; if ( length2 == <NUM_LIT:0> ) return ; int length1 = this . addedFiles == null ? <NUM_LIT:0> : this . addedFiles . length ; IFile [ ] merged = new IFile [ length1 + length2 ] ; if ( length1 > <NUM_LIT:0> ) System . arraycopy ( this . addedFiles , <NUM_LIT:0> , merged , <NUM_LIT:0> , length1 ) ; System . arraycopy ( addedGeneratedFiles , <NUM_LIT:0> , merged , length1 , length2 ) ; this . addedFiles = merged ; } public void recordDeletedGeneratedFiles ( IFile [ ] deletedGeneratedFiles ) { int length2 = deletedGeneratedFiles . length ; if ( length2 == <NUM_LIT:0> ) return ; int length1 = this . deletedFiles == null ? <NUM_LIT:0> : this . deletedFiles . length ; IFile [ ] merged = new IFile [ length1 + length2 ] ; if ( length1 > <NUM_LIT:0> ) System . arraycopy ( this . deletedFiles , <NUM_LIT:0> , merged , <NUM_LIT:0> , length1 ) ; System . arraycopy ( deletedGeneratedFiles , <NUM_LIT:0> , merged , length1 , length2 ) ; this . deletedFiles = merged ; } public void recordDependencies ( String [ ] typeNameDependencies ) { int length2 = typeNameDependencies . length ; if ( length2 == <NUM_LIT:0> ) return ; int length1 = this . dependencies == null ? <NUM_LIT:0> : this . dependencies . length ; String [ ] merged = new String [ length1 + length2 ] ; if ( length1 > <NUM_LIT:0> ) System . arraycopy ( this . dependencies , <NUM_LIT:0> , merged , <NUM_LIT:0> , length1 ) ; System . arraycopy ( typeNameDependencies , <NUM_LIT:0> , merged , length1 , length2 ) ; this . dependencies = merged ; } public void recordNewProblems ( CategorizedProblem [ ] newProblems ) { int length2 = newProblems . length ; if ( length2 == <NUM_LIT:0> ) return ; int length1 = this . problems == null ? <NUM_LIT:0> : this . problems . length ; CategorizedProblem [ ] merged = new CategorizedProblem [ length1 + length2 ] ; if ( length1 > <NUM_LIT:0> ) System . arraycopy ( this . problems , <NUM_LIT:0> , merged , <NUM_LIT:0> , length1 ) ; System . arraycopy ( newProblems , <NUM_LIT:0> , merged , length1 , length2 ) ; this . problems = merged ; } void reset ( boolean detectedAnnotations ) { this . hasAnnotations = detectedAnnotations ; this . addedFiles = null ; this . deletedFiles = null ; this . problems = null ; this . dependencies = null ; } public String toString ( ) { return this . sourceFile . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . resources . IFile ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; public interface ICompilationUnitLocator { public ICompilationUnit fromIFile ( IFile file ) ; } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; public class ReferenceCollection { char [ ] [ ] [ ] qualifiedNameReferences ; char [ ] [ ] simpleNameReferences ; char [ ] [ ] rootReferences ; protected ReferenceCollection ( char [ ] [ ] [ ] qualifiedNameReferences , char [ ] [ ] simpleNameReferences , char [ ] [ ] rootReferences ) { this . qualifiedNameReferences = internQualifiedNames ( qualifiedNameReferences , false ) ; this . simpleNameReferences = internSimpleNames ( simpleNameReferences , true ) ; this . rootReferences = internSimpleNames ( rootReferences , false ) ; } public void addDependencies ( String [ ] typeNameDependencies ) { char [ ] [ ] [ ] qNames = new char [ typeNameDependencies . length ] [ ] [ ] ; for ( int i = typeNameDependencies . length ; -- i >= <NUM_LIT:0> ; ) qNames [ i ] = CharOperation . splitOn ( '<CHAR_LIT:.>' , typeNameDependencies [ i ] . toCharArray ( ) ) ; qNames = internQualifiedNames ( qNames , false ) ; next : for ( int i = qNames . length ; -- i >= <NUM_LIT:0> ; ) { char [ ] [ ] qualifiedTypeName = qNames [ i ] ; while ( ! includes ( qualifiedTypeName ) ) { if ( ! includes ( qualifiedTypeName [ qualifiedTypeName . length - <NUM_LIT:1> ] ) ) { int length = this . simpleNameReferences . length ; System . arraycopy ( this . simpleNameReferences , <NUM_LIT:0> , this . simpleNameReferences = new char [ length + <NUM_LIT:1> ] [ ] , <NUM_LIT:0> , length ) ; this . simpleNameReferences [ length ] = qualifiedTypeName [ qualifiedTypeName . length - <NUM_LIT:1> ] ; } if ( ! insideRoot ( qualifiedTypeName [ <NUM_LIT:0> ] ) ) { int length = this . rootReferences . length ; System . arraycopy ( this . rootReferences , <NUM_LIT:0> , this . rootReferences = new char [ length + <NUM_LIT:1> ] [ ] , <NUM_LIT:0> , length ) ; this . rootReferences [ length ] = qualifiedTypeName [ <NUM_LIT:0> ] ; } int length = this . qualifiedNameReferences . length ; System . arraycopy ( this . qualifiedNameReferences , <NUM_LIT:0> , this . qualifiedNameReferences = new char [ length + <NUM_LIT:1> ] [ ] [ ] , <NUM_LIT:0> , length ) ; this . qualifiedNameReferences [ length ] = qualifiedTypeName ; qualifiedTypeName = CharOperation . subarray ( qualifiedTypeName , <NUM_LIT:0> , qualifiedTypeName . length - <NUM_LIT:1> ) ; char [ ] [ ] [ ] temp = internQualifiedNames ( new char [ ] [ ] [ ] { qualifiedTypeName } , false ) ; if ( temp == EmptyQualifiedNames ) continue next ; qualifiedTypeName = temp [ <NUM_LIT:0> ] ; } } } public boolean includes ( char [ ] simpleName ) { for ( int i = <NUM_LIT:0> , l = this . simpleNameReferences . length ; i < l ; i ++ ) if ( simpleName == this . simpleNameReferences [ i ] ) return true ; return false ; } public boolean includes ( char [ ] [ ] qualifiedName ) { for ( int i = <NUM_LIT:0> , l = this . qualifiedNameReferences . length ; i < l ; i ++ ) if ( qualifiedName == this . qualifiedNameReferences [ i ] ) return true ; return false ; } public boolean includes ( char [ ] [ ] [ ] qualifiedNames , char [ ] [ ] simpleNames ) { return includes ( qualifiedNames , simpleNames , null ) ; } public boolean includes ( char [ ] [ ] [ ] qualifiedNames , char [ ] [ ] simpleNames , char [ ] [ ] rootNames ) { if ( rootNames != null ) { boolean foundRoot = false ; for ( int i = <NUM_LIT:0> , l = rootNames . length ; ! foundRoot && i < l ; i ++ ) foundRoot = insideRoot ( rootNames [ i ] ) ; if ( ! foundRoot ) return false ; } if ( simpleNames == null || qualifiedNames == null ) { if ( simpleNames == null && qualifiedNames == null ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; return true ; } else if ( qualifiedNames == null ) { for ( int i = <NUM_LIT:0> , l = simpleNames . length ; i < l ; i ++ ) { if ( includes ( simpleNames [ i ] ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + new String ( simpleNames [ i ] ) ) ; return true ; } } } else { for ( int i = <NUM_LIT:0> , l = qualifiedNames . length ; i < l ; i ++ ) { char [ ] [ ] qualifiedName = qualifiedNames [ i ] ; if ( qualifiedName . length == <NUM_LIT:1> ? includes ( qualifiedName [ <NUM_LIT:0> ] ) : includes ( qualifiedName ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + CharOperation . toString ( qualifiedName ) ) ; return true ; } } } return false ; } int sLength = simpleNames . length ; int qLength = qualifiedNames . length ; if ( sLength <= qLength ) { for ( int i = <NUM_LIT:0> ; i < sLength ; i ++ ) { if ( includes ( simpleNames [ i ] ) ) { for ( int j = <NUM_LIT:0> ; j < qLength ; j ++ ) { char [ ] [ ] qualifiedName = qualifiedNames [ j ] ; if ( qualifiedName . length == <NUM_LIT:1> ? includes ( qualifiedName [ <NUM_LIT:0> ] ) : includes ( qualifiedName ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + CharOperation . toString ( qualifiedName ) + "<STR_LIT:U+0020toU+0020>" + new String ( simpleNames [ i ] ) ) ; return true ; } } return false ; } } } else { for ( int i = <NUM_LIT:0> ; i < qLength ; i ++ ) { char [ ] [ ] qualifiedName = qualifiedNames [ i ] ; if ( qualifiedName . length == <NUM_LIT:1> ? includes ( qualifiedName [ <NUM_LIT:0> ] ) : includes ( qualifiedName ) ) { for ( int j = <NUM_LIT:0> ; j < sLength ; j ++ ) { if ( includes ( simpleNames [ j ] ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + CharOperation . toString ( qualifiedName ) + "<STR_LIT:U+0020toU+0020>" + new String ( simpleNames [ j ] ) ) ; return true ; } } return false ; } } } return false ; } public boolean insideRoot ( char [ ] rootName ) { for ( int i = <NUM_LIT:0> , l = this . rootReferences . length ; i < l ; i ++ ) if ( rootName == this . rootReferences [ i ] ) return true ; return false ; } static final char [ ] [ ] [ ] WellKnownQualifiedNames = new char [ ] [ ] [ ] { TypeConstants . JAVA_LANG_RUNTIMEEXCEPTION , TypeConstants . JAVA_LANG_THROWABLE , TypeConstants . JAVA_LANG_OBJECT , TypeConstants . JAVA_LANG , new char [ ] [ ] { TypeConstants . JAVA } , new char [ ] [ ] { new char [ ] { '<CHAR_LIT>' , '<CHAR_LIT>' , '<CHAR_LIT>' } } , new char [ ] [ ] { new char [ ] { '<CHAR_LIT:c>' , '<CHAR_LIT>' , '<CHAR_LIT>' } } , CharOperation . NO_CHAR_CHAR } ; static final char [ ] [ ] WellKnownSimpleNames = new char [ ] [ ] { TypeConstants . JAVA_LANG_RUNTIMEEXCEPTION [ <NUM_LIT:2> ] , TypeConstants . JAVA_LANG_THROWABLE [ <NUM_LIT:2> ] , TypeConstants . JAVA_LANG_OBJECT [ <NUM_LIT:2> ] , TypeConstants . JAVA , TypeConstants . LANG , new char [ ] { '<CHAR_LIT>' , '<CHAR_LIT>' , '<CHAR_LIT>' } , new char [ ] { '<CHAR_LIT:c>' , '<CHAR_LIT>' , '<CHAR_LIT>' } } ; static final char [ ] [ ] [ ] EmptyQualifiedNames = new char [ <NUM_LIT:0> ] [ ] [ ] ; static final char [ ] [ ] EmptySimpleNames = CharOperation . NO_CHAR_CHAR ; static final int MaxQualifiedNames = <NUM_LIT:7> ; static QualifiedNameSet [ ] InternedQualifiedNames = new QualifiedNameSet [ MaxQualifiedNames ] ; static final int MaxSimpleNames = <NUM_LIT:30> ; static NameSet [ ] InternedSimpleNames = new NameSet [ MaxSimpleNames ] ; static { for ( int i = <NUM_LIT:0> ; i < MaxQualifiedNames ; i ++ ) InternedQualifiedNames [ i ] = new QualifiedNameSet ( <NUM_LIT> ) ; for ( int i = <NUM_LIT:0> ; i < MaxSimpleNames ; i ++ ) InternedSimpleNames [ i ] = new NameSet ( <NUM_LIT> ) ; } public static char [ ] [ ] [ ] internQualifiedNames ( StringSet qualifiedStrings ) { if ( qualifiedStrings == null ) return EmptyQualifiedNames ; int length = qualifiedStrings . elementSize ; if ( length == <NUM_LIT:0> ) return EmptyQualifiedNames ; char [ ] [ ] [ ] result = new char [ length ] [ ] [ ] ; String [ ] strings = qualifiedStrings . values ; for ( int i = <NUM_LIT:0> , l = strings . length ; i < l ; i ++ ) if ( strings [ i ] != null ) result [ -- length ] = CharOperation . splitOn ( '<CHAR_LIT:/>' , strings [ i ] . toCharArray ( ) ) ; return internQualifiedNames ( result , false ) ; } public static char [ ] [ ] [ ] internQualifiedNames ( char [ ] [ ] [ ] qualifiedNames ) { return internQualifiedNames ( qualifiedNames , false ) ; } public static char [ ] [ ] [ ] internQualifiedNames ( char [ ] [ ] [ ] qualifiedNames , boolean keepWellKnown ) { if ( qualifiedNames == null ) return EmptyQualifiedNames ; int length = qualifiedNames . length ; if ( length == <NUM_LIT:0> ) return EmptyQualifiedNames ; char [ ] [ ] [ ] keepers = new char [ length ] [ ] [ ] ; int index = <NUM_LIT:0> ; next : for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char [ ] [ ] qualifiedName = qualifiedNames [ i ] ; int qLength = qualifiedName . length ; for ( int j = <NUM_LIT:0> , m = WellKnownQualifiedNames . length ; j < m ; j ++ ) { char [ ] [ ] wellKnownName = WellKnownQualifiedNames [ j ] ; if ( qLength > wellKnownName . length ) break ; if ( CharOperation . equals ( qualifiedName , wellKnownName ) ) { if ( keepWellKnown ) { keepers [ index ++ ] = wellKnownName ; } continue next ; } } QualifiedNameSet internedNames = InternedQualifiedNames [ qLength <= MaxQualifiedNames ? qLength - <NUM_LIT:1> : <NUM_LIT:0> ] ; qualifiedName = internSimpleNames ( qualifiedName , false ) ; keepers [ index ++ ] = internedNames . add ( qualifiedName ) ; } if ( length > index ) { if ( index == <NUM_LIT:0> ) return EmptyQualifiedNames ; System . arraycopy ( keepers , <NUM_LIT:0> , keepers = new char [ index ] [ ] [ ] , <NUM_LIT:0> , index ) ; } return keepers ; } public static char [ ] [ ] internSimpleNames ( StringSet simpleStrings ) { return internSimpleNames ( simpleStrings , true ) ; } public static char [ ] [ ] internSimpleNames ( StringSet simpleStrings , boolean removeWellKnown ) { if ( simpleStrings == null ) return EmptySimpleNames ; int length = simpleStrings . elementSize ; if ( length == <NUM_LIT:0> ) return EmptySimpleNames ; char [ ] [ ] result = new char [ length ] [ ] ; String [ ] strings = simpleStrings . values ; for ( int i = <NUM_LIT:0> , l = strings . length ; i < l ; i ++ ) if ( strings [ i ] != null ) result [ -- length ] = strings [ i ] . toCharArray ( ) ; return internSimpleNames ( result , removeWellKnown ) ; } public static char [ ] [ ] internSimpleNames ( char [ ] [ ] simpleNames , boolean removeWellKnown ) { if ( simpleNames == null ) return EmptySimpleNames ; int length = simpleNames . length ; if ( length == <NUM_LIT:0> ) return EmptySimpleNames ; char [ ] [ ] keepers = new char [ length ] [ ] ; int index = <NUM_LIT:0> ; next : for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char [ ] name = simpleNames [ i ] ; int sLength = name . length ; for ( int j = <NUM_LIT:0> , m = WellKnownSimpleNames . length ; j < m ; j ++ ) { char [ ] wellKnownName = WellKnownSimpleNames [ j ] ; if ( sLength > wellKnownName . length ) break ; if ( CharOperation . equals ( name , wellKnownName ) ) { if ( ! removeWellKnown ) keepers [ index ++ ] = WellKnownSimpleNames [ j ] ; continue next ; } } NameSet internedNames = InternedSimpleNames [ sLength < MaxSimpleNames ? sLength : <NUM_LIT:0> ] ; keepers [ index ++ ] = internedNames . add ( name ) ; } if ( length > index ) { if ( index == <NUM_LIT:0> ) return EmptySimpleNames ; System . arraycopy ( keepers , <NUM_LIT:0> , keepers = new char [ index ] [ ] , <NUM_LIT:0> , index ) ; } return keepers ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFormatException ; import org . eclipse . jdt . internal . compiler . env . AccessRuleSet ; import org . eclipse . jdt . internal . compiler . env . NameEnvironmentAnswer ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . compiler . util . SimpleSet ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . util . Util ; import java . io . * ; import java . util . * ; import java . util . zip . * ; public class ClasspathJar extends ClasspathLocation { static class PackageCacheEntry { long lastModified ; long fileSize ; SimpleSet packageSet ; PackageCacheEntry ( long lastModified , long fileSize , SimpleSet packageSet ) { this . lastModified = lastModified ; this . fileSize = fileSize ; this . packageSet = packageSet ; } } static SimpleLookupTable PackageCache = new SimpleLookupTable ( ) ; static SimpleSet findPackageSet ( ClasspathJar jar ) { String zipFileName = jar . zipFilename ; long lastModified = jar . lastModified ( ) ; long fileSize = new File ( zipFileName ) . length ( ) ; PackageCacheEntry cacheEntry = ( PackageCacheEntry ) PackageCache . get ( zipFileName ) ; if ( cacheEntry != null && cacheEntry . lastModified == lastModified && cacheEntry . fileSize == fileSize ) return cacheEntry . packageSet ; SimpleSet packageSet = new SimpleSet ( <NUM_LIT> ) ; packageSet . add ( "<STR_LIT>" ) ; nextEntry : for ( Enumeration e = jar . zipFile . entries ( ) ; e . hasMoreElements ( ) ; ) { String fileName = ( ( ZipEntry ) e . nextElement ( ) ) . getName ( ) ; int last = fileName . lastIndexOf ( '<CHAR_LIT:/>' ) ; while ( last > <NUM_LIT:0> ) { String packageName = fileName . substring ( <NUM_LIT:0> , last ) ; if ( packageSet . addIfNotIncluded ( packageName ) == null ) continue nextEntry ; last = packageName . lastIndexOf ( '<CHAR_LIT:/>' ) ; } } PackageCache . put ( zipFileName , new PackageCacheEntry ( lastModified , fileSize , packageSet ) ) ; return packageSet ; } String zipFilename ; IFile resource ; ZipFile zipFile ; long lastModified ; boolean closeZipFileAtEnd ; SimpleSet knownPackageNames ; AccessRuleSet accessRuleSet ; ClasspathJar ( IFile resource , AccessRuleSet accessRuleSet ) { this . resource = resource ; try { java . net . URI location = resource . getLocationURI ( ) ; if ( location == null ) { this . zipFilename = "<STR_LIT>" ; } else { File localFile = Util . toLocalFile ( location , null ) ; this . zipFilename = localFile . getPath ( ) ; } } catch ( CoreException e ) { } this . zipFile = null ; this . knownPackageNames = null ; this . accessRuleSet = accessRuleSet ; } ClasspathJar ( String zipFilename , long lastModified , AccessRuleSet accessRuleSet ) { this . zipFilename = zipFilename ; this . lastModified = lastModified ; this . zipFile = null ; this . knownPackageNames = null ; this . accessRuleSet = accessRuleSet ; } public ClasspathJar ( ZipFile zipFile , AccessRuleSet accessRuleSet ) { this . zipFilename = zipFile . getName ( ) ; this . zipFile = zipFile ; this . closeZipFileAtEnd = false ; this . knownPackageNames = null ; this . accessRuleSet = accessRuleSet ; } public void cleanup ( ) { if ( this . zipFile != null && this . closeZipFileAtEnd ) { try { this . zipFile . close ( ) ; } catch ( IOException e ) { } this . zipFile = null ; } this . knownPackageNames = null ; } public boolean equals ( Object o ) { if ( this == o ) return true ; if ( ! ( o instanceof ClasspathJar ) ) return false ; ClasspathJar jar = ( ClasspathJar ) o ; if ( this . accessRuleSet != jar . accessRuleSet ) if ( this . accessRuleSet == null || ! this . accessRuleSet . equals ( jar . accessRuleSet ) ) return false ; return this . zipFilename . equals ( jar . zipFilename ) && lastModified ( ) == jar . lastModified ( ) ; } public NameEnvironmentAnswer findClass ( String binaryFileName , String qualifiedPackageName , String qualifiedBinaryFileName ) { if ( ! isPackage ( qualifiedPackageName ) ) return null ; try { ClassFileReader reader = ClassFileReader . read ( this . zipFile , qualifiedBinaryFileName ) ; if ( reader != null ) { if ( this . accessRuleSet == null ) return new NameEnvironmentAnswer ( reader , null ) ; String fileNameWithoutExtension = qualifiedBinaryFileName . substring ( <NUM_LIT:0> , qualifiedBinaryFileName . length ( ) - SuffixConstants . SUFFIX_CLASS . length ) ; return new NameEnvironmentAnswer ( reader , this . accessRuleSet . getViolatedRestriction ( fileNameWithoutExtension . toCharArray ( ) ) ) ; } } catch ( IOException e ) { } catch ( ClassFormatException e ) { } return null ; } public IPath getProjectRelativePath ( ) { if ( this . resource == null ) return null ; return this . resource . getProjectRelativePath ( ) ; } public int hashCode ( ) { return this . zipFilename == null ? super . hashCode ( ) : this . zipFilename . hashCode ( ) ; } public boolean isPackage ( String qualifiedPackageName ) { if ( this . knownPackageNames != null ) return this . knownPackageNames . includes ( qualifiedPackageName ) ; try { if ( this . zipFile == null ) { if ( org . eclipse . jdt . internal . core . JavaModelManager . ZIP_ACCESS_VERBOSE ) { System . out . println ( "<STR_LIT:(>" + Thread . currentThread ( ) + "<STR_LIT>" + this . zipFilename ) ; } this . zipFile = new ZipFile ( this . zipFilename ) ; this . closeZipFileAtEnd = true ; } this . knownPackageNames = findPackageSet ( this ) ; } catch ( Exception e ) { this . knownPackageNames = new SimpleSet ( ) ; } return this . knownPackageNames . includes ( qualifiedPackageName ) ; } public long lastModified ( ) { if ( this . lastModified == <NUM_LIT:0> ) this . lastModified = new File ( this . zipFilename ) . lastModified ( ) ; return this . lastModified ; } public String toString ( ) { String start = "<STR_LIT>" + this . zipFilename ; if ( this . accessRuleSet == null ) return start ; return start + "<STR_LIT>" + this . accessRuleSet ; } public String debugPathString ( ) { long time = lastModified ( ) ; if ( time == <NUM_LIT:0> ) return this . zipFilename ; return this . zipFilename + '<CHAR_LIT:(>' + ( new Date ( time ) ) + "<STR_LIT:U+0020:U+0020>" + time + '<CHAR_LIT:)>' ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . runtime . * ; public class ImageBuilderInternalException extends RuntimeException { private static final long serialVersionUID = <NUM_LIT> ; protected CoreException coreException ; public ImageBuilderInternalException ( CoreException e ) { this . coreException = e ; } public CoreException getThrowable ( ) { return this . coreException ; } public void printStackTrace ( ) { if ( this . coreException != null ) { System . err . println ( this ) ; System . err . println ( "<STR_LIT>" ) ; this . coreException . printStackTrace ( ) ; } else { super . printStackTrace ( ) ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . jdt . core . compiler . CharOperation ; public final class NameSet { public char [ ] [ ] names ; public int elementSize ; public int threshold ; public NameSet ( int size ) { this . elementSize = <NUM_LIT:0> ; this . threshold = size ; int extraRoom = ( int ) ( size * <NUM_LIT> ) ; if ( this . threshold == extraRoom ) extraRoom ++ ; this . names = new char [ extraRoom ] [ ] ; } public char [ ] add ( char [ ] name ) { int length = this . names . length ; int index = CharOperation . hashCode ( name ) % length ; char [ ] current ; while ( ( current = this . names [ index ] ) != null ) { if ( CharOperation . equals ( current , name ) ) return current ; if ( ++ index == length ) index = <NUM_LIT:0> ; } this . names [ index ] = name ; if ( ++ this . elementSize > this . threshold ) rehash ( ) ; return name ; } private void rehash ( ) { NameSet newSet = new NameSet ( this . elementSize * <NUM_LIT:2> ) ; char [ ] current ; for ( int i = this . names . length ; -- i >= <NUM_LIT:0> ; ) if ( ( current = this . names [ i ] ) != null ) newSet . add ( current ) ; this . names = newSet . names ; this . elementSize = newSet . elementSize ; this . threshold = newSet . threshold ; } public String toString ( ) { String s = "<STR_LIT>" ; char [ ] name ; for ( int i = <NUM_LIT:0> , l = this . names . length ; i < l ; i ++ ) if ( ( name = this . names [ i ] ) != null ) s += new String ( name ) + "<STR_LIT:n>" ; return s ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . internal . compiler . env . AccessRuleSet ; import org . eclipse . jdt . internal . compiler . env . NameEnvironmentAnswer ; public abstract class ClasspathLocation { static ClasspathLocation forSourceFolder ( IContainer sourceFolder , IContainer outputFolder , char [ ] [ ] inclusionPatterns , char [ ] [ ] exclusionPatterns , boolean ignoreOptionalProblems ) { return new ClasspathMultiDirectory ( sourceFolder , outputFolder , inclusionPatterns , exclusionPatterns , ignoreOptionalProblems ) ; } public static ClasspathLocation forBinaryFolder ( IContainer binaryFolder , boolean isOutputFolder , AccessRuleSet accessRuleSet ) { return new ClasspathDirectory ( binaryFolder , isOutputFolder , accessRuleSet ) ; } static ClasspathLocation forLibrary ( String libraryPathname , long lastModified , AccessRuleSet accessRuleSet ) { return new ClasspathJar ( libraryPathname , lastModified , accessRuleSet ) ; } static ClasspathLocation forLibrary ( String libraryPathname , AccessRuleSet accessRuleSet ) { return forLibrary ( libraryPathname , <NUM_LIT:0> , accessRuleSet ) ; } static ClasspathLocation forLibrary ( IFile library , AccessRuleSet accessRuleSet ) { return new ClasspathJar ( library , accessRuleSet ) ; } public abstract NameEnvironmentAnswer findClass ( String binaryFileName , String qualifiedPackageName , String qualifiedBinaryFileName ) ; public abstract IPath getProjectRelativePath ( ) ; public boolean isOutputFolder ( ) { return false ; } public abstract boolean isPackage ( String qualifiedPackageName ) ; public void cleanup ( ) { } public void reset ( ) { } public abstract String debugPathString ( ) ; } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; 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 . compiler . env . * ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . compiler . util . SimpleSet ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . * ; import java . io . * ; import java . util . * ; public class NameEnvironment implements INameEnvironment , SuffixConstants { boolean isIncrementalBuild ; ClasspathMultiDirectory [ ] sourceLocations ; ClasspathLocation [ ] binaryLocations ; BuildNotifier notifier ; SimpleSet initialTypeNames ; SimpleLookupTable additionalUnits ; NameEnvironment ( IWorkspaceRoot root , JavaProject javaProject , SimpleLookupTable binaryLocationsPerProject , BuildNotifier notifier ) throws CoreException { this . isIncrementalBuild = false ; this . notifier = notifier ; computeClasspathLocations ( root , javaProject , binaryLocationsPerProject ) ; setNames ( null , null ) ; } public NameEnvironment ( IJavaProject javaProject ) { this . isIncrementalBuild = false ; try { computeClasspathLocations ( javaProject . getProject ( ) . getWorkspace ( ) . getRoot ( ) , ( JavaProject ) javaProject , null ) ; } catch ( CoreException e ) { this . sourceLocations = new ClasspathMultiDirectory [ <NUM_LIT:0> ] ; this . binaryLocations = new ClasspathLocation [ <NUM_LIT:0> ] ; } setNames ( null , null ) ; } private void computeClasspathLocations ( IWorkspaceRoot root , JavaProject javaProject , SimpleLookupTable binaryLocationsPerProject ) throws CoreException { IMarker cycleMarker = javaProject . getCycleMarker ( ) ; if ( cycleMarker != null ) { int severity = JavaCore . ERROR . equals ( javaProject . getOption ( JavaCore . CORE_CIRCULAR_CLASSPATH , true ) ) ? IMarker . SEVERITY_ERROR : IMarker . SEVERITY_WARNING ; if ( severity != cycleMarker . getAttribute ( IMarker . SEVERITY , severity ) ) cycleMarker . setAttribute ( IMarker . SEVERITY , severity ) ; } IClasspathEntry [ ] classpathEntries = javaProject . getExpandedClasspath ( ) ; ArrayList sLocations = new ArrayList ( classpathEntries . length ) ; ArrayList bLocations = new ArrayList ( classpathEntries . length ) ; nextEntry : for ( int i = <NUM_LIT:0> , l = classpathEntries . length ; i < l ; i ++ ) { ClasspathEntry entry = ( ClasspathEntry ) classpathEntries [ i ] ; IPath path = entry . getPath ( ) ; Object target = JavaModel . getTarget ( path , true ) ; if ( target == null ) continue nextEntry ; switch ( entry . getEntryKind ( ) ) { case IClasspathEntry . CPE_SOURCE : if ( ! ( target instanceof IContainer ) ) continue nextEntry ; IPath outputPath = entry . getOutputLocation ( ) != null ? entry . getOutputLocation ( ) : javaProject . getOutputLocation ( ) ; IContainer outputFolder ; if ( outputPath . segmentCount ( ) == <NUM_LIT:1> ) { outputFolder = javaProject . getProject ( ) ; } else { outputFolder = root . getFolder ( outputPath ) ; if ( ! outputFolder . exists ( ) ) createOutputFolder ( outputFolder ) ; } sLocations . add ( ClasspathLocation . forSourceFolder ( ( IContainer ) target , outputFolder , entry . fullInclusionPatternChars ( ) , entry . fullExclusionPatternChars ( ) , entry . ignoreOptionalProblems ( ) ) ) ; continue nextEntry ; case IClasspathEntry . CPE_PROJECT : if ( ! ( target instanceof IProject ) ) continue nextEntry ; IProject prereqProject = ( IProject ) target ; if ( ! JavaProject . hasJavaNature ( prereqProject ) ) continue nextEntry ; JavaProject prereqJavaProject = ( JavaProject ) JavaCore . create ( prereqProject ) ; IClasspathEntry [ ] prereqClasspathEntries = prereqJavaProject . getRawClasspath ( ) ; ArrayList seen = new ArrayList ( ) ; nextPrereqEntry : for ( int j = <NUM_LIT:0> , m = prereqClasspathEntries . length ; j < m ; j ++ ) { IClasspathEntry prereqEntry = prereqClasspathEntries [ j ] ; if ( prereqEntry . getEntryKind ( ) == IClasspathEntry . CPE_SOURCE ) { Object prereqTarget = JavaModel . getTarget ( prereqEntry . getPath ( ) , true ) ; if ( ! ( prereqTarget instanceof IContainer ) ) continue nextPrereqEntry ; IPath prereqOutputPath = prereqEntry . getOutputLocation ( ) != null ? prereqEntry . getOutputLocation ( ) : prereqJavaProject . getOutputLocation ( ) ; IContainer binaryFolder = prereqOutputPath . segmentCount ( ) == <NUM_LIT:1> ? ( IContainer ) prereqProject : ( IContainer ) root . getFolder ( prereqOutputPath ) ; if ( binaryFolder . exists ( ) && ! seen . contains ( binaryFolder ) ) { seen . add ( binaryFolder ) ; ClasspathLocation bLocation = ClasspathLocation . forBinaryFolder ( binaryFolder , true , entry . getAccessRuleSet ( ) ) ; bLocations . add ( bLocation ) ; if ( binaryLocationsPerProject != null ) { ClasspathLocation [ ] existingLocations = ( ClasspathLocation [ ] ) binaryLocationsPerProject . get ( prereqProject ) ; if ( existingLocations == null ) { existingLocations = new ClasspathLocation [ ] { bLocation } ; } else { int size = existingLocations . length ; System . arraycopy ( existingLocations , <NUM_LIT:0> , existingLocations = new ClasspathLocation [ size + <NUM_LIT:1> ] , <NUM_LIT:0> , size ) ; existingLocations [ size ] = bLocation ; } binaryLocationsPerProject . put ( prereqProject , existingLocations ) ; } } } } continue nextEntry ; case IClasspathEntry . CPE_LIBRARY : if ( target instanceof IResource ) { IResource resource = ( IResource ) target ; ClasspathLocation bLocation = null ; if ( resource instanceof IFile ) { AccessRuleSet accessRuleSet = ( JavaCore . IGNORE . equals ( javaProject . getOption ( JavaCore . COMPILER_PB_FORBIDDEN_REFERENCE , true ) ) && JavaCore . IGNORE . equals ( javaProject . getOption ( JavaCore . COMPILER_PB_DISCOURAGED_REFERENCE , true ) ) ) ? null : entry . getAccessRuleSet ( ) ; bLocation = ClasspathLocation . forLibrary ( ( IFile ) resource , accessRuleSet ) ; } else if ( resource instanceof IContainer ) { AccessRuleSet accessRuleSet = ( JavaCore . IGNORE . equals ( javaProject . getOption ( JavaCore . COMPILER_PB_FORBIDDEN_REFERENCE , true ) ) && JavaCore . IGNORE . equals ( javaProject . getOption ( JavaCore . COMPILER_PB_DISCOURAGED_REFERENCE , true ) ) ) ? null : entry . getAccessRuleSet ( ) ; bLocation = ClasspathLocation . forBinaryFolder ( ( IContainer ) target , false , accessRuleSet ) ; } bLocations . add ( bLocation ) ; if ( binaryLocationsPerProject != null ) { IProject p = resource . getProject ( ) ; ClasspathLocation [ ] existingLocations = ( ClasspathLocation [ ] ) binaryLocationsPerProject . get ( p ) ; if ( existingLocations == null ) { existingLocations = new ClasspathLocation [ ] { bLocation } ; } else { int size = existingLocations . length ; System . arraycopy ( existingLocations , <NUM_LIT:0> , existingLocations = new ClasspathLocation [ size + <NUM_LIT:1> ] , <NUM_LIT:0> , size ) ; existingLocations [ size ] = bLocation ; } binaryLocationsPerProject . put ( p , existingLocations ) ; } } else if ( target instanceof File ) { AccessRuleSet accessRuleSet = ( JavaCore . IGNORE . equals ( javaProject . getOption ( JavaCore . COMPILER_PB_FORBIDDEN_REFERENCE , true ) ) && JavaCore . IGNORE . equals ( javaProject . getOption ( JavaCore . COMPILER_PB_DISCOURAGED_REFERENCE , true ) ) ) ? null : entry . getAccessRuleSet ( ) ; bLocations . add ( ClasspathLocation . forLibrary ( path . toString ( ) , accessRuleSet ) ) ; } continue nextEntry ; } } ArrayList outputFolders = new ArrayList ( <NUM_LIT:1> ) ; this . sourceLocations = new ClasspathMultiDirectory [ sLocations . size ( ) ] ; if ( ! sLocations . isEmpty ( ) ) { sLocations . toArray ( this . sourceLocations ) ; next : for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) { ClasspathMultiDirectory md = this . sourceLocations [ i ] ; IPath outputPath = md . binaryFolder . getFullPath ( ) ; for ( int j = <NUM_LIT:0> ; j < i ; j ++ ) { if ( outputPath . equals ( this . sourceLocations [ j ] . binaryFolder . getFullPath ( ) ) ) { md . hasIndependentOutputFolder = this . sourceLocations [ j ] . hasIndependentOutputFolder ; continue next ; } } outputFolders . add ( md ) ; for ( int j = <NUM_LIT:0> , m = this . sourceLocations . length ; j < m ; j ++ ) if ( outputPath . equals ( this . sourceLocations [ j ] . sourceFolder . getFullPath ( ) ) ) continue next ; md . hasIndependentOutputFolder = true ; } } this . binaryLocations = new ClasspathLocation [ outputFolders . size ( ) + bLocations . size ( ) ] ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , l = outputFolders . size ( ) ; i < l ; i ++ ) this . binaryLocations [ index ++ ] = ( ClasspathLocation ) outputFolders . get ( i ) ; for ( int i = <NUM_LIT:0> , l = bLocations . size ( ) ; i < l ; i ++ ) this . binaryLocations [ index ++ ] = ( ClasspathLocation ) bLocations . get ( i ) ; } public void cleanup ( ) { this . initialTypeNames = null ; this . additionalUnits = null ; for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) this . sourceLocations [ i ] . cleanup ( ) ; for ( int i = <NUM_LIT:0> , l = this . binaryLocations . length ; i < l ; i ++ ) this . binaryLocations [ i ] . cleanup ( ) ; } private void createOutputFolder ( IContainer outputFolder ) throws CoreException { createParentFolder ( outputFolder . getParent ( ) ) ; ( ( IFolder ) outputFolder ) . create ( IResource . FORCE | IResource . DERIVED , true , null ) ; } private void createParentFolder ( IContainer parent ) throws CoreException { if ( ! parent . exists ( ) ) { createParentFolder ( parent . getParent ( ) ) ; ( ( IFolder ) parent ) . create ( true , true , null ) ; } } private NameEnvironmentAnswer findClass ( String qualifiedTypeName , char [ ] typeName ) { if ( this . notifier != null ) this . notifier . checkCancelWithinCompiler ( ) ; if ( this . initialTypeNames != null && this . initialTypeNames . includes ( qualifiedTypeName ) ) { if ( this . isIncrementalBuild ) throw new AbortCompilation ( true , new AbortIncrementalBuildException ( qualifiedTypeName ) ) ; return null ; } if ( this . additionalUnits != null && this . sourceLocations . length > <NUM_LIT:0> ) { int index = qualifiedTypeName . indexOf ( '<CHAR_LIT>' ) ; if ( index > <NUM_LIT:0> ) { String enclosingTypeName = qualifiedTypeName . substring ( <NUM_LIT:0> , index ) ; SourceFile unit = ( SourceFile ) this . additionalUnits . get ( enclosingTypeName ) ; if ( unit != null ) return new NameEnvironmentAnswer ( unit , null ) ; } SourceFile unit = ( SourceFile ) this . additionalUnits . get ( qualifiedTypeName ) ; if ( unit != null ) return new NameEnvironmentAnswer ( unit , null ) ; } String qBinaryFileName = qualifiedTypeName + SUFFIX_STRING_class ; String binaryFileName = qBinaryFileName ; String qPackageName = "<STR_LIT>" ; if ( qualifiedTypeName . length ( ) > typeName . length ) { int typeNameStart = qBinaryFileName . length ( ) - typeName . length - <NUM_LIT:6> ; qPackageName = qBinaryFileName . substring ( <NUM_LIT:0> , typeNameStart - <NUM_LIT:1> ) ; binaryFileName = qBinaryFileName . substring ( typeNameStart ) ; } NameEnvironmentAnswer suggestedAnswer = null ; for ( int i = <NUM_LIT:0> , l = this . binaryLocations . length ; i < l ; i ++ ) { NameEnvironmentAnswer answer = this . binaryLocations [ i ] . findClass ( binaryFileName , qPackageName , qBinaryFileName ) ; if ( answer != null ) { if ( ! answer . ignoreIfBetter ( ) ) { if ( answer . isBetter ( suggestedAnswer ) ) return answer ; } else if ( answer . isBetter ( suggestedAnswer ) ) suggestedAnswer = answer ; } } if ( suggestedAnswer != null ) return suggestedAnswer ; return null ; } public NameEnvironmentAnswer findType ( char [ ] [ ] compoundName ) { if ( compoundName != null ) return findClass ( new String ( CharOperation . concatWith ( compoundName , '<CHAR_LIT:/>' ) ) , compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; return null ; } public NameEnvironmentAnswer findType ( char [ ] typeName , char [ ] [ ] packageName ) { if ( typeName != null ) return findClass ( new String ( CharOperation . concatWith ( packageName , typeName , '<CHAR_LIT:/>' ) ) , typeName ) ; return null ; } public boolean isPackage ( char [ ] [ ] compoundName , char [ ] packageName ) { return isPackage ( new String ( CharOperation . concatWith ( compoundName , packageName , '<CHAR_LIT:/>' ) ) ) ; } public boolean isPackage ( String qualifiedPackageName ) { for ( int i = <NUM_LIT:0> , l = this . binaryLocations . length ; i < l ; i ++ ) if ( this . binaryLocations [ i ] . isPackage ( qualifiedPackageName ) ) return true ; return false ; } void setNames ( String [ ] typeNames , SourceFile [ ] additionalFiles ) { if ( typeNames == null ) { this . initialTypeNames = null ; } else { this . initialTypeNames = new SimpleSet ( typeNames . length ) ; for ( int i = <NUM_LIT:0> , l = typeNames . length ; i < l ; i ++ ) this . initialTypeNames . add ( typeNames [ i ] ) ; } if ( additionalFiles == null ) { this . additionalUnits = null ; } else { this . additionalUnits = new SimpleLookupTable ( additionalFiles . length ) ; for ( int i = <NUM_LIT:0> , l = additionalFiles . length ; i < l ; i ++ ) { SourceFile additionalUnit = additionalFiles [ i ] ; if ( additionalUnit != null ) this . additionalUnits . put ( additionalUnit . initialTypeName , additionalFiles [ i ] ) ; } } for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) this . sourceLocations [ i ] . reset ( ) ; for ( int i = <NUM_LIT:0> , l = this . binaryLocations . length ; i < l ; i ++ ) this . binaryLocations [ i ] . reset ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . runtime . * ; import org . eclipse . core . resources . * ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . core . util . CompilerUtils ; import org . eclipse . jdt . internal . compiler . * ; import org . eclipse . jdt . internal . compiler . Compiler ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . problem . * ; import org . eclipse . jdt . internal . compiler . util . SimpleSet ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . JavaModelManager ; import org . eclipse . jdt . internal . core . PackageFragment ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; import java . io . * ; import java . util . * ; public abstract class AbstractImageBuilder implements ICompilerRequestor , ICompilationUnitLocator { protected JavaBuilder javaBuilder ; protected State newState ; protected NameEnvironment nameEnvironment ; protected ClasspathMultiDirectory [ ] sourceLocations ; public BuildNotifier notifier ; protected Compiler compiler ; protected WorkQueue workQueue ; protected ArrayList problemSourceFiles ; protected boolean compiledAllAtOnce ; private boolean inCompiler ; protected boolean keepStoringProblemMarkers ; protected SimpleSet filesWithAnnotations = null ; public static int MAX_AT_ONCE = <NUM_LIT> ; public final static String [ ] JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES = { IMarker . MESSAGE , IMarker . SEVERITY , IJavaModelMarker . ID , IMarker . CHAR_START , IMarker . CHAR_END , IMarker . LINE_NUMBER , IJavaModelMarker . ARGUMENTS , IJavaModelMarker . CATEGORY_ID , } ; public final static String [ ] JAVA_TASK_MARKER_ATTRIBUTE_NAMES = { IMarker . MESSAGE , IMarker . PRIORITY , IJavaModelMarker . ID , IMarker . CHAR_START , IMarker . CHAR_END , IMarker . LINE_NUMBER , IMarker . USER_EDITABLE , IMarker . SOURCE_ID , } ; public final static Integer S_ERROR = new Integer ( IMarker . SEVERITY_ERROR ) ; public final static Integer S_WARNING = new Integer ( IMarker . SEVERITY_WARNING ) ; public final static Integer P_HIGH = new Integer ( IMarker . PRIORITY_HIGH ) ; public final static Integer P_NORMAL = new Integer ( IMarker . PRIORITY_NORMAL ) ; public final static Integer P_LOW = new Integer ( IMarker . PRIORITY_LOW ) ; protected AbstractImageBuilder ( JavaBuilder javaBuilder , boolean buildStarting , State newState ) { this . javaBuilder = javaBuilder ; this . nameEnvironment = javaBuilder . nameEnvironment ; this . sourceLocations = this . nameEnvironment . sourceLocations ; this . notifier = javaBuilder . notifier ; this . keepStoringProblemMarkers = true ; if ( buildStarting ) { this . newState = newState == null ? new State ( javaBuilder ) : newState ; this . compiler = newCompiler ( ) ; this . workQueue = new WorkQueue ( ) ; this . problemSourceFiles = new ArrayList ( <NUM_LIT:3> ) ; if ( this . javaBuilder . participants != null ) { for ( int i = <NUM_LIT:0> , l = this . javaBuilder . participants . length ; i < l ; i ++ ) { if ( this . javaBuilder . participants [ i ] . isAnnotationProcessor ( ) ) { this . filesWithAnnotations = new SimpleSet ( <NUM_LIT:1> ) ; break ; } } } } } public void acceptResult ( CompilationResult result ) { SourceFile compilationUnit = ( SourceFile ) result . getCompilationUnit ( ) ; if ( ! this . workQueue . isCompiled ( compilationUnit ) ) { this . workQueue . finished ( compilationUnit ) ; try { updateProblemsFor ( compilationUnit , result ) ; updateTasksFor ( compilationUnit , result ) ; } catch ( CoreException e ) { throw internalException ( e ) ; } if ( result . hasInconsistentToplevelHierarchies ) if ( ! this . problemSourceFiles . contains ( compilationUnit ) ) this . problemSourceFiles . add ( compilationUnit ) ; IType mainType = null ; String mainTypeName = null ; String typeLocator = compilationUnit . typeLocator ( ) ; ClassFile [ ] classFiles = result . getClassFiles ( ) ; int length = classFiles . length ; ArrayList duplicateTypeNames = null ; ArrayList definedTypeNames = new ArrayList ( length ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ClassFile classFile = classFiles [ i ] ; char [ ] [ ] compoundName = classFile . getCompoundName ( ) ; char [ ] typeName = compoundName [ compoundName . length - <NUM_LIT:1> ] ; boolean isNestedType = classFile . isNestedType ; if ( isNestedType ) { String qualifiedTypeName = new String ( classFile . outerMostEnclosingClassFile ( ) . fileName ( ) ) ; if ( this . newState . isDuplicateLocator ( qualifiedTypeName , typeLocator ) ) continue ; } else { String qualifiedTypeName = new String ( classFile . fileName ( ) ) ; if ( this . newState . isDuplicateLocator ( qualifiedTypeName , typeLocator ) ) { if ( duplicateTypeNames == null ) duplicateTypeNames = new ArrayList ( ) ; duplicateTypeNames . add ( compoundName ) ; if ( mainType == null ) { try { mainTypeName = compilationUnit . initialTypeName ; mainType = this . javaBuilder . javaProject . findType ( mainTypeName . replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ) ; } catch ( JavaModelException e ) { } } IType type ; if ( qualifiedTypeName . equals ( mainTypeName ) ) { type = mainType ; } else { String simpleName = qualifiedTypeName . substring ( qualifiedTypeName . lastIndexOf ( '<CHAR_LIT:/>' ) + <NUM_LIT:1> ) ; type = mainType == null ? null : mainType . getCompilationUnit ( ) . getType ( simpleName ) ; } createProblemFor ( compilationUnit . resource , type , Messages . bind ( Messages . build_duplicateClassFile , new String ( typeName ) ) , JavaCore . ERROR ) ; continue ; } this . newState . recordLocatorForType ( qualifiedTypeName , typeLocator ) ; if ( result . checkSecondaryTypes && ! qualifiedTypeName . equals ( compilationUnit . initialTypeName ) ) acceptSecondaryType ( classFile ) ; } try { definedTypeNames . add ( writeClassFile ( classFile , compilationUnit , ! isNestedType ) ) ; } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" ) ; if ( e . getStatus ( ) . getCode ( ) == IResourceStatus . CASE_VARIANT_EXISTS ) createProblemFor ( compilationUnit . resource , null , Messages . bind ( Messages . build_classFileCollision , e . getMessage ( ) ) , JavaCore . ERROR ) ; else createProblemFor ( compilationUnit . resource , null , Messages . build_inconsistentClassFile , JavaCore . ERROR ) ; } } if ( result . hasAnnotations && this . filesWithAnnotations != null ) this . filesWithAnnotations . add ( compilationUnit ) ; this . compiler . lookupEnvironment . releaseClassFiles ( classFiles ) ; finishedWith ( typeLocator , result , compilationUnit . getMainTypeName ( ) , definedTypeNames , duplicateTypeNames ) ; this . notifier . compiled ( compilationUnit ) ; } } protected void acceptSecondaryType ( ClassFile classFile ) { } protected void addAllSourceFiles ( final ArrayList sourceFiles ) throws CoreException { final boolean isInterestingProject = LanguageSupportFactory . isInterestingProject ( this . javaBuilder . getProject ( ) ) ; for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) { final ClasspathMultiDirectory sourceLocation = this . sourceLocations [ i ] ; final char [ ] [ ] exclusionPatterns = sourceLocation . exclusionPatterns ; final char [ ] [ ] inclusionPatterns = sourceLocation . inclusionPatterns ; final boolean isAlsoProject = sourceLocation . sourceFolder . equals ( this . javaBuilder . currentProject ) ; final int segmentCount = sourceLocation . sourceFolder . getFullPath ( ) . segmentCount ( ) ; final IContainer outputFolder = sourceLocation . binaryFolder ; final boolean isOutputFolder = sourceLocation . sourceFolder . equals ( outputFolder ) ; sourceLocation . sourceFolder . accept ( new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) throws CoreException { switch ( proxy . getType ( ) ) { case IResource . FILE : String resourceName = proxy . getName ( ) ; if ( ( ! isInterestingProject && org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( resourceName ) && ! LanguageSupportFactory . isInterestingSourceFile ( resourceName ) ) || ( isInterestingProject && LanguageSupportFactory . isSourceFile ( resourceName , isInterestingProject ) ) ) { IResource resource = proxy . requestResource ( ) ; if ( exclusionPatterns != null || inclusionPatterns != null ) if ( Util . isExcluded ( resource . getFullPath ( ) , inclusionPatterns , exclusionPatterns , false ) ) return false ; sourceFiles . add ( new SourceFile ( ( IFile ) resource , sourceLocation ) ) ; } return false ; case IResource . FOLDER : IPath folderPath = null ; if ( isAlsoProject ) if ( isExcludedFromProject ( folderPath = proxy . requestFullPath ( ) ) ) return false ; if ( exclusionPatterns != null ) { if ( folderPath == null ) folderPath = proxy . requestFullPath ( ) ; if ( Util . isExcluded ( folderPath , inclusionPatterns , exclusionPatterns , true ) ) { return inclusionPatterns != null ; } } if ( ! isOutputFolder ) { if ( folderPath == null ) folderPath = proxy . requestFullPath ( ) ; String packageName = folderPath . lastSegment ( ) ; if ( packageName . length ( ) > <NUM_LIT:0> ) { String sourceLevel = AbstractImageBuilder . this . javaBuilder . javaProject . getOption ( JavaCore . COMPILER_SOURCE , true ) ; String complianceLevel = AbstractImageBuilder . this . javaBuilder . javaProject . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ; if ( JavaConventions . validatePackageName ( packageName , sourceLevel , complianceLevel ) . getSeverity ( ) != IStatus . ERROR ) createFolder ( folderPath . removeFirstSegments ( segmentCount ) , outputFolder ) ; } } } return true ; } } , IResource . NONE ) ; this . notifier . checkCancel ( ) ; } } protected void cleanUp ( ) { this . nameEnvironment . cleanup ( ) ; this . javaBuilder = null ; this . nameEnvironment = null ; this . sourceLocations = null ; this . notifier = null ; this . compiler = null ; this . workQueue = null ; this . problemSourceFiles = null ; } protected void compile ( SourceFile [ ] units ) { if ( this . filesWithAnnotations != null && this . filesWithAnnotations . elementSize > <NUM_LIT:0> ) this . filesWithAnnotations . clear ( ) ; CompilationParticipantResult [ ] participantResults = this . javaBuilder . participants == null ? null : notifyParticipants ( units ) ; if ( participantResults != null && participantResults . length > units . length ) { units = new SourceFile [ participantResults . length ] ; for ( int i = participantResults . length ; -- i >= <NUM_LIT:0> ; ) units [ i ] = participantResults [ i ] . sourceFile ; } int unitsLength = units . length ; this . compiledAllAtOnce = unitsLength <= MAX_AT_ONCE ; if ( this . compiler != null && this . compiler . options != null && this . compiler . options . buildGroovyFiles == <NUM_LIT:2> ) { this . compiledAllAtOnce = true ; } if ( this . compiledAllAtOnce ) { if ( JavaBuilder . DEBUG ) for ( int i = <NUM_LIT:0> ; i < unitsLength ; i ++ ) System . out . println ( "<STR_LIT>" + units [ i ] . typeLocator ( ) ) ; compile ( units , null , true ) ; } else { SourceFile [ ] remainingUnits = new SourceFile [ unitsLength ] ; System . arraycopy ( units , <NUM_LIT:0> , remainingUnits , <NUM_LIT:0> , unitsLength ) ; int doNow = unitsLength < MAX_AT_ONCE ? unitsLength : MAX_AT_ONCE ; SourceFile [ ] toCompile = new SourceFile [ doNow ] ; int remainingIndex = <NUM_LIT:0> ; boolean compilingFirstGroup = true ; while ( remainingIndex < unitsLength ) { int count = <NUM_LIT:0> ; while ( remainingIndex < unitsLength && count < doNow ) { SourceFile unit = remainingUnits [ remainingIndex ] ; if ( unit != null && ( compilingFirstGroup || this . workQueue . isWaiting ( unit ) ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + remainingIndex + "<STR_LIT:U+0020:U+0020>" + unit . typeLocator ( ) ) ; toCompile [ count ++ ] = unit ; } remainingUnits [ remainingIndex ++ ] = null ; } if ( count < doNow ) System . arraycopy ( toCompile , <NUM_LIT:0> , toCompile = new SourceFile [ count ] , <NUM_LIT:0> , count ) ; if ( ! compilingFirstGroup ) for ( int a = remainingIndex ; a < unitsLength ; a ++ ) if ( remainingUnits [ a ] != null && this . workQueue . isCompiled ( remainingUnits [ a ] ) ) remainingUnits [ a ] = null ; compile ( toCompile , remainingUnits , compilingFirstGroup ) ; compilingFirstGroup = false ; } } if ( participantResults != null ) { for ( int i = participantResults . length ; -- i >= <NUM_LIT:0> ; ) if ( participantResults [ i ] != null ) recordParticipantResult ( participantResults [ i ] ) ; processAnnotations ( participantResults ) ; } } protected void compile ( SourceFile [ ] units , SourceFile [ ] additionalUnits , boolean compilingFirstGroup ) { if ( units . length == <NUM_LIT:0> ) return ; this . notifier . aboutToCompile ( units [ <NUM_LIT:0> ] ) ; if ( ! this . problemSourceFiles . isEmpty ( ) ) { int toAdd = this . problemSourceFiles . size ( ) ; int length = additionalUnits == null ? <NUM_LIT:0> : additionalUnits . length ; if ( length == <NUM_LIT:0> ) additionalUnits = new SourceFile [ toAdd ] ; else System . arraycopy ( additionalUnits , <NUM_LIT:0> , additionalUnits = new SourceFile [ length + toAdd ] , <NUM_LIT:0> , length ) ; for ( int i = <NUM_LIT:0> ; i < toAdd ; i ++ ) additionalUnits [ length + i ] = ( SourceFile ) this . problemSourceFiles . get ( i ) ; } String [ ] initialTypeNames = new String [ units . length ] ; for ( int i = <NUM_LIT:0> , l = units . length ; i < l ; i ++ ) initialTypeNames [ i ] = units [ i ] . initialTypeName ; this . nameEnvironment . setNames ( initialTypeNames , additionalUnits ) ; this . notifier . checkCancel ( ) ; try { this . inCompiler = true ; this . compiler . compile ( units ) ; } catch ( AbortCompilation ignored ) { } finally { this . inCompiler = false ; } this . notifier . checkCancel ( ) ; } protected void copyResource ( IResource source , IResource destination ) throws CoreException { IPath destPath = destination . getFullPath ( ) ; try { source . copy ( destPath , IResource . FORCE | IResource . DERIVED , null ) ; } catch ( CoreException e ) { source . refreshLocal ( <NUM_LIT:0> , null ) ; if ( ! source . exists ( ) ) return ; throw e ; } Util . setReadOnly ( destination , false ) ; } protected void createProblemFor ( IResource resource , IMember javaElement , String message , String problemSeverity ) { try { IMarker marker = resource . createMarker ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER ) ; int severity = problemSeverity . equals ( JavaCore . WARNING ) ? IMarker . SEVERITY_WARNING : IMarker . SEVERITY_ERROR ; ISourceRange range = null ; if ( javaElement != null ) { try { range = javaElement . getNameRange ( ) ; } catch ( JavaModelException e ) { if ( e . getJavaModelStatus ( ) . getCode ( ) != IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST ) { throw e ; } if ( ! CharOperation . equals ( javaElement . getElementName ( ) . toCharArray ( ) , TypeConstants . PACKAGE_INFO_NAME ) ) { throw e ; } } } int start = range == null ? <NUM_LIT:0> : range . getOffset ( ) ; int end = range == null ? <NUM_LIT:1> : start + range . getLength ( ) ; marker . setAttributes ( new String [ ] { IMarker . MESSAGE , IMarker . SEVERITY , IMarker . CHAR_START , IMarker . CHAR_END , IMarker . SOURCE_ID } , new Object [ ] { message , new Integer ( severity ) , new Integer ( start ) , new Integer ( end ) , JavaBuilder . SOURCE_ID } ) ; } catch ( CoreException e ) { throw internalException ( e ) ; } } protected void deleteGeneratedFiles ( IFile [ ] deletedGeneratedFiles ) { } protected SourceFile findSourceFile ( IFile file , boolean mustExist ) { if ( mustExist && ! file . exists ( ) ) return null ; ClasspathMultiDirectory md = this . sourceLocations [ <NUM_LIT:0> ] ; if ( this . sourceLocations . length > <NUM_LIT:1> ) { IPath sourceFileFullPath = file . getFullPath ( ) ; for ( int j = <NUM_LIT:0> , m = this . sourceLocations . length ; j < m ; j ++ ) { if ( this . sourceLocations [ j ] . sourceFolder . getFullPath ( ) . isPrefixOf ( sourceFileFullPath ) ) { md = this . sourceLocations [ j ] ; if ( md . exclusionPatterns == null && md . inclusionPatterns == null ) break ; if ( ! Util . isExcluded ( file , md . inclusionPatterns , md . exclusionPatterns ) ) break ; } } } return new SourceFile ( file , md ) ; } protected void finishedWith ( String sourceLocator , CompilationResult result , char [ ] mainTypeName , ArrayList definedTypeNames , ArrayList duplicateTypeNames ) { if ( duplicateTypeNames == null ) { this . newState . record ( sourceLocator , result . qualifiedReferences , result . simpleNameReferences , result . rootReferences , mainTypeName , definedTypeNames ) ; return ; } char [ ] [ ] simpleRefs = result . simpleNameReferences ; next : for ( int i = <NUM_LIT:0> , l = duplicateTypeNames . size ( ) ; i < l ; i ++ ) { char [ ] [ ] compoundName = ( char [ ] [ ] ) duplicateTypeNames . get ( i ) ; char [ ] typeName = compoundName [ compoundName . length - <NUM_LIT:1> ] ; int sLength = simpleRefs . length ; for ( int j = <NUM_LIT:0> ; j < sLength ; j ++ ) if ( CharOperation . equals ( simpleRefs [ j ] , typeName ) ) continue next ; System . arraycopy ( simpleRefs , <NUM_LIT:0> , simpleRefs = new char [ sLength + <NUM_LIT:1> ] [ ] , <NUM_LIT:0> , sLength ) ; simpleRefs [ sLength ] = typeName ; } this . newState . record ( sourceLocator , result . qualifiedReferences , simpleRefs , result . rootReferences , mainTypeName , definedTypeNames ) ; } protected IContainer createFolder ( IPath packagePath , IContainer outputFolder ) throws CoreException { if ( packagePath . isEmpty ( ) ) return outputFolder ; IFolder folder = outputFolder . getFolder ( packagePath ) ; if ( ! folder . exists ( ) ) { createFolder ( packagePath . removeLastSegments ( <NUM_LIT:1> ) , outputFolder ) ; folder . create ( IResource . FORCE | IResource . DERIVED , true , null ) ; } return folder ; } public ICompilationUnit fromIFile ( IFile file ) { return findSourceFile ( file , true ) ; } protected void initializeAnnotationProcessorManager ( Compiler newCompiler ) { AbstractAnnotationProcessorManager annotationManager = JavaModelManager . getJavaModelManager ( ) . createAnnotationProcessorManager ( ) ; if ( annotationManager != null ) { annotationManager . configureFromPlatform ( newCompiler , this , this . javaBuilder . javaProject ) ; annotationManager . setErr ( new PrintWriter ( System . err ) ) ; annotationManager . setOut ( new PrintWriter ( System . out ) ) ; } newCompiler . annotationProcessorManager = annotationManager ; } protected RuntimeException internalException ( CoreException t ) { ImageBuilderInternalException imageBuilderException = new ImageBuilderInternalException ( t ) ; if ( this . inCompiler ) return new AbortCompilation ( true , imageBuilderException ) ; return imageBuilderException ; } protected boolean isExcludedFromProject ( IPath childPath ) throws JavaModelException { if ( childPath . segmentCount ( ) > <NUM_LIT:2> ) return false ; for ( int j = <NUM_LIT:0> , k = this . sourceLocations . length ; j < k ; j ++ ) { if ( childPath . equals ( this . sourceLocations [ j ] . binaryFolder . getFullPath ( ) ) ) return true ; if ( childPath . equals ( this . sourceLocations [ j ] . sourceFolder . getFullPath ( ) ) ) return true ; } return childPath . equals ( this . javaBuilder . javaProject . getOutputLocation ( ) ) ; } protected Compiler newCompiler ( ) { Map projectOptions = this . javaBuilder . javaProject . getOptions ( true ) ; String option = ( String ) projectOptions . get ( JavaCore . COMPILER_PB_INVALID_JAVADOC ) ; if ( option == null || option . equals ( JavaCore . IGNORE ) ) { option = ( String ) projectOptions . get ( JavaCore . COMPILER_PB_MISSING_JAVADOC_TAGS ) ; if ( option == null || option . equals ( JavaCore . IGNORE ) ) { option = ( String ) projectOptions . get ( JavaCore . COMPILER_PB_MISSING_JAVADOC_COMMENTS ) ; if ( option == null || option . equals ( JavaCore . IGNORE ) ) { option = ( String ) projectOptions . get ( JavaCore . COMPILER_PB_UNUSED_IMPORT ) ; if ( option == null || option . equals ( JavaCore . IGNORE ) ) { projectOptions . put ( JavaCore . COMPILER_DOC_COMMENT_SUPPORT , JavaCore . DISABLED ) ; } } } } CompilerOptions compilerOptions = new CompilerOptions ( projectOptions ) ; compilerOptions . performMethodsFullRecovery = true ; compilerOptions . performStatementsRecovery = true ; CompilerUtils . configureOptionsBasedOnNature ( compilerOptions , this . javaBuilder . javaProject ) ; Compiler newCompiler = new Compiler ( this . nameEnvironment , DefaultErrorHandlingPolicies . proceedWithAllProblems ( ) , compilerOptions , this , ProblemFactory . getProblemFactory ( Locale . getDefault ( ) ) ) ; CompilerOptions options = newCompiler . options ; String setting = System . getProperty ( "<STR_LIT>" ) ; newCompiler . useSingleThread = setting != null && setting . equals ( "<STR_LIT:true>" ) ; options . produceReferenceInfo = true ; if ( options . complianceLevel >= ClassFileConstants . JDK1_6 && options . processAnnotations ) { initializeAnnotationProcessorManager ( newCompiler ) ; } return newCompiler ; } protected CompilationParticipantResult [ ] notifyParticipants ( SourceFile [ ] unitsAboutToCompile ) { CompilationParticipantResult [ ] results = new CompilationParticipantResult [ unitsAboutToCompile . length ] ; for ( int i = unitsAboutToCompile . length ; -- i >= <NUM_LIT:0> ; ) results [ i ] = new CompilationParticipantResult ( unitsAboutToCompile [ i ] ) ; for ( int i = <NUM_LIT:0> , l = this . javaBuilder . participants . length ; i < l ; i ++ ) this . javaBuilder . participants [ i ] . buildStarting ( results , this instanceof BatchImageBuilder ) ; SimpleSet uniqueFiles = null ; CompilationParticipantResult [ ] toAdd = null ; int added = <NUM_LIT:0> ; for ( int i = results . length ; -- i >= <NUM_LIT:0> ; ) { CompilationParticipantResult result = results [ i ] ; if ( result == null ) continue ; IFile [ ] deletedGeneratedFiles = result . deletedFiles ; if ( deletedGeneratedFiles != null ) deleteGeneratedFiles ( deletedGeneratedFiles ) ; IFile [ ] addedGeneratedFiles = result . addedFiles ; if ( addedGeneratedFiles != null ) { for ( int j = addedGeneratedFiles . length ; -- j >= <NUM_LIT:0> ; ) { SourceFile sourceFile = findSourceFile ( addedGeneratedFiles [ j ] , true ) ; if ( sourceFile == null ) continue ; if ( uniqueFiles == null ) { uniqueFiles = new SimpleSet ( unitsAboutToCompile . length + <NUM_LIT:3> ) ; for ( int f = unitsAboutToCompile . length ; -- f >= <NUM_LIT:0> ; ) uniqueFiles . add ( unitsAboutToCompile [ f ] ) ; } if ( uniqueFiles . addIfNotIncluded ( sourceFile ) == sourceFile ) { CompilationParticipantResult newResult = new CompilationParticipantResult ( sourceFile ) ; if ( toAdd == null ) { toAdd = new CompilationParticipantResult [ addedGeneratedFiles . length ] ; } else { int length = toAdd . length ; if ( added == length ) System . arraycopy ( toAdd , <NUM_LIT:0> , toAdd = new CompilationParticipantResult [ length + addedGeneratedFiles . length ] , <NUM_LIT:0> , length ) ; } toAdd [ added ++ ] = newResult ; } } } } if ( added > <NUM_LIT:0> ) { int length = results . length ; System . arraycopy ( results , <NUM_LIT:0> , results = new CompilationParticipantResult [ length + added ] , <NUM_LIT:0> , length ) ; System . arraycopy ( toAdd , <NUM_LIT:0> , results , length , added ) ; } return results ; } protected abstract void processAnnotationResults ( CompilationParticipantResult [ ] results ) ; protected void processAnnotations ( CompilationParticipantResult [ ] results ) { boolean hasAnnotationProcessor = false ; for ( int i = <NUM_LIT:0> , l = this . javaBuilder . participants . length ; ! hasAnnotationProcessor && i < l ; i ++ ) hasAnnotationProcessor = this . javaBuilder . participants [ i ] . isAnnotationProcessor ( ) ; if ( ! hasAnnotationProcessor ) return ; boolean foundAnnotations = this . filesWithAnnotations != null && this . filesWithAnnotations . elementSize > <NUM_LIT:0> ; for ( int i = results . length ; -- i >= <NUM_LIT:0> ; ) results [ i ] . reset ( foundAnnotations && this . filesWithAnnotations . includes ( results [ i ] . sourceFile ) ) ; for ( int i = <NUM_LIT:0> , l = this . javaBuilder . participants . length ; i < l ; i ++ ) if ( this . javaBuilder . participants [ i ] . isAnnotationProcessor ( ) ) this . javaBuilder . participants [ i ] . processAnnotations ( results ) ; processAnnotationResults ( results ) ; } protected void recordParticipantResult ( CompilationParticipantResult result ) { CategorizedProblem [ ] problems = result . problems ; if ( problems != null && problems . length > <NUM_LIT:0> ) { this . notifier . updateProblemCounts ( problems ) ; try { storeProblemsFor ( result . sourceFile , problems ) ; } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" ) ; } } String [ ] dependencies = result . dependencies ; if ( dependencies != null ) { ReferenceCollection refs = ( ReferenceCollection ) this . newState . references . get ( result . sourceFile . typeLocator ( ) ) ; if ( refs != null ) refs . addDependencies ( dependencies ) ; } } protected void storeProblemsFor ( SourceFile sourceFile , CategorizedProblem [ ] problems ) throws CoreException { if ( sourceFile == null || problems == null || problems . length == <NUM_LIT:0> ) return ; if ( ! this . keepStoringProblemMarkers ) return ; HashSet managedMarkerTypes = JavaModelManager . getJavaModelManager ( ) . compilationParticipants . managedMarkerTypes ( ) ; problems : for ( int i = <NUM_LIT:0> , l = problems . length ; i < l ; i ++ ) { CategorizedProblem problem = problems [ i ] ; int id = problem . getID ( ) ; IResource resource = sourceFile . resource ; if ( id == IProblem . IsClassPathCorrect ) { String missingClassfileName = problem . getArguments ( ) [ <NUM_LIT:0> ] ; if ( JavaBuilder . DEBUG ) System . out . println ( Messages . bind ( Messages . build_incompleteClassPath , missingClassfileName ) ) ; boolean isInvalidClasspathError = JavaCore . ERROR . equals ( this . javaBuilder . javaProject . getOption ( JavaCore . CORE_INCOMPLETE_CLASSPATH , true ) ) ; if ( isInvalidClasspathError && JavaCore . ABORT . equals ( this . javaBuilder . javaProject . getOption ( JavaCore . CORE_JAVA_BUILD_INVALID_CLASSPATH , true ) ) ) { JavaBuilder . removeProblemsAndTasksFor ( this . javaBuilder . currentProject ) ; this . keepStoringProblemMarkers = false ; } IMarker marker = this . javaBuilder . currentProject . createMarker ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER ) ; marker . setAttributes ( new String [ ] { IMarker . MESSAGE , IMarker . SEVERITY , IJavaModelMarker . CATEGORY_ID , IMarker . SOURCE_ID } , new Object [ ] { Messages . bind ( Messages . build_incompleteClassPath , missingClassfileName ) , new Integer ( isInvalidClasspathError ? IMarker . SEVERITY_ERROR : IMarker . SEVERITY_WARNING ) , new Integer ( CategorizedProblem . CAT_BUILDPATH ) , JavaBuilder . SOURCE_ID } ) ; } String markerType = problem . getMarkerType ( ) ; boolean managedProblem = false ; if ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER . equals ( markerType ) || ( managedProblem = managedMarkerTypes . contains ( markerType ) ) ) { if ( id == IProblem . MissingNonNullByDefaultAnnotationOnPackage && ! ( CharOperation . equals ( sourceFile . getMainTypeName ( ) , TypeConstants . PACKAGE_INFO_NAME ) ) ) { char [ ] fileName = sourceFile . getFileName ( ) ; int pkgEnd = CharOperation . lastIndexOf ( '<CHAR_LIT:/>' , fileName ) ; if ( pkgEnd == - <NUM_LIT:1> ) pkgEnd = CharOperation . lastIndexOf ( File . separatorChar , fileName ) ; PackageFragment pkg = null ; if ( pkgEnd != - <NUM_LIT:1> ) pkg = ( PackageFragment ) Util . getPackageFragment ( sourceFile . getFileName ( ) , pkgEnd , - <NUM_LIT:1> ) ; if ( pkg != null ) { try { IMarker [ ] existingMarkers = pkg . resource ( ) . findMarkers ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER , false , IResource . DEPTH_ZERO ) ; int len = existingMarkers . length ; for ( int j = <NUM_LIT:0> ; j < len ; j ++ ) { if ( ( ( Integer ) existingMarkers [ j ] . getAttribute ( IJavaModelMarker . ID ) ) . intValue ( ) == IProblem . MissingNonNullByDefaultAnnotationOnPackage ) { continue problems ; } } } catch ( CoreException e ) { if ( JavaModelManager . VERBOSE ) { e . printStackTrace ( ) ; } } IResource tempRes = pkg . resource ( ) ; if ( tempRes != null ) { resource = tempRes ; } } } IMarker marker = resource . createMarker ( markerType ) ; String [ ] attributeNames = JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES ; int standardLength = attributeNames . length ; String [ ] allNames = attributeNames ; int managedLength = managedProblem ? <NUM_LIT:0> : <NUM_LIT:1> ; String [ ] extraAttributeNames = problem . getExtraMarkerAttributeNames ( ) ; int extraLength = extraAttributeNames == null ? <NUM_LIT:0> : extraAttributeNames . length ; if ( managedLength > <NUM_LIT:0> || extraLength > <NUM_LIT:0> ) { allNames = new String [ standardLength + managedLength + extraLength ] ; System . arraycopy ( attributeNames , <NUM_LIT:0> , allNames , <NUM_LIT:0> , standardLength ) ; if ( managedLength > <NUM_LIT:0> ) allNames [ standardLength ] = IMarker . SOURCE_ID ; System . arraycopy ( extraAttributeNames , <NUM_LIT:0> , allNames , standardLength + managedLength , extraLength ) ; } Object [ ] allValues = new Object [ allNames . length ] ; int index = <NUM_LIT:0> ; allValues [ index ++ ] = problem . getMessage ( ) ; allValues [ index ++ ] = problem . isError ( ) ? S_ERROR : S_WARNING ; allValues [ index ++ ] = new Integer ( id ) ; allValues [ index ++ ] = new Integer ( problem . getSourceStart ( ) ) ; allValues [ index ++ ] = new Integer ( problem . getSourceEnd ( ) + <NUM_LIT:1> ) ; allValues [ index ++ ] = new Integer ( problem . getSourceLineNumber ( ) ) ; allValues [ index ++ ] = Util . getProblemArgumentsForMarker ( problem . getArguments ( ) ) ; allValues [ index ++ ] = new Integer ( problem . getCategoryID ( ) ) ; if ( managedLength > <NUM_LIT:0> ) allValues [ index ++ ] = JavaBuilder . SOURCE_ID ; if ( extraLength > <NUM_LIT:0> ) System . arraycopy ( problem . getExtraMarkerAttributeValues ( ) , <NUM_LIT:0> , allValues , index , extraLength ) ; marker . setAttributes ( allNames , allValues ) ; if ( ! this . keepStoringProblemMarkers ) return ; } } } protected void storeTasksFor ( SourceFile sourceFile , CategorizedProblem [ ] tasks ) throws CoreException { if ( sourceFile == null || tasks == null || tasks . length == <NUM_LIT:0> ) return ; IResource resource = sourceFile . resource ; for ( int i = <NUM_LIT:0> , l = tasks . length ; i < l ; i ++ ) { CategorizedProblem task = tasks [ i ] ; if ( task . getID ( ) == IProblem . Task ) { IMarker marker = resource . createMarker ( IJavaModelMarker . TASK_MARKER ) ; Integer priority = P_NORMAL ; String compilerPriority = task . getArguments ( ) [ <NUM_LIT:2> ] ; if ( JavaCore . COMPILER_TASK_PRIORITY_HIGH . equals ( compilerPriority ) ) priority = P_HIGH ; else if ( JavaCore . COMPILER_TASK_PRIORITY_LOW . equals ( compilerPriority ) ) priority = P_LOW ; String [ ] attributeNames = JAVA_TASK_MARKER_ATTRIBUTE_NAMES ; int standardLength = attributeNames . length ; String [ ] allNames = attributeNames ; String [ ] extraAttributeNames = task . getExtraMarkerAttributeNames ( ) ; int extraLength = extraAttributeNames == null ? <NUM_LIT:0> : extraAttributeNames . length ; if ( extraLength > <NUM_LIT:0> ) { allNames = new String [ standardLength + extraLength ] ; System . arraycopy ( attributeNames , <NUM_LIT:0> , allNames , <NUM_LIT:0> , standardLength ) ; System . arraycopy ( extraAttributeNames , <NUM_LIT:0> , allNames , standardLength , extraLength ) ; } Object [ ] allValues = new Object [ allNames . length ] ; int index = <NUM_LIT:0> ; allValues [ index ++ ] = task . getMessage ( ) ; allValues [ index ++ ] = priority ; allValues [ index ++ ] = new Integer ( task . getID ( ) ) ; allValues [ index ++ ] = new Integer ( task . getSourceStart ( ) ) ; allValues [ index ++ ] = new Integer ( task . getSourceEnd ( ) + <NUM_LIT:1> ) ; allValues [ index ++ ] = new Integer ( task . getSourceLineNumber ( ) ) ; allValues [ index ++ ] = Boolean . FALSE ; allValues [ index ++ ] = JavaBuilder . SOURCE_ID ; if ( extraLength > <NUM_LIT:0> ) System . arraycopy ( task . getExtraMarkerAttributeValues ( ) , <NUM_LIT:0> , allValues , index , extraLength ) ; marker . setAttributes ( allNames , allValues ) ; } } } protected void updateProblemsFor ( SourceFile sourceFile , CompilationResult result ) throws CoreException { CategorizedProblem [ ] problems = result . getProblems ( ) ; if ( problems == null || problems . length == <NUM_LIT:0> ) return ; this . notifier . updateProblemCounts ( problems ) ; storeProblemsFor ( sourceFile , problems ) ; } protected void updateTasksFor ( SourceFile sourceFile , CompilationResult result ) throws CoreException { CategorizedProblem [ ] tasks = result . getTasks ( ) ; if ( tasks == null || tasks . length == <NUM_LIT:0> ) return ; storeTasksFor ( sourceFile , tasks ) ; } protected char [ ] writeClassFile ( ClassFile classFile , SourceFile compilationUnit , boolean isTopLevelType ) throws CoreException { String fileName = new String ( classFile . fileName ( ) ) ; IPath filePath = new Path ( fileName ) ; IContainer outputFolder = compilationUnit . sourceLocation . binaryFolder ; IContainer container = outputFolder ; if ( filePath . segmentCount ( ) > <NUM_LIT:1> ) { container = createFolder ( filePath . removeLastSegments ( <NUM_LIT:1> ) , outputFolder ) ; filePath = new Path ( filePath . lastSegment ( ) ) ; } IFile file = container . getFile ( filePath . addFileExtension ( SuffixConstants . EXTENSION_class ) ) ; writeClassFileContents ( classFile , file , fileName , isTopLevelType , compilationUnit ) ; return filePath . lastSegment ( ) . toCharArray ( ) ; } protected void writeClassFileContents ( ClassFile classFile , IFile file , String qualifiedFileName , boolean isTopLevelType , SourceFile compilationUnit ) throws CoreException { InputStream input = new ByteArrayInputStream ( classFile . getBytes ( ) ) ; if ( file . exists ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + file . getName ( ) ) ; if ( ! file . isDerived ( ) ) file . setDerived ( true , null ) ; file . setContents ( input , true , false , null ) ; } else { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + file . getName ( ) ) ; file . create ( input , IResource . FORCE | IResource . DERIVED , null ) ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; public class MissingSourceFileException extends RuntimeException { protected String missingSourceFile ; private static final long serialVersionUID = - <NUM_LIT> ; public MissingSourceFileException ( String missingSourceFile ) { this . missingSourceFile = missingSourceFile ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . jdt . core . compiler . CharOperation ; public class QualifiedNameSet { public char [ ] [ ] [ ] qualifiedNames ; public int elementSize ; public int threshold ; public QualifiedNameSet ( int size ) { this . elementSize = <NUM_LIT:0> ; this . threshold = size ; int extraRoom = ( int ) ( size * <NUM_LIT> ) ; if ( this . threshold == extraRoom ) extraRoom ++ ; this . qualifiedNames = new char [ extraRoom ] [ ] [ ] ; } public char [ ] [ ] add ( char [ ] [ ] qualifiedName ) { int qLength = qualifiedName . length ; if ( qLength == <NUM_LIT:0> ) return CharOperation . NO_CHAR_CHAR ; int length = this . qualifiedNames . length ; int index = CharOperation . hashCode ( qualifiedName [ qLength - <NUM_LIT:1> ] ) % length ; char [ ] [ ] current ; while ( ( current = this . qualifiedNames [ index ] ) != null ) { if ( CharOperation . equals ( current , qualifiedName ) ) return current ; if ( ++ index == length ) index = <NUM_LIT:0> ; } this . qualifiedNames [ index ] = qualifiedName ; if ( ++ this . elementSize > this . threshold ) rehash ( ) ; return qualifiedName ; } private void rehash ( ) { QualifiedNameSet newSet = new QualifiedNameSet ( this . elementSize * <NUM_LIT:2> ) ; char [ ] [ ] current ; for ( int i = this . qualifiedNames . length ; -- i >= <NUM_LIT:0> ; ) if ( ( current = this . qualifiedNames [ i ] ) != null ) newSet . add ( current ) ; this . qualifiedNames = newSet . qualifiedNames ; this . elementSize = newSet . elementSize ; this . threshold = newSet . threshold ; } public String toString ( ) { String s = "<STR_LIT>" ; char [ ] [ ] qualifiedName ; for ( int i = <NUM_LIT:0> , l = this . qualifiedNames . length ; i < l ; i ++ ) if ( ( qualifiedName = this . qualifiedNames [ i ] ) != null ) s += CharOperation . toString ( qualifiedName ) + "<STR_LIT:n>" ; return s ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . env . AccessRuleSet ; import org . eclipse . jdt . internal . compiler . env . AccessRule ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . core . ClasspathAccessRule ; import org . eclipse . jdt . internal . core . JavaModelManager ; import java . io . * ; import java . util . * ; public class State { String javaProjectName ; public ClasspathMultiDirectory [ ] sourceLocations ; ClasspathLocation [ ] binaryLocations ; SimpleLookupTable references ; public SimpleLookupTable typeLocators ; int buildNumber ; long lastStructuralBuildTime ; SimpleLookupTable structuralBuildTimes ; private String [ ] knownPackageNames ; private long previousStructuralBuildTime ; private StringSet structurallyChangedTypes ; public static int MaxStructurallyChangedTypes = <NUM_LIT:100> ; public static final byte VERSION = <NUM_LIT> ; static final byte SOURCE_FOLDER = <NUM_LIT:1> ; static final byte BINARY_FOLDER = <NUM_LIT:2> ; static final byte EXTERNAL_JAR = <NUM_LIT:3> ; static final byte INTERNAL_JAR = <NUM_LIT:4> ; State ( ) { } protected State ( JavaBuilder javaBuilder ) { this . knownPackageNames = null ; this . previousStructuralBuildTime = - <NUM_LIT:1> ; this . structurallyChangedTypes = null ; this . javaProjectName = javaBuilder . currentProject . getName ( ) ; this . sourceLocations = javaBuilder . nameEnvironment . sourceLocations ; this . binaryLocations = javaBuilder . nameEnvironment . binaryLocations ; this . references = new SimpleLookupTable ( <NUM_LIT:7> ) ; this . typeLocators = new SimpleLookupTable ( <NUM_LIT:7> ) ; this . buildNumber = <NUM_LIT:0> ; this . lastStructuralBuildTime = computeStructuralBuildTime ( javaBuilder . lastState == null ? <NUM_LIT:0> : javaBuilder . lastState . lastStructuralBuildTime ) ; this . structuralBuildTimes = new SimpleLookupTable ( <NUM_LIT:3> ) ; } long computeStructuralBuildTime ( long previousTime ) { long newTime = System . currentTimeMillis ( ) ; if ( newTime <= previousTime ) newTime = previousTime + <NUM_LIT:1> ; return newTime ; } void copyFrom ( State lastState ) { this . knownPackageNames = null ; this . previousStructuralBuildTime = lastState . previousStructuralBuildTime ; this . structurallyChangedTypes = lastState . structurallyChangedTypes ; this . buildNumber = lastState . buildNumber + <NUM_LIT:1> ; this . lastStructuralBuildTime = lastState . lastStructuralBuildTime ; this . structuralBuildTimes = lastState . structuralBuildTimes ; try { this . references = ( SimpleLookupTable ) lastState . references . clone ( ) ; this . typeLocators = ( SimpleLookupTable ) lastState . typeLocators . clone ( ) ; } catch ( CloneNotSupportedException e ) { this . references = new SimpleLookupTable ( lastState . references . elementSize ) ; Object [ ] keyTable = lastState . references . keyTable ; Object [ ] valueTable = lastState . references . valueTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) if ( keyTable [ i ] != null ) this . references . put ( keyTable [ i ] , valueTable [ i ] ) ; this . typeLocators = new SimpleLookupTable ( lastState . typeLocators . elementSize ) ; keyTable = lastState . typeLocators . keyTable ; valueTable = lastState . typeLocators . valueTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) if ( keyTable [ i ] != null ) this . typeLocators . put ( keyTable [ i ] , valueTable [ i ] ) ; } } public char [ ] [ ] getDefinedTypeNamesFor ( String typeLocator ) { Object c = this . references . get ( typeLocator ) ; if ( c instanceof AdditionalTypeCollection ) return ( ( AdditionalTypeCollection ) c ) . definedTypeNames ; return null ; } public SimpleLookupTable getReferences ( ) { return this . references ; } StringSet getStructurallyChangedTypes ( State prereqState ) { if ( prereqState != null && prereqState . previousStructuralBuildTime > <NUM_LIT:0> ) { Object o = this . structuralBuildTimes . get ( prereqState . javaProjectName ) ; long previous = o == null ? <NUM_LIT:0> : ( ( Long ) o ) . longValue ( ) ; if ( previous == prereqState . previousStructuralBuildTime ) return prereqState . structurallyChangedTypes ; } return null ; } public boolean isDuplicateLocator ( String qualifiedTypeName , String typeLocator ) { String existing = ( String ) this . typeLocators . get ( qualifiedTypeName ) ; return existing != null && ! existing . equals ( typeLocator ) ; } public boolean isKnownPackage ( String qualifiedPackageName ) { if ( this . knownPackageNames == null ) { ArrayList names = new ArrayList ( this . typeLocators . elementSize ) ; Object [ ] keyTable = this . typeLocators . keyTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { if ( keyTable [ i ] != null ) { String packageName = ( String ) keyTable [ i ] ; int last = packageName . lastIndexOf ( '<CHAR_LIT:/>' ) ; packageName = last == - <NUM_LIT:1> ? null : packageName . substring ( <NUM_LIT:0> , last ) ; while ( packageName != null && ! names . contains ( packageName ) ) { names . add ( packageName ) ; last = packageName . lastIndexOf ( '<CHAR_LIT:/>' ) ; packageName = last == - <NUM_LIT:1> ? null : packageName . substring ( <NUM_LIT:0> , last ) ; } } } this . knownPackageNames = new String [ names . size ( ) ] ; names . toArray ( this . knownPackageNames ) ; } for ( int i = <NUM_LIT:0> , l = this . knownPackageNames . length ; i < l ; i ++ ) if ( this . knownPackageNames [ i ] . equals ( qualifiedPackageName ) ) return true ; return false ; } public boolean isKnownType ( String qualifiedTypeName ) { return this . typeLocators . containsKey ( qualifiedTypeName ) ; } boolean isSourceFolderEmpty ( IContainer sourceFolder ) { String sourceFolderName = sourceFolder . getProjectRelativePath ( ) . addTrailingSeparator ( ) . toString ( ) ; Object [ ] table = this . typeLocators . valueTable ; for ( int i = <NUM_LIT:0> , l = table . length ; i < l ; i ++ ) if ( table [ i ] != null && ( ( String ) table [ i ] ) . startsWith ( sourceFolderName ) ) return false ; return true ; } void record ( String typeLocator , char [ ] [ ] [ ] qualifiedRefs , char [ ] [ ] simpleRefs , char [ ] [ ] rootRefs , char [ ] mainTypeName , ArrayList typeNames ) { if ( typeNames . size ( ) == <NUM_LIT:1> && CharOperation . equals ( mainTypeName , ( char [ ] ) typeNames . get ( <NUM_LIT:0> ) ) ) { this . references . put ( typeLocator , new ReferenceCollection ( qualifiedRefs , simpleRefs , rootRefs ) ) ; } else { char [ ] [ ] definedTypeNames = new char [ typeNames . size ( ) ] [ ] ; typeNames . toArray ( definedTypeNames ) ; this . references . put ( typeLocator , new AdditionalTypeCollection ( definedTypeNames , qualifiedRefs , simpleRefs , rootRefs ) ) ; } } void recordLocatorForType ( String qualifiedTypeName , String typeLocator ) { this . knownPackageNames = null ; int start = typeLocator . indexOf ( qualifiedTypeName , <NUM_LIT:0> ) ; if ( start > <NUM_LIT:0> ) qualifiedTypeName = typeLocator . substring ( start , start + qualifiedTypeName . length ( ) ) ; this . typeLocators . put ( qualifiedTypeName , typeLocator ) ; } void recordStructuralDependency ( IProject prereqProject , State prereqState ) { if ( prereqState != null ) if ( prereqState . lastStructuralBuildTime > <NUM_LIT:0> ) this . structuralBuildTimes . put ( prereqProject . getName ( ) , new Long ( prereqState . lastStructuralBuildTime ) ) ; } void removeLocator ( String typeLocatorToRemove ) { this . knownPackageNames = null ; this . references . removeKey ( typeLocatorToRemove ) ; this . typeLocators . removeValue ( typeLocatorToRemove ) ; } void removePackage ( IResourceDelta sourceDelta ) { IResource resource = sourceDelta . getResource ( ) ; switch ( resource . getType ( ) ) { case IResource . FOLDER : IResourceDelta [ ] children = sourceDelta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> , l = children . length ; i < l ; i ++ ) removePackage ( children [ i ] ) ; return ; case IResource . FILE : IPath typeLocatorPath = resource . getProjectRelativePath ( ) ; if ( org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( typeLocatorPath . lastSegment ( ) ) ) removeLocator ( typeLocatorPath . toString ( ) ) ; } } void removeQualifiedTypeName ( String qualifiedTypeNameToRemove ) { this . knownPackageNames = null ; this . typeLocators . removeKey ( qualifiedTypeNameToRemove ) ; } static State read ( IProject project , DataInputStream in ) throws IOException { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + project . getName ( ) ) ; if ( VERSION != in . readByte ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + project . getName ( ) ) ; return null ; } State newState = new State ( ) ; newState . javaProjectName = in . readUTF ( ) ; if ( ! project . getName ( ) . equals ( newState . javaProjectName ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; return null ; } newState . buildNumber = in . readInt ( ) ; newState . lastStructuralBuildTime = in . readLong ( ) ; int length = in . readInt ( ) ; newState . sourceLocations = new ClasspathMultiDirectory [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IContainer sourceFolder = project , outputFolder = project ; String folderName ; if ( ( folderName = in . readUTF ( ) ) . length ( ) > <NUM_LIT:0> ) sourceFolder = project . getFolder ( folderName ) ; if ( ( folderName = in . readUTF ( ) ) . length ( ) > <NUM_LIT:0> ) outputFolder = project . getFolder ( folderName ) ; ClasspathMultiDirectory md = ( ClasspathMultiDirectory ) ClasspathLocation . forSourceFolder ( sourceFolder , outputFolder , readNames ( in ) , readNames ( in ) , in . readBoolean ( ) ) ; if ( in . readBoolean ( ) ) md . hasIndependentOutputFolder = true ; newState . sourceLocations [ i ] = md ; } length = in . readInt ( ) ; newState . binaryLocations = new ClasspathLocation [ length ] ; IWorkspaceRoot root = project . getWorkspace ( ) . getRoot ( ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { switch ( in . readByte ( ) ) { case SOURCE_FOLDER : newState . binaryLocations [ i ] = newState . sourceLocations [ in . readInt ( ) ] ; break ; case BINARY_FOLDER : IPath path = new Path ( in . readUTF ( ) ) ; IContainer outputFolder = path . segmentCount ( ) == <NUM_LIT:1> ? ( IContainer ) root . getProject ( path . toString ( ) ) : ( IContainer ) root . getFolder ( path ) ; newState . binaryLocations [ i ] = ClasspathLocation . forBinaryFolder ( outputFolder , in . readBoolean ( ) , readRestriction ( in ) ) ; break ; case EXTERNAL_JAR : newState . binaryLocations [ i ] = ClasspathLocation . forLibrary ( in . readUTF ( ) , in . readLong ( ) , readRestriction ( in ) ) ; break ; case INTERNAL_JAR : newState . binaryLocations [ i ] = ClasspathLocation . forLibrary ( root . getFile ( new Path ( in . readUTF ( ) ) ) , readRestriction ( in ) ) ; } } newState . structuralBuildTimes = new SimpleLookupTable ( length = in . readInt ( ) ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) newState . structuralBuildTimes . put ( in . readUTF ( ) , new Long ( in . readLong ( ) ) ) ; String [ ] internedTypeLocators = new String [ length = in . readInt ( ) ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) internedTypeLocators [ i ] = in . readUTF ( ) ; newState . typeLocators = new SimpleLookupTable ( length = in . readInt ( ) ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) newState . recordLocatorForType ( in . readUTF ( ) , internedTypeLocators [ in . readInt ( ) ] ) ; char [ ] [ ] internedRootNames = ReferenceCollection . internSimpleNames ( readNames ( in ) , false ) ; char [ ] [ ] internedSimpleNames = ReferenceCollection . internSimpleNames ( readNames ( in ) , false ) ; char [ ] [ ] [ ] internedQualifiedNames = new char [ length = in . readInt ( ) ] [ ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { int qLength = in . readInt ( ) ; char [ ] [ ] qName = new char [ qLength ] [ ] ; for ( int j = <NUM_LIT:0> ; j < qLength ; j ++ ) qName [ j ] = internedSimpleNames [ in . readInt ( ) ] ; internedQualifiedNames [ i ] = qName ; } internedQualifiedNames = ReferenceCollection . internQualifiedNames ( internedQualifiedNames , false ) ; newState . references = new SimpleLookupTable ( length = in . readInt ( ) ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { String typeLocator = internedTypeLocators [ in . readInt ( ) ] ; ReferenceCollection collection = null ; switch ( in . readByte ( ) ) { case <NUM_LIT:1> : char [ ] [ ] additionalTypeNames = readNames ( in ) ; char [ ] [ ] [ ] qualifiedNames = new char [ in . readInt ( ) ] [ ] [ ] ; for ( int j = <NUM_LIT:0> , m = qualifiedNames . length ; j < m ; j ++ ) qualifiedNames [ j ] = internedQualifiedNames [ in . readInt ( ) ] ; char [ ] [ ] simpleNames = new char [ in . readInt ( ) ] [ ] ; for ( int j = <NUM_LIT:0> , m = simpleNames . length ; j < m ; j ++ ) simpleNames [ j ] = internedSimpleNames [ in . readInt ( ) ] ; char [ ] [ ] rootNames = new char [ in . readInt ( ) ] [ ] ; for ( int j = <NUM_LIT:0> , m = rootNames . length ; j < m ; j ++ ) rootNames [ j ] = internedRootNames [ in . readInt ( ) ] ; collection = new AdditionalTypeCollection ( additionalTypeNames , qualifiedNames , simpleNames , rootNames ) ; break ; case <NUM_LIT:2> : char [ ] [ ] [ ] qNames = new char [ in . readInt ( ) ] [ ] [ ] ; for ( int j = <NUM_LIT:0> , m = qNames . length ; j < m ; j ++ ) qNames [ j ] = internedQualifiedNames [ in . readInt ( ) ] ; char [ ] [ ] sNames = new char [ in . readInt ( ) ] [ ] ; for ( int j = <NUM_LIT:0> , m = sNames . length ; j < m ; j ++ ) sNames [ j ] = internedSimpleNames [ in . readInt ( ) ] ; char [ ] [ ] rNames = new char [ in . readInt ( ) ] [ ] ; for ( int j = <NUM_LIT:0> , m = rNames . length ; j < m ; j ++ ) rNames [ j ] = internedRootNames [ in . readInt ( ) ] ; collection = new ReferenceCollection ( qNames , sNames , rNames ) ; } newState . references . put ( typeLocator , collection ) ; } if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + newState . javaProjectName ) ; return newState ; } private static char [ ] readName ( DataInputStream in ) throws IOException { int nLength = in . readInt ( ) ; char [ ] name = new char [ nLength ] ; for ( int j = <NUM_LIT:0> ; j < nLength ; j ++ ) name [ j ] = in . readChar ( ) ; return name ; } private static char [ ] [ ] readNames ( DataInputStream in ) throws IOException { int length = in . readInt ( ) ; char [ ] [ ] names = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) names [ i ] = readName ( in ) ; return names ; } private static AccessRuleSet readRestriction ( DataInputStream in ) throws IOException { int length = in . readInt ( ) ; if ( length == <NUM_LIT:0> ) return null ; AccessRule [ ] accessRules = new AccessRule [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char [ ] pattern = readName ( in ) ; int problemId = in . readInt ( ) ; accessRules [ i ] = new ClasspathAccessRule ( pattern , problemId ) ; } JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; return new AccessRuleSet ( accessRules , in . readByte ( ) , manager . intern ( in . readUTF ( ) ) ) ; } void tagAsNoopBuild ( ) { this . buildNumber = - <NUM_LIT:1> ; } boolean wasNoopBuild ( ) { return this . buildNumber == - <NUM_LIT:1> ; } void tagAsStructurallyChanged ( ) { this . previousStructuralBuildTime = this . lastStructuralBuildTime ; this . structurallyChangedTypes = new StringSet ( <NUM_LIT:7> ) ; this . lastStructuralBuildTime = computeStructuralBuildTime ( this . previousStructuralBuildTime ) ; } boolean wasStructurallyChanged ( IProject prereqProject , State prereqState ) { if ( prereqState != null ) { Object o = this . structuralBuildTimes . get ( prereqProject . getName ( ) ) ; long previous = o == null ? <NUM_LIT:0> : ( ( Long ) o ) . longValue ( ) ; if ( previous == prereqState . lastStructuralBuildTime ) return false ; } return true ; } void wasStructurallyChanged ( String typeName ) { if ( this . structurallyChangedTypes != null ) { if ( this . structurallyChangedTypes . elementSize > MaxStructurallyChangedTypes ) this . structurallyChangedTypes = null ; else this . structurallyChangedTypes . add ( typeName ) ; } } void write ( DataOutputStream out ) throws IOException { int length ; Object [ ] keyTable ; Object [ ] valueTable ; out . writeByte ( VERSION ) ; out . writeUTF ( this . javaProjectName ) ; out . writeInt ( this . buildNumber ) ; out . writeLong ( this . lastStructuralBuildTime ) ; out . writeInt ( length = this . sourceLocations . length ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ClasspathMultiDirectory md = this . sourceLocations [ i ] ; out . writeUTF ( md . sourceFolder . getProjectRelativePath ( ) . toString ( ) ) ; out . writeUTF ( md . binaryFolder . getProjectRelativePath ( ) . toString ( ) ) ; writeNames ( md . inclusionPatterns , out ) ; writeNames ( md . exclusionPatterns , out ) ; out . writeBoolean ( md . ignoreOptionalProblems ) ; out . writeBoolean ( md . hasIndependentOutputFolder ) ; } out . writeInt ( length = this . binaryLocations . length ) ; next : for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ClasspathLocation c = this . binaryLocations [ i ] ; if ( c instanceof ClasspathMultiDirectory ) { out . writeByte ( SOURCE_FOLDER ) ; for ( int j = <NUM_LIT:0> , m = this . sourceLocations . length ; j < m ; j ++ ) { if ( this . sourceLocations [ j ] == c ) { out . writeInt ( j ) ; continue next ; } } } else if ( c instanceof ClasspathDirectory ) { out . writeByte ( BINARY_FOLDER ) ; ClasspathDirectory cd = ( ClasspathDirectory ) c ; out . writeUTF ( cd . binaryFolder . getFullPath ( ) . toString ( ) ) ; out . writeBoolean ( cd . isOutputFolder ) ; writeRestriction ( cd . accessRuleSet , out ) ; } else { ClasspathJar jar = ( ClasspathJar ) c ; if ( jar . resource == null ) { out . writeByte ( EXTERNAL_JAR ) ; out . writeUTF ( jar . zipFilename ) ; out . writeLong ( jar . lastModified ( ) ) ; } else { out . writeByte ( INTERNAL_JAR ) ; out . writeUTF ( jar . resource . getFullPath ( ) . toString ( ) ) ; } writeRestriction ( jar . accessRuleSet , out ) ; } } out . writeInt ( length = this . structuralBuildTimes . elementSize ) ; if ( length > <NUM_LIT:0> ) { keyTable = this . structuralBuildTimes . keyTable ; valueTable = this . structuralBuildTimes . valueTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { if ( keyTable [ i ] != null ) { length -- ; out . writeUTF ( ( String ) keyTable [ i ] ) ; out . writeLong ( ( ( Long ) valueTable [ i ] ) . longValue ( ) ) ; } } if ( JavaBuilder . DEBUG && length != <NUM_LIT:0> ) System . out . println ( "<STR_LIT>" ) ; } out . writeInt ( length = this . references . elementSize ) ; SimpleLookupTable internedTypeLocators = new SimpleLookupTable ( length ) ; if ( length > <NUM_LIT:0> ) { keyTable = this . references . keyTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { if ( keyTable [ i ] != null ) { length -- ; String key = ( String ) keyTable [ i ] ; out . writeUTF ( key ) ; internedTypeLocators . put ( key , new Integer ( internedTypeLocators . elementSize ) ) ; } } if ( JavaBuilder . DEBUG && length != <NUM_LIT:0> ) System . out . println ( "<STR_LIT>" ) ; } out . writeInt ( length = this . typeLocators . elementSize ) ; if ( length > <NUM_LIT:0> ) { keyTable = this . typeLocators . keyTable ; valueTable = this . typeLocators . valueTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { if ( keyTable [ i ] != null ) { length -- ; out . writeUTF ( ( String ) keyTable [ i ] ) ; Integer index = ( Integer ) internedTypeLocators . get ( valueTable [ i ] ) ; out . writeInt ( index . intValue ( ) ) ; } } if ( JavaBuilder . DEBUG && length != <NUM_LIT:0> ) System . out . println ( "<STR_LIT>" ) ; } SimpleLookupTable internedRootNames = new SimpleLookupTable ( <NUM_LIT:3> ) ; SimpleLookupTable internedQualifiedNames = new SimpleLookupTable ( <NUM_LIT:31> ) ; SimpleLookupTable internedSimpleNames = new SimpleLookupTable ( <NUM_LIT:31> ) ; valueTable = this . references . valueTable ; for ( int i = <NUM_LIT:0> , l = valueTable . length ; i < l ; i ++ ) { if ( valueTable [ i ] != null ) { ReferenceCollection collection = ( ReferenceCollection ) valueTable [ i ] ; char [ ] [ ] rNames = collection . rootReferences ; for ( int j = <NUM_LIT:0> , m = rNames . length ; j < m ; j ++ ) { char [ ] rName = rNames [ j ] ; if ( ! internedRootNames . containsKey ( rName ) ) internedRootNames . put ( rName , new Integer ( internedRootNames . elementSize ) ) ; } char [ ] [ ] [ ] qNames = collection . qualifiedNameReferences ; for ( int j = <NUM_LIT:0> , m = qNames . length ; j < m ; j ++ ) { char [ ] [ ] qName = qNames [ j ] ; if ( ! internedQualifiedNames . containsKey ( qName ) ) { internedQualifiedNames . put ( qName , new Integer ( internedQualifiedNames . elementSize ) ) ; for ( int k = <NUM_LIT:0> , n = qName . length ; k < n ; k ++ ) { char [ ] sName = qName [ k ] ; if ( ! internedSimpleNames . containsKey ( sName ) ) internedSimpleNames . put ( sName , new Integer ( internedSimpleNames . elementSize ) ) ; } } } char [ ] [ ] sNames = collection . simpleNameReferences ; for ( int j = <NUM_LIT:0> , m = sNames . length ; j < m ; j ++ ) { char [ ] sName = sNames [ j ] ; if ( ! internedSimpleNames . containsKey ( sName ) ) internedSimpleNames . put ( sName , new Integer ( internedSimpleNames . elementSize ) ) ; } } } char [ ] [ ] internedArray = new char [ internedRootNames . elementSize ] [ ] ; Object [ ] rootNames = internedRootNames . keyTable ; Object [ ] positions = internedRootNames . valueTable ; for ( int i = positions . length ; -- i >= <NUM_LIT:0> ; ) { if ( positions [ i ] != null ) { int index = ( ( Integer ) positions [ i ] ) . intValue ( ) ; internedArray [ index ] = ( char [ ] ) rootNames [ i ] ; } } writeNames ( internedArray , out ) ; internedArray = new char [ internedSimpleNames . elementSize ] [ ] ; Object [ ] simpleNames = internedSimpleNames . keyTable ; positions = internedSimpleNames . valueTable ; for ( int i = positions . length ; -- i >= <NUM_LIT:0> ; ) { if ( positions [ i ] != null ) { int index = ( ( Integer ) positions [ i ] ) . intValue ( ) ; internedArray [ index ] = ( char [ ] ) simpleNames [ i ] ; } } writeNames ( internedArray , out ) ; char [ ] [ ] [ ] internedQArray = new char [ internedQualifiedNames . elementSize ] [ ] [ ] ; Object [ ] qualifiedNames = internedQualifiedNames . keyTable ; positions = internedQualifiedNames . valueTable ; for ( int i = positions . length ; -- i >= <NUM_LIT:0> ; ) { if ( positions [ i ] != null ) { int index = ( ( Integer ) positions [ i ] ) . intValue ( ) ; internedQArray [ index ] = ( char [ ] [ ] ) qualifiedNames [ i ] ; } } out . writeInt ( length = internedQArray . length ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char [ ] [ ] qName = internedQArray [ i ] ; int qLength = qName . length ; out . writeInt ( qLength ) ; for ( int j = <NUM_LIT:0> ; j < qLength ; j ++ ) { Integer index = ( Integer ) internedSimpleNames . get ( qName [ j ] ) ; out . writeInt ( index . intValue ( ) ) ; } } out . writeInt ( length = this . references . elementSize ) ; if ( length > <NUM_LIT:0> ) { keyTable = this . references . keyTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { if ( keyTable [ i ] != null ) { length -- ; Integer index = ( Integer ) internedTypeLocators . get ( keyTable [ i ] ) ; out . writeInt ( index . intValue ( ) ) ; ReferenceCollection collection = ( ReferenceCollection ) valueTable [ i ] ; if ( collection instanceof AdditionalTypeCollection ) { out . writeByte ( <NUM_LIT:1> ) ; AdditionalTypeCollection atc = ( AdditionalTypeCollection ) collection ; writeNames ( atc . definedTypeNames , out ) ; } else { out . writeByte ( <NUM_LIT:2> ) ; } char [ ] [ ] [ ] qNames = collection . qualifiedNameReferences ; int qLength = qNames . length ; out . writeInt ( qLength ) ; for ( int j = <NUM_LIT:0> ; j < qLength ; j ++ ) { index = ( Integer ) internedQualifiedNames . get ( qNames [ j ] ) ; out . writeInt ( index . intValue ( ) ) ; } char [ ] [ ] sNames = collection . simpleNameReferences ; int sLength = sNames . length ; out . writeInt ( sLength ) ; for ( int j = <NUM_LIT:0> ; j < sLength ; j ++ ) { index = ( Integer ) internedSimpleNames . get ( sNames [ j ] ) ; out . writeInt ( index . intValue ( ) ) ; } char [ ] [ ] rNames = collection . rootReferences ; int rLength = rNames . length ; out . writeInt ( rLength ) ; for ( int j = <NUM_LIT:0> ; j < rLength ; j ++ ) { index = ( Integer ) internedRootNames . get ( rNames [ j ] ) ; out . writeInt ( index . intValue ( ) ) ; } } } if ( JavaBuilder . DEBUG && length != <NUM_LIT:0> ) System . out . println ( "<STR_LIT>" ) ; } } private void writeName ( char [ ] name , DataOutputStream out ) throws IOException { int nLength = name . length ; out . writeInt ( nLength ) ; for ( int j = <NUM_LIT:0> ; j < nLength ; j ++ ) out . writeChar ( name [ j ] ) ; } private void writeNames ( char [ ] [ ] names , DataOutputStream out ) throws IOException { int length = names == null ? <NUM_LIT:0> : names . length ; out . writeInt ( length ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) writeName ( names [ i ] , out ) ; } private void writeRestriction ( AccessRuleSet accessRuleSet , DataOutputStream out ) throws IOException { if ( accessRuleSet == null ) { out . writeInt ( <NUM_LIT:0> ) ; } else { AccessRule [ ] accessRules = accessRuleSet . getAccessRules ( ) ; int length = accessRules . length ; out . writeInt ( length ) ; if ( length != <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { AccessRule accessRule = accessRules [ i ] ; writeName ( accessRule . pattern , out ) ; out . writeInt ( accessRule . problemId ) ; } out . writeByte ( accessRuleSet . classpathEntryType ) ; out . writeUTF ( accessRuleSet . classpathEntryName ) ; } } } public String toString ( ) { return "<STR_LIT>" + this . javaProjectName + "<STR_LIT>" + this . buildNumber + "<STR_LIT>" + new Date ( this . lastStructuralBuildTime ) + "<STR_LIT:)>" ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . jdt . internal . compiler . util . SimpleSet ; public class WorkQueue { private SimpleSet needsCompileList ; private SimpleSet compiledList ; public WorkQueue ( ) { this . needsCompileList = new SimpleSet ( ) ; this . compiledList = new SimpleSet ( ) ; } public void add ( SourceFile element ) { this . needsCompileList . add ( element ) ; } public void addAll ( SourceFile [ ] elements ) { for ( int i = <NUM_LIT:0> , l = elements . length ; i < l ; i ++ ) add ( elements [ i ] ) ; } public void clear ( ) { this . needsCompileList . clear ( ) ; this . compiledList . clear ( ) ; } public void finished ( SourceFile element ) { this . needsCompileList . remove ( element ) ; this . compiledList . add ( element ) ; } public boolean isCompiled ( SourceFile element ) { return this . compiledList . includes ( element ) ; } public boolean isWaiting ( SourceFile element ) { return this . needsCompileList . includes ( element ) ; } public String toString ( ) { return "<STR_LIT>" + this . needsCompileList ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . resources . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . core . util . Util ; public class ClasspathMultiDirectory extends ClasspathDirectory { IContainer sourceFolder ; char [ ] [ ] inclusionPatterns ; char [ ] [ ] exclusionPatterns ; boolean hasIndependentOutputFolder ; public boolean ignoreOptionalProblems ; ClasspathMultiDirectory ( IContainer sourceFolder , IContainer binaryFolder , char [ ] [ ] inclusionPatterns , char [ ] [ ] exclusionPatterns , boolean ignoreOptionalProblems ) { super ( binaryFolder , true , null ) ; this . sourceFolder = sourceFolder ; this . inclusionPatterns = inclusionPatterns ; this . exclusionPatterns = exclusionPatterns ; this . hasIndependentOutputFolder = false ; this . ignoreOptionalProblems = ignoreOptionalProblems ; if ( this . inclusionPatterns != null && this . inclusionPatterns . length == <NUM_LIT:0> ) this . inclusionPatterns = null ; if ( this . exclusionPatterns != null && this . exclusionPatterns . length == <NUM_LIT:0> ) this . exclusionPatterns = null ; } public boolean equals ( Object o ) { if ( this == o ) return true ; if ( ! ( o instanceof ClasspathMultiDirectory ) ) return false ; ClasspathMultiDirectory md = ( ClasspathMultiDirectory ) o ; return this . ignoreOptionalProblems == md . ignoreOptionalProblems && this . sourceFolder . equals ( md . sourceFolder ) && this . binaryFolder . equals ( md . binaryFolder ) && CharOperation . equals ( this . inclusionPatterns , md . inclusionPatterns ) && CharOperation . equals ( this . exclusionPatterns , md . exclusionPatterns ) ; } protected boolean isExcluded ( IResource resource ) { if ( this . exclusionPatterns != null || this . inclusionPatterns != null ) if ( this . sourceFolder . equals ( this . binaryFolder ) ) return Util . isExcluded ( resource , this . inclusionPatterns , this . exclusionPatterns ) ; return false ; } public String toString ( ) { return "<STR_LIT>" + this . sourceFolder . getFullPath ( ) . toString ( ) + "<STR_LIT>" + super . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import java . io . IOException ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFormatException ; import org . eclipse . jdt . internal . compiler . env . AccessRuleSet ; import org . eclipse . jdt . internal . compiler . env . NameEnvironmentAnswer ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . util . Util ; public class ClasspathDirectory extends ClasspathLocation { IContainer binaryFolder ; boolean isOutputFolder ; SimpleLookupTable directoryCache ; String [ ] missingPackageHolder = new String [ <NUM_LIT:1> ] ; AccessRuleSet accessRuleSet ; ClasspathDirectory ( IContainer binaryFolder , boolean isOutputFolder , AccessRuleSet accessRuleSet ) { this . binaryFolder = binaryFolder ; this . isOutputFolder = isOutputFolder || binaryFolder . getProjectRelativePath ( ) . isEmpty ( ) ; this . directoryCache = new SimpleLookupTable ( <NUM_LIT:5> ) ; this . accessRuleSet = accessRuleSet ; } public void cleanup ( ) { this . directoryCache = null ; } String [ ] directoryList ( String qualifiedPackageName ) { String [ ] dirList = ( String [ ] ) this . directoryCache . get ( qualifiedPackageName ) ; if ( dirList == this . missingPackageHolder ) return null ; if ( dirList != null ) return dirList ; try { IResource container = this . binaryFolder . findMember ( qualifiedPackageName ) ; if ( container instanceof IContainer ) { IResource [ ] members = ( ( IContainer ) container ) . members ( ) ; dirList = new String [ members . length ] ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , l = members . length ; i < l ; i ++ ) { IResource m = members [ i ] ; if ( m . getType ( ) == IResource . FILE && org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( m . getName ( ) ) ) dirList [ index ++ ] = m . getName ( ) ; } if ( index < dirList . length ) System . arraycopy ( dirList , <NUM_LIT:0> , dirList = new String [ index ] , <NUM_LIT:0> , index ) ; this . directoryCache . put ( qualifiedPackageName , dirList ) ; return dirList ; } } catch ( CoreException ignored ) { } this . directoryCache . put ( qualifiedPackageName , this . missingPackageHolder ) ; return null ; } boolean doesFileExist ( String fileName , String qualifiedPackageName , String qualifiedFullName ) { String [ ] dirList = directoryList ( qualifiedPackageName ) ; if ( dirList == null ) return false ; for ( int i = dirList . length ; -- i >= <NUM_LIT:0> ; ) if ( fileName . equals ( dirList [ i ] ) ) return true ; return false ; } public boolean equals ( Object o ) { if ( this == o ) return true ; if ( ! ( o instanceof ClasspathDirectory ) ) return false ; ClasspathDirectory dir = ( ClasspathDirectory ) o ; if ( this . accessRuleSet != dir . accessRuleSet ) if ( this . accessRuleSet == null || ! this . accessRuleSet . equals ( dir . accessRuleSet ) ) return false ; return this . binaryFolder . equals ( dir . binaryFolder ) ; } public NameEnvironmentAnswer findClass ( String binaryFileName , String qualifiedPackageName , String qualifiedBinaryFileName ) { if ( ! doesFileExist ( binaryFileName , qualifiedPackageName , qualifiedBinaryFileName ) ) return null ; ClassFileReader reader = null ; try { reader = Util . newClassFileReader ( this . binaryFolder . getFile ( new Path ( qualifiedBinaryFileName ) ) ) ; } catch ( CoreException e ) { return null ; } catch ( ClassFormatException e ) { return null ; } catch ( IOException e ) { return null ; } if ( reader != null ) { if ( this . accessRuleSet == null ) return new NameEnvironmentAnswer ( reader , null ) ; String fileNameWithoutExtension = qualifiedBinaryFileName . substring ( <NUM_LIT:0> , qualifiedBinaryFileName . length ( ) - SuffixConstants . SUFFIX_CLASS . length ) ; return new NameEnvironmentAnswer ( reader , this . accessRuleSet . getViolatedRestriction ( fileNameWithoutExtension . toCharArray ( ) ) ) ; } return null ; } public IPath getProjectRelativePath ( ) { return this . binaryFolder . getProjectRelativePath ( ) ; } public int hashCode ( ) { return this . binaryFolder == null ? super . hashCode ( ) : this . binaryFolder . hashCode ( ) ; } protected boolean isExcluded ( IResource resource ) { return false ; } public boolean isOutputFolder ( ) { return this . isOutputFolder ; } public boolean isPackage ( String qualifiedPackageName ) { return directoryList ( qualifiedPackageName ) != null ; } public void reset ( ) { this . directoryCache = new SimpleLookupTable ( <NUM_LIT:5> ) ; } public String toString ( ) { String start = "<STR_LIT>" + this . binaryFolder . getFullPath ( ) . toString ( ) ; if ( this . accessRuleSet == null ) return start ; return start + "<STR_LIT>" + this . accessRuleSet ; } public String debugPathString ( ) { return this . binaryFolder . getFullPath ( ) . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . * ; import org . eclipse . jdt . internal . compiler . classfmt . * ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . problem . * ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; import java . io . * ; import java . net . URI ; import java . util . * ; public class IncrementalImageBuilder extends AbstractImageBuilder { protected ArrayList sourceFiles ; protected ArrayList previousSourceFiles ; protected StringSet qualifiedStrings ; protected StringSet simpleStrings ; protected StringSet rootStrings ; protected SimpleLookupTable secondaryTypesToRemove ; protected boolean hasStructuralChanges ; protected int compileLoop ; protected boolean makeOutputFolderConsistent ; public static int MaxCompileLoop = <NUM_LIT:5> ; protected IncrementalImageBuilder ( JavaBuilder javaBuilder , State buildState ) { super ( javaBuilder , true , buildState ) ; this . nameEnvironment . isIncrementalBuild = true ; this . makeOutputFolderConsistent = JavaCore . ENABLED . equals ( javaBuilder . javaProject . getOption ( JavaCore . CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER , true ) ) ; } protected IncrementalImageBuilder ( JavaBuilder javaBuilder ) { this ( javaBuilder , null ) ; this . newState . copyFrom ( javaBuilder . lastState ) ; } protected IncrementalImageBuilder ( BatchImageBuilder batchBuilder ) { this ( batchBuilder . javaBuilder , batchBuilder . newState ) ; resetCollections ( ) ; } public boolean build ( SimpleLookupTable deltas ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; try { resetCollections ( ) ; this . notifier . subTask ( Messages . build_analyzingDeltas ) ; if ( this . javaBuilder . hasBuildpathErrors ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; this . javaBuilder . currentProject . deleteMarkers ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER , false , IResource . DEPTH_ZERO ) ; addAllSourceFiles ( this . sourceFiles ) ; this . notifier . updateProgressDelta ( <NUM_LIT> ) ; } else { IResourceDelta sourceDelta = ( IResourceDelta ) deltas . get ( this . javaBuilder . currentProject ) ; if ( sourceDelta != null ) if ( ! findSourceFiles ( sourceDelta ) ) return false ; this . notifier . updateProgressDelta ( <NUM_LIT> ) ; Object [ ] keyTable = deltas . keyTable ; Object [ ] valueTable = deltas . valueTable ; for ( int i = <NUM_LIT:0> , l = valueTable . length ; i < l ; i ++ ) { IResourceDelta delta = ( IResourceDelta ) valueTable [ i ] ; if ( delta != null ) { IProject p = ( IProject ) keyTable [ i ] ; ClasspathLocation [ ] classFoldersAndJars = ( ClasspathLocation [ ] ) this . javaBuilder . binaryLocationsPerProject . get ( p ) ; if ( classFoldersAndJars != null ) if ( ! findAffectedSourceFiles ( delta , classFoldersAndJars , p ) ) return false ; } } this . notifier . updateProgressDelta ( <NUM_LIT> ) ; this . notifier . subTask ( Messages . build_analyzingSources ) ; addAffectedSourceFiles ( ) ; this . notifier . updateProgressDelta ( <NUM_LIT> ) ; } this . compileLoop = <NUM_LIT:0> ; float increment = <NUM_LIT> ; while ( this . sourceFiles . size ( ) > <NUM_LIT:0> ) { if ( ++ this . compileLoop > MaxCompileLoop ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; return false ; } this . notifier . checkCancel ( ) ; SourceFile [ ] allSourceFiles = new SourceFile [ this . sourceFiles . size ( ) ] ; this . sourceFiles . toArray ( allSourceFiles ) ; resetCollections ( ) ; this . workQueue . addAll ( allSourceFiles ) ; this . notifier . setProgressPerCompilationUnit ( increment / allSourceFiles . length ) ; increment = increment / <NUM_LIT:2> ; compile ( allSourceFiles ) ; removeSecondaryTypes ( ) ; addAffectedSourceFiles ( ) ; } if ( this . hasStructuralChanges && this . javaBuilder . javaProject . hasCycleMarker ( ) ) this . javaBuilder . mustPropagateStructuralChanges ( ) ; } catch ( AbortIncrementalBuildException e ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + e . qualifiedTypeName + "<STR_LIT>" ) ; return false ; } catch ( CoreException e ) { throw internalException ( e ) ; } finally { cleanUp ( ) ; } return true ; } protected void buildAfterBatchBuild ( ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + new Date ( System . currentTimeMillis ( ) ) ) ; try { addAffectedSourceFiles ( ) ; while ( this . sourceFiles . size ( ) > <NUM_LIT:0> ) { this . notifier . checkCancel ( ) ; SourceFile [ ] allSourceFiles = new SourceFile [ this . sourceFiles . size ( ) ] ; this . sourceFiles . toArray ( allSourceFiles ) ; resetCollections ( ) ; this . notifier . setProgressPerCompilationUnit ( <NUM_LIT> / allSourceFiles . length ) ; this . workQueue . addAll ( allSourceFiles ) ; compile ( allSourceFiles ) ; removeSecondaryTypes ( ) ; addAffectedSourceFiles ( ) ; } } catch ( CoreException e ) { throw internalException ( e ) ; } finally { cleanUp ( ) ; } } protected void addAffectedSourceFiles ( ) { if ( this . qualifiedStrings . elementSize == <NUM_LIT:0> && this . simpleStrings . elementSize == <NUM_LIT:0> ) return ; addAffectedSourceFiles ( this . qualifiedStrings , this . simpleStrings , this . rootStrings , null ) ; } protected void addAffectedSourceFiles ( StringSet qualifiedSet , StringSet simpleSet , StringSet rootSet , StringSet affectedTypes ) { char [ ] [ ] [ ] internedQualifiedNames = ReferenceCollection . internQualifiedNames ( qualifiedSet ) ; if ( internedQualifiedNames . length < qualifiedSet . elementSize ) internedQualifiedNames = null ; char [ ] [ ] internedSimpleNames = ReferenceCollection . internSimpleNames ( simpleSet , true ) ; if ( internedSimpleNames . length < simpleSet . elementSize ) internedSimpleNames = null ; char [ ] [ ] internedRootNames = ReferenceCollection . internSimpleNames ( rootSet , false ) ; Object [ ] keyTable = this . newState . references . keyTable ; Object [ ] valueTable = this . newState . references . valueTable ; next : for ( int i = <NUM_LIT:0> , l = valueTable . length ; i < l ; i ++ ) { String typeLocator = ( String ) keyTable [ i ] ; if ( typeLocator != null ) { if ( affectedTypes != null && ! affectedTypes . includes ( typeLocator ) ) continue next ; ReferenceCollection refs = ( ReferenceCollection ) valueTable [ i ] ; if ( refs . includes ( internedQualifiedNames , internedSimpleNames , internedRootNames ) ) { IFile file = this . javaBuilder . currentProject . getFile ( typeLocator ) ; SourceFile sourceFile = findSourceFile ( file , true ) ; if ( sourceFile == null ) continue next ; if ( this . sourceFiles . contains ( sourceFile ) ) continue next ; if ( this . compiledAllAtOnce && this . previousSourceFiles != null && this . previousSourceFiles . contains ( sourceFile ) ) continue next ; if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typeLocator ) ; this . sourceFiles . add ( sourceFile ) ; } } } } protected void addDependentsOf ( IPath path , boolean isStructuralChange ) { addDependentsOf ( path , isStructuralChange , this . qualifiedStrings , this . simpleStrings , this . rootStrings ) ; } protected void addDependentsOf ( IPath path , boolean isStructuralChange , StringSet qualifiedNames , StringSet simpleNames , StringSet rootNames ) { path = path . setDevice ( null ) ; if ( isStructuralChange ) { String last = path . lastSegment ( ) ; if ( last . length ( ) == TypeConstants . PACKAGE_INFO_NAME . length ) if ( CharOperation . equals ( last . toCharArray ( ) , TypeConstants . PACKAGE_INFO_NAME ) ) { path = path . removeLastSegments ( <NUM_LIT:1> ) ; if ( path . isEmpty ( ) ) return ; } } if ( isStructuralChange && ! this . hasStructuralChanges ) { this . newState . tagAsStructurallyChanged ( ) ; this . hasStructuralChanges = true ; } rootNames . add ( path . segment ( <NUM_LIT:0> ) ) ; String packageName = path . removeLastSegments ( <NUM_LIT:1> ) . toString ( ) ; boolean wasNew = qualifiedNames . add ( packageName ) ; String typeName = path . lastSegment ( ) ; int memberIndex = typeName . indexOf ( '<CHAR_LIT>' ) ; if ( memberIndex > <NUM_LIT:0> ) typeName = typeName . substring ( <NUM_LIT:0> , memberIndex ) ; wasNew = simpleNames . add ( typeName ) | wasNew ; if ( wasNew && JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typeName + "<STR_LIT>" + packageName ) ; } protected boolean checkForClassFileChanges ( IResourceDelta binaryDelta , ClasspathMultiDirectory md , int segmentCount ) throws CoreException { IResource resource = binaryDelta . getResource ( ) ; boolean isExcluded = ( md . exclusionPatterns != null || md . inclusionPatterns != null ) && Util . isExcluded ( resource , md . inclusionPatterns , md . exclusionPatterns ) ; switch ( resource . getType ( ) ) { case IResource . FOLDER : if ( isExcluded && md . inclusionPatterns == null ) return true ; IResourceDelta [ ] children = binaryDelta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> , l = children . length ; i < l ; i ++ ) if ( ! checkForClassFileChanges ( children [ i ] , md , segmentCount ) ) return false ; return true ; case IResource . FILE : if ( ! isExcluded && org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( resource . getName ( ) ) ) { IPath typePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) . removeFileExtension ( ) ; if ( this . newState . isKnownType ( typePath . toString ( ) ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath ) ; return false ; } return true ; } } return true ; } protected void cleanUp ( ) { super . cleanUp ( ) ; this . sourceFiles = null ; this . previousSourceFiles = null ; this . qualifiedStrings = null ; this . simpleStrings = null ; this . rootStrings = null ; this . secondaryTypesToRemove = null ; this . hasStructuralChanges = false ; this . compileLoop = <NUM_LIT:0> ; } protected void compile ( SourceFile [ ] units , SourceFile [ ] additionalUnits , boolean compilingFirstGroup ) { if ( compilingFirstGroup && additionalUnits != null ) { ArrayList extras = null ; for ( int i = <NUM_LIT:0> , l = additionalUnits . length ; i < l ; i ++ ) { SourceFile unit = additionalUnits [ i ] ; if ( unit != null && this . newState . getDefinedTypeNamesFor ( unit . typeLocator ( ) ) != null ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + unit . typeLocator ( ) ) ; if ( extras == null ) extras = new ArrayList ( <NUM_LIT:3> ) ; extras . add ( unit ) ; } } if ( extras != null ) { int oldLength = units . length ; int toAdd = extras . size ( ) ; System . arraycopy ( units , <NUM_LIT:0> , units = new SourceFile [ oldLength + toAdd ] , <NUM_LIT:0> , oldLength ) ; for ( int i = <NUM_LIT:0> ; i < toAdd ; i ++ ) units [ oldLength ++ ] = ( SourceFile ) extras . get ( i ) ; } } super . compile ( units , additionalUnits , compilingFirstGroup ) ; } protected void deleteGeneratedFiles ( IFile [ ] deletedGeneratedFiles ) { try { for ( int j = deletedGeneratedFiles . length ; -- j >= <NUM_LIT:0> ; ) { IFile deletedFile = deletedGeneratedFiles [ j ] ; if ( deletedFile . exists ( ) ) continue ; SourceFile sourceFile = findSourceFile ( deletedFile , false ) ; String typeLocator = sourceFile . typeLocator ( ) ; int mdSegmentCount = sourceFile . sourceLocation . sourceFolder . getFullPath ( ) . segmentCount ( ) ; IPath typePath = sourceFile . resource . getFullPath ( ) . removeFirstSegments ( mdSegmentCount ) . removeFileExtension ( ) ; addDependentsOf ( typePath , true ) ; this . previousSourceFiles = null ; char [ ] [ ] definedTypeNames = this . newState . getDefinedTypeNamesFor ( typeLocator ) ; if ( definedTypeNames == null ) { removeClassFile ( typePath , sourceFile . sourceLocation . binaryFolder ) ; } else { if ( definedTypeNames . length > <NUM_LIT:0> ) { IPath packagePath = typePath . removeLastSegments ( <NUM_LIT:1> ) ; for ( int d = <NUM_LIT:0> , l = definedTypeNames . length ; d < l ; d ++ ) removeClassFile ( packagePath . append ( new String ( definedTypeNames [ d ] ) ) , sourceFile . sourceLocation . binaryFolder ) ; } } this . newState . removeLocator ( typeLocator ) ; } } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" ) ; } } protected boolean findAffectedSourceFiles ( IResourceDelta delta , ClasspathLocation [ ] classFoldersAndJars , IProject prereqProject ) { for ( int i = <NUM_LIT:0> , l = classFoldersAndJars . length ; i < l ; i ++ ) { ClasspathLocation bLocation = classFoldersAndJars [ i ] ; if ( bLocation != null ) { IPath p = bLocation . getProjectRelativePath ( ) ; if ( p != null ) { IResourceDelta binaryDelta = delta . findMember ( p ) ; if ( binaryDelta != null ) { if ( bLocation instanceof ClasspathJar ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; return false ; } if ( binaryDelta . getKind ( ) == IResourceDelta . ADDED || binaryDelta . getKind ( ) == IResourceDelta . REMOVED ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; return false ; } int segmentCount = binaryDelta . getFullPath ( ) . segmentCount ( ) ; IResourceDelta [ ] children = binaryDelta . getAffectedChildren ( ) ; StringSet structurallyChangedTypes = null ; if ( bLocation . isOutputFolder ( ) ) structurallyChangedTypes = this . newState . getStructurallyChangedTypes ( this . javaBuilder . getLastState ( prereqProject ) ) ; for ( int j = <NUM_LIT:0> , m = children . length ; j < m ; j ++ ) findAffectedSourceFiles ( children [ j ] , segmentCount , structurallyChangedTypes ) ; this . notifier . checkCancel ( ) ; } } } } return true ; } protected void findAffectedSourceFiles ( IResourceDelta binaryDelta , int segmentCount , StringSet structurallyChangedTypes ) { IResource resource = binaryDelta . getResource ( ) ; switch ( resource . getType ( ) ) { case IResource . FOLDER : switch ( binaryDelta . getKind ( ) ) { case IResourceDelta . ADDED : case IResourceDelta . REMOVED : IPath packagePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) ; String packageName = packagePath . toString ( ) ; if ( binaryDelta . getKind ( ) == IResourceDelta . ADDED ) { if ( ! this . newState . isKnownPackage ( packageName ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + packageName ) ; addDependentsOf ( packagePath , false ) ; return ; } if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + packageName ) ; } else { if ( ! this . nameEnvironment . isPackage ( packageName ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + packageName ) ; addDependentsOf ( packagePath , false ) ; return ; } if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + packageName ) ; } case IResourceDelta . CHANGED : IResourceDelta [ ] children = binaryDelta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> , l = children . length ; i < l ; i ++ ) findAffectedSourceFiles ( children [ i ] , segmentCount , structurallyChangedTypes ) ; } return ; case IResource . FILE : if ( org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( resource . getName ( ) ) ) { IPath typePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) . removeFileExtension ( ) ; switch ( binaryDelta . getKind ( ) ) { case IResourceDelta . ADDED : case IResourceDelta . REMOVED : if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath ) ; addDependentsOf ( typePath , false ) ; return ; case IResourceDelta . CHANGED : if ( ( binaryDelta . getFlags ( ) & IResourceDelta . CONTENT ) == <NUM_LIT:0> ) return ; if ( structurallyChangedTypes != null && ! structurallyChangedTypes . includes ( typePath . toString ( ) ) ) return ; if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath ) ; addDependentsOf ( typePath , false ) ; } return ; } } } protected boolean findSourceFiles ( IResourceDelta delta ) throws CoreException { ArrayList visited = this . makeOutputFolderConsistent ? new ArrayList ( this . sourceLocations . length ) : null ; for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) { ClasspathMultiDirectory md = this . sourceLocations [ i ] ; if ( this . makeOutputFolderConsistent && md . hasIndependentOutputFolder && ! visited . contains ( md . binaryFolder ) ) { visited . add ( md . binaryFolder ) ; IResourceDelta binaryDelta = delta . findMember ( md . binaryFolder . getProjectRelativePath ( ) ) ; if ( binaryDelta != null ) { int segmentCount = binaryDelta . getFullPath ( ) . segmentCount ( ) ; IResourceDelta [ ] children = binaryDelta . getAffectedChildren ( ) ; for ( int j = <NUM_LIT:0> , m = children . length ; j < m ; j ++ ) if ( ! checkForClassFileChanges ( children [ j ] , md , segmentCount ) ) return false ; } } if ( md . sourceFolder . equals ( this . javaBuilder . currentProject ) ) { int segmentCount = delta . getFullPath ( ) . segmentCount ( ) ; IResourceDelta [ ] children = delta . getAffectedChildren ( ) ; for ( int j = <NUM_LIT:0> , m = children . length ; j < m ; j ++ ) if ( ! isExcludedFromProject ( children [ j ] . getFullPath ( ) ) ) if ( ! findSourceFiles ( children [ j ] , md , segmentCount ) ) return false ; } else { IResourceDelta sourceDelta = delta . findMember ( md . sourceFolder . getProjectRelativePath ( ) ) ; if ( sourceDelta != null ) { if ( sourceDelta . getKind ( ) == IResourceDelta . REMOVED ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; return false ; } int segmentCount = sourceDelta . getFullPath ( ) . segmentCount ( ) ; IResourceDelta [ ] children = sourceDelta . getAffectedChildren ( ) ; try { for ( int j = <NUM_LIT:0> , m = children . length ; j < m ; j ++ ) if ( ! findSourceFiles ( children [ j ] , md , segmentCount ) ) return false ; } catch ( CoreException e ) { if ( e . getStatus ( ) . getCode ( ) == IResourceStatus . CASE_VARIANT_EXISTS ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" ) ; return false ; } throw e ; } } } this . notifier . checkCancel ( ) ; } return true ; } protected boolean findSourceFiles ( IResourceDelta sourceDelta , ClasspathMultiDirectory md , int segmentCount ) throws CoreException { IResource resource = sourceDelta . getResource ( ) ; boolean isExcluded = ( md . exclusionPatterns != null || md . inclusionPatterns != null ) && Util . isExcluded ( resource , md . inclusionPatterns , md . exclusionPatterns ) ; switch ( resource . getType ( ) ) { case IResource . FOLDER : if ( isExcluded && md . inclusionPatterns == null ) return true ; switch ( sourceDelta . getKind ( ) ) { case IResourceDelta . ADDED : if ( ! isExcluded ) { IPath addedPackagePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) ; createFolder ( addedPackagePath , md . binaryFolder ) ; if ( this . sourceLocations . length > <NUM_LIT:1> && this . newState . isKnownPackage ( addedPackagePath . toString ( ) ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + addedPackagePath ) ; } else { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + addedPackagePath ) ; addDependentsOf ( addedPackagePath , true ) ; } } case IResourceDelta . CHANGED : IResourceDelta [ ] children = sourceDelta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> , l = children . length ; i < l ; i ++ ) if ( ! findSourceFiles ( children [ i ] , md , segmentCount ) ) return false ; return true ; case IResourceDelta . REMOVED : if ( isExcluded ) { children = sourceDelta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> , l = children . length ; i < l ; i ++ ) if ( ! findSourceFiles ( children [ i ] , md , segmentCount ) ) return false ; return true ; } IPath removedPackagePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) ; if ( this . sourceLocations . length > <NUM_LIT:1> ) { for ( int i = <NUM_LIT:0> , l = this . sourceLocations . length ; i < l ; i ++ ) { if ( this . sourceLocations [ i ] . sourceFolder . getFolder ( removedPackagePath ) . exists ( ) ) { if ( md . hasIndependentOutputFolder ) createFolder ( removedPackagePath , md . binaryFolder ) ; IResourceDelta [ ] removedChildren = sourceDelta . getAffectedChildren ( ) ; for ( int j = <NUM_LIT:0> , m = removedChildren . length ; j < m ; j ++ ) if ( ! findSourceFiles ( removedChildren [ j ] , md , segmentCount ) ) return false ; return true ; } } } if ( ( sourceDelta . getFlags ( ) & IResourceDelta . MOVED_TO ) != <NUM_LIT:0> ) { IResource movedFolder = this . javaBuilder . workspaceRoot . getFolder ( sourceDelta . getMovedToPath ( ) ) ; JavaBuilder . removeProblemsAndTasksFor ( movedFolder ) ; } IFolder removedPackageFolder = md . binaryFolder . getFolder ( removedPackagePath ) ; if ( removedPackageFolder . exists ( ) ) removedPackageFolder . delete ( IResource . FORCE , null ) ; if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + removedPackagePath ) ; addDependentsOf ( removedPackagePath , true ) ; this . newState . removePackage ( sourceDelta ) ; } return true ; case IResource . FILE : if ( isExcluded ) return true ; String resourceName = resource . getName ( ) ; final boolean isInterestingProject = LanguageSupportFactory . isInterestingProject ( this . javaBuilder . getProject ( ) ) ; if ( ( ! isInterestingProject && org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( resourceName ) && ! LanguageSupportFactory . isInterestingSourceFile ( resourceName ) ) || ( isInterestingProject && LanguageSupportFactory . isSourceFile ( resourceName , isInterestingProject ) ) ) { IPath typePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) . removeFileExtension ( ) ; String typeLocator = resource . getProjectRelativePath ( ) . toString ( ) ; switch ( sourceDelta . getKind ( ) ) { case IResourceDelta . ADDED : if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typeLocator ) ; this . sourceFiles . add ( new SourceFile ( ( IFile ) resource , md , true ) ) ; String typeName = typePath . toString ( ) ; if ( ! this . newState . isDuplicateLocator ( typeName , typeLocator ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typeName ) ; addDependentsOf ( typePath , true ) ; } return true ; case IResourceDelta . REMOVED : char [ ] [ ] definedTypeNames = this . newState . getDefinedTypeNamesFor ( typeLocator ) ; if ( definedTypeNames == null ) { removeClassFile ( typePath , md . binaryFolder ) ; if ( ( sourceDelta . getFlags ( ) & IResourceDelta . MOVED_TO ) != <NUM_LIT:0> ) { IResource movedFile = this . javaBuilder . workspaceRoot . getFile ( sourceDelta . getMovedToPath ( ) ) ; JavaBuilder . removeProblemsAndTasksFor ( movedFile ) ; } } else { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath . toString ( ) ) ; addDependentsOf ( typePath , true ) ; if ( definedTypeNames . length > <NUM_LIT:0> ) { IPath packagePath = typePath . removeLastSegments ( <NUM_LIT:1> ) ; for ( int i = <NUM_LIT:0> , l = definedTypeNames . length ; i < l ; i ++ ) removeClassFile ( packagePath . append ( new String ( definedTypeNames [ i ] ) ) , md . binaryFolder ) ; } } this . newState . removeLocator ( typeLocator ) ; return true ; case IResourceDelta . CHANGED : if ( ( sourceDelta . getFlags ( ) & IResourceDelta . CONTENT ) == <NUM_LIT:0> && ( sourceDelta . getFlags ( ) & IResourceDelta . ENCODING ) == <NUM_LIT:0> ) return true ; if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typeLocator ) ; this . sourceFiles . add ( new SourceFile ( ( IFile ) resource , md , true ) ) ; } return true ; } else if ( org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( resourceName ) ) { if ( this . makeOutputFolderConsistent ) { IPath typePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) . removeFileExtension ( ) ; if ( this . newState . isKnownType ( typePath . toString ( ) ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath ) ; return false ; } } return true ; } else if ( md . hasIndependentOutputFolder ) { if ( this . javaBuilder . filterExtraResource ( resource ) ) return true ; IPath resourcePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) ; IResource outputFile = md . binaryFolder . getFile ( resourcePath ) ; switch ( sourceDelta . getKind ( ) ) { case IResourceDelta . ADDED : if ( outputFile . exists ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + resourcePath ) ; outputFile . delete ( IResource . FORCE , null ) ; } if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + resourcePath ) ; createFolder ( resourcePath . removeLastSegments ( <NUM_LIT:1> ) , md . binaryFolder ) ; copyResource ( resource , outputFile ) ; return true ; case IResourceDelta . REMOVED : if ( outputFile . exists ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + resourcePath ) ; outputFile . delete ( IResource . FORCE , null ) ; } return true ; case IResourceDelta . CHANGED : if ( ( sourceDelta . getFlags ( ) & IResourceDelta . CONTENT ) == <NUM_LIT:0> && ( sourceDelta . getFlags ( ) & IResourceDelta . ENCODING ) == <NUM_LIT:0> ) return true ; if ( outputFile . exists ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + resourcePath ) ; outputFile . delete ( IResource . FORCE , null ) ; } if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + resourcePath ) ; createFolder ( resourcePath . removeLastSegments ( <NUM_LIT:1> ) , md . binaryFolder ) ; copyResource ( resource , outputFile ) ; } return true ; } } return true ; } protected void finishedWith ( String sourceLocator , CompilationResult result , char [ ] mainTypeName , ArrayList definedTypeNames , ArrayList duplicateTypeNames ) { char [ ] [ ] previousTypeNames = this . newState . getDefinedTypeNamesFor ( sourceLocator ) ; if ( previousTypeNames == null ) previousTypeNames = new char [ ] [ ] { mainTypeName } ; IPath packagePath = null ; next : for ( int i = <NUM_LIT:0> , l = previousTypeNames . length ; i < l ; i ++ ) { char [ ] previous = previousTypeNames [ i ] ; for ( int j = <NUM_LIT:0> , m = definedTypeNames . size ( ) ; j < m ; j ++ ) if ( CharOperation . equals ( previous , ( char [ ] ) definedTypeNames . get ( j ) ) ) continue next ; SourceFile sourceFile = ( SourceFile ) result . getCompilationUnit ( ) ; if ( packagePath == null ) { int count = sourceFile . sourceLocation . sourceFolder . getFullPath ( ) . segmentCount ( ) ; packagePath = sourceFile . resource . getFullPath ( ) . removeFirstSegments ( count ) . removeLastSegments ( <NUM_LIT:1> ) ; } if ( this . secondaryTypesToRemove == null ) this . secondaryTypesToRemove = new SimpleLookupTable ( ) ; ArrayList types = ( ArrayList ) this . secondaryTypesToRemove . get ( sourceFile . sourceLocation . binaryFolder ) ; if ( types == null ) types = new ArrayList ( definedTypeNames . size ( ) ) ; types . add ( packagePath . append ( new String ( previous ) ) ) ; this . secondaryTypesToRemove . put ( sourceFile . sourceLocation . binaryFolder , types ) ; } super . finishedWith ( sourceLocator , result , mainTypeName , definedTypeNames , duplicateTypeNames ) ; } protected void processAnnotationResults ( CompilationParticipantResult [ ] results ) { for ( int i = results . length ; -- i >= <NUM_LIT:0> ; ) { CompilationParticipantResult result = results [ i ] ; if ( result == null ) continue ; IFile [ ] deletedGeneratedFiles = result . deletedFiles ; if ( deletedGeneratedFiles != null ) deleteGeneratedFiles ( deletedGeneratedFiles ) ; IFile [ ] addedGeneratedFiles = result . addedFiles ; if ( addedGeneratedFiles != null ) { for ( int j = addedGeneratedFiles . length ; -- j >= <NUM_LIT:0> ; ) { SourceFile sourceFile = findSourceFile ( addedGeneratedFiles [ j ] , true ) ; if ( sourceFile != null && ! this . sourceFiles . contains ( sourceFile ) ) this . sourceFiles . add ( sourceFile ) ; } } recordParticipantResult ( result ) ; } } protected void removeClassFile ( IPath typePath , IContainer outputFolder ) throws CoreException { if ( typePath . lastSegment ( ) . indexOf ( '<CHAR_LIT>' ) == - <NUM_LIT:1> ) { this . newState . removeQualifiedTypeName ( typePath . toString ( ) ) ; if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath ) ; addDependentsOf ( typePath , true ) ; } IFile classFile = outputFolder . getFile ( typePath . addFileExtension ( SuffixConstants . EXTENSION_class ) ) ; if ( classFile . exists ( ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + typePath ) ; classFile . delete ( IResource . FORCE , null ) ; } } protected void removeSecondaryTypes ( ) throws CoreException { if ( this . secondaryTypesToRemove != null ) { Object [ ] keyTable = this . secondaryTypesToRemove . keyTable ; Object [ ] valueTable = this . secondaryTypesToRemove . valueTable ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { IContainer outputFolder = ( IContainer ) keyTable [ i ] ; if ( outputFolder != null ) { ArrayList paths = ( ArrayList ) valueTable [ i ] ; for ( int j = <NUM_LIT:0> , m = paths . size ( ) ; j < m ; j ++ ) removeClassFile ( ( IPath ) paths . get ( j ) , outputFolder ) ; } } this . secondaryTypesToRemove = null ; if ( this . previousSourceFiles != null ) this . previousSourceFiles = null ; } } protected void resetCollections ( ) { if ( this . sourceFiles == null ) { this . sourceFiles = new ArrayList ( <NUM_LIT> ) ; this . previousSourceFiles = null ; this . qualifiedStrings = new StringSet ( <NUM_LIT:3> ) ; this . simpleStrings = new StringSet ( <NUM_LIT:3> ) ; this . rootStrings = new StringSet ( <NUM_LIT:3> ) ; this . hasStructuralChanges = false ; this . compileLoop = <NUM_LIT:0> ; } else { this . previousSourceFiles = this . sourceFiles . isEmpty ( ) ? null : ( ArrayList ) this . sourceFiles . clone ( ) ; this . sourceFiles . clear ( ) ; this . qualifiedStrings . clear ( ) ; this . simpleStrings . clear ( ) ; this . rootStrings . clear ( ) ; this . workQueue . clear ( ) ; } } protected void updateProblemsFor ( SourceFile sourceFile , CompilationResult result ) throws CoreException { if ( CharOperation . equals ( sourceFile . getMainTypeName ( ) , TypeConstants . PACKAGE_INFO_NAME ) ) { IResource pkgResource = sourceFile . resource . getParent ( ) ; pkgResource . deleteMarkers ( IJavaModelMarker . JAVA_MODEL_PROBLEM_MARKER , false , IResource . DEPTH_INFINITE ) ; } IMarker [ ] markers = JavaBuilder . getProblemsFor ( sourceFile . resource ) ; CategorizedProblem [ ] problems = result . getProblems ( ) ; if ( problems == null && markers . length == <NUM_LIT:0> ) return ; this . notifier . updateProblemCounts ( markers , problems ) ; JavaBuilder . removeProblemsFor ( sourceFile . resource ) ; storeProblemsFor ( sourceFile , problems ) ; } protected void updateTasksFor ( SourceFile sourceFile , CompilationResult result ) throws CoreException { IMarker [ ] markers = JavaBuilder . getTasksFor ( sourceFile . resource ) ; CategorizedProblem [ ] tasks = result . getTasks ( ) ; if ( tasks == null && markers . length == <NUM_LIT:0> ) return ; JavaBuilder . removeTasksFor ( sourceFile . resource ) ; storeTasksFor ( sourceFile , tasks ) ; } protected void writeClassFileContents ( ClassFile classfile , IFile file , String qualifiedFileName , boolean isTopLevelType , SourceFile compilationUnit ) throws CoreException { byte [ ] bytes = classfile . getBytes ( ) ; if ( file . exists ( ) ) { if ( writeClassFileCheck ( file , qualifiedFileName , bytes ) || compilationUnit . updateClassFile ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + file . getName ( ) ) ; if ( ! file . isDerived ( ) ) file . setDerived ( true , null ) ; file . setContents ( new ByteArrayInputStream ( bytes ) , true , false , null ) ; } else if ( JavaBuilder . DEBUG ) { System . out . println ( "<STR_LIT>" + file . getName ( ) ) ; } } else { if ( isTopLevelType ) addDependentsOf ( new Path ( qualifiedFileName ) , true ) ; if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + file . getName ( ) ) ; try { file . create ( new ByteArrayInputStream ( bytes ) , IResource . FORCE | IResource . DERIVED , null ) ; } catch ( CoreException e ) { if ( e . getStatus ( ) . getCode ( ) == IResourceStatus . CASE_VARIANT_EXISTS ) { IStatus status = e . getStatus ( ) ; if ( status instanceof IResourceStatus ) { IPath oldFilePath = ( ( IResourceStatus ) status ) . getPath ( ) ; char [ ] oldTypeName = oldFilePath . removeFileExtension ( ) . lastSegment ( ) . toCharArray ( ) ; char [ ] [ ] previousTypeNames = this . newState . getDefinedTypeNamesFor ( compilationUnit . typeLocator ( ) ) ; boolean fromSameFile = false ; if ( previousTypeNames == null ) { fromSameFile = CharOperation . equals ( compilationUnit . getMainTypeName ( ) , oldTypeName ) ; } else { for ( int i = <NUM_LIT:0> , l = previousTypeNames . length ; i < l ; i ++ ) { if ( CharOperation . equals ( previousTypeNames [ i ] , oldTypeName ) ) { fromSameFile = true ; break ; } } } if ( fromSameFile ) { IFile collision = file . getParent ( ) . getFile ( new Path ( oldFilePath . lastSegment ( ) ) ) ; collision . delete ( true , false , null ) ; boolean success = false ; try { file . create ( new ByteArrayInputStream ( bytes ) , IResource . FORCE | IResource . DERIVED , null ) ; success = true ; } catch ( CoreException ignored ) { } if ( success ) return ; } } throw new AbortCompilation ( true , new AbortIncrementalBuildException ( qualifiedFileName ) ) ; } throw e ; } } } protected boolean writeClassFileCheck ( IFile file , String fileName , byte [ ] newBytes ) throws CoreException { try { byte [ ] oldBytes = Util . getResourceContentsAsByteArray ( file ) ; notEqual : if ( newBytes . length == oldBytes . length ) { for ( int i = newBytes . length ; -- i >= <NUM_LIT:0> ; ) if ( newBytes [ i ] != oldBytes [ i ] ) break notEqual ; return false ; } URI location = file . getLocationURI ( ) ; if ( location == null ) return false ; String filePath = location . getSchemeSpecificPart ( ) ; ClassFileReader reader = new ClassFileReader ( oldBytes , filePath . toCharArray ( ) ) ; if ( ! ( reader . isLocal ( ) || reader . isAnonymous ( ) ) && reader . hasStructuralChanges ( newBytes ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( "<STR_LIT>" + fileName ) ; addDependentsOf ( new Path ( fileName ) , true ) ; this . newState . wasStructurallyChanged ( fileName ) ; } } catch ( ClassFormatException e ) { addDependentsOf ( new Path ( fileName ) , true ) ; this . newState . wasStructurallyChanged ( fileName ) ; } return true ; } public String toString ( ) { return "<STR_LIT>" + this . newState ; } } </s>
|
<s> package org . eclipse . jdt . internal . core . builder ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . core . util . Messages ; public class BuildNotifier { protected IProgressMonitor monitor ; protected boolean cancelling ; protected float percentComplete ; protected float progressPerCompilationUnit ; protected int newErrorCount ; protected int fixedErrorCount ; protected int newWarningCount ; protected int fixedWarningCount ; protected int workDone ; protected int totalWork ; protected String previousSubtask ; public static int NewErrorCount = <NUM_LIT:0> ; public static int FixedErrorCount = <NUM_LIT:0> ; public static int NewWarningCount = <NUM_LIT:0> ; public static int FixedWarningCount = <NUM_LIT:0> ; public static void resetProblemCounters ( ) { NewErrorCount = <NUM_LIT:0> ; FixedErrorCount = <NUM_LIT:0> ; NewWarningCount = <NUM_LIT:0> ; FixedWarningCount = <NUM_LIT:0> ; } public BuildNotifier ( IProgressMonitor monitor , IProject project ) { this . monitor = monitor ; this . cancelling = false ; this . newErrorCount = NewErrorCount ; this . fixedErrorCount = FixedErrorCount ; this . newWarningCount = NewWarningCount ; this . fixedWarningCount = FixedWarningCount ; this . workDone = <NUM_LIT:0> ; this . totalWork = <NUM_LIT> ; } public void aboutToCompile ( SourceFile unit ) { String message = Messages . bind ( Messages . build_compiling , unit . resource . getFullPath ( ) . removeLastSegments ( <NUM_LIT:1> ) . makeRelative ( ) . toString ( ) ) ; subTask ( message ) ; } public void begin ( ) { if ( this . monitor != null ) this . monitor . beginTask ( "<STR_LIT>" , this . totalWork ) ; this . previousSubtask = null ; } public void checkCancel ( ) { if ( this . monitor != null && this . monitor . isCanceled ( ) ) throw new OperationCanceledException ( ) ; } public void checkCancelWithinCompiler ( ) { if ( this . monitor != null && this . monitor . isCanceled ( ) && ! this . cancelling ) { setCancelling ( true ) ; throw new AbortCompilation ( true , null ) ; } } public void compiled ( SourceFile unit ) { String message = Messages . bind ( Messages . build_compiling , unit . resource . getFullPath ( ) . removeLastSegments ( <NUM_LIT:1> ) . makeRelative ( ) . toString ( ) ) ; subTask ( message ) ; updateProgressDelta ( this . progressPerCompilationUnit ) ; checkCancelWithinCompiler ( ) ; } public void done ( ) { NewErrorCount = this . newErrorCount ; FixedErrorCount = this . fixedErrorCount ; NewWarningCount = this . newWarningCount ; FixedWarningCount = this . fixedWarningCount ; updateProgress ( <NUM_LIT:1.0f> ) ; subTask ( Messages . build_done ) ; if ( this . monitor != null ) this . monitor . done ( ) ; this . previousSubtask = null ; } protected String problemsMessage ( ) { int numNew = this . newErrorCount + this . newWarningCount ; int numFixed = this . fixedErrorCount + this . fixedWarningCount ; if ( numNew == <NUM_LIT:0> && numFixed == <NUM_LIT:0> ) return "<STR_LIT>" ; boolean displayBoth = numNew > <NUM_LIT:0> && numFixed > <NUM_LIT:0> ; StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( '<CHAR_LIT:(>' ) ; if ( numNew > <NUM_LIT:0> ) { buffer . append ( Messages . build_foundHeader ) ; buffer . append ( '<CHAR_LIT:U+0020>' ) ; if ( displayBoth || this . newErrorCount > <NUM_LIT:0> ) { if ( this . newErrorCount == <NUM_LIT:1> ) buffer . append ( Messages . build_oneError ) ; else buffer . append ( Messages . bind ( Messages . build_multipleErrors , String . valueOf ( this . newErrorCount ) ) ) ; if ( displayBoth || this . newWarningCount > <NUM_LIT:0> ) buffer . append ( "<STR_LIT>" ) ; } if ( displayBoth || this . newWarningCount > <NUM_LIT:0> ) { if ( this . newWarningCount == <NUM_LIT:1> ) buffer . append ( Messages . build_oneWarning ) ; else buffer . append ( Messages . bind ( Messages . build_multipleWarnings , String . valueOf ( this . newWarningCount ) ) ) ; } if ( numFixed > <NUM_LIT:0> ) buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } if ( numFixed > <NUM_LIT:0> ) { buffer . append ( Messages . build_fixedHeader ) ; buffer . append ( '<CHAR_LIT:U+0020>' ) ; if ( displayBoth ) { buffer . append ( String . valueOf ( this . fixedErrorCount ) ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( String . valueOf ( this . fixedWarningCount ) ) ; } else { if ( this . fixedErrorCount > <NUM_LIT:0> ) { if ( this . fixedErrorCount == <NUM_LIT:1> ) buffer . append ( Messages . build_oneError ) ; else buffer . append ( Messages . bind ( Messages . build_multipleErrors , String . valueOf ( this . fixedErrorCount ) ) ) ; if ( this . fixedWarningCount > <NUM_LIT:0> ) buffer . append ( "<STR_LIT>" ) ; } if ( this . fixedWarningCount > <NUM_LIT:0> ) { if ( this . fixedWarningCount == <NUM_LIT:1> ) buffer . append ( Messages . build_oneWarning ) ; else buffer . append ( Messages . bind ( Messages . build_multipleWarnings , String . valueOf ( this . fixedWarningCount ) ) ) ; } } } buffer . append ( '<CHAR_LIT:)>' ) ; return buffer . toString ( ) ; } public void setCancelling ( boolean cancelling ) { this . cancelling = cancelling ; } public void setProgressPerCompilationUnit ( float progress ) { this . progressPerCompilationUnit = progress ; } public void subTask ( String message ) { String pm = problemsMessage ( ) ; String msg = pm . length ( ) == <NUM_LIT:0> ? message : pm + "<STR_LIT:U+0020>" + message ; if ( msg . equals ( this . previousSubtask ) ) return ; if ( this . monitor != null ) this . monitor . subTask ( msg ) ; this . previousSubtask = msg ; } protected void updateProblemCounts ( CategorizedProblem [ ] newProblems ) { for ( int i = <NUM_LIT:0> , l = newProblems . length ; i < l ; i ++ ) if ( newProblems [ i ] . isError ( ) ) this . newErrorCount ++ ; else this . newWarningCount ++ ; } protected void updateProblemCounts ( IMarker [ ] oldProblems , CategorizedProblem [ ] newProblems ) { if ( newProblems != null ) { next : for ( int i = <NUM_LIT:0> , l = newProblems . length ; i < l ; i ++ ) { CategorizedProblem newProblem = newProblems [ i ] ; if ( newProblem . getID ( ) == IProblem . Task ) continue ; boolean isError = newProblem . isError ( ) ; String message = newProblem . getMessage ( ) ; if ( oldProblems != null ) { for ( int j = <NUM_LIT:0> , m = oldProblems . length ; j < m ; j ++ ) { IMarker pb = oldProblems [ j ] ; if ( pb == null ) continue ; boolean wasError = IMarker . SEVERITY_ERROR == pb . getAttribute ( IMarker . SEVERITY , IMarker . SEVERITY_ERROR ) ; if ( isError == wasError && message . equals ( pb . getAttribute ( IMarker . MESSAGE , "<STR_LIT>" ) ) ) { oldProblems [ j ] = null ; continue next ; } } } if ( isError ) this . newErrorCount ++ ; else this . newWarningCount ++ ; } } if ( oldProblems != null ) { next : for ( int i = <NUM_LIT:0> , l = oldProblems . length ; i < l ; i ++ ) { IMarker oldProblem = oldProblems [ i ] ; if ( oldProblem == null ) continue next ; boolean wasError = IMarker . SEVERITY_ERROR == oldProblem . getAttribute ( IMarker . SEVERITY , IMarker . SEVERITY_ERROR ) ; String message = oldProblem . getAttribute ( IMarker . MESSAGE , "<STR_LIT>" ) ; if ( newProblems != null ) { for ( int j = <NUM_LIT:0> , m = newProblems . length ; j < m ; j ++ ) { CategorizedProblem pb = newProblems [ j ] ; if ( pb . getID ( ) == IProblem . Task ) continue ; if ( wasError == pb . isError ( ) && message . equals ( pb . getMessage ( ) ) ) continue next ; } } if ( wasError ) this . fixedErrorCount ++ ; else this . fixedWarningCount ++ ; } } } public void updateProgress ( float newPercentComplete ) { if ( newPercentComplete > this . percentComplete ) { this . percentComplete = Math . min ( newPercentComplete , <NUM_LIT:1.0f> ) ; int work = Math . round ( this . percentComplete * this . totalWork ) ; if ( work > this . workDone ) { if ( this . monitor != null ) this . monitor . worked ( work - this . workDone ) ; this . workDone = work ; } } } public void updateProgressDelta ( float percentWorked ) { updateProgress ( this . percentComplete + percentWorked ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . ISourceRange ; import org . eclipse . jdt . core . SourceRange ; class SourceRefElementInfo extends JavaElementInfo { protected int sourceRangeStart , sourceRangeEnd ; public int getDeclarationSourceEnd ( ) { return this . sourceRangeEnd ; } public int getDeclarationSourceStart ( ) { return this . sourceRangeStart ; } protected ISourceRange getSourceRange ( ) { return new SourceRange ( this . sourceRangeStart , this . sourceRangeEnd - this . sourceRangeStart + <NUM_LIT:1> ) ; } protected void setSourceRangeEnd ( int end ) { this . sourceRangeEnd = end ; } protected void setSourceRangeStart ( int start ) { this . sourceRangeStart = start ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . BufferedInputStream ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . InputStream ; import java . lang . reflect . InvocationTargetException ; import java . lang . reflect . Method ; import java . net . JarURLConnection ; import java . net . MalformedURLException ; import java . net . ProtocolException ; import java . net . SocketException ; import java . net . SocketTimeoutException ; import java . net . URL ; import java . net . URLConnection ; import java . net . UnknownHostException ; import java . util . ArrayList ; import java . util . HashMap ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . * ; import org . eclipse . core . runtime . jobs . ISchedulingRule ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . core . util . MementoTokenizer ; import org . eclipse . jdt . internal . core . util . Util ; public abstract class JavaElement extends PlatformObject implements IJavaElement { private static final byte [ ] CLOSING_DOUBLE_QUOTE = new byte [ ] { <NUM_LIT> } ; private static final byte [ ] CHARSET = new byte [ ] { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; private static final byte [ ] CONTENT_TYPE = new byte [ ] { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; private static final byte [ ] CONTENT = new byte [ ] { <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ; public static final char JEM_ESCAPE = '<STR_LIT:\\>' ; public static final char JEM_JAVAPROJECT = '<CHAR_LIT:=>' ; public static final char JEM_PACKAGEFRAGMENTROOT = '<CHAR_LIT:/>' ; public static final char JEM_PACKAGEFRAGMENT = '<CHAR_LIT>' ; public static final char JEM_FIELD = '<CHAR_LIT>' ; public static final char JEM_METHOD = '<CHAR_LIT>' ; public static final char JEM_INITIALIZER = '<CHAR_LIT>' ; public static final char JEM_COMPILATIONUNIT = '<CHAR_LIT>' ; public static final char JEM_CLASSFILE = '<CHAR_LIT:(>' ; public static final char JEM_TYPE = '<CHAR_LIT:[>' ; public static final char JEM_PACKAGEDECLARATION = '<CHAR_LIT>' ; public static final char JEM_IMPORTDECLARATION = '<CHAR_LIT>' ; public static final char JEM_COUNT = '<CHAR_LIT>' ; public static final char JEM_LOCALVARIABLE = '<CHAR_LIT>' ; public static final char JEM_TYPE_PARAMETER = '<CHAR_LIT:]>' ; public static final char JEM_ANNOTATION = '<CHAR_LIT:}>' ; protected JavaElement parent ; protected static final JavaElement [ ] NO_ELEMENTS = new JavaElement [ <NUM_LIT:0> ] ; protected static final Object NO_INFO = new Object ( ) ; protected JavaElement ( JavaElement parent ) throws IllegalArgumentException { this . parent = parent ; } public void close ( ) throws JavaModelException { JavaModelManager . getJavaModelManager ( ) . removeInfoAndChildren ( this ) ; } protected abstract void closing ( Object info ) throws JavaModelException ; protected abstract Object createElementInfo ( ) ; public boolean equals ( Object o ) { if ( this == o ) return true ; if ( this . parent == null ) return super . equals ( o ) ; JavaElement other = ( JavaElement ) o ; return getElementName ( ) . equals ( other . getElementName ( ) ) && this . parent . equals ( other . parent ) ; } protected void escapeMementoName ( StringBuffer buffer , String mementoName ) { for ( int i = <NUM_LIT:0> , length = mementoName . length ( ) ; i < length ; i ++ ) { char character = mementoName . charAt ( i ) ; switch ( character ) { case JEM_ESCAPE : case JEM_COUNT : case JEM_JAVAPROJECT : case JEM_PACKAGEFRAGMENTROOT : case JEM_PACKAGEFRAGMENT : case JEM_FIELD : case JEM_METHOD : case JEM_INITIALIZER : case JEM_COMPILATIONUNIT : case JEM_CLASSFILE : case JEM_TYPE : case JEM_PACKAGEDECLARATION : case JEM_IMPORTDECLARATION : case JEM_LOCALVARIABLE : case JEM_TYPE_PARAMETER : case JEM_ANNOTATION : buffer . append ( JEM_ESCAPE ) ; } buffer . append ( character ) ; } } public boolean exists ( ) { try { getElementInfo ( ) ; return true ; } catch ( JavaModelException e ) { } return false ; } public ASTNode findNode ( CompilationUnit ast ) { return null ; } protected abstract void generateInfos ( Object info , HashMap newElements , IProgressMonitor pm ) throws JavaModelException ; public IJavaElement getAncestor ( int ancestorType ) { IJavaElement element = this ; while ( element != null ) { if ( element . getElementType ( ) == ancestorType ) return element ; element = element . getParent ( ) ; } return null ; } public IJavaElement [ ] getChildren ( ) throws JavaModelException { Object elementInfo = getElementInfo ( ) ; if ( elementInfo instanceof JavaElementInfo ) { return ( ( JavaElementInfo ) elementInfo ) . getChildren ( ) ; } else { return NO_ELEMENTS ; } } public ArrayList getChildrenOfType ( int type ) throws JavaModelException { IJavaElement [ ] children = getChildren ( ) ; int size = children . length ; ArrayList list = new ArrayList ( size ) ; for ( int i = <NUM_LIT:0> ; i < size ; ++ i ) { JavaElement elt = ( JavaElement ) children [ i ] ; if ( elt . getElementType ( ) == type ) { list . add ( elt ) ; } } return list ; } public IClassFile getClassFile ( ) { return null ; } public ICompilationUnit getCompilationUnit ( ) { return null ; } public Object getElementInfo ( ) throws JavaModelException { return getElementInfo ( null ) ; } public Object getElementInfo ( IProgressMonitor monitor ) throws JavaModelException { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; Object info = manager . getInfo ( this ) ; if ( info != null ) return info ; return openWhenClosed ( createElementInfo ( ) , false , monitor ) ; } public String getElementName ( ) { return "<STR_LIT>" ; } public abstract IJavaElement getHandleFromMemento ( String token , MementoTokenizer memento , WorkingCopyOwner owner ) ; public IJavaElement getHandleFromMemento ( MementoTokenizer memento , WorkingCopyOwner owner ) { if ( ! memento . hasMoreTokens ( ) ) return this ; String token = memento . nextToken ( ) ; return getHandleFromMemento ( token , memento , owner ) ; } public String getHandleIdentifier ( ) { return getHandleMemento ( ) ; } public String getHandleMemento ( ) { StringBuffer buff = new StringBuffer ( ) ; getHandleMemento ( buff ) ; return buff . toString ( ) ; } protected void getHandleMemento ( StringBuffer buff ) { ( ( JavaElement ) getParent ( ) ) . getHandleMemento ( buff ) ; buff . append ( getHandleMementoDelimiter ( ) ) ; escapeMementoName ( buff , getElementName ( ) ) ; } protected abstract char getHandleMementoDelimiter ( ) ; public IJavaModel getJavaModel ( ) { IJavaElement current = this ; do { if ( current instanceof IJavaModel ) return ( IJavaModel ) current ; } while ( ( current = current . getParent ( ) ) != null ) ; return null ; } public IJavaProject getJavaProject ( ) { IJavaElement current = this ; do { if ( current instanceof IJavaProject ) return ( IJavaProject ) current ; } while ( ( current = current . getParent ( ) ) != null ) ; return null ; } public IOpenable getOpenable ( ) { return getOpenableParent ( ) ; } public IOpenable getOpenableParent ( ) { return ( IOpenable ) this . parent ; } public IJavaElement getParent ( ) { return this . parent ; } public IJavaElement getPrimaryElement ( ) { return getPrimaryElement ( true ) ; } public IJavaElement getPrimaryElement ( boolean checkOwner ) { return this ; } public IResource getResource ( ) { return resource ( ) ; } public abstract IResource resource ( ) ; protected IJavaElement getSourceElementAt ( int position ) throws JavaModelException { if ( this instanceof ISourceReference ) { IJavaElement [ ] children = getChildren ( ) ; for ( int i = children . length - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { IJavaElement aChild = children [ i ] ; if ( aChild instanceof SourceRefElement ) { SourceRefElement child = ( SourceRefElement ) children [ i ] ; ISourceRange range = child . getSourceRange ( ) ; int start = range . getOffset ( ) ; int end = start + range . getLength ( ) ; if ( start <= position && position <= end ) { if ( child instanceof IField ) { int declarationStart = start ; SourceRefElement candidate = null ; do { range = ( ( IField ) child ) . getNameRange ( ) ; if ( position <= range . getOffset ( ) + range . getLength ( ) ) { candidate = child ; } else { return candidate == null ? child . getSourceElementAt ( position ) : candidate . getSourceElementAt ( position ) ; } child = -- i >= <NUM_LIT:0> ? ( SourceRefElement ) children [ i ] : null ; } while ( child != null && child . getSourceRange ( ) . getOffset ( ) == declarationStart ) ; return candidate . getSourceElementAt ( position ) ; } else if ( child instanceof IParent ) { return child . getSourceElementAt ( position ) ; } else { return child ; } } } } } else { Assert . isTrue ( false ) ; } return this ; } public SourceMapper getSourceMapper ( ) { return ( ( JavaElement ) getParent ( ) ) . getSourceMapper ( ) ; } public ISchedulingRule getSchedulingRule ( ) { IResource resource = resource ( ) ; if ( resource == null ) { class NoResourceSchedulingRule implements ISchedulingRule { public IPath path ; public NoResourceSchedulingRule ( IPath path ) { this . path = path ; } public boolean contains ( ISchedulingRule rule ) { if ( rule instanceof NoResourceSchedulingRule ) { return this . path . isPrefixOf ( ( ( NoResourceSchedulingRule ) rule ) . path ) ; } else { return false ; } } public boolean isConflicting ( ISchedulingRule rule ) { if ( rule instanceof NoResourceSchedulingRule ) { IPath otherPath = ( ( NoResourceSchedulingRule ) rule ) . path ; return this . path . isPrefixOf ( otherPath ) || otherPath . isPrefixOf ( this . path ) ; } else { return false ; } } } return new NoResourceSchedulingRule ( getPath ( ) ) ; } else { return resource ; } } public boolean hasChildren ( ) throws JavaModelException { Object elementInfo = JavaModelManager . getJavaModelManager ( ) . getInfo ( this ) ; if ( elementInfo instanceof JavaElementInfo ) { return ( ( JavaElementInfo ) elementInfo ) . getChildren ( ) . length > <NUM_LIT:0> ; } else { return true ; } } public int hashCode ( ) { if ( this . parent == null ) return super . hashCode ( ) ; return Util . combineHashCodes ( getElementName ( ) . hashCode ( ) , this . parent . hashCode ( ) ) ; } public boolean isAncestorOf ( IJavaElement e ) { IJavaElement parentElement = e . getParent ( ) ; while ( parentElement != null && ! parentElement . equals ( this ) ) { parentElement = parentElement . getParent ( ) ; } return parentElement != null ; } public boolean isReadOnly ( ) { return false ; } public JavaModelException newNotPresentException ( ) { return new JavaModelException ( newDoesNotExistStatus ( ) ) ; } protected JavaModelStatus newDoesNotExistStatus ( ) { return new JavaModelStatus ( IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST , this ) ; } public JavaModelException newJavaModelException ( IStatus status ) { if ( status instanceof IJavaModelStatus ) return new JavaModelException ( ( IJavaModelStatus ) status ) ; else return new JavaModelException ( new JavaModelStatus ( status . getSeverity ( ) , status . getCode ( ) , status . getMessage ( ) ) ) ; } protected Object openWhenClosed ( Object info , IProgressMonitor monitor ) throws JavaModelException { return openWhenClosed ( info , true , monitor ) ; } protected Object openWhenClosed ( Object info , boolean forceAdd , IProgressMonitor monitor ) throws JavaModelException { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; boolean hadTemporaryCache = manager . hasTemporaryCache ( ) ; try { HashMap newElements = manager . getTemporaryCache ( ) ; generateInfos ( info , newElements , monitor ) ; if ( info == null ) { info = newElements . get ( this ) ; } if ( info == null ) { Openable openable = ( Openable ) getOpenable ( ) ; if ( newElements . containsKey ( openable ) ) { openable . closeBuffer ( ) ; } throw newNotPresentException ( ) ; } if ( ! hadTemporaryCache ) { info = manager . putInfos ( this , info , forceAdd , newElements ) ; } } finally { if ( ! hadTemporaryCache ) { manager . resetTemporaryCache ( ) ; } } return info ; } public String readableName ( ) { return getElementName ( ) ; } public JavaElement resolved ( Binding binding ) { return this ; } public JavaElement unresolved ( ) { return this ; } protected String tabString ( int tab ) { StringBuffer buffer = new StringBuffer ( ) ; for ( int i = tab ; i > <NUM_LIT:0> ; i -- ) buffer . append ( "<STR_LIT:U+0020U+0020>" ) ; return buffer . toString ( ) ; } public String toDebugString ( ) { StringBuffer buffer = new StringBuffer ( ) ; this . toStringInfo ( <NUM_LIT:0> , buffer , NO_INFO , true ) ; return buffer . toString ( ) ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; toString ( <NUM_LIT:0> , buffer ) ; return buffer . toString ( ) ; } protected void toString ( int tab , StringBuffer buffer ) { Object info = this . toStringInfo ( tab , buffer ) ; if ( tab == <NUM_LIT:0> ) { toStringAncestors ( buffer ) ; } toStringChildren ( tab , buffer , info ) ; } public String toStringWithAncestors ( ) { return toStringWithAncestors ( true ) ; } public String toStringWithAncestors ( boolean showResolvedInfo ) { StringBuffer buffer = new StringBuffer ( ) ; this . toStringInfo ( <NUM_LIT:0> , buffer , NO_INFO , showResolvedInfo ) ; toStringAncestors ( buffer ) ; return buffer . toString ( ) ; } protected void toStringAncestors ( StringBuffer buffer ) { JavaElement parentElement = ( JavaElement ) getParent ( ) ; if ( parentElement != null && parentElement . getParent ( ) != null ) { buffer . append ( "<STR_LIT>" ) ; parentElement . toStringInfo ( <NUM_LIT:0> , buffer , NO_INFO , false ) ; parentElement . toStringAncestors ( buffer ) ; buffer . append ( "<STR_LIT:]>" ) ; } } protected void toStringChildren ( int tab , StringBuffer buffer , Object info ) { if ( info == null || ! ( info instanceof JavaElementInfo ) ) return ; IJavaElement [ ] children = ( ( JavaElementInfo ) info ) . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { buffer . append ( "<STR_LIT:n>" ) ; ( ( JavaElement ) children [ i ] ) . toString ( tab + <NUM_LIT:1> , buffer ) ; } } public Object toStringInfo ( int tab , StringBuffer buffer ) { Object info = JavaModelManager . getJavaModelManager ( ) . peekAtInfo ( this ) ; this . toStringInfo ( tab , buffer , info , true ) ; return info ; } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { buffer . append ( tabString ( tab ) ) ; toStringName ( buffer ) ; if ( info == null ) { buffer . append ( "<STR_LIT>" ) ; } } protected void toStringName ( StringBuffer buffer ) { buffer . append ( getElementName ( ) ) ; } protected URL getJavadocBaseLocation ( ) throws JavaModelException { IPackageFragmentRoot root = ( IPackageFragmentRoot ) getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; if ( root == null ) { return null ; } if ( root . getKind ( ) == IPackageFragmentRoot . K_BINARY ) { IClasspathEntry entry = null ; try { entry = root . getResolvedClasspathEntry ( ) ; URL url = getLibraryJavadocLocation ( entry ) ; if ( url != null ) { return url ; } } catch ( JavaModelException jme ) { } entry = root . getRawClasspathEntry ( ) ; switch ( entry . getEntryKind ( ) ) { case IClasspathEntry . CPE_LIBRARY : case IClasspathEntry . CPE_VARIABLE : return getLibraryJavadocLocation ( entry ) ; default : return null ; } } return null ; } protected static URL getLibraryJavadocLocation ( IClasspathEntry entry ) throws JavaModelException { switch ( entry . getEntryKind ( ) ) { case IClasspathEntry . CPE_LIBRARY : case IClasspathEntry . CPE_VARIABLE : break ; default : throw new IllegalArgumentException ( "<STR_LIT>" ) ; } IClasspathAttribute [ ] extraAttributes = entry . getExtraAttributes ( ) ; for ( int i = <NUM_LIT:0> ; i < extraAttributes . length ; i ++ ) { IClasspathAttribute attrib = extraAttributes [ i ] ; if ( IClasspathAttribute . JAVADOC_LOCATION_ATTRIBUTE_NAME . equals ( attrib . getName ( ) ) ) { String value = attrib . getValue ( ) ; try { return new URL ( value ) ; } catch ( MalformedURLException e ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . CANNOT_RETRIEVE_ATTACHED_JAVADOC , value ) ) ; } } } return null ; } public String getAttachedJavadoc ( IProgressMonitor monitor ) throws JavaModelException { return null ; } int getIndexOf ( byte [ ] array , byte [ ] toBeFound , int start ) { if ( array == null || toBeFound == null ) return - <NUM_LIT:1> ; final int toBeFoundLength = toBeFound . length ; final int arrayLength = array . length ; if ( arrayLength < toBeFoundLength ) return - <NUM_LIT:1> ; loop : for ( int i = start , max = arrayLength - toBeFoundLength + <NUM_LIT:1> ; i < max ; i ++ ) { if ( array [ i ] == toBeFound [ <NUM_LIT:0> ] ) { for ( int j = <NUM_LIT:1> ; j < toBeFoundLength ; j ++ ) { if ( array [ i + j ] != toBeFound [ j ] ) continue loop ; } return i ; } } return - <NUM_LIT:1> ; } protected String getURLContents ( String docUrlValue ) throws JavaModelException { InputStream stream = null ; JarURLConnection connection2 = null ; try { URL docUrl = new URL ( docUrlValue ) ; URLConnection connection = docUrl . openConnection ( ) ; Class [ ] parameterTypes = new Class [ ] { int . class } ; Integer timeoutVal = new Integer ( <NUM_LIT> ) ; Class URLClass = connection . getClass ( ) ; try { Method connectTimeoutMethod = URLClass . getDeclaredMethod ( "<STR_LIT>" , parameterTypes ) ; Method readTimeoutMethod = URLClass . getDeclaredMethod ( "<STR_LIT>" , parameterTypes ) ; connectTimeoutMethod . invoke ( connection , new Object [ ] { timeoutVal } ) ; readTimeoutMethod . invoke ( connection , new Object [ ] { timeoutVal } ) ; } catch ( SecurityException e ) { } catch ( IllegalArgumentException e ) { } catch ( NoSuchMethodException e ) { } catch ( IllegalAccessException e ) { } catch ( InvocationTargetException e ) { } if ( connection instanceof JarURLConnection ) { connection2 = ( JarURLConnection ) connection ; connection . setUseCaches ( false ) ; } try { stream = new BufferedInputStream ( connection . getInputStream ( ) ) ; } catch ( IllegalArgumentException e ) { return null ; } catch ( NullPointerException e ) { return null ; } String encoding = connection . getContentEncoding ( ) ; byte [ ] contents = org . eclipse . jdt . internal . compiler . util . Util . getInputStreamAsByteArray ( stream , connection . getContentLength ( ) ) ; if ( encoding == null ) { int index = getIndexOf ( contents , CONTENT_TYPE , <NUM_LIT:0> ) ; if ( index != - <NUM_LIT:1> ) { index = getIndexOf ( contents , CONTENT , index ) ; if ( index != - <NUM_LIT:1> ) { int offset = index + CONTENT . length ; int index2 = getIndexOf ( contents , CLOSING_DOUBLE_QUOTE , offset ) ; if ( index2 != - <NUM_LIT:1> ) { final int charsetIndex = getIndexOf ( contents , CHARSET , offset ) ; if ( charsetIndex != - <NUM_LIT:1> ) { int start = charsetIndex + CHARSET . length ; encoding = new String ( contents , start , index2 - start , org . eclipse . jdt . internal . compiler . util . Util . UTF_8 ) ; } } } } } try { if ( encoding == null ) { encoding = getJavaProject ( ) . getProject ( ) . getDefaultCharset ( ) ; } } catch ( CoreException e ) { } if ( contents != null ) { if ( encoding != null ) { return new String ( contents , encoding ) ; } else { return new String ( contents ) ; } } } catch ( SocketTimeoutException e ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . CANNOT_RETRIEVE_ATTACHED_JAVADOC_TIMEOUT , this ) ) ; } catch ( MalformedURLException e ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . CANNOT_RETRIEVE_ATTACHED_JAVADOC , this ) ) ; } catch ( FileNotFoundException e ) { } catch ( SocketException e ) { } catch ( UnknownHostException e ) { } catch ( ProtocolException e ) { } catch ( IOException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . IO_EXCEPTION ) ; } finally { if ( stream != null ) { try { stream . close ( ) ; } catch ( IOException e ) { } } if ( connection2 != null ) { try { connection2 . getJarFile ( ) . close ( ) ; } catch ( IOException e ) { } catch ( IllegalStateException e ) { } } } return null ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . InputStream ; import org . eclipse . core . resources . IContainer ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IResource ; 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 class NonJavaResource extends PlatformObject implements IJarEntryResource { private static final IJarEntryResource [ ] NO_CHILDREN = new IJarEntryResource [ <NUM_LIT:0> ] ; protected Object parent ; protected IResource resource ; public NonJavaResource ( Object parent , IResource resource ) { this . parent = parent ; this . resource = resource ; } public boolean equals ( Object obj ) { if ( ! ( obj instanceof NonJavaResource ) ) return false ; NonJavaResource other = ( NonJavaResource ) obj ; return this . parent . equals ( other . parent ) && this . resource . equals ( other . resource ) ; } public IJarEntryResource [ ] getChildren ( ) { if ( this . resource instanceof IContainer ) { IResource [ ] members ; try { members = ( ( IContainer ) this . resource ) . members ( ) ; } catch ( CoreException e ) { Util . log ( e , "<STR_LIT>" + this . resource . getFullPath ( ) ) ; return NO_CHILDREN ; } int length = members . length ; if ( length == <NUM_LIT:0> ) return NO_CHILDREN ; IJarEntryResource [ ] children = new IJarEntryResource [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { children [ i ] = new NonJavaResource ( this , members [ i ] ) ; } return children ; } return NO_CHILDREN ; } public InputStream getContents ( ) throws CoreException { if ( this . resource instanceof IFile ) return ( ( IFile ) this . resource ) . getContents ( ) ; return null ; } 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 = ( ( NonJavaResource ) this . parent ) . getEntryName ( ) + '<CHAR_LIT:/>' ; } return parentEntryName + getName ( ) ; } public IPath getFullPath ( ) { return new Path ( getEntryName ( ) ) . makeAbsolute ( ) ; } public String getName ( ) { return this . resource . getName ( ) ; } 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 ( ( NonJavaResource ) this . parent ) . getPackageFragmentRoot ( ) ; } } public Object getParent ( ) { return this . parent ; } public int hashCode ( ) { return Util . combineHashCodes ( this . resource . hashCode ( ) , this . parent . hashCode ( ) ) ; } public boolean isFile ( ) { return this . resource instanceof IFile ; } public boolean isReadOnly ( ) { return true ; } public String toString ( ) { return "<STR_LIT>" + getEntryName ( ) + "<STR_LIT:]>" ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . IFile ; import org . eclipse . jdt . core . IOpenable ; public class NullBuffer extends Buffer { public NullBuffer ( IFile file , IOpenable owner , boolean readOnly ) { super ( file , owner , readOnly ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaElementDelta ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaModelException ; public class DiscardWorkingCopyOperation extends JavaModelOperation { public DiscardWorkingCopyOperation ( IJavaElement workingCopy ) { super ( new IJavaElement [ ] { workingCopy } ) ; } protected void executeOperation ( ) throws JavaModelException { CompilationUnit workingCopy = getWorkingCopy ( ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; int useCount = manager . discardPerWorkingCopyInfo ( workingCopy ) ; if ( useCount == <NUM_LIT:0> ) { IJavaProject javaProject = workingCopy . getJavaProject ( ) ; if ( ExternalJavaProject . EXTERNAL_PROJECT_NAME . equals ( javaProject . getElementName ( ) ) ) { manager . removePerProjectInfo ( ( JavaProject ) javaProject , true ) ; manager . containerRemove ( javaProject ) ; } if ( ! workingCopy . isPrimary ( ) ) { JavaElementDelta delta = new JavaElementDelta ( getJavaModel ( ) ) ; delta . removed ( workingCopy ) ; addDelta ( delta ) ; removeReconcileDelta ( workingCopy ) ; } else { if ( workingCopy . getResource ( ) . isAccessible ( ) ) { JavaElementDelta delta = new JavaElementDelta ( getJavaModel ( ) ) ; delta . changed ( workingCopy , IJavaElementDelta . F_PRIMARY_WORKING_COPY ) ; addDelta ( delta ) ; } else { JavaElementDelta delta = new JavaElementDelta ( getJavaModel ( ) ) ; delta . removed ( workingCopy , IJavaElementDelta . F_PRIMARY_WORKING_COPY ) ; addDelta ( delta ) ; } } } } protected CompilationUnit getWorkingCopy ( ) { return ( CompilationUnit ) getElementToProcess ( ) ; } public boolean isReadOnly ( ) { return true ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IJavaElement ; public class ImportContainerInfo extends JavaElementInfo { protected IJavaElement [ ] children = JavaElement . NO_ELEMENTS ; public IJavaElement [ ] getChildren ( ) { return this . children ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . HashMap ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . env . ISourceField ; import org . eclipse . jdt . internal . compiler . env . ISourceImport ; import org . eclipse . jdt . internal . compiler . env . ISourceMethod ; import org . eclipse . jdt . internal . compiler . env . ISourceType ; public class SourceTypeElementInfo extends AnnotatableInfo implements ISourceType { protected static final ISourceImport [ ] NO_IMPORTS = new ISourceImport [ <NUM_LIT:0> ] ; protected static final InitializerElementInfo [ ] NO_INITIALIZERS = new InitializerElementInfo [ <NUM_LIT:0> ] ; protected static final SourceField [ ] NO_FIELDS = new SourceField [ <NUM_LIT:0> ] ; protected static final SourceMethod [ ] NO_METHODS = new SourceMethod [ <NUM_LIT:0> ] ; protected static final SourceType [ ] NO_TYPES = new SourceType [ <NUM_LIT:0> ] ; protected IJavaElement [ ] children = JavaElement . NO_ELEMENTS ; protected char [ ] superclassName ; protected char [ ] [ ] superInterfaceNames ; protected IType handle = null ; protected ITypeParameter [ ] typeParameters = TypeParameter . NO_TYPE_PARAMETERS ; protected HashMap categories ; protected void addCategories ( IJavaElement element , char [ ] [ ] elementCategories ) { if ( elementCategories == null ) return ; if ( this . categories == null ) this . categories = new HashMap ( ) ; this . categories . put ( element , CharOperation . toStrings ( elementCategories ) ) ; } public HashMap getCategories ( ) { return this . categories ; } public IJavaElement [ ] getChildren ( ) { return this . children ; } public ISourceType getEnclosingType ( ) { IJavaElement parent = this . handle . getParent ( ) ; if ( parent != null && parent . getElementType ( ) == IJavaElement . TYPE ) { try { return ( ISourceType ) ( ( JavaElement ) parent ) . getElementInfo ( ) ; } catch ( JavaModelException e ) { return null ; } } else { return null ; } } public ISourceField [ ] getFields ( ) { SourceField [ ] fieldHandles = getFieldHandles ( ) ; int length = fieldHandles . length ; ISourceField [ ] fields = new ISourceField [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { try { ISourceField field = ( ISourceField ) fieldHandles [ i ] . getElementInfo ( ) ; fields [ i ] = field ; } catch ( JavaModelException e ) { } } return fields ; } public SourceField [ ] getFieldHandles ( ) { int length = this . children . length ; if ( length == <NUM_LIT:0> ) return NO_FIELDS ; SourceField [ ] fields = new SourceField [ length ] ; int fieldIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IJavaElement child = this . children [ i ] ; if ( child instanceof SourceField ) fields [ fieldIndex ++ ] = ( SourceField ) child ; } if ( fieldIndex == <NUM_LIT:0> ) return NO_FIELDS ; if ( fieldIndex < length ) System . arraycopy ( fields , <NUM_LIT:0> , fields = new SourceField [ fieldIndex ] , <NUM_LIT:0> , fieldIndex ) ; return fields ; } public char [ ] getFileName ( ) { return this . handle . getPath ( ) . toString ( ) . toCharArray ( ) ; } public IType getHandle ( ) { return this . handle ; } public InitializerElementInfo [ ] getInitializers ( ) { int length = this . children . length ; if ( length == <NUM_LIT:0> ) return NO_INITIALIZERS ; InitializerElementInfo [ ] initializers = new InitializerElementInfo [ length ] ; int initializerIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IJavaElement child = this . children [ i ] ; if ( child instanceof Initializer ) { try { InitializerElementInfo initializer = ( InitializerElementInfo ) ( ( Initializer ) child ) . getElementInfo ( ) ; initializers [ initializerIndex ++ ] = initializer ; } catch ( JavaModelException e ) { } } } if ( initializerIndex == <NUM_LIT:0> ) return NO_INITIALIZERS ; System . arraycopy ( initializers , <NUM_LIT:0> , initializers = new InitializerElementInfo [ initializerIndex ] , <NUM_LIT:0> , initializerIndex ) ; return initializers ; } public char [ ] [ ] getInterfaceNames ( ) { if ( this . handle . getElementName ( ) . length ( ) == <NUM_LIT:0> ) { return null ; } return this . superInterfaceNames ; } public ISourceType [ ] getMemberTypes ( ) { SourceType [ ] memberTypeHandles = getMemberTypeHandles ( ) ; int length = memberTypeHandles . length ; ISourceType [ ] memberTypes = new ISourceType [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { try { ISourceType type = ( ISourceType ) memberTypeHandles [ i ] . getElementInfo ( ) ; memberTypes [ i ] = type ; } catch ( JavaModelException e ) { } } return memberTypes ; } public SourceType [ ] getMemberTypeHandles ( ) { int length = this . children . length ; if ( length == <NUM_LIT:0> ) return NO_TYPES ; SourceType [ ] memberTypes = new SourceType [ length ] ; int typeIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IJavaElement child = this . children [ i ] ; if ( child instanceof SourceType ) memberTypes [ typeIndex ++ ] = ( SourceType ) child ; } if ( typeIndex == <NUM_LIT:0> ) return NO_TYPES ; if ( typeIndex < length ) System . arraycopy ( memberTypes , <NUM_LIT:0> , memberTypes = new SourceType [ typeIndex ] , <NUM_LIT:0> , typeIndex ) ; return memberTypes ; } public ISourceMethod [ ] getMethods ( ) { SourceMethod [ ] methodHandles = getMethodHandles ( ) ; int length = methodHandles . length ; ISourceMethod [ ] methods = new ISourceMethod [ length ] ; int methodIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { try { ISourceMethod method = ( ISourceMethod ) methodHandles [ i ] . getElementInfo ( ) ; methods [ methodIndex ++ ] = method ; } catch ( JavaModelException e ) { } } return methods ; } public SourceMethod [ ] getMethodHandles ( ) { int length = this . children . length ; if ( length == <NUM_LIT:0> ) return NO_METHODS ; SourceMethod [ ] methods = new SourceMethod [ length ] ; int methodIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IJavaElement child = this . children [ i ] ; if ( child instanceof SourceMethod ) methods [ methodIndex ++ ] = ( SourceMethod ) child ; } if ( methodIndex == <NUM_LIT:0> ) return NO_METHODS ; if ( methodIndex < length ) System . arraycopy ( methods , <NUM_LIT:0> , methods = new SourceMethod [ methodIndex ] , <NUM_LIT:0> , methodIndex ) ; return methods ; } public char [ ] getName ( ) { return this . handle . getElementName ( ) . toCharArray ( ) ; } public char [ ] getSuperclassName ( ) { if ( this . handle . getElementName ( ) . length ( ) == <NUM_LIT:0> ) { char [ ] [ ] interfaceNames = this . superInterfaceNames ; if ( interfaceNames != null && interfaceNames . length > <NUM_LIT:0> ) { return interfaceNames [ <NUM_LIT:0> ] ; } } return this . superclassName ; } 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 boolean isBinaryType ( ) { return false ; } public boolean isAnonymousMember ( ) { return false ; } protected void setHandle ( IType handle ) { this . handle = handle ; } protected void setSuperclassName ( char [ ] superclassName ) { this . superclassName = superclassName ; } protected void setSuperInterfaceNames ( char [ ] [ ] superInterfaceNames ) { this . superInterfaceNames = superInterfaceNames ; } public String toString ( ) { return "<STR_LIT>" + this . handle . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . List ; import java . util . Map ; 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 . IType ; 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 . ASTParser ; import org . eclipse . jdt . core . dom . AnnotationTypeDeclaration ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . core . dom . EnumDeclaration ; import org . eclipse . jdt . core . dom . SimpleName ; import org . eclipse . jdt . core . dom . StructuralPropertyDescriptor ; import org . eclipse . jdt . core . dom . TypeDeclaration ; import org . eclipse . jdt . core . dom . rewrite . ASTRewrite ; import org . eclipse . jdt . core . formatter . IndentManipulation ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; public abstract class CreateTypeMemberOperation extends CreateElementInCUOperation { protected String source = null ; protected String alteredName ; protected ASTNode createdNode ; public CreateTypeMemberOperation ( IJavaElement parentElement , String source , boolean force ) { super ( parentElement ) ; this . source = source ; this . force = force ; } protected StructuralPropertyDescriptor getChildPropertyDescriptor ( ASTNode parent ) { switch ( parent . getNodeType ( ) ) { case ASTNode . COMPILATION_UNIT : return CompilationUnit . TYPES_PROPERTY ; case ASTNode . ENUM_DECLARATION : return EnumDeclaration . BODY_DECLARATIONS_PROPERTY ; case ASTNode . ANNOTATION_TYPE_DECLARATION : return AnnotationTypeDeclaration . BODY_DECLARATIONS_PROPERTY ; default : return TypeDeclaration . BODY_DECLARATIONS_PROPERTY ; } } protected ASTNode generateElementAST ( ASTRewrite rewriter , ICompilationUnit cu ) throws JavaModelException { if ( this . createdNode == null ) { this . source = removeIndentAndNewLines ( this . source , cu ) ; ASTParser parser = ASTParser . newParser ( AST . JLS4 ) ; parser . setSource ( this . source . toCharArray ( ) ) ; parser . setProject ( getCompilationUnit ( ) . getJavaProject ( ) ) ; parser . setKind ( ASTParser . K_CLASS_BODY_DECLARATIONS ) ; ASTNode node = parser . createAST ( this . progressMonitor ) ; String createdNodeSource ; if ( node . getNodeType ( ) != ASTNode . TYPE_DECLARATION ) { createdNodeSource = generateSyntaxIncorrectAST ( ) ; if ( this . createdNode == null ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_CONTENTS ) ) ; } else { TypeDeclaration typeDeclaration = ( TypeDeclaration ) node ; if ( ( typeDeclaration . getFlags ( ) & ASTNode . MALFORMED ) != <NUM_LIT:0> ) { createdNodeSource = generateSyntaxIncorrectAST ( ) ; if ( this . createdNode == null ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_CONTENTS ) ) ; } else { List bodyDeclarations = typeDeclaration . bodyDeclarations ( ) ; if ( bodyDeclarations . size ( ) == <NUM_LIT:0> ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_CONTENTS ) ) ; } this . createdNode = ( ASTNode ) bodyDeclarations . iterator ( ) . next ( ) ; createdNodeSource = this . source ; } } if ( this . alteredName != null ) { SimpleName newName = this . createdNode . getAST ( ) . newSimpleName ( this . alteredName ) ; SimpleName oldName = rename ( this . createdNode , newName ) ; int nameStart = oldName . getStartPosition ( ) ; int nameEnd = nameStart + oldName . getLength ( ) ; StringBuffer newSource = new StringBuffer ( ) ; if ( this . source . equals ( createdNodeSource ) ) { newSource . append ( createdNodeSource . substring ( <NUM_LIT:0> , nameStart ) ) ; newSource . append ( this . alteredName ) ; newSource . append ( createdNodeSource . substring ( nameEnd ) ) ; } else { int createdNodeStart = this . createdNode . getStartPosition ( ) ; int createdNodeEnd = createdNodeStart + this . createdNode . getLength ( ) ; newSource . append ( createdNodeSource . substring ( createdNodeStart , nameStart ) ) ; newSource . append ( this . alteredName ) ; newSource . append ( createdNodeSource . substring ( nameEnd , createdNodeEnd ) ) ; } this . source = newSource . toString ( ) ; } } if ( rewriter == null ) return this . createdNode ; return rewriter . createStringPlaceholder ( this . source , this . createdNode . getNodeType ( ) ) ; } private String removeIndentAndNewLines ( String code , ICompilationUnit cu ) throws JavaModelException { IJavaProject project = cu . getJavaProject ( ) ; Map options = project . getOptions ( true ) ; int tabWidth = IndentManipulation . getTabWidth ( options ) ; int indentWidth = IndentManipulation . getIndentWidth ( options ) ; int indent = IndentManipulation . measureIndentUnits ( code , tabWidth , indentWidth ) ; int firstNonWhiteSpace = - <NUM_LIT:1> ; int length = code . length ( ) ; while ( firstNonWhiteSpace < length - <NUM_LIT:1> ) if ( ! ScannerHelper . isWhitespace ( code . charAt ( ++ firstNonWhiteSpace ) ) ) break ; int lastNonWhiteSpace = length ; while ( lastNonWhiteSpace > <NUM_LIT:0> ) if ( ! ScannerHelper . isWhitespace ( code . charAt ( -- lastNonWhiteSpace ) ) ) break ; String lineDelimiter = cu . findRecommendedLineSeparator ( ) ; return IndentManipulation . changeIndent ( code . substring ( firstNonWhiteSpace , lastNonWhiteSpace + <NUM_LIT:1> ) , indent , tabWidth , indentWidth , "<STR_LIT>" , lineDelimiter ) ; } protected abstract SimpleName rename ( ASTNode node , SimpleName newName ) ; protected String generateSyntaxIncorrectAST ( ) { StringBuffer buff = new StringBuffer ( ) ; IType type = getType ( ) ; String lineSeparator = org . eclipse . jdt . internal . core . util . Util . getLineSeparator ( this . source , type == null ? null : type . getJavaProject ( ) ) ; buff . append ( lineSeparator + "<STR_LIT>" + lineSeparator ) ; buff . append ( this . source ) ; buff . append ( lineSeparator ) . append ( '<CHAR_LIT:}>' ) ; ASTParser parser = ASTParser . newParser ( AST . JLS4 ) ; parser . setSource ( buff . toString ( ) . toCharArray ( ) ) ; CompilationUnit compilationUnit = ( CompilationUnit ) parser . createAST ( null ) ; TypeDeclaration typeDeclaration = ( TypeDeclaration ) compilationUnit . types ( ) . iterator ( ) . next ( ) ; List bodyDeclarations = typeDeclaration . bodyDeclarations ( ) ; if ( bodyDeclarations . size ( ) != <NUM_LIT:0> ) this . createdNode = ( ASTNode ) bodyDeclarations . iterator ( ) . next ( ) ; return buff . toString ( ) ; } protected IType getType ( ) { return ( IType ) getParentElement ( ) ; } protected void setAlteredName ( String newName ) { this . alteredName = newName ; } public IJavaModelStatus verify ( ) { IJavaModelStatus status = super . verify ( ) ; if ( ! status . isOK ( ) ) { return status ; } if ( this . source == null ) { return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_CONTENTS ) ; } if ( ! this . force ) { try { ICompilationUnit cu = getCompilationUnit ( ) ; generateElementAST ( null , cu ) ; } catch ( JavaModelException jme ) { return jme . getJavaModelStatus ( ) ; } return verifyNameCollision ( ) ; } return JavaModelStatus . VERIFIED_OK ; } protected IJavaModelStatus verifyNameCollision ( ) { return JavaModelStatus . VERIFIED_OK ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; public class ExternalJavaProject extends JavaProject { public static final String EXTERNAL_PROJECT_NAME = "<STR_LIT:U+0020>" ; public ExternalJavaProject ( IClasspathEntry [ ] rawClasspath ) { super ( ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getProject ( EXTERNAL_PROJECT_NAME ) , JavaModelManager . getJavaModelManager ( ) . getJavaModel ( ) ) ; try { getPerProjectInfo ( ) . setRawClasspath ( rawClasspath , defaultOutputLocation ( ) , JavaModelStatus . VERIFIED_OK ) ; } catch ( JavaModelException e ) { } } public boolean equals ( Object o ) { return this == o ; } public boolean exists ( ) { return false ; } public String getOption ( String optionName , boolean inheritJavaCoreOptions ) { if ( JavaCore . COMPILER_PB_FORBIDDEN_REFERENCE . equals ( optionName ) || JavaCore . COMPILER_PB_DISCOURAGED_REFERENCE . equals ( optionName ) ) return JavaCore . IGNORE ; return super . getOption ( optionName , inheritJavaCoreOptions ) ; } public boolean isOnClasspath ( IJavaElement element ) { return false ; } public boolean isOnClasspath ( IResource resource ) { return false ; } protected IStatus validateExistence ( IResource underlyingResource ) { return JavaModelStatus . VERIFIED_OK ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . Iterator ; import java . util . List ; 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 . IType ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . MethodDeclaration ; import org . eclipse . jdt . core . dom . SimpleName ; import org . eclipse . jdt . core . dom . SingleVariableDeclaration ; import org . eclipse . jdt . core . dom . rewrite . ASTRewrite ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; public class CreateMethodOperation extends CreateTypeMemberOperation { protected String [ ] parameterTypes ; public CreateMethodOperation ( IType parentElement , String source , boolean force ) { super ( parentElement , source , force ) ; } protected String [ ] convertASTMethodTypesToSignatures ( ) { if ( this . parameterTypes == null ) { if ( this . createdNode != null ) { MethodDeclaration methodDeclaration = ( MethodDeclaration ) this . createdNode ; List parameters = methodDeclaration . parameters ( ) ; int size = parameters . size ( ) ; this . parameterTypes = new String [ size ] ; Iterator iterator = parameters . iterator ( ) ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { SingleVariableDeclaration parameter = ( SingleVariableDeclaration ) iterator . next ( ) ; String typeSig = Util . getSignature ( parameter . getType ( ) ) ; int extraDimensions = parameter . getExtraDimensions ( ) ; if ( methodDeclaration . isVarargs ( ) && i == size - <NUM_LIT:1> ) extraDimensions ++ ; this . parameterTypes [ i ] = Signature . createArraySignature ( typeSig , extraDimensions ) ; } } } return this . parameterTypes ; } protected ASTNode generateElementAST ( ASTRewrite rewriter , ICompilationUnit cu ) throws JavaModelException { ASTNode node = super . generateElementAST ( rewriter , cu ) ; if ( node . getNodeType ( ) != ASTNode . METHOD_DECLARATION ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_CONTENTS ) ) ; return node ; } protected IJavaElement generateResultHandle ( ) { String [ ] types = convertASTMethodTypesToSignatures ( ) ; String name = getASTNodeName ( ) ; return getType ( ) . getMethod ( name , types ) ; } private String getASTNodeName ( ) { return ( ( MethodDeclaration ) this . createdNode ) . getName ( ) . getIdentifier ( ) ; } public String getMainTaskName ( ) { return Messages . operation_createMethodProgress ; } protected SimpleName rename ( ASTNode node , SimpleName newName ) { MethodDeclaration method = ( MethodDeclaration ) node ; SimpleName oldName = method . getName ( ) ; method . setName ( newName ) ; return oldName ; } protected IJavaModelStatus verifyNameCollision ( ) { if ( this . createdNode != null ) { IType type = getType ( ) ; String name ; if ( ( ( MethodDeclaration ) this . createdNode ) . isConstructor ( ) ) name = type . getElementName ( ) ; else name = getASTNodeName ( ) ; String [ ] types = convertASTMethodTypesToSignatures ( ) ; if ( type . getMethod ( name , types ) . exists ( ) ) { return new JavaModelStatus ( IJavaModelStatusConstants . NAME_COLLISION , Messages . bind ( Messages . status_nameCollision , name ) ) ; } } return JavaModelStatus . VERIFIED_OK ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . jobs . ISchedulingRule ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . JavaModelException ; public abstract class ChangeClasspathOperation extends JavaModelOperation { protected boolean canChangeResources ; public ChangeClasspathOperation ( IJavaElement [ ] elements , boolean canChangeResources ) { super ( elements ) ; this . canChangeResources = canChangeResources ; } protected boolean canModifyRoots ( ) { return true ; } protected void classpathChanged ( ClasspathChange change , boolean refreshExternalFolder ) throws JavaModelException { JavaProject project = change . project ; project . resetCaches ( ) ; if ( this . canChangeResources ) { if ( isTopLevelOperation ( ) && ! ResourcesPlugin . getWorkspace ( ) . isTreeLocked ( ) ) { new ClasspathValidation ( project ) . validate ( ) ; } new ProjectReferenceChange ( project , change . oldResolvedClasspath ) . updateProjectReferencesIfNecessary ( ) ; new ExternalFolderChange ( project , change . oldResolvedClasspath ) . updateExternalFoldersIfNecessary ( refreshExternalFolder , null ) ; } else { DeltaProcessingState state = JavaModelManager . getDeltaState ( ) ; JavaElementDelta delta = new JavaElementDelta ( getJavaModel ( ) ) ; int result = change . generateDelta ( delta , true ) ; if ( ( result & ClasspathChange . HAS_DELTA ) != <NUM_LIT:0> ) { addDelta ( delta ) ; state . rootsAreStale = true ; change . requestIndexing ( ) ; state . addClasspathValidation ( project ) ; } if ( ( result & ClasspathChange . HAS_PROJECT_CHANGE ) != <NUM_LIT:0> ) { state . addProjectReferenceChange ( project , change . oldResolvedClasspath ) ; } if ( ( result & ClasspathChange . HAS_LIBRARY_CHANGE ) != <NUM_LIT:0> ) { state . addExternalFolderChange ( project , change . oldResolvedClasspath ) ; } } } protected ISchedulingRule getSchedulingRule ( ) { return null ; } public boolean isReadOnly ( ) { return ! this . canChangeResources ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IMemberValuePair ; public class AnnotationInfo extends SourceRefElementInfo { public int nameStart = - <NUM_LIT:1> ; public int nameEnd = - <NUM_LIT:1> ; public IMemberValuePair [ ] members ; } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . core . runtime . IPath ; 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 . IMember ; import org . eclipse . jdt . core . IParent ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . util . Messages ; public class CopyElementsOperation extends MultiOperation implements SuffixConstants { private Map sources = new HashMap ( ) ; public CopyElementsOperation ( IJavaElement [ ] elementsToCopy , IJavaElement [ ] destContainers , boolean force ) { super ( elementsToCopy , destContainers , force ) ; } public CopyElementsOperation ( IJavaElement [ ] elementsToCopy , IJavaElement destContainer , boolean force ) { this ( elementsToCopy , new IJavaElement [ ] { destContainer } , force ) ; } protected String getMainTaskName ( ) { return Messages . operation_copyElementProgress ; } protected JavaModelOperation getNestedOperation ( IJavaElement element ) { try { IJavaElement dest = getDestinationParent ( element ) ; switch ( element . getElementType ( ) ) { case IJavaElement . PACKAGE_DECLARATION : return new CreatePackageDeclarationOperation ( element . getElementName ( ) , ( ICompilationUnit ) dest ) ; case IJavaElement . IMPORT_DECLARATION : IImportDeclaration importDeclaration = ( IImportDeclaration ) element ; return new CreateImportOperation ( element . getElementName ( ) , ( ICompilationUnit ) dest , importDeclaration . getFlags ( ) ) ; case IJavaElement . TYPE : if ( isRenamingMainType ( element , dest ) ) { IPath path = element . getPath ( ) ; String extension = path . getFileExtension ( ) ; return new RenameResourceElementsOperation ( new IJavaElement [ ] { dest } , new IJavaElement [ ] { dest . getParent ( ) } , new String [ ] { getNewNameFor ( element ) + '<CHAR_LIT:.>' + extension } , this . force ) ; } else { String source = getSourceFor ( element ) ; String lineSeparator = org . eclipse . jdt . internal . core . util . Util . getLineSeparator ( source , element . getJavaProject ( ) ) ; return new CreateTypeOperation ( dest , source + lineSeparator , this . force ) ; } case IJavaElement . METHOD : String source = getSourceFor ( element ) ; String lineSeparator = org . eclipse . jdt . internal . core . util . Util . getLineSeparator ( source , element . getJavaProject ( ) ) ; return new CreateMethodOperation ( ( IType ) dest , source + lineSeparator , this . force ) ; case IJavaElement . FIELD : source = getSourceFor ( element ) ; lineSeparator = org . eclipse . jdt . internal . core . util . Util . getLineSeparator ( source , element . getJavaProject ( ) ) ; return new CreateFieldOperation ( ( IType ) dest , source + lineSeparator , this . force ) ; case IJavaElement . INITIALIZER : source = getSourceFor ( element ) ; lineSeparator = org . eclipse . jdt . internal . core . util . Util . getLineSeparator ( source , element . getJavaProject ( ) ) ; return new CreateInitializerOperation ( ( IType ) dest , source + lineSeparator ) ; default : return null ; } } catch ( JavaModelException npe ) { return null ; } } private String getSourceFor ( IJavaElement element ) throws JavaModelException { String source = ( String ) this . sources . get ( element ) ; if ( source == null && element instanceof IMember ) { source = ( ( IMember ) element ) . getSource ( ) ; this . sources . put ( element , source ) ; } return source ; } protected boolean isRenamingMainType ( IJavaElement element , IJavaElement dest ) throws JavaModelException { if ( ( isRename ( ) || getNewNameFor ( element ) != null ) && dest . getElementType ( ) == IJavaElement . COMPILATION_UNIT ) { String typeName = dest . getElementName ( ) ; typeName = org . eclipse . jdt . internal . core . util . Util . getNameWithoutJavaLikeExtension ( typeName ) ; return element . getElementName ( ) . equals ( typeName ) && element . getParent ( ) . equals ( dest ) ; } return false ; } protected void processElement ( IJavaElement element ) throws JavaModelException { JavaModelOperation op = getNestedOperation ( element ) ; boolean createElementInCUOperation = op instanceof CreateElementInCUOperation ; if ( op == null ) { return ; } if ( createElementInCUOperation ) { IJavaElement sibling = ( IJavaElement ) this . insertBeforeElements . get ( element ) ; if ( sibling != null ) { ( ( CreateElementInCUOperation ) op ) . setRelativePosition ( sibling , CreateElementInCUOperation . INSERT_BEFORE ) ; } else if ( isRename ( ) ) { IJavaElement anchor = resolveRenameAnchor ( element ) ; if ( anchor != null ) { ( ( CreateElementInCUOperation ) op ) . setRelativePosition ( anchor , CreateElementInCUOperation . INSERT_AFTER ) ; } } String newName = getNewNameFor ( element ) ; if ( newName != null ) { ( ( CreateElementInCUOperation ) op ) . setAlteredName ( newName ) ; } } executeNestedOperation ( op , <NUM_LIT:1> ) ; JavaElement destination = ( JavaElement ) getDestinationParent ( element ) ; ICompilationUnit unit = destination . getCompilationUnit ( ) ; if ( ! unit . isWorkingCopy ( ) ) { unit . close ( ) ; } if ( createElementInCUOperation && isMove ( ) && ! isRenamingMainType ( element , destination ) ) { JavaModelOperation deleteOp = new DeleteElementsOperation ( new IJavaElement [ ] { element } , this . force ) ; executeNestedOperation ( deleteOp , <NUM_LIT:1> ) ; } } private IJavaElement resolveRenameAnchor ( IJavaElement element ) throws JavaModelException { IParent parent = ( IParent ) element . getParent ( ) ; IJavaElement [ ] children = parent . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { IJavaElement child = children [ i ] ; if ( child . equals ( element ) ) { return child ; } } return null ; } protected IJavaModelStatus verify ( ) { IJavaModelStatus status = super . verify ( ) ; if ( ! status . isOK ( ) ) { return status ; } if ( this . renamingsList != null && this . renamingsList . length != this . elementsToProcess . length ) { return new JavaModelStatus ( IJavaModelStatusConstants . INDEX_OUT_OF_BOUNDS ) ; } return JavaModelStatus . VERIFIED_OK ; } protected void verify ( IJavaElement element ) throws JavaModelException { if ( element == null || ! element . exists ( ) ) error ( IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST , element ) ; if ( element . getElementType ( ) < IJavaElement . TYPE ) error ( IJavaModelStatusConstants . INVALID_ELEMENT_TYPES , element ) ; if ( element . isReadOnly ( ) ) error ( IJavaModelStatusConstants . READ_ONLY , element ) ; IJavaElement dest = getDestinationParent ( element ) ; verifyDestination ( element , dest ) ; verifySibling ( element , dest ) ; if ( this . renamingsList != null ) { verifyRenaming ( element ) ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . IOException ; import java . io . StringReader ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . Map ; import java . util . Set ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . core . runtime . preferences . IEclipsePreferences ; import org . eclipse . jdt . core . IClasspathContainer ; import org . eclipse . jdt . core . IClasspathEntry ; 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 . Util ; import org . osgi . service . prefs . BackingStoreException ; public class UserLibraryManager { public final static String CP_USERLIBRARY_PREFERENCES_PREFIX = JavaCore . PLUGIN_ID + "<STR_LIT>" ; private Map userLibraries ; public UserLibraryManager ( ) { initialize ( ) ; } public synchronized UserLibrary getUserLibrary ( String libName ) { return ( UserLibrary ) this . userLibraries . get ( libName ) ; } public synchronized String [ ] getUserLibraryNames ( ) { Set set = this . userLibraries . keySet ( ) ; return ( String [ ] ) set . toArray ( new String [ set . size ( ) ] ) ; } private void initialize ( ) { this . userLibraries = new HashMap ( ) ; IEclipsePreferences instancePreferences = JavaModelManager . getJavaModelManager ( ) . getInstancePreferences ( ) ; String [ ] propertyNames ; try { propertyNames = instancePreferences . keys ( ) ; } catch ( BackingStoreException e ) { Util . log ( e , "<STR_LIT>" ) ; return ; } boolean preferencesNeedFlush = false ; for ( int i = <NUM_LIT:0> , length = propertyNames . length ; i < length ; i ++ ) { String propertyName = propertyNames [ i ] ; if ( propertyName . startsWith ( CP_USERLIBRARY_PREFERENCES_PREFIX ) ) { String propertyValue = instancePreferences . get ( propertyName , null ) ; if ( propertyValue != null ) { String libName = propertyName . substring ( CP_USERLIBRARY_PREFERENCES_PREFIX . length ( ) ) ; StringReader reader = new StringReader ( propertyValue ) ; UserLibrary library ; try { library = UserLibrary . createFromString ( reader ) ; } catch ( IOException e ) { Util . log ( e , "<STR_LIT>" + libName ) ; instancePreferences . remove ( propertyName ) ; preferencesNeedFlush = true ; continue ; } catch ( ClasspathEntry . AssertionFailedException e ) { Util . log ( e , "<STR_LIT>" + libName ) ; instancePreferences . remove ( propertyName ) ; preferencesNeedFlush = true ; continue ; } this . userLibraries . put ( libName , library ) ; } } } if ( preferencesNeedFlush ) { try { instancePreferences . flush ( ) ; } catch ( BackingStoreException e ) { Util . log ( e , "<STR_LIT>" ) ; } } } public void updateUserLibrary ( String libName , String encodedUserLibrary ) { try { IPath containerPath = new Path ( JavaCore . USER_LIBRARY_CONTAINER_ID ) . append ( libName ) ; IJavaProject [ ] allJavaProjects = JavaCore . create ( ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ) . getJavaProjects ( ) ; ArrayList affectedProjects = new ArrayList ( ) ; for ( int i = <NUM_LIT:0> ; i < allJavaProjects . length ; i ++ ) { IJavaProject javaProject = allJavaProjects [ i ] ; IClasspathEntry [ ] entries = javaProject . getRawClasspath ( ) ; for ( int j = <NUM_LIT:0> ; j < entries . length ; j ++ ) { IClasspathEntry entry = entries [ j ] ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_CONTAINER ) { if ( containerPath . equals ( entry . getPath ( ) ) ) { affectedProjects . add ( javaProject ) ; break ; } } } } UserLibrary userLibrary = encodedUserLibrary == null ? null : UserLibrary . createFromString ( new StringReader ( encodedUserLibrary ) ) ; synchronized ( this ) { if ( userLibrary != null ) { this . userLibraries . put ( libName , userLibrary ) ; } else { this . userLibraries . remove ( libName ) ; } } int length = affectedProjects . size ( ) ; if ( length == <NUM_LIT:0> ) return ; IJavaProject [ ] projects = new IJavaProject [ length ] ; affectedProjects . toArray ( projects ) ; IClasspathContainer [ ] containers = new IClasspathContainer [ length ] ; if ( userLibrary != null ) { UserLibraryClasspathContainer container = new UserLibraryClasspathContainer ( libName ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { containers [ i ] = container ; } } JavaCore . setClasspathContainer ( containerPath , projects , containers , null ) ; } catch ( IOException e ) { Util . log ( e , "<STR_LIT>" + libName + "<STR_LIT>" ) ; } catch ( JavaModelException e ) { Util . log ( e , "<STR_LIT>" + libName + "<STR_LIT>" ) ; } catch ( ClasspathEntry . AssertionFailedException ase ) { Util . log ( ase , "<STR_LIT>" + libName + "<STR_LIT>" ) ; } } public void removeUserLibrary ( String libName ) { synchronized ( this . userLibraries ) { IEclipsePreferences instancePreferences = JavaModelManager . getJavaModelManager ( ) . getInstancePreferences ( ) ; String propertyName = CP_USERLIBRARY_PREFERENCES_PREFIX + libName ; instancePreferences . remove ( propertyName ) ; try { instancePreferences . flush ( ) ; } catch ( BackingStoreException e ) { Util . log ( e , "<STR_LIT>" + libName ) ; } } } public void setUserLibrary ( String libName , IClasspathEntry [ ] entries , boolean isSystemLibrary ) { synchronized ( this . userLibraries ) { IEclipsePreferences instancePreferences = JavaModelManager . getJavaModelManager ( ) . getInstancePreferences ( ) ; String propertyName = CP_USERLIBRARY_PREFERENCES_PREFIX + libName ; try { String propertyValue = UserLibrary . serialize ( entries , isSystemLibrary ) ; instancePreferences . put ( propertyName , propertyValue ) ; } catch ( IOException e ) { Util . log ( e , "<STR_LIT>" + libName ) ; return ; } try { instancePreferences . flush ( ) ; } catch ( BackingStoreException e ) { Util . log ( e , "<STR_LIT>" + libName ) ; } } } } </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 java . util . Stack ; import org . eclipse . core . runtime . Assert ; import org . eclipse . jdt . core . Flags ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IMemberValuePair ; import org . eclipse . jdt . core . ITypeParameter ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . ArrayInitializer ; import org . eclipse . jdt . internal . compiler . ast . ClassLiteralAccess ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . Literal ; import org . eclipse . jdt . internal . compiler . ast . MemberValuePair ; import org . eclipse . jdt . internal . compiler . ast . NullLiteral ; import org . eclipse . jdt . internal . compiler . ast . OperatorIds ; import org . eclipse . jdt . internal . compiler . ast . QualifiedNameReference ; import org . eclipse . jdt . internal . compiler . ast . SingleNameReference ; import org . eclipse . jdt . internal . compiler . ast . UnaryExpression ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . parser . RecoveryScanner ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObject ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObjectToInt ; import org . eclipse . jdt . internal . core . util . ReferenceInfoAdapter ; import org . eclipse . jdt . internal . core . util . Util ; public class CompilationUnitStructureRequestor extends ReferenceInfoAdapter implements ISourceElementRequestor { protected ICompilationUnit unit ; protected CompilationUnitElementInfo unitInfo ; protected ImportContainerInfo importContainerInfo = null ; protected ImportContainer importContainer ; protected Map newElements ; private HashtableOfObjectToInt occurenceCounts ; private HashtableOfObjectToInt localOccurrenceCounts ; protected Stack infoStack ; protected HashMap children ; protected Stack handleStack ; protected int referenceCount = <NUM_LIT:0> ; protected boolean hasSyntaxErrors = false ; protected Parser parser ; protected HashtableOfObject fieldRefCache ; protected HashtableOfObject messageRefCache ; protected HashtableOfObject typeRefCache ; protected HashtableOfObject unknownRefCache ; protected CompilationUnitStructureRequestor ( ICompilationUnit unit , CompilationUnitElementInfo unitInfo , Map newElements ) { this . unit = unit ; this . unitInfo = unitInfo ; this . newElements = newElements ; this . occurenceCounts = new HashtableOfObjectToInt ( ) ; this . localOccurrenceCounts = new HashtableOfObjectToInt ( <NUM_LIT:5> ) ; } public void acceptImport ( int declarationStart , int declarationEnd , int nameSourceStart , int nameSourceEnd , char [ ] [ ] tokens , boolean onDemand , int modifiers ) { JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; if ( ! ( parentHandle . getElementType ( ) == IJavaElement . COMPILATION_UNIT ) ) { Assert . isTrue ( false ) ; } ICompilationUnit parentCU = ( ICompilationUnit ) parentHandle ; if ( this . importContainer == null ) { this . importContainer = createImportContainer ( parentCU ) ; this . importContainerInfo = new ImportContainerInfo ( ) ; Object parentInfo = this . infoStack . peek ( ) ; addToChildren ( parentInfo , this . importContainer ) ; this . newElements . put ( this . importContainer , this . importContainerInfo ) ; } String elementName = JavaModelManager . getJavaModelManager ( ) . intern ( new String ( CharOperation . concatWith ( tokens , '<CHAR_LIT:.>' ) ) ) ; ImportDeclaration handle = createImportDeclaration ( this . importContainer , elementName , onDemand ) ; resolveDuplicates ( handle ) ; ImportDeclarationElementInfo info = new ImportDeclarationElementInfo ( ) ; info . setSourceRangeStart ( declarationStart ) ; info . setSourceRangeEnd ( declarationEnd ) ; info . setNameSourceStart ( nameSourceStart ) ; info . setNameSourceEnd ( nameSourceEnd ) ; info . setFlags ( modifiers ) ; addToChildren ( this . importContainerInfo , handle ) ; this . newElements . put ( handle , info ) ; } public void acceptLineSeparatorPositions ( int [ ] positions ) { } public void acceptPackage ( ImportReference importReference ) { Object parentInfo = this . infoStack . peek ( ) ; JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; PackageDeclaration handle = null ; if ( parentHandle . getElementType ( ) == IJavaElement . COMPILATION_UNIT ) { char [ ] name = CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) ; handle = createPackageDeclaration ( parentHandle , new String ( name ) ) ; } else { Assert . isTrue ( false ) ; } resolveDuplicates ( handle ) ; AnnotatableInfo info = new AnnotatableInfo ( ) ; info . setSourceRangeStart ( importReference . declarationSourceStart ) ; info . setSourceRangeEnd ( importReference . declarationSourceEnd ) ; info . setNameSourceStart ( importReference . sourceStart ) ; info . setNameSourceEnd ( importReference . sourceEnd ) ; addToChildren ( parentInfo , handle ) ; this . newElements . put ( handle , info ) ; if ( importReference . annotations != null ) { for ( int i = <NUM_LIT:0> , length = importReference . annotations . length ; i < length ; i ++ ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = importReference . annotations [ i ] ; acceptAnnotation ( annotation , info , handle ) ; } } } public void acceptProblem ( CategorizedProblem problem ) { if ( ( problem . getID ( ) & IProblem . Syntax ) != <NUM_LIT:0> ) { this . hasSyntaxErrors = true ; } } private void addToChildren ( Object parentInfo , JavaElement handle ) { ArrayList childrenList = ( ArrayList ) this . children . get ( parentInfo ) ; if ( childrenList == null ) this . children . put ( parentInfo , childrenList = new ArrayList ( ) ) ; childrenList . add ( handle ) ; } protected Annotation createAnnotation ( JavaElement parent , String name ) { return new Annotation ( parent , name ) ; } protected SourceField createField ( JavaElement parent , FieldInfo fieldInfo ) { String fieldName = JavaModelManager . getJavaModelManager ( ) . intern ( new String ( fieldInfo . name ) ) ; return new SourceField ( parent , fieldName ) ; } protected ImportContainer createImportContainer ( ICompilationUnit parent ) { return ( ImportContainer ) parent . getImportContainer ( ) ; } protected ImportDeclaration createImportDeclaration ( ImportContainer parent , String name , boolean onDemand ) { return new ImportDeclaration ( parent , name , onDemand ) ; } protected Initializer createInitializer ( JavaElement parent ) { return new Initializer ( parent , <NUM_LIT:1> ) ; } protected SourceMethod createMethodHandle ( JavaElement parent , MethodInfo methodInfo ) { String selector = JavaModelManager . getJavaModelManager ( ) . intern ( new String ( methodInfo . name ) ) ; String [ ] parameterTypeSigs = convertTypeNamesToSigs ( methodInfo . parameterTypes ) ; return new SourceMethod ( parent , selector , parameterTypeSigs ) ; } protected PackageDeclaration createPackageDeclaration ( JavaElement parent , String name ) { return new PackageDeclaration ( ( CompilationUnit ) parent , name ) ; } protected SourceType createTypeHandle ( JavaElement parent , TypeInfo typeInfo ) { String nameString = new String ( typeInfo . name ) ; return new SourceType ( parent , nameString ) ; } protected TypeParameter createTypeParameter ( JavaElement parent , String name ) { return new TypeParameter ( parent , name ) ; } protected static String [ ] convertTypeNamesToSigs ( char [ ] [ ] typeNames ) { if ( typeNames == null ) return CharOperation . NO_STRINGS ; int n = typeNames . length ; if ( n == <NUM_LIT:0> ) return CharOperation . NO_STRINGS ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; String [ ] typeSigs = new String [ n ] ; for ( int i = <NUM_LIT:0> ; i < n ; ++ i ) { typeSigs [ i ] = manager . intern ( Signature . createTypeSignature ( typeNames [ i ] , false ) ) ; } return typeSigs ; } protected IAnnotation acceptAnnotation ( org . eclipse . jdt . internal . compiler . ast . Annotation annotation , AnnotatableInfo parentInfo , JavaElement parentHandle ) { String nameString = new String ( CharOperation . concatWith ( annotation . type . getTypeName ( ) , '<CHAR_LIT:.>' ) ) ; Annotation handle = createAnnotation ( parentHandle , nameString ) ; resolveDuplicates ( handle ) ; AnnotationInfo info = new AnnotationInfo ( ) ; this . newElements . put ( handle , info ) ; this . handleStack . push ( handle ) ; info . setSourceRangeStart ( annotation . sourceStart ( ) ) ; info . nameStart = annotation . type . sourceStart ( ) ; info . nameEnd = annotation . type . sourceEnd ( ) ; MemberValuePair [ ] memberValuePairs = annotation . memberValuePairs ( ) ; int membersLength = memberValuePairs . length ; if ( membersLength == <NUM_LIT:0> ) { info . members = Annotation . NO_MEMBER_VALUE_PAIRS ; } else { info . members = getMemberValuePairs ( memberValuePairs ) ; } if ( parentInfo != null ) { IAnnotation [ ] annotations = parentInfo . annotations ; int length = annotations . length ; System . arraycopy ( annotations , <NUM_LIT:0> , annotations = new IAnnotation [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; annotations [ length ] = handle ; parentInfo . annotations = annotations ; } info . setSourceRangeEnd ( annotation . declarationSourceEnd ) ; this . handleStack . pop ( ) ; return handle ; } public void enterCompilationUnit ( ) { this . infoStack = new Stack ( ) ; this . children = new HashMap ( ) ; this . handleStack = new Stack ( ) ; this . infoStack . push ( this . unitInfo ) ; this . handleStack . push ( this . unit ) ; } public void enterConstructor ( MethodInfo methodInfo ) { enterMethod ( methodInfo ) ; } public void enterField ( FieldInfo fieldInfo ) { TypeInfo parentInfo = ( TypeInfo ) this . infoStack . peek ( ) ; JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; SourceField handle = null ; if ( parentHandle . getElementType ( ) == IJavaElement . TYPE ) { handle = createField ( parentHandle , fieldInfo ) ; } else { Assert . isTrue ( false ) ; } resolveDuplicates ( handle ) ; addToChildren ( parentInfo , handle ) ; parentInfo . childrenCategories . put ( handle , fieldInfo . categories ) ; this . infoStack . push ( fieldInfo ) ; this . handleStack . push ( handle ) ; } public void enterInitializer ( int declarationSourceStart , int modifiers ) { Object parentInfo = this . infoStack . peek ( ) ; JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; Initializer handle = null ; if ( parentHandle . getElementType ( ) == IJavaElement . TYPE ) { handle = createInitializer ( parentHandle ) ; } else { Assert . isTrue ( false ) ; } resolveDuplicates ( handle ) ; addToChildren ( parentInfo , handle ) ; this . infoStack . push ( new int [ ] { declarationSourceStart , modifiers } ) ; this . handleStack . push ( handle ) ; } public void enterMethod ( MethodInfo methodInfo ) { TypeInfo parentInfo = ( TypeInfo ) this . infoStack . peek ( ) ; JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; SourceMethod handle = null ; if ( methodInfo . parameterTypes == null ) { methodInfo . parameterTypes = CharOperation . NO_CHAR_CHAR ; } if ( methodInfo . parameterNames == null ) { methodInfo . parameterNames = CharOperation . NO_CHAR_CHAR ; } if ( methodInfo . exceptionTypes == null ) { methodInfo . exceptionTypes = CharOperation . NO_CHAR_CHAR ; } if ( parentHandle . getElementType ( ) == IJavaElement . TYPE ) { handle = createMethodHandle ( parentHandle , methodInfo ) ; } else { Assert . isTrue ( false ) ; } resolveDuplicates ( handle ) ; this . infoStack . push ( methodInfo ) ; this . handleStack . push ( handle ) ; addToChildren ( parentInfo , handle ) ; parentInfo . childrenCategories . put ( handle , methodInfo . categories ) ; } private SourceMethodElementInfo createMethodInfo ( MethodInfo methodInfo , SourceMethod handle ) { IJavaElement [ ] elements = getChildren ( methodInfo ) ; SourceMethodElementInfo info ; if ( methodInfo . isConstructor ) { info = elements . length == <NUM_LIT:0> ? new SourceConstructorInfo ( ) : new SourceConstructorWithChildrenInfo ( elements ) ; } else if ( methodInfo . isAnnotation ) { info = new SourceAnnotationMethodInfo ( ) ; } else { info = elements . length == <NUM_LIT:0> ? new SourceMethodInfo ( ) : new SourceMethodWithChildrenInfo ( elements ) ; } info . setSourceRangeStart ( methodInfo . declarationStart ) ; int flags = methodInfo . modifiers ; info . setNameSourceStart ( methodInfo . nameSourceStart ) ; info . setNameSourceEnd ( methodInfo . nameSourceEnd ) ; info . setFlags ( flags ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; char [ ] [ ] parameterNames = methodInfo . parameterNames ; for ( int i = <NUM_LIT:0> , length = parameterNames . length ; i < length ; i ++ ) parameterNames [ i ] = manager . intern ( parameterNames [ i ] ) ; info . setArgumentNames ( parameterNames ) ; char [ ] returnType = methodInfo . returnType == null ? new char [ ] { '<CHAR_LIT>' , '<CHAR_LIT>' , '<CHAR_LIT>' , '<CHAR_LIT>' } : methodInfo . returnType ; info . setReturnType ( manager . intern ( returnType ) ) ; char [ ] [ ] exceptionTypes = methodInfo . exceptionTypes ; info . setExceptionTypeNames ( exceptionTypes ) ; for ( int i = <NUM_LIT:0> , length = exceptionTypes . length ; i < length ; i ++ ) exceptionTypes [ i ] = manager . intern ( exceptionTypes [ i ] ) ; this . newElements . put ( handle , info ) ; if ( methodInfo . typeParameters != null ) { for ( int i = <NUM_LIT:0> , length = methodInfo . typeParameters . length ; i < length ; i ++ ) { TypeParameterInfo typeParameterInfo = methodInfo . typeParameters [ i ] ; acceptTypeParameter ( typeParameterInfo , info ) ; } } if ( methodInfo . annotations != null ) { int length = methodInfo . annotations . length ; this . unitInfo . annotationNumber += length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = methodInfo . annotations [ i ] ; acceptAnnotation ( annotation , info , handle ) ; } } if ( methodInfo . node != null && methodInfo . node . arguments != null ) { info . arguments = acceptMethodParameters ( methodInfo . node . arguments , handle , methodInfo ) ; } return info ; } private LocalVariable [ ] acceptMethodParameters ( Argument [ ] arguments , JavaElement methodHandle , MethodInfo methodInfo ) { if ( arguments == null ) return null ; LocalVariable [ ] result = new LocalVariable [ arguments . length ] ; Annotation [ ] [ ] paramAnnotations = new Annotation [ arguments . length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < arguments . length ; i ++ ) { Argument argument = arguments [ i ] ; AnnotatableInfo localVarInfo = new AnnotatableInfo ( ) ; localVarInfo . setSourceRangeStart ( argument . declarationSourceStart ) ; localVarInfo . setSourceRangeEnd ( argument . declarationSourceStart ) ; localVarInfo . setNameSourceStart ( argument . sourceStart ) ; localVarInfo . setNameSourceEnd ( argument . sourceEnd ) ; String paramTypeSig = JavaModelManager . getJavaModelManager ( ) . intern ( Signature . createTypeSignature ( methodInfo . parameterTypes [ i ] , false ) ) ; result [ i ] = new LocalVariable ( methodHandle , new String ( argument . name ) , argument . declarationSourceStart , argument . declarationSourceEnd , argument . sourceStart , argument . sourceEnd , paramTypeSig , argument . annotations , argument . modifiers , true ) ; this . newElements . put ( result [ i ] , localVarInfo ) ; this . infoStack . push ( localVarInfo ) ; this . handleStack . push ( result [ i ] ) ; if ( argument . annotations != null ) { paramAnnotations [ i ] = new Annotation [ argument . annotations . length ] ; for ( int j = <NUM_LIT:0> ; j < argument . annotations . length ; j ++ ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = argument . annotations [ j ] ; acceptAnnotation ( annotation , localVarInfo , result [ i ] ) ; } } this . infoStack . pop ( ) ; this . handleStack . pop ( ) ; } return result ; } public void enterType ( TypeInfo typeInfo ) { Object parentInfo = this . infoStack . peek ( ) ; JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; SourceType handle = createTypeHandle ( parentHandle , typeInfo ) ; resolveDuplicates ( handle ) ; this . infoStack . push ( typeInfo ) ; this . handleStack . push ( handle ) ; if ( parentHandle . getElementType ( ) == IJavaElement . TYPE ) ( ( TypeInfo ) parentInfo ) . childrenCategories . put ( handle , typeInfo . categories ) ; addToChildren ( parentInfo , handle ) ; } private SourceTypeElementInfo createTypeInfo ( TypeInfo typeInfo , SourceType handle ) { SourceTypeElementInfo info = typeInfo . anonymousMember ? new SourceTypeElementInfo ( ) { public boolean isAnonymousMember ( ) { return true ; } } : new SourceTypeElementInfo ( ) ; info . setHandle ( handle ) ; info . setSourceRangeStart ( typeInfo . declarationStart ) ; info . setFlags ( typeInfo . modifiers ) ; info . setNameSourceStart ( typeInfo . nameSourceStart ) ; info . setNameSourceEnd ( typeInfo . nameSourceEnd ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; char [ ] superclass = typeInfo . superclass ; info . setSuperclassName ( superclass == null ? null : manager . intern ( superclass ) ) ; char [ ] [ ] superinterfaces = typeInfo . superinterfaces ; for ( int i = <NUM_LIT:0> , length = superinterfaces == null ? <NUM_LIT:0> : superinterfaces . length ; i < length ; i ++ ) superinterfaces [ i ] = manager . intern ( superinterfaces [ i ] ) ; info . setSuperInterfaceNames ( superinterfaces ) ; info . addCategories ( handle , typeInfo . categories ) ; this . newElements . put ( handle , info ) ; if ( typeInfo . typeParameters != null ) { for ( int i = <NUM_LIT:0> , length = typeInfo . typeParameters . length ; i < length ; i ++ ) { TypeParameterInfo typeParameterInfo = typeInfo . typeParameters [ i ] ; acceptTypeParameter ( typeParameterInfo , info ) ; } } if ( typeInfo . annotations != null ) { int length = typeInfo . annotations . length ; this . unitInfo . annotationNumber += length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = typeInfo . annotations [ i ] ; acceptAnnotation ( annotation , info , handle ) ; } } if ( typeInfo . childrenCategories != null ) { Iterator iterator = typeInfo . childrenCategories . entrySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) iterator . next ( ) ; info . addCategories ( ( IJavaElement ) entry . getKey ( ) , ( char [ ] [ ] ) entry . getValue ( ) ) ; } } return info ; } protected void acceptTypeParameter ( TypeParameterInfo typeParameterInfo , JavaElementInfo parentInfo ) { JavaElement parentHandle = ( JavaElement ) this . handleStack . peek ( ) ; String nameString = new String ( typeParameterInfo . name ) ; TypeParameter handle = createTypeParameter ( parentHandle , nameString ) ; resolveDuplicates ( handle ) ; TypeParameterElementInfo info = new TypeParameterElementInfo ( ) ; info . setSourceRangeStart ( typeParameterInfo . declarationStart ) ; info . nameStart = typeParameterInfo . nameSourceStart ; info . nameEnd = typeParameterInfo . nameSourceEnd ; info . bounds = typeParameterInfo . bounds ; if ( parentInfo instanceof SourceTypeElementInfo ) { SourceTypeElementInfo elementInfo = ( SourceTypeElementInfo ) parentInfo ; ITypeParameter [ ] typeParameters = elementInfo . typeParameters ; int length = typeParameters . length ; System . arraycopy ( typeParameters , <NUM_LIT:0> , typeParameters = new ITypeParameter [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; typeParameters [ length ] = handle ; elementInfo . typeParameters = typeParameters ; } else { SourceMethodElementInfo elementInfo = ( SourceMethodElementInfo ) parentInfo ; ITypeParameter [ ] typeParameters = elementInfo . typeParameters ; int length = typeParameters . length ; System . arraycopy ( typeParameters , <NUM_LIT:0> , typeParameters = new ITypeParameter [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; typeParameters [ length ] = handle ; elementInfo . typeParameters = typeParameters ; } this . newElements . put ( handle , info ) ; info . setSourceRangeEnd ( typeParameterInfo . declarationEnd ) ; } public void exitCompilationUnit ( int declarationEnd ) { if ( this . importContainerInfo != null ) { this . importContainerInfo . children = getChildren ( this . importContainerInfo ) ; } this . unitInfo . children = getChildren ( this . unitInfo ) ; this . unitInfo . setSourceLength ( declarationEnd + <NUM_LIT:1> ) ; this . unitInfo . setIsStructureKnown ( ! this . hasSyntaxErrors ) ; } public void exitConstructor ( int declarationEnd ) { exitMethod ( declarationEnd , null ) ; } public void exitField ( int initializationStart , int declarationEnd , int declarationSourceEnd ) { JavaElement handle = ( JavaElement ) this . handleStack . peek ( ) ; FieldInfo fieldInfo = ( FieldInfo ) this . infoStack . peek ( ) ; IJavaElement [ ] elements = getChildren ( fieldInfo ) ; SourceFieldElementInfo info = elements . length == <NUM_LIT:0> ? new SourceFieldElementInfo ( ) : new SourceFieldWithChildrenInfo ( elements ) ; info . setNameSourceStart ( fieldInfo . nameSourceStart ) ; info . setNameSourceEnd ( fieldInfo . nameSourceEnd ) ; info . setSourceRangeStart ( fieldInfo . declarationStart ) ; info . setFlags ( fieldInfo . modifiers ) ; char [ ] typeName = JavaModelManager . getJavaModelManager ( ) . intern ( fieldInfo . type ) ; info . setTypeName ( typeName ) ; this . newElements . put ( handle , info ) ; if ( fieldInfo . annotations != null ) { int length = fieldInfo . annotations . length ; this . unitInfo . annotationNumber += length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = fieldInfo . annotations [ i ] ; acceptAnnotation ( annotation , info , handle ) ; } } info . setSourceRangeEnd ( declarationSourceEnd ) ; this . handleStack . pop ( ) ; this . infoStack . pop ( ) ; if ( initializationStart != - <NUM_LIT:1> ) { int flags = info . flags ; Object typeInfo ; if ( Flags . isStatic ( flags ) && Flags . isFinal ( flags ) || ( ( typeInfo = this . infoStack . peek ( ) ) instanceof TypeInfo && ( Flags . isInterface ( ( ( TypeInfo ) typeInfo ) . modifiers ) ) ) ) { int length = declarationEnd - initializationStart ; if ( length > <NUM_LIT:0> ) { char [ ] initializer = new char [ length ] ; System . arraycopy ( this . parser . scanner . source , initializationStart , initializer , <NUM_LIT:0> , length ) ; info . initializationSource = initializer ; } } } } public void exitInitializer ( int declarationEnd ) { JavaElement handle = ( JavaElement ) this . handleStack . peek ( ) ; int [ ] initializerInfo = ( int [ ] ) this . infoStack . peek ( ) ; IJavaElement [ ] elements = getChildren ( initializerInfo ) ; InitializerElementInfo info = elements . length == <NUM_LIT:0> ? new InitializerElementInfo ( ) : new InitializerWithChildrenInfo ( elements ) ; info . setSourceRangeStart ( initializerInfo [ <NUM_LIT:0> ] ) ; info . setFlags ( initializerInfo [ <NUM_LIT:1> ] ) ; info . setSourceRangeEnd ( declarationEnd ) ; this . newElements . put ( handle , info ) ; this . handleStack . pop ( ) ; this . infoStack . pop ( ) ; } public void exitMethod ( int declarationEnd , Expression defaultValue ) { SourceMethod handle = ( SourceMethod ) this . handleStack . peek ( ) ; MethodInfo methodInfo = ( MethodInfo ) this . infoStack . peek ( ) ; SourceMethodElementInfo info = createMethodInfo ( methodInfo , handle ) ; info . setSourceRangeEnd ( declarationEnd ) ; if ( info . isAnnotationMethod ( ) && defaultValue != null ) { SourceAnnotationMethodInfo annotationMethodInfo = ( SourceAnnotationMethodInfo ) info ; annotationMethodInfo . defaultValueStart = defaultValue . sourceStart ; annotationMethodInfo . defaultValueEnd = defaultValue . sourceEnd ; JavaElement element = ( JavaElement ) this . handleStack . peek ( ) ; org . eclipse . jdt . internal . core . MemberValuePair defaultMemberValuePair = new org . eclipse . jdt . internal . core . MemberValuePair ( element . getElementName ( ) ) ; defaultMemberValuePair . value = getMemberValue ( defaultMemberValuePair , defaultValue ) ; annotationMethodInfo . defaultValue = defaultMemberValuePair ; } this . handleStack . pop ( ) ; this . infoStack . pop ( ) ; } public void exitType ( int declarationEnd ) { SourceType handle = ( SourceType ) this . handleStack . peek ( ) ; TypeInfo typeInfo = ( TypeInfo ) this . infoStack . peek ( ) ; SourceTypeElementInfo info = createTypeInfo ( typeInfo , handle ) ; info . setSourceRangeEnd ( declarationEnd ) ; info . children = getChildren ( typeInfo ) ; this . handleStack . pop ( ) ; this . infoStack . pop ( ) ; } protected void resolveDuplicates ( SourceRefElement handle ) { int occurenceCount = this . occurenceCounts . get ( handle ) ; if ( occurenceCount == - <NUM_LIT:1> ) this . occurenceCounts . put ( handle , <NUM_LIT:1> ) ; else { this . occurenceCounts . put ( handle , ++ occurenceCount ) ; handle . occurrenceCount = occurenceCount ; } if ( handle instanceof SourceType && handle . getElementName ( ) . length ( ) == <NUM_LIT:0> ) { Object key = handle . getParent ( ) . getAncestor ( IJavaElement . TYPE ) ; occurenceCount = this . localOccurrenceCounts . get ( key ) ; if ( occurenceCount == - <NUM_LIT:1> ) this . localOccurrenceCounts . put ( key , <NUM_LIT:1> ) ; else { this . localOccurrenceCounts . put ( key , ++ occurenceCount ) ; ( ( SourceType ) handle ) . localOccurrenceCount = occurenceCount ; } } } protected IMemberValuePair getMemberValuePair ( MemberValuePair memberValuePair ) { String memberName = new String ( memberValuePair . name ) ; org . eclipse . jdt . internal . core . MemberValuePair result = new org . eclipse . jdt . internal . core . MemberValuePair ( memberName ) ; result . value = getMemberValue ( result , memberValuePair . value ) ; return result ; } protected IMemberValuePair [ ] getMemberValuePairs ( MemberValuePair [ ] memberValuePairs ) { int membersLength = memberValuePairs . length ; IMemberValuePair [ ] members = new IMemberValuePair [ membersLength ] ; for ( int j = <NUM_LIT:0> ; j < membersLength ; j ++ ) { members [ j ] = getMemberValuePair ( memberValuePairs [ j ] ) ; } return members ; } private IJavaElement [ ] getChildren ( Object info ) { ArrayList childrenList = ( ArrayList ) this . children . get ( info ) ; if ( childrenList != null ) { return ( IJavaElement [ ] ) childrenList . toArray ( new IJavaElement [ childrenList . size ( ) ] ) ; } return JavaElement . NO_ELEMENTS ; } protected Object getMemberValue ( org . eclipse . jdt . internal . core . MemberValuePair memberValuePair , Expression expression ) { if ( expression instanceof NullLiteral ) { return null ; } else if ( expression instanceof Literal ) { ( ( Literal ) expression ) . computeConstant ( ) ; return Util . getAnnotationMemberValue ( memberValuePair , expression . constant ) ; } else if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . Annotation ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = ( org . eclipse . jdt . internal . compiler . ast . Annotation ) expression ; Object handle = acceptAnnotation ( annotation , null , ( JavaElement ) this . handleStack . peek ( ) ) ; memberValuePair . valueKind = IMemberValuePair . K_ANNOTATION ; return handle ; } else if ( expression instanceof ClassLiteralAccess ) { ClassLiteralAccess classLiteral = ( ClassLiteralAccess ) expression ; char [ ] name = CharOperation . concatWith ( classLiteral . type . getTypeName ( ) , '<CHAR_LIT:.>' ) ; memberValuePair . valueKind = IMemberValuePair . K_CLASS ; return new String ( name ) ; } else if ( expression instanceof QualifiedNameReference ) { char [ ] qualifiedName = CharOperation . concatWith ( ( ( QualifiedNameReference ) expression ) . tokens , '<CHAR_LIT:.>' ) ; memberValuePair . valueKind = IMemberValuePair . K_QUALIFIED_NAME ; return new String ( qualifiedName ) ; } else if ( expression instanceof SingleNameReference ) { char [ ] simpleName = ( ( SingleNameReference ) expression ) . token ; if ( simpleName == RecoveryScanner . FAKE_IDENTIFIER ) { memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return null ; } memberValuePair . valueKind = IMemberValuePair . K_SIMPLE_NAME ; return new String ( simpleName ) ; } else if ( expression instanceof ArrayInitializer ) { memberValuePair . valueKind = - <NUM_LIT:1> ; Expression [ ] expressions = ( ( ArrayInitializer ) expression ) . expressions ; int length = expressions == null ? <NUM_LIT:0> : expressions . length ; Object [ ] values = new Object [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { int previousValueKind = memberValuePair . valueKind ; Object value = getMemberValue ( memberValuePair , expressions [ i ] ) ; if ( previousValueKind != - <NUM_LIT:1> && memberValuePair . valueKind != previousValueKind ) { memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; } values [ i ] = value ; } if ( memberValuePair . valueKind == - <NUM_LIT:1> ) memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return values ; } else if ( expression instanceof UnaryExpression ) { UnaryExpression unaryExpression = ( UnaryExpression ) expression ; if ( ( unaryExpression . bits & ASTNode . OperatorMASK ) > > ASTNode . OperatorSHIFT == OperatorIds . MINUS ) { if ( unaryExpression . expression instanceof Literal ) { Literal subExpression = ( Literal ) unaryExpression . expression ; subExpression . computeConstant ( ) ; return Util . getNegativeAnnotationMemberValue ( memberValuePair , subExpression . constant ) ; } } memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return null ; } else { memberValuePair . valueKind = IMemberValuePair . K_UNKNOWN ; return null ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . net . URL ; import java . util . ArrayList ; import java . util . HashSet ; import java . util . Map ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . resources . IContainer ; 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 . OperationCanceledException ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . IClassFile ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; 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 . IParent ; import org . eclipse . jdt . core . ISourceManipulation ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . JavaModelManager . PerProjectInfo ; 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 PackageFragment extends Openable implements IPackageFragment , SuffixConstants { protected static final IClassFile [ ] NO_CLASSFILES = new IClassFile [ ] { } ; protected static final ICompilationUnit [ ] NO_COMPILATION_UNITS = new ICompilationUnit [ ] { } ; public String [ ] names ; protected PackageFragment ( PackageFragmentRoot root , String [ ] names ) { super ( root ) ; this . names = names ; } protected boolean buildStructure ( OpenableElementInfo info , IProgressMonitor pm , Map newElements , IResource underlyingResource ) throws JavaModelException { HashSet vChildren = new HashSet ( ) ; int kind = getKind ( ) ; try { PackageFragmentRoot root = getPackageFragmentRoot ( ) ; char [ ] [ ] inclusionPatterns = root . fullInclusionPatternChars ( ) ; char [ ] [ ] exclusionPatterns = root . fullExclusionPatternChars ( ) ; IResource [ ] members = ( ( IContainer ) underlyingResource ) . members ( ) ; int length = members . length ; if ( length > <NUM_LIT:0> ) { IJavaProject project = getJavaProject ( ) ; String sourceLevel = project . getOption ( JavaCore . COMPILER_SOURCE , true ) ; String complianceLevel = project . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IResource child = members [ i ] ; if ( child . getType ( ) != IResource . FOLDER && ! Util . isExcluded ( child , inclusionPatterns , exclusionPatterns ) ) { IJavaElement childElement ; if ( kind == IPackageFragmentRoot . K_SOURCE && Util . isValidCompilationUnitName ( child . getName ( ) , sourceLevel , complianceLevel ) ) { childElement = LanguageSupportFactory . newCompilationUnit ( this , child . getName ( ) , DefaultWorkingCopyOwner . PRIMARY ) ; vChildren . add ( childElement ) ; } else if ( kind == IPackageFragmentRoot . K_BINARY && Util . isValidClassFileName ( child . getName ( ) , sourceLevel , complianceLevel ) ) { childElement = getClassFile ( child . getName ( ) ) ; vChildren . add ( childElement ) ; } } } } } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } if ( kind == IPackageFragmentRoot . K_SOURCE ) { ICompilationUnit [ ] primaryCompilationUnits = getCompilationUnits ( DefaultWorkingCopyOwner . PRIMARY ) ; for ( int i = <NUM_LIT:0> , length = primaryCompilationUnits . length ; i < length ; i ++ ) { ICompilationUnit primary = primaryCompilationUnits [ i ] ; vChildren . add ( primary ) ; } } IJavaElement [ ] children = new IJavaElement [ vChildren . size ( ) ] ; vChildren . toArray ( children ) ; info . setChildren ( children ) ; return true ; } public boolean containsJavaResources ( ) throws JavaModelException { return ( ( PackageFragmentInfo ) getElementInfo ( ) ) . containsJavaResources ( ) ; } 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 ICompilationUnit createCompilationUnit ( String cuName , String contents , boolean force , IProgressMonitor monitor ) throws JavaModelException { CreateCompilationUnitOperation op = new CreateCompilationUnitOperation ( this , cuName , contents , force ) ; op . runOperation ( monitor ) ; return LanguageSupportFactory . newCompilationUnit ( this , cuName , DefaultWorkingCopyOwner . PRIMARY ) ; } protected Object createElementInfo ( ) { return new PackageFragmentInfo ( ) ; } 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 ( this == o ) return true ; if ( ! ( o instanceof PackageFragment ) ) return false ; PackageFragment other = ( PackageFragment ) o ; return Util . equalArraysOrNull ( this . names , other . names ) && this . parent . equals ( other . parent ) ; } public boolean exists ( ) { return super . exists ( ) && ! Util . isExcluded ( this ) && isValidPackageName ( ) ; } public IClassFile getClassFile ( String classFileName ) { if ( ! org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( classFileName ) ) { throw new IllegalArgumentException ( Messages . bind ( Messages . element_invalidClassFileName , classFileName ) ) ; } int length = classFileName . length ( ) - <NUM_LIT:6> ; char [ ] nameWithoutExtension = new char [ length ] ; classFileName . getChars ( <NUM_LIT:0> , length , nameWithoutExtension , <NUM_LIT:0> ) ; return new ClassFile ( this , new String ( nameWithoutExtension ) ) ; } public IClassFile [ ] getClassFiles ( ) throws JavaModelException { if ( getKind ( ) == IPackageFragmentRoot . K_SOURCE ) { return NO_CLASSFILES ; } ArrayList list = getChildrenOfType ( CLASS_FILE ) ; IClassFile [ ] array = new IClassFile [ list . size ( ) ] ; list . toArray ( array ) ; return array ; } public ICompilationUnit getCompilationUnit ( String cuName ) { if ( ! org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( cuName ) ) { throw new IllegalArgumentException ( Messages . convention_unit_notJavaName ) ; } return LanguageSupportFactory . newCompilationUnit ( this , cuName , DefaultWorkingCopyOwner . PRIMARY ) ; } public ICompilationUnit [ ] getCompilationUnits ( ) throws JavaModelException { if ( getKind ( ) == IPackageFragmentRoot . K_BINARY ) { return NO_COMPILATION_UNITS ; } ArrayList list = getChildrenOfType ( COMPILATION_UNIT ) ; ICompilationUnit [ ] array = new ICompilationUnit [ list . size ( ) ] ; list . toArray ( array ) ; return array ; } public ICompilationUnit [ ] getCompilationUnits ( WorkingCopyOwner owner ) { ICompilationUnit [ ] workingCopies = JavaModelManager . getJavaModelManager ( ) . getWorkingCopies ( owner , false ) ; if ( workingCopies == null ) return JavaModelManager . NO_WORKING_COPY ; int length = workingCopies . length ; ICompilationUnit [ ] result = new ICompilationUnit [ length ] ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ICompilationUnit wc = workingCopies [ i ] ; if ( equals ( wc . getParent ( ) ) && ! Util . isExcluded ( wc ) ) { result [ index ++ ] = wc ; } } if ( index != length ) { System . arraycopy ( result , <NUM_LIT:0> , result = new ICompilationUnit [ index ] , <NUM_LIT:0> , index ) ; } return result ; } public String getElementName ( ) { if ( this . names . length == <NUM_LIT:0> ) return DEFAULT_PACKAGE_NAME ; return Util . concatWith ( this . names , '<CHAR_LIT:.>' ) ; } public int getElementType ( ) { return PACKAGE_FRAGMENT ; } public IJavaElement getHandleFromMemento ( String token , MementoTokenizer memento , WorkingCopyOwner owner ) { switch ( token . charAt ( <NUM_LIT:0> ) ) { case JEM_CLASSFILE : if ( ! memento . hasMoreTokens ( ) ) return this ; String classFileName = memento . nextToken ( ) ; JavaElement classFile = ( JavaElement ) getClassFile ( classFileName ) ; return classFile . getHandleFromMemento ( memento , owner ) ; case JEM_COMPILATIONUNIT : if ( ! memento . hasMoreTokens ( ) ) return this ; String cuName = memento . nextToken ( ) ; JavaElement cu = LanguageSupportFactory . newCompilationUnit ( this , cuName , owner ) ; return cu . getHandleFromMemento ( memento , owner ) ; } return null ; } protected char getHandleMementoDelimiter ( ) { return JavaElement . JEM_PACKAGEFRAGMENT ; } public int getKind ( ) throws JavaModelException { return ( ( IPackageFragmentRoot ) getParent ( ) ) . getKind ( ) ; } public Object [ ] getNonJavaResources ( ) throws JavaModelException { if ( isDefaultPackage ( ) ) { return JavaElementInfo . NO_NON_JAVA_RESOURCES ; } else { return ( ( PackageFragmentInfo ) getElementInfo ( ) ) . getNonJavaResources ( resource ( ) , getPackageFragmentRoot ( ) ) ; } } public IPath getPath ( ) { PackageFragmentRoot root = getPackageFragmentRoot ( ) ; if ( root . isArchive ( ) ) { return root . getPath ( ) ; } else { IPath path = root . getPath ( ) ; for ( int i = <NUM_LIT:0> , length = this . names . length ; i < length ; i ++ ) { String name = this . names [ i ] ; path = path . append ( name ) ; } return path ; } } public IResource resource ( PackageFragmentRoot root ) { int length = this . names . length ; if ( length == <NUM_LIT:0> ) { return root . resource ( root ) ; } else { IPath path = new Path ( this . names [ <NUM_LIT:0> ] ) ; for ( int i = <NUM_LIT:1> ; i < length ; i ++ ) path = path . append ( this . names [ i ] ) ; return ( ( IContainer ) root . resource ( root ) ) . getFolder ( path ) ; } } public IResource getUnderlyingResource ( ) throws JavaModelException { IResource rootResource = this . parent . getUnderlyingResource ( ) ; if ( rootResource == null ) { return null ; } if ( rootResource . getType ( ) == IResource . FOLDER || rootResource . getType ( ) == IResource . PROJECT ) { IContainer folder = ( IContainer ) rootResource ; String [ ] segs = this . names ; for ( int i = <NUM_LIT:0> ; i < segs . length ; ++ i ) { IResource child = folder . findMember ( segs [ i ] ) ; if ( child == null || child . getType ( ) != IResource . FOLDER ) { throw newNotPresentException ( ) ; } folder = ( IFolder ) child ; } return folder ; } else { return rootResource ; } } public int hashCode ( ) { int hash = this . parent . hashCode ( ) ; for ( int i = <NUM_LIT:0> , length = this . names . length ; i < length ; i ++ ) hash = Util . combineHashCodes ( this . names [ i ] . hashCode ( ) , hash ) ; return hash ; } public boolean hasChildren ( ) throws JavaModelException { return getChildren ( ) . length > <NUM_LIT:0> ; } public boolean hasSubpackages ( ) throws JavaModelException { IJavaElement [ ] packages = ( ( IPackageFragmentRoot ) getParent ( ) ) . getChildren ( ) ; int namesLength = this . names . length ; nextPackage : for ( int i = <NUM_LIT:0> , length = packages . length ; i < length ; i ++ ) { String [ ] otherNames = ( ( PackageFragment ) packages [ i ] ) . names ; if ( otherNames . length <= namesLength ) continue nextPackage ; for ( int j = <NUM_LIT:0> ; j < namesLength ; j ++ ) if ( ! this . names [ j ] . equals ( otherNames [ j ] ) ) continue nextPackage ; return true ; } return false ; } public boolean isDefaultPackage ( ) { return this . names . length == <NUM_LIT:0> ; } private boolean isValidPackageName ( ) { JavaProject javaProject = ( JavaProject ) getJavaProject ( ) ; String sourceLevel = javaProject . getOption ( JavaCore . COMPILER_SOURCE , true ) ; String complianceLevel = javaProject . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ; for ( int i = <NUM_LIT:0> , length = this . names . length ; i < length ; i ++ ) { if ( ! Util . isValidFolderNameForPackage ( this . names [ i ] , sourceLevel , complianceLevel ) ) return false ; } 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 toStringChildren ( int tab , StringBuffer buffer , Object info ) { if ( tab == <NUM_LIT:0> ) { super . toStringChildren ( tab , buffer , info ) ; } } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { buffer . append ( tabString ( tab ) ) ; if ( this . names . length == <NUM_LIT:0> ) { buffer . append ( "<STR_LIT>" ) ; } else { toStringName ( buffer ) ; } if ( info == null ) { buffer . append ( "<STR_LIT>" ) ; } else { if ( tab > <NUM_LIT:0> ) { buffer . append ( "<STR_LIT>" ) ; } } } public String getAttachedJavadoc ( IProgressMonitor monitor ) throws JavaModelException { PerProjectInfo projectInfo = JavaModelManager . getJavaModelManager ( ) . getPerProjectInfoCheckExistence ( getJavaProject ( ) . getProject ( ) ) ; String cachedJavadoc = null ; synchronized ( projectInfo . javadocCache ) { cachedJavadoc = ( String ) projectInfo . javadocCache . get ( this ) ; } if ( cachedJavadoc != null ) { return cachedJavadoc ; } URL baseLocation = getJavadocBaseLocation ( ) ; if ( baseLocation == null ) { return null ; } StringBuffer pathBuffer = new StringBuffer ( baseLocation . toExternalForm ( ) ) ; if ( ! ( pathBuffer . charAt ( pathBuffer . length ( ) - <NUM_LIT:1> ) == '<CHAR_LIT:/>' ) ) { pathBuffer . append ( '<CHAR_LIT:/>' ) ; } String packPath = getElementName ( ) . replace ( '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) ; pathBuffer . append ( packPath ) . append ( '<CHAR_LIT:/>' ) . append ( JavadocConstants . PACKAGE_FILE_NAME ) ; if ( monitor != null && monitor . isCanceled ( ) ) throw new OperationCanceledException ( ) ; final String contents = getURLContents ( String . valueOf ( pathBuffer ) ) ; if ( monitor != null && monitor . isCanceled ( ) ) throw new OperationCanceledException ( ) ; if ( contents == null ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . CANNOT_RETRIEVE_ATTACHED_JAVADOC , this ) ) ; synchronized ( projectInfo . javadocCache ) { projectInfo . javadocCache . put ( this , contents ) ; } return contents ; } protected IStatus validateExistence ( IResource underlyingResource ) { if ( ! isValidPackageName ( ) ) return newDoesNotExistStatus ( ) ; if ( underlyingResource != null && ! resourceExists ( underlyingResource ) ) return newDoesNotExistStatus ( ) ; int kind ; try { kind = getKind ( ) ; } catch ( JavaModelException e ) { return e . getStatus ( ) ; } if ( kind == IPackageFragmentRoot . K_SOURCE && Util . isExcluded ( this ) ) return newDoesNotExistStatus ( ) ; return JavaModelStatus . VERIFIED_OK ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . Iterator ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . jdt . core . Flags ; 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 . compiler . CharOperation ; 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 . ImportDeclaration ; import org . eclipse . jdt . core . dom . Name ; 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 CreateImportOperation extends CreateElementInCUOperation { protected String importName ; protected int flags ; public CreateImportOperation ( String importName , ICompilationUnit parentElement , int flags ) { super ( parentElement ) ; this . importName = importName ; this . flags = flags ; } protected StructuralPropertyDescriptor getChildPropertyDescriptor ( ASTNode parent ) { return CompilationUnit . IMPORTS_PROPERTY ; } protected ASTNode generateElementAST ( ASTRewrite rewriter , ICompilationUnit cu ) throws JavaModelException { Iterator imports = this . cuAST . imports ( ) . iterator ( ) ; boolean onDemand = this . importName . endsWith ( "<STR_LIT>" ) ; String importActualName = this . importName ; if ( onDemand ) { importActualName = this . importName . substring ( <NUM_LIT:0> , this . importName . length ( ) - <NUM_LIT:2> ) ; } while ( imports . hasNext ( ) ) { ImportDeclaration importDeclaration = ( ImportDeclaration ) imports . next ( ) ; if ( importActualName . equals ( importDeclaration . getName ( ) . getFullyQualifiedName ( ) ) && ( onDemand == importDeclaration . isOnDemand ( ) ) && ( Flags . isStatic ( this . flags ) == importDeclaration . isStatic ( ) ) ) { this . creationOccurred = false ; return null ; } } AST ast = this . cuAST . getAST ( ) ; ImportDeclaration importDeclaration = ast . newImportDeclaration ( ) ; importDeclaration . setStatic ( Flags . isStatic ( this . flags ) ) ; char [ ] [ ] charFragments = CharOperation . splitOn ( '<CHAR_LIT:.>' , importActualName . toCharArray ( ) , <NUM_LIT:0> , importActualName . length ( ) ) ; int length = charFragments . length ; String [ ] strFragments = new String [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { strFragments [ i ] = String . valueOf ( charFragments [ i ] ) ; } Name name = ast . newName ( strFragments ) ; importDeclaration . setName ( name ) ; if ( onDemand ) importDeclaration . setOnDemand ( true ) ; return importDeclaration ; } protected IJavaElement generateResultHandle ( ) { return getCompilationUnit ( ) . getImport ( this . importName ) ; } public String getMainTaskName ( ) { return Messages . operation_createImportsProgress ; } protected void initializeDefaultPosition ( ) { try { ICompilationUnit cu = getCompilationUnit ( ) ; IImportDeclaration [ ] imports = cu . getImports ( ) ; if ( imports . length > <NUM_LIT:0> ) { createAfter ( imports [ imports . length - <NUM_LIT:1> ] ) ; return ; } IType [ ] types = cu . getTypes ( ) ; if ( types . length > <NUM_LIT:0> ) { createBefore ( types [ <NUM_LIT:0> ] ) ; return ; } IJavaElement [ ] children = cu . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { if ( children [ i ] . getElementType ( ) == IJavaElement . PACKAGE_DECLARATION ) { createAfter ( children [ i ] ) ; return ; } } } catch ( JavaModelException e ) { } } public IJavaModelStatus verify ( ) { IJavaModelStatus status = super . verify ( ) ; if ( ! status . isOK ( ) ) { return status ; } IJavaProject project = getParentElement ( ) . getJavaProject ( ) ; if ( JavaConventions . validateImportDeclaration ( this . importName , project . getOption ( JavaCore . COMPILER_SOURCE , true ) , project . getOption ( JavaCore . COMPILER_COMPLIANCE , true ) ) . getSeverity ( ) == IStatus . ERROR ) { return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_NAME , this . importName ) ; } return JavaModelStatus . VERIFIED_OK ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . net . URL ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Iterator ; import java . util . Map ; import org . eclipse . core . resources . IFolder ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IWorkspace ; 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 . IJavaElementDelta ; import org . eclipse . jdt . core . IPackageFragment ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . compiler . util . ObjectVector ; import org . eclipse . jdt . internal . core . DeltaProcessor . RootInfo ; import org . eclipse . jdt . internal . core . JavaModelManager . PerProjectInfo ; import org . eclipse . jdt . internal . core . search . indexing . IndexManager ; import org . eclipse . jdt . internal . core . util . Util ; public class ClasspathChange { public static final int NO_DELTA = <NUM_LIT:0x00> ; public static final int HAS_DELTA = <NUM_LIT> ; public static final int HAS_PROJECT_CHANGE = <NUM_LIT> ; public static final int HAS_LIBRARY_CHANGE = <NUM_LIT> ; JavaProject project ; IClasspathEntry [ ] oldRawClasspath ; IPath oldOutputLocation ; IClasspathEntry [ ] oldResolvedClasspath ; public ClasspathChange ( JavaProject project , IClasspathEntry [ ] oldRawClasspath , IPath oldOutputLocation , IClasspathEntry [ ] oldResolvedClasspath ) { this . project = project ; this . oldRawClasspath = oldRawClasspath ; this . oldOutputLocation = oldOutputLocation ; this . oldResolvedClasspath = oldResolvedClasspath ; } private void addClasspathDeltas ( JavaElementDelta delta , IPackageFragmentRoot [ ] roots , int flag ) { for ( int i = <NUM_LIT:0> ; i < roots . length ; i ++ ) { IPackageFragmentRoot root = roots [ i ] ; delta . changed ( root , flag ) ; if ( ( flag & IJavaElementDelta . F_REMOVED_FROM_CLASSPATH ) != <NUM_LIT:0> || ( flag & IJavaElementDelta . F_SOURCEATTACHED ) != <NUM_LIT:0> || ( flag & IJavaElementDelta . F_SOURCEDETACHED ) != <NUM_LIT:0> ) { try { root . close ( ) ; } catch ( JavaModelException e ) { } } } } private int classpathContains ( IClasspathEntry [ ] list , IClasspathEntry entry ) { IPath [ ] exclusionPatterns = entry . getExclusionPatterns ( ) ; IPath [ ] inclusionPatterns = entry . getInclusionPatterns ( ) ; int listLen = list == null ? <NUM_LIT:0> : list . length ; nextEntry : for ( int i = <NUM_LIT:0> ; i < listLen ; i ++ ) { IClasspathEntry other = list [ i ] ; if ( other . getContentKind ( ) == entry . getContentKind ( ) && other . getEntryKind ( ) == entry . getEntryKind ( ) && other . isExported ( ) == entry . isExported ( ) && other . getPath ( ) . equals ( entry . getPath ( ) ) ) { IPath entryOutput = entry . getOutputLocation ( ) ; IPath otherOutput = other . getOutputLocation ( ) ; if ( entryOutput == null ) { if ( otherOutput != null ) continue ; } else { if ( ! entryOutput . equals ( otherOutput ) ) continue ; } IPath [ ] otherIncludes = other . getInclusionPatterns ( ) ; if ( inclusionPatterns != otherIncludes ) { if ( inclusionPatterns == null ) continue ; int includeLength = inclusionPatterns . length ; if ( otherIncludes == null || otherIncludes . length != includeLength ) continue ; for ( int j = <NUM_LIT:0> ; j < includeLength ; j ++ ) { if ( ! inclusionPatterns [ j ] . toString ( ) . equals ( otherIncludes [ j ] . toString ( ) ) ) continue nextEntry ; } } IPath [ ] otherExcludes = other . getExclusionPatterns ( ) ; if ( exclusionPatterns != otherExcludes ) { if ( exclusionPatterns == null ) continue ; int excludeLength = exclusionPatterns . length ; if ( otherExcludes == null || otherExcludes . length != excludeLength ) continue ; for ( int j = <NUM_LIT:0> ; j < excludeLength ; j ++ ) { if ( ! exclusionPatterns [ j ] . toString ( ) . equals ( otherExcludes [ j ] . toString ( ) ) ) continue nextEntry ; } } return i ; } } return - <NUM_LIT:1> ; } private void collectAllSubfolders ( IFolder folder , ArrayList collection ) throws JavaModelException { try { IResource [ ] members = folder . members ( ) ; for ( int i = <NUM_LIT:0> , max = members . length ; i < max ; i ++ ) { IResource r = members [ i ] ; if ( r . getType ( ) == IResource . FOLDER ) { collection . add ( r ) ; collectAllSubfolders ( ( IFolder ) r , collection ) ; } } } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } private ArrayList determineAffectedPackageFragments ( IPath location ) throws JavaModelException { ArrayList fragments = new ArrayList ( ) ; IWorkspace workspace = ResourcesPlugin . getWorkspace ( ) ; IResource resource = null ; if ( location != null ) { resource = workspace . getRoot ( ) . findMember ( location ) ; } if ( resource != null && resource . getType ( ) == IResource . FOLDER ) { IFolder folder = ( IFolder ) resource ; IClasspathEntry [ ] classpath = this . project . getExpandedClasspath ( ) ; for ( int i = <NUM_LIT:0> ; i < classpath . length ; i ++ ) { IClasspathEntry entry = classpath [ i ] ; IPath path = classpath [ i ] . getPath ( ) ; if ( entry . getEntryKind ( ) != IClasspathEntry . CPE_PROJECT && path . isPrefixOf ( location ) && ! path . equals ( location ) ) { IPackageFragmentRoot [ ] roots = this . project . computePackageFragmentRoots ( classpath [ i ] ) ; PackageFragmentRoot root = ( PackageFragmentRoot ) roots [ <NUM_LIT:0> ] ; ArrayList folders = new ArrayList ( ) ; folders . add ( folder ) ; collectAllSubfolders ( folder , folders ) ; Iterator elements = folders . iterator ( ) ; int segments = path . segmentCount ( ) ; while ( elements . hasNext ( ) ) { IFolder f = ( IFolder ) elements . next ( ) ; IPath relativePath = f . getFullPath ( ) . removeFirstSegments ( segments ) ; String [ ] pkgName = relativePath . segments ( ) ; IPackageFragment pkg = root . getPackageFragment ( pkgName ) ; if ( ! Util . isExcluded ( pkg ) ) fragments . add ( pkg ) ; } } } } return fragments ; } public boolean equals ( Object obj ) { if ( ! ( obj instanceof ClasspathChange ) ) return false ; return this . project . equals ( ( ( ClasspathChange ) obj ) . project ) ; } public int generateDelta ( JavaElementDelta delta , boolean addClasspathChange ) { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; DeltaProcessingState state = manager . deltaState ; if ( state . findJavaProject ( this . project . getElementName ( ) ) == null ) return NO_DELTA ; DeltaProcessor deltaProcessor = state . getDeltaProcessor ( ) ; IClasspathEntry [ ] newResolvedClasspath = null ; IPath newOutputLocation = null ; int result = NO_DELTA ; try { PerProjectInfo perProjectInfo = this . project . getPerProjectInfo ( ) ; this . project . resolveClasspath ( perProjectInfo , false , addClasspathChange ) ; IClasspathEntry [ ] newRawClasspath ; synchronized ( perProjectInfo ) { newRawClasspath = perProjectInfo . rawClasspath ; newResolvedClasspath = perProjectInfo . getResolvedClasspath ( ) ; newOutputLocation = perProjectInfo . outputLocation ; } if ( newResolvedClasspath == null ) { PerProjectInfo temporaryInfo = this . project . newTemporaryInfo ( ) ; this . project . resolveClasspath ( temporaryInfo , false , addClasspathChange ) ; newRawClasspath = temporaryInfo . rawClasspath ; newResolvedClasspath = temporaryInfo . getResolvedClasspath ( ) ; newOutputLocation = temporaryInfo . outputLocation ; } if ( this . oldRawClasspath != null && ! JavaProject . areClasspathsEqual ( this . oldRawClasspath , newRawClasspath , this . oldOutputLocation , newOutputLocation ) ) { delta . changed ( this . project , IJavaElementDelta . F_CLASSPATH_CHANGED ) ; result |= HAS_DELTA ; for ( int i = <NUM_LIT:0> , length = this . oldRawClasspath . length ; i < length ; i ++ ) { IClasspathEntry entry = this . oldRawClasspath [ i ] ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_CONTAINER ) { if ( classpathContains ( newRawClasspath , entry ) == - <NUM_LIT:1> ) manager . containerPut ( this . project , entry . getPath ( ) , null ) ; } } } if ( this . oldResolvedClasspath != null && JavaProject . areClasspathsEqual ( this . oldResolvedClasspath , newResolvedClasspath , this . oldOutputLocation , newOutputLocation ) ) return result ; this . project . close ( ) ; deltaProcessor . projectCachesToReset . add ( this . project ) ; } catch ( JavaModelException e ) { if ( DeltaProcessor . VERBOSE ) { e . printStackTrace ( ) ; } return result ; } if ( this . oldResolvedClasspath == null ) return result ; delta . changed ( this . project , IJavaElementDelta . F_RESOLVED_CLASSPATH_CHANGED ) ; result |= HAS_DELTA ; state . addForRefresh ( this . project ) ; Map removedRoots = null ; IPackageFragmentRoot [ ] roots = null ; Map allOldRoots ; if ( ( allOldRoots = deltaProcessor . oldRoots ) != null ) { roots = ( IPackageFragmentRoot [ ] ) allOldRoots . get ( this . project ) ; } if ( roots != null ) { removedRoots = new HashMap ( ) ; for ( int i = <NUM_LIT:0> ; i < roots . length ; i ++ ) { IPackageFragmentRoot root = roots [ i ] ; removedRoots . put ( root . getPath ( ) , root ) ; } } int newLength = newResolvedClasspath . length ; int oldLength = this . oldResolvedClasspath . length ; for ( int i = <NUM_LIT:0> ; i < oldLength ; i ++ ) { int index = classpathContains ( newResolvedClasspath , this . oldResolvedClasspath [ i ] ) ; if ( index == - <NUM_LIT:1> ) { int entryKind = this . oldResolvedClasspath [ i ] . getEntryKind ( ) ; if ( entryKind == IClasspathEntry . CPE_PROJECT ) { result |= HAS_PROJECT_CHANGE ; continue ; } if ( entryKind == IClasspathEntry . CPE_LIBRARY ) { result |= HAS_LIBRARY_CHANGE ; } IPackageFragmentRoot [ ] pkgFragmentRoots = null ; if ( removedRoots != null ) { PackageFragmentRoot oldRoot = ( PackageFragmentRoot ) removedRoots . get ( this . oldResolvedClasspath [ i ] . getPath ( ) ) ; if ( oldRoot != null ) { pkgFragmentRoots = new PackageFragmentRoot [ ] { oldRoot } ; } } if ( pkgFragmentRoots == null ) { try { ObjectVector accumulatedRoots = new ObjectVector ( ) ; HashSet rootIDs = new HashSet ( <NUM_LIT:5> ) ; rootIDs . add ( this . project . rootID ( ) ) ; this . project . computePackageFragmentRoots ( this . oldResolvedClasspath [ i ] , accumulatedRoots , rootIDs , null , false , null ) ; RootInfo rootInfo = ( RootInfo ) state . oldRoots . get ( this . oldResolvedClasspath [ i ] . getPath ( ) ) ; if ( rootInfo != null && rootInfo . cache != null ) { IPackageFragmentRoot oldRoot = rootInfo . cache ; boolean found = false ; for ( int j = <NUM_LIT:0> ; j < accumulatedRoots . size ( ) ; j ++ ) { IPackageFragmentRoot root = ( IPackageFragmentRoot ) accumulatedRoots . elementAt ( j ) ; if ( root . getPath ( ) . equals ( oldRoot . getPath ( ) ) ) { found = true ; break ; } } if ( ! found ) accumulatedRoots . add ( oldRoot ) ; } pkgFragmentRoots = new PackageFragmentRoot [ accumulatedRoots . size ( ) ] ; accumulatedRoots . copyInto ( pkgFragmentRoots ) ; } catch ( JavaModelException e ) { pkgFragmentRoots = new PackageFragmentRoot [ ] { } ; } } addClasspathDeltas ( delta , pkgFragmentRoots , IJavaElementDelta . F_REMOVED_FROM_CLASSPATH ) ; } else { if ( this . oldResolvedClasspath [ i ] . getEntryKind ( ) == IClasspathEntry . CPE_PROJECT ) { result |= HAS_PROJECT_CHANGE ; continue ; } if ( index != i ) { addClasspathDeltas ( delta , this . project . computePackageFragmentRoots ( this . oldResolvedClasspath [ i ] ) , IJavaElementDelta . F_REORDER ) ; } IPath newSourcePath = newResolvedClasspath [ index ] . getSourceAttachmentPath ( ) ; int sourceAttachmentFlags = getSourceAttachmentDeltaFlag ( this . oldResolvedClasspath [ i ] . getSourceAttachmentPath ( ) , newSourcePath ) ; IPath oldRootPath = this . oldResolvedClasspath [ i ] . getSourceAttachmentRootPath ( ) ; IPath newRootPath = newResolvedClasspath [ index ] . getSourceAttachmentRootPath ( ) ; int sourceAttachmentRootFlags = getSourceAttachmentDeltaFlag ( oldRootPath , newRootPath ) ; int flags = sourceAttachmentFlags | sourceAttachmentRootFlags ; if ( flags != <NUM_LIT:0> ) { addClasspathDeltas ( delta , this . project . computePackageFragmentRoots ( this . oldResolvedClasspath [ i ] ) , flags ) ; } else { if ( oldRootPath == null && newRootPath == null ) { IPackageFragmentRoot [ ] computedRoots = this . project . computePackageFragmentRoots ( this . oldResolvedClasspath [ i ] ) ; for ( int j = <NUM_LIT:0> ; j < computedRoots . length ; j ++ ) { IPackageFragmentRoot root = computedRoots [ j ] ; try { root . close ( ) ; } catch ( JavaModelException e ) { } } } } } } for ( int i = <NUM_LIT:0> ; i < newLength ; i ++ ) { int index = classpathContains ( this . oldResolvedClasspath , newResolvedClasspath [ i ] ) ; if ( index == - <NUM_LIT:1> ) { int entryKind = newResolvedClasspath [ i ] . getEntryKind ( ) ; if ( entryKind == IClasspathEntry . CPE_PROJECT ) { result |= HAS_PROJECT_CHANGE ; continue ; } if ( entryKind == IClasspathEntry . CPE_LIBRARY ) { result |= HAS_LIBRARY_CHANGE ; } addClasspathDeltas ( delta , this . project . computePackageFragmentRoots ( newResolvedClasspath [ i ] ) , IJavaElementDelta . F_ADDED_TO_CLASSPATH ) ; } } if ( ( newOutputLocation == null && this . oldOutputLocation != null ) || ( newOutputLocation != null && ! newOutputLocation . equals ( this . oldOutputLocation ) ) ) { try { ArrayList added = determineAffectedPackageFragments ( this . oldOutputLocation ) ; Iterator iter = added . iterator ( ) ; while ( iter . hasNext ( ) ) { IPackageFragment frag = ( IPackageFragment ) iter . next ( ) ; ( ( IPackageFragmentRoot ) frag . getParent ( ) ) . close ( ) ; delta . added ( frag ) ; } ArrayList removed = determineAffectedPackageFragments ( newOutputLocation ) ; iter = removed . iterator ( ) ; while ( iter . hasNext ( ) ) { IPackageFragment frag = ( IPackageFragment ) iter . next ( ) ; ( ( IPackageFragmentRoot ) frag . getParent ( ) ) . close ( ) ; delta . removed ( frag ) ; } } catch ( JavaModelException e ) { if ( DeltaProcessor . VERBOSE ) e . printStackTrace ( ) ; } } return result ; } private int getSourceAttachmentDeltaFlag ( IPath oldPath , IPath newPath ) { if ( oldPath == null ) { if ( newPath != null ) { return IJavaElementDelta . F_SOURCEATTACHED ; } else { return <NUM_LIT:0> ; } } else if ( newPath == null ) { return IJavaElementDelta . F_SOURCEDETACHED ; } else if ( ! oldPath . equals ( newPath ) ) { return IJavaElementDelta . F_SOURCEATTACHED | IJavaElementDelta . F_SOURCEDETACHED ; } else { return <NUM_LIT:0> ; } } public int hashCode ( ) { return this . project . hashCode ( ) ; } public void requestIndexing ( ) { IClasspathEntry [ ] newResolvedClasspath = null ; try { newResolvedClasspath = this . project . getResolvedClasspath ( ) ; } catch ( JavaModelException e ) { return ; } JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; IndexManager indexManager = manager . indexManager ; if ( indexManager == null ) return ; DeltaProcessingState state = manager . deltaState ; int newLength = newResolvedClasspath . length ; int oldLength = this . oldResolvedClasspath == null ? <NUM_LIT:0> : this . oldResolvedClasspath . length ; for ( int i = <NUM_LIT:0> ; i < oldLength ; i ++ ) { int index = classpathContains ( newResolvedClasspath , this . oldResolvedClasspath [ i ] ) ; if ( index == - <NUM_LIT:1> ) { if ( this . oldResolvedClasspath [ i ] . getEntryKind ( ) == IClasspathEntry . CPE_PROJECT ) { continue ; } IClasspathEntry oldEntry = this . oldResolvedClasspath [ i ] ; final IPath path = oldEntry . getPath ( ) ; int changeKind = this . oldResolvedClasspath [ i ] . getEntryKind ( ) ; switch ( changeKind ) { case IClasspathEntry . CPE_SOURCE : char [ ] [ ] inclusionPatterns = ( ( ClasspathEntry ) oldEntry ) . fullInclusionPatternChars ( ) ; char [ ] [ ] exclusionPatterns = ( ( ClasspathEntry ) oldEntry ) . fullExclusionPatternChars ( ) ; indexManager . removeSourceFolderFromIndex ( this . project , path , inclusionPatterns , exclusionPatterns ) ; break ; case IClasspathEntry . CPE_LIBRARY : if ( state . otherRoots . get ( path ) == null ) { indexManager . discardJobs ( path . toString ( ) ) ; indexManager . removeIndex ( path ) ; } break ; } } } for ( int i = <NUM_LIT:0> ; i < newLength ; i ++ ) { int index = classpathContains ( this . oldResolvedClasspath , newResolvedClasspath [ i ] ) ; if ( index == - <NUM_LIT:1> || newResolvedClasspath [ i ] . getEntryKind ( ) == IClasspathEntry . CPE_LIBRARY ) { if ( newResolvedClasspath [ i ] . getEntryKind ( ) == IClasspathEntry . CPE_PROJECT ) { continue ; } int entryKind = newResolvedClasspath [ i ] . getEntryKind ( ) ; URL newurl = ( ( ClasspathEntry ) newResolvedClasspath [ i ] ) . getLibraryIndexLocation ( ) ; switch ( entryKind ) { case IClasspathEntry . CPE_LIBRARY : boolean pathHasChanged = true ; IPath newPath = newResolvedClasspath [ i ] . getPath ( ) ; for ( int j = <NUM_LIT:0> ; j < oldLength ; j ++ ) { IClasspathEntry oldEntry = this . oldResolvedClasspath [ j ] ; if ( oldEntry . getPath ( ) . equals ( newPath ) ) { URL oldurl = ( ( ClasspathEntry ) oldEntry ) . getLibraryIndexLocation ( ) ; if ( oldurl == null && newurl == null ) { pathHasChanged = false ; } else if ( oldurl != null && newurl != null ) { pathHasChanged = ! ( newurl . equals ( oldurl ) ) ; } else if ( oldurl != null ) { indexManager . removeIndex ( newPath ) ; } break ; } } if ( pathHasChanged ) { indexManager . indexLibrary ( newPath , this . project . getProject ( ) , newurl ) ; } break ; case IClasspathEntry . CPE_SOURCE : IClasspathEntry entry = newResolvedClasspath [ i ] ; IPath path = entry . getPath ( ) ; char [ ] [ ] inclusionPatterns = ( ( ClasspathEntry ) entry ) . fullInclusionPatternChars ( ) ; char [ ] [ ] exclusionPatterns = ( ( ClasspathEntry ) entry ) . fullExclusionPatternChars ( ) ; indexManager . indexSourceFolder ( this . project , path , inclusionPatterns , exclusionPatterns ) ; break ; } } } } public String toString ( ) { return "<STR_LIT>" + this . project . getElementName ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IJavaElement ; public class JavaElementInfo implements Cloneable { static Object [ ] NO_NON_JAVA_RESOURCES = new Object [ ] { } ; public Object clone ( ) { try { return super . clone ( ) ; } catch ( CloneNotSupportedException e ) { throw new Error ( ) ; } } public IJavaElement [ ] getChildren ( ) { return JavaElement . NO_ELEMENTS ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . Enumeration ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . core . runtime . PerformanceStats ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . internal . codeassist . CompletionEngine ; import org . eclipse . jdt . internal . codeassist . SelectionEngine ; import org . eclipse . jdt . internal . core . util . Util ; public abstract class Openable extends JavaElement implements IOpenable , IBufferChangedListener { protected Openable ( JavaElement parent ) { super ( parent ) ; } public void bufferChanged ( BufferChangedEvent event ) { if ( event . getBuffer ( ) . isClosed ( ) ) { JavaModelManager . getJavaModelManager ( ) . getElementsOutOfSynchWithBuffers ( ) . remove ( this ) ; getBufferManager ( ) . removeBuffer ( event . getBuffer ( ) ) ; } else { JavaModelManager . getJavaModelManager ( ) . getElementsOutOfSynchWithBuffers ( ) . add ( this ) ; } } protected abstract boolean buildStructure ( OpenableElementInfo info , IProgressMonitor pm , Map newElements , IResource underlyingResource ) throws JavaModelException ; public boolean canBeRemovedFromCache ( ) { try { return ! hasUnsavedChanges ( ) ; } catch ( JavaModelException e ) { return false ; } } public boolean canBufferBeRemovedFromCache ( IBuffer buffer ) { return ! buffer . hasUnsavedChanges ( ) ; } protected void closeBuffer ( ) { if ( ! hasBuffer ( ) ) return ; IBuffer buffer = getBufferManager ( ) . getBuffer ( this ) ; if ( buffer != null ) { buffer . close ( ) ; buffer . removeBufferChangedListener ( this ) ; } } protected void closing ( Object info ) { closeBuffer ( ) ; } protected void codeComplete ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit cu , org . eclipse . jdt . internal . compiler . env . ICompilationUnit unitToSkip , int position , CompletionRequestor requestor , WorkingCopyOwner owner , ITypeRoot typeRoot , IProgressMonitor monitor ) throws JavaModelException { if ( requestor == null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } PerformanceStats performanceStats = CompletionEngine . PERF ? PerformanceStats . getStats ( JavaModelManager . COMPLETION_PERF , this ) : null ; if ( performanceStats != null ) { performanceStats . startRun ( new String ( cu . getFileName ( ) ) + "<STR_LIT>" + position ) ; } IBuffer buffer = getBuffer ( ) ; if ( buffer == null ) { return ; } if ( position < - <NUM_LIT:1> || position > buffer . getLength ( ) ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INDEX_OUT_OF_BOUNDS ) ) ; } JavaProject project = ( JavaProject ) getJavaProject ( ) ; SearchableEnvironment environment = project . newSearchableNameEnvironment ( owner ) ; environment . unitToSkip = unitToSkip ; CompletionEngine engine = new CompletionEngine ( environment , requestor , project . getOptions ( true ) , project , owner , monitor ) ; engine . complete ( cu , position , <NUM_LIT:0> , typeRoot ) ; if ( performanceStats != null ) { performanceStats . endRun ( ) ; } if ( NameLookup . VERBOSE ) { System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInSourcePackage + "<STR_LIT>" ) ; System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInBinaryPackage + "<STR_LIT>" ) ; } } protected IJavaElement [ ] codeSelect ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit cu , int offset , int length , WorkingCopyOwner owner ) throws JavaModelException { PerformanceStats performanceStats = SelectionEngine . PERF ? PerformanceStats . getStats ( JavaModelManager . SELECTION_PERF , this ) : null ; if ( performanceStats != null ) { performanceStats . startRun ( new String ( cu . getFileName ( ) ) + "<STR_LIT>" + offset + "<STR_LIT:U+002C>" + length + "<STR_LIT:]>" ) ; } JavaProject project = ( JavaProject ) getJavaProject ( ) ; SearchableEnvironment environment = project . newSearchableNameEnvironment ( owner ) ; SelectionRequestor requestor = new SelectionRequestor ( environment . nameLookup , this ) ; IBuffer buffer = getBuffer ( ) ; if ( buffer == null ) { return requestor . getElements ( ) ; } int end = buffer . getLength ( ) ; if ( offset < <NUM_LIT:0> || length < <NUM_LIT:0> || offset + length > end ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INDEX_OUT_OF_BOUNDS ) ) ; } SelectionEngine engine = new SelectionEngine ( environment , requestor , project . getOptions ( true ) , owner ) ; engine . select ( cu , offset , offset + length - <NUM_LIT:1> ) ; if ( performanceStats != null ) { performanceStats . endRun ( ) ; } if ( NameLookup . VERBOSE ) { System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInSourcePackage + "<STR_LIT>" ) ; System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInBinaryPackage + "<STR_LIT>" ) ; } return requestor . getElements ( ) ; } protected Object createElementInfo ( ) { return new OpenableElementInfo ( ) ; } public boolean exists ( ) { if ( JavaModelManager . getJavaModelManager ( ) . getInfo ( this ) != null ) return true ; switch ( getElementType ( ) ) { case IJavaElement . PACKAGE_FRAGMENT : PackageFragmentRoot root = getPackageFragmentRoot ( ) ; if ( root . isArchive ( ) ) { JarPackageFragmentRootInfo rootInfo ; try { rootInfo = ( JarPackageFragmentRootInfo ) root . getElementInfo ( ) ; } catch ( JavaModelException e ) { return false ; } return rootInfo . rawPackageInfo . containsKey ( ( ( PackageFragment ) this ) . names ) ; } break ; case IJavaElement . CLASS_FILE : if ( getPackageFragmentRoot ( ) . isArchive ( ) ) { return super . exists ( ) ; } break ; } return validateExistence ( resource ( ) ) . isOK ( ) ; } public String findRecommendedLineSeparator ( ) throws JavaModelException { IBuffer buffer = getBuffer ( ) ; String source = buffer == null ? null : buffer . getContents ( ) ; return Util . getLineSeparator ( source , getJavaProject ( ) ) ; } protected void generateInfos ( Object info , HashMap newElements , IProgressMonitor monitor ) throws JavaModelException { if ( JavaModelCache . VERBOSE ) { String element ; switch ( getElementType ( ) ) { case JAVA_PROJECT : element = "<STR_LIT>" ; break ; case PACKAGE_FRAGMENT_ROOT : element = "<STR_LIT:root>" ; break ; case PACKAGE_FRAGMENT : element = "<STR_LIT>" ; break ; case CLASS_FILE : element = "<STR_LIT>" ; break ; case COMPILATION_UNIT : element = "<STR_LIT>" ; break ; default : element = "<STR_LIT>" ; } System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + element + "<STR_LIT:U+0020>" + this . toStringWithAncestors ( ) ) ; } openAncestors ( newElements , monitor ) ; IResource underlResource = resource ( ) ; IStatus status = validateExistence ( underlResource ) ; if ( ! status . isOK ( ) ) throw newJavaModelException ( status ) ; if ( monitor != null && monitor . isCanceled ( ) ) throw new OperationCanceledException ( ) ; newElements . put ( this , info ) ; try { OpenableElementInfo openableElementInfo = ( OpenableElementInfo ) info ; boolean isStructureKnown = buildStructure ( openableElementInfo , monitor , newElements , underlResource ) ; openableElementInfo . setIsStructureKnown ( isStructureKnown ) ; } catch ( JavaModelException e ) { newElements . remove ( this ) ; throw e ; } JavaModelManager . getJavaModelManager ( ) . getElementsOutOfSynchWithBuffers ( ) . remove ( this ) ; if ( JavaModelCache . VERBOSE ) { System . out . println ( JavaModelManager . getJavaModelManager ( ) . cacheToString ( "<STR_LIT>" ) ) ; } } public IBuffer getBuffer ( ) throws JavaModelException { if ( hasBuffer ( ) ) { Object info = getElementInfo ( ) ; IBuffer buffer = getBufferManager ( ) . getBuffer ( this ) ; if ( buffer == null ) { buffer = openBuffer ( null , info ) ; } if ( buffer instanceof NullBuffer ) { return null ; } return buffer ; } else { return null ; } } public IBufferFactory getBufferFactory ( ) { return getBufferManager ( ) . getDefaultBufferFactory ( ) ; } protected BufferManager getBufferManager ( ) { return BufferManager . getDefaultBufferManager ( ) ; } public IResource getCorrespondingResource ( ) throws JavaModelException { return getUnderlyingResource ( ) ; } public IOpenable getOpenable ( ) { return this ; } public IResource getUnderlyingResource ( ) throws JavaModelException { IResource parentResource = this . parent . getUnderlyingResource ( ) ; if ( parentResource == null ) { return null ; } int type = parentResource . getType ( ) ; if ( type == IResource . FOLDER || type == IResource . PROJECT ) { IContainer folder = ( IContainer ) parentResource ; IResource resource = folder . findMember ( getElementName ( ) ) ; if ( resource == null ) { throw newNotPresentException ( ) ; } else { return resource ; } } else { return parentResource ; } } protected boolean hasBuffer ( ) { return false ; } public boolean hasUnsavedChanges ( ) throws JavaModelException { if ( isReadOnly ( ) || ! isOpen ( ) ) { return false ; } IBuffer buf = getBuffer ( ) ; if ( buf != null && buf . hasUnsavedChanges ( ) ) { return true ; } int elementType = getElementType ( ) ; if ( elementType == PACKAGE_FRAGMENT || elementType == PACKAGE_FRAGMENT_ROOT || elementType == JAVA_PROJECT || elementType == JAVA_MODEL ) { Enumeration openBuffers = getBufferManager ( ) . getOpenBuffers ( ) ; while ( openBuffers . hasMoreElements ( ) ) { IBuffer buffer = ( IBuffer ) openBuffers . nextElement ( ) ; if ( buffer . hasUnsavedChanges ( ) ) { IJavaElement owner = ( IJavaElement ) buffer . getOwner ( ) ; if ( isAncestorOf ( owner ) ) { return true ; } } } } return false ; } public boolean isConsistent ( ) { return true ; } public boolean isOpen ( ) { return JavaModelManager . getJavaModelManager ( ) . getInfo ( this ) != null ; } protected boolean isSourceElement ( ) { return false ; } public boolean isStructureKnown ( ) throws JavaModelException { return ( ( OpenableElementInfo ) getElementInfo ( ) ) . isStructureKnown ( ) ; } public void makeConsistent ( IProgressMonitor monitor ) throws JavaModelException { } public void open ( IProgressMonitor pm ) throws JavaModelException { getElementInfo ( pm ) ; } protected IBuffer openBuffer ( IProgressMonitor pm , Object info ) throws JavaModelException { return null ; } public IResource getResource ( ) { PackageFragmentRoot root = getPackageFragmentRoot ( ) ; if ( root != null ) { if ( root . isExternal ( ) ) return null ; if ( root . isArchive ( ) ) return root . resource ( root ) ; } return resource ( root ) ; } public IResource resource ( ) { PackageFragmentRoot root = getPackageFragmentRoot ( ) ; if ( root != null && root . isArchive ( ) ) return root . resource ( root ) ; return resource ( root ) ; } protected abstract IResource resource ( PackageFragmentRoot root ) ; protected boolean resourceExists ( IResource underlyingResource ) { return underlyingResource . isAccessible ( ) ; } public void save ( IProgressMonitor pm , boolean force ) throws JavaModelException { if ( isReadOnly ( ) ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . READ_ONLY , this ) ) ; } IBuffer buf = getBuffer ( ) ; if ( buf != null ) { buf . save ( pm , force ) ; makeConsistent ( pm ) ; } } public PackageFragmentRoot getPackageFragmentRoot ( ) { return ( PackageFragmentRoot ) getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; } abstract protected IStatus validateExistence ( IResource underlyingResource ) ; protected void openAncestors ( HashMap newElements , IProgressMonitor monitor ) throws JavaModelException { Openable openableParent = ( Openable ) getOpenableParent ( ) ; if ( openableParent != null && ! openableParent . isOpen ( ) ) { openableParent . generateInfos ( openableParent . createElementInfo ( ) , newElements , monitor ) ; } } } </s>
|
<s> package org . eclipse . jdt . internal . core ; public class ResolvedBinaryField extends BinaryField { private String uniqueKey ; public ResolvedBinaryField ( JavaElement parent , String name , String uniqueKey ) { super ( parent , name ) ; 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 BinaryField ( this . parent , this . name ) ; handle . occurrenceCount = this . occurrenceCount ; return handle ; } } </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 . IJavaModelStatusConstants ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . IType ; 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 . env . IBinaryMethod ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObjectToIntArray ; import org . eclipse . jdt . internal . core . util . Util ; public class JavadocContents { private static final int [ ] UNKNOWN_FORMAT = new int [ <NUM_LIT:0> ] ; private BinaryType type ; private char [ ] content ; private int childrenStart ; private boolean hasComputedChildrenSections = false ; private int indexOfFieldDetails ; private int indexOfConstructorDetails ; private int indexOfMethodDetails ; private int indexOfEndOfClassData ; private int indexOfFieldsBottom ; private int indexOfAllMethodsTop ; private int indexOfAllMethodsBottom ; private int [ ] typeDocRange ; private HashtableOfObjectToIntArray fieldDocRanges ; private HashtableOfObjectToIntArray methodDocRanges ; private int [ ] fieldAnchorIndexes ; private int fieldAnchorIndexesCount ; private int fieldLastAnchorFoundIndex ; private int [ ] methodAnchorIndexes ; private int methodAnchorIndexesCount ; private int methodLastAnchorFoundIndex ; private int [ ] unknownFormatAnchorIndexes ; private int unknownFormatAnchorIndexesCount ; private int unknownFormatLastAnchorFoundIndex ; private int [ ] tempAnchorIndexes ; private int tempAnchorIndexesCount ; private int tempLastAnchorFoundIndex ; public JavadocContents ( BinaryType type , String content ) { this . type = type ; this . content = content != null ? content . toCharArray ( ) : null ; } public String getTypeDoc ( ) throws JavaModelException { if ( this . content == null ) return null ; synchronized ( this ) { if ( this . typeDocRange == null ) { computeTypeRange ( ) ; } } if ( this . typeDocRange != null ) { if ( this . typeDocRange == UNKNOWN_FORMAT ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . UNKNOWN_JAVADOC_FORMAT , this . type ) ) ; return String . valueOf ( CharOperation . subarray ( this . content , this . typeDocRange [ <NUM_LIT:0> ] , this . typeDocRange [ <NUM_LIT:1> ] ) ) ; } return null ; } public String getFieldDoc ( IField child ) throws JavaModelException { if ( this . content == null ) return null ; int [ ] range = null ; synchronized ( this ) { if ( this . fieldDocRanges == null ) { this . fieldDocRanges = new HashtableOfObjectToIntArray ( ) ; } else { range = this . fieldDocRanges . get ( child ) ; } if ( range == null ) { range = computeFieldRange ( child ) ; this . fieldDocRanges . put ( child , range ) ; } } if ( range != null ) { if ( range == UNKNOWN_FORMAT ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . UNKNOWN_JAVADOC_FORMAT , child ) ) ; return String . valueOf ( CharOperation . subarray ( this . content , range [ <NUM_LIT:0> ] , range [ <NUM_LIT:1> ] ) ) ; } return null ; } public String getMethodDoc ( IMethod child ) throws JavaModelException { if ( this . content == null ) return null ; int [ ] range = null ; synchronized ( this ) { if ( this . methodDocRanges == null ) { this . methodDocRanges = new HashtableOfObjectToIntArray ( ) ; } else { range = this . methodDocRanges . get ( child ) ; } if ( range == null ) { range = computeMethodRange ( child ) ; this . methodDocRanges . put ( child , range ) ; } } if ( range != null ) { if ( range == UNKNOWN_FORMAT ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . UNKNOWN_JAVADOC_FORMAT , child ) ) ; } return String . valueOf ( CharOperation . subarray ( this . content , range [ <NUM_LIT:0> ] , range [ <NUM_LIT:1> ] ) ) ; } return null ; } private int [ ] computeChildRange ( char [ ] anchor , int indexOfSectionBottom ) throws JavaModelException { if ( this . tempAnchorIndexesCount > <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < this . tempAnchorIndexesCount ; i ++ ) { int anchorEndStart = this . tempAnchorIndexes [ i ] ; if ( anchorEndStart != - <NUM_LIT:1> && CharOperation . prefixEquals ( anchor , this . content , false , anchorEndStart ) ) { this . tempAnchorIndexes [ i ] = - <NUM_LIT:1> ; return computeChildRange ( anchorEndStart , anchor , indexOfSectionBottom ) ; } } } int fromIndex = this . tempLastAnchorFoundIndex ; int index ; while ( ( index = CharOperation . indexOf ( JavadocConstants . ANCHOR_PREFIX_START , this . content , false , fromIndex ) ) != - <NUM_LIT:1> && ( index < indexOfSectionBottom || indexOfSectionBottom == - <NUM_LIT:1> ) ) { fromIndex = index + <NUM_LIT:1> ; int anchorEndStart = index + JavadocConstants . ANCHOR_PREFIX_START_LENGHT ; this . tempLastAnchorFoundIndex = anchorEndStart ; if ( CharOperation . prefixEquals ( anchor , this . content , false , anchorEndStart ) ) { return computeChildRange ( anchorEndStart , anchor , indexOfSectionBottom ) ; } else { if ( this . tempAnchorIndexes . length == this . tempAnchorIndexesCount ) { System . arraycopy ( this . tempAnchorIndexes , <NUM_LIT:0> , this . tempAnchorIndexes = new int [ this . tempAnchorIndexesCount + <NUM_LIT:20> ] , <NUM_LIT:0> , this . tempAnchorIndexesCount ) ; } this . tempAnchorIndexes [ this . tempAnchorIndexesCount ++ ] = anchorEndStart ; } } return null ; } private int [ ] computeChildRange ( int anchorEndStart , char [ ] anchor , int indexOfBottom ) { int [ ] range = null ; if ( indexOfBottom != - <NUM_LIT:1> ) { int indexOfEndLink = CharOperation . indexOf ( JavadocConstants . ANCHOR_SUFFIX , this . content , false , anchorEndStart + anchor . length ) ; if ( indexOfEndLink != - <NUM_LIT:1> ) { int indexOfNextElement = CharOperation . indexOf ( JavadocConstants . ANCHOR_PREFIX_START , this . content , false , indexOfEndLink ) ; int javadocStart = indexOfEndLink + JavadocConstants . ANCHOR_SUFFIX_LENGTH ; int javadocEnd = indexOfNextElement == - <NUM_LIT:1> ? indexOfBottom : Math . min ( indexOfNextElement , indexOfBottom ) ; range = new int [ ] { javadocStart , javadocEnd } ; } else { range = UNKNOWN_FORMAT ; } } else { range = UNKNOWN_FORMAT ; } return range ; } private void computeChildrenSections ( ) { int lastIndex = CharOperation . indexOf ( JavadocConstants . SEPARATOR_START , this . content , false , this . childrenStart ) ; lastIndex = lastIndex == - <NUM_LIT:1> ? this . childrenStart : lastIndex ; this . indexOfFieldDetails = CharOperation . indexOf ( JavadocConstants . FIELD_DETAIL , this . content , false , lastIndex ) ; lastIndex = this . indexOfFieldDetails == - <NUM_LIT:1> ? lastIndex : this . indexOfFieldDetails ; this . indexOfConstructorDetails = CharOperation . indexOf ( JavadocConstants . CONSTRUCTOR_DETAIL , this . content , false , lastIndex ) ; lastIndex = this . indexOfConstructorDetails == - <NUM_LIT:1> ? lastIndex : this . indexOfConstructorDetails ; this . indexOfMethodDetails = CharOperation . indexOf ( JavadocConstants . METHOD_DETAIL , this . content , false , lastIndex ) ; lastIndex = this . indexOfMethodDetails == - <NUM_LIT:1> ? lastIndex : this . indexOfMethodDetails ; this . indexOfEndOfClassData = CharOperation . indexOf ( JavadocConstants . END_OF_CLASS_DATA , this . content , false , lastIndex ) ; this . indexOfFieldsBottom = this . indexOfConstructorDetails != - <NUM_LIT:1> ? this . indexOfConstructorDetails : this . indexOfMethodDetails != - <NUM_LIT:1> ? this . indexOfMethodDetails : this . indexOfEndOfClassData ; this . indexOfAllMethodsTop = this . indexOfConstructorDetails != - <NUM_LIT:1> ? this . indexOfConstructorDetails : this . indexOfMethodDetails ; this . indexOfAllMethodsBottom = this . indexOfEndOfClassData ; this . hasComputedChildrenSections = true ; } private int [ ] computeFieldRange ( IField field ) throws JavaModelException { if ( ! this . hasComputedChildrenSections ) { computeChildrenSections ( ) ; } StringBuffer buffer = new StringBuffer ( field . getElementName ( ) ) ; buffer . append ( JavadocConstants . ANCHOR_PREFIX_END ) ; char [ ] anchor = String . valueOf ( buffer ) . toCharArray ( ) ; int [ ] range = null ; if ( this . indexOfFieldDetails == - <NUM_LIT:1> || this . indexOfFieldsBottom == - <NUM_LIT:1> ) { if ( this . unknownFormatAnchorIndexes == null ) { this . unknownFormatAnchorIndexes = new int [ this . type . getChildren ( ) . length ] ; this . unknownFormatAnchorIndexesCount = <NUM_LIT:0> ; this . unknownFormatLastAnchorFoundIndex = this . childrenStart ; } this . tempAnchorIndexes = this . unknownFormatAnchorIndexes ; this . tempAnchorIndexesCount = this . unknownFormatAnchorIndexesCount ; this . tempLastAnchorFoundIndex = this . unknownFormatLastAnchorFoundIndex ; range = computeChildRange ( anchor , this . indexOfFieldsBottom ) ; this . unknownFormatLastAnchorFoundIndex = this . tempLastAnchorFoundIndex ; this . unknownFormatAnchorIndexesCount = this . tempAnchorIndexesCount ; this . unknownFormatAnchorIndexes = this . tempAnchorIndexes ; } else { if ( this . fieldAnchorIndexes == null ) { this . fieldAnchorIndexes = new int [ this . type . getFields ( ) . length ] ; this . fieldAnchorIndexesCount = <NUM_LIT:0> ; this . fieldLastAnchorFoundIndex = this . indexOfFieldDetails ; } this . tempAnchorIndexes = this . fieldAnchorIndexes ; this . tempAnchorIndexesCount = this . fieldAnchorIndexesCount ; this . tempLastAnchorFoundIndex = this . fieldLastAnchorFoundIndex ; range = computeChildRange ( anchor , this . indexOfFieldsBottom ) ; this . fieldLastAnchorFoundIndex = this . tempLastAnchorFoundIndex ; this . fieldAnchorIndexesCount = this . tempAnchorIndexesCount ; this . fieldAnchorIndexes = this . tempAnchorIndexes ; } return range ; } private int [ ] computeMethodRange ( IMethod method ) throws JavaModelException { if ( ! this . hasComputedChildrenSections ) { computeChildrenSections ( ) ; } char [ ] anchor = computeMethodAnchorPrefixEnd ( ( BinaryMethod ) method ) . toCharArray ( ) ; int [ ] range = null ; if ( this . indexOfAllMethodsTop == - <NUM_LIT:1> || this . indexOfAllMethodsBottom == - <NUM_LIT:1> ) { if ( this . unknownFormatAnchorIndexes == null ) { this . unknownFormatAnchorIndexes = new int [ this . type . getChildren ( ) . length ] ; this . unknownFormatAnchorIndexesCount = <NUM_LIT:0> ; this . unknownFormatLastAnchorFoundIndex = this . childrenStart ; } this . tempAnchorIndexes = this . unknownFormatAnchorIndexes ; this . tempAnchorIndexesCount = this . unknownFormatAnchorIndexesCount ; this . tempLastAnchorFoundIndex = this . unknownFormatLastAnchorFoundIndex ; range = computeChildRange ( anchor , this . indexOfFieldsBottom ) ; this . unknownFormatLastAnchorFoundIndex = this . tempLastAnchorFoundIndex ; this . unknownFormatAnchorIndexesCount = this . tempAnchorIndexesCount ; this . unknownFormatAnchorIndexes = this . tempAnchorIndexes ; } else { if ( this . methodAnchorIndexes == null ) { this . methodAnchorIndexes = new int [ this . type . getFields ( ) . length ] ; this . methodAnchorIndexesCount = <NUM_LIT:0> ; this . methodLastAnchorFoundIndex = this . indexOfAllMethodsTop ; } this . tempAnchorIndexes = this . methodAnchorIndexes ; this . tempAnchorIndexesCount = this . methodAnchorIndexesCount ; this . tempLastAnchorFoundIndex = this . methodLastAnchorFoundIndex ; range = computeChildRange ( anchor , this . indexOfAllMethodsBottom ) ; this . methodLastAnchorFoundIndex = this . tempLastAnchorFoundIndex ; this . methodAnchorIndexesCount = this . tempAnchorIndexesCount ; this . methodAnchorIndexes = this . tempAnchorIndexes ; } return range ; } private String computeMethodAnchorPrefixEnd ( BinaryMethod method ) throws JavaModelException { String typeQualifiedName = null ; if ( this . type . isMember ( ) ) { IType currentType = this . type ; StringBuffer buffer = new StringBuffer ( ) ; while ( currentType != null ) { buffer . insert ( <NUM_LIT:0> , currentType . getElementName ( ) ) ; currentType = currentType . getDeclaringType ( ) ; if ( currentType != null ) { buffer . insert ( <NUM_LIT:0> , '<CHAR_LIT:.>' ) ; } } typeQualifiedName = new String ( buffer . toString ( ) ) ; } else { typeQualifiedName = this . type . getElementName ( ) ; } String methodName = method . getElementName ( ) ; if ( method . isConstructor ( ) ) { methodName = typeQualifiedName ; } IBinaryMethod info = ( IBinaryMethod ) method . getElementInfo ( ) ; char [ ] genericSignature = info . getGenericSignature ( ) ; String anchor = null ; if ( genericSignature != null ) { genericSignature = CharOperation . replaceOnCopy ( genericSignature , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; anchor = Util . toAnchor ( <NUM_LIT:0> , genericSignature , methodName , Flags . isVarargs ( method . getFlags ( ) ) ) ; if ( anchor == null ) throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . UNKNOWN_JAVADOC_FORMAT , method ) ) ; } else { anchor = Signature . toString ( method . getSignature ( ) . replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) , methodName , null , true , false , Flags . isVarargs ( method . getFlags ( ) ) ) ; } IType declaringType = this . type ; if ( declaringType . isMember ( ) ) { if ( method . isConstructor ( ) && ! Flags . isStatic ( declaringType . getFlags ( ) ) ) { int indexOfOpeningParen = anchor . indexOf ( '<CHAR_LIT:(>' ) ; if ( indexOfOpeningParen == - <NUM_LIT:1> ) { return null ; } int index = indexOfOpeningParen ; indexOfOpeningParen ++ ; int indexOfComma = anchor . indexOf ( '<CHAR_LIT:U+002C>' , index ) ; if ( indexOfComma != - <NUM_LIT:1> ) { index = indexOfComma + <NUM_LIT:2> ; } else { index = anchor . indexOf ( '<CHAR_LIT:)>' , index ) ; } anchor = anchor . substring ( <NUM_LIT:0> , indexOfOpeningParen ) + anchor . substring ( index ) ; } } return anchor + JavadocConstants . ANCHOR_PREFIX_END ; } private void computeTypeRange ( ) throws JavaModelException { final int indexOfStartOfClassData = CharOperation . indexOf ( JavadocConstants . START_OF_CLASS_DATA , this . content , false ) ; if ( indexOfStartOfClassData == - <NUM_LIT:1> ) { this . typeDocRange = UNKNOWN_FORMAT ; return ; } int indexOfNextSeparator = CharOperation . indexOf ( JavadocConstants . SEPARATOR_START , this . content , false , indexOfStartOfClassData ) ; if ( indexOfNextSeparator == - <NUM_LIT:1> ) { this . typeDocRange = UNKNOWN_FORMAT ; return ; } int indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . NESTED_CLASS_SUMMARY , this . content , false , indexOfNextSeparator ) ; if ( indexOfNextSummary == - <NUM_LIT:1> && this . type . isEnum ( ) ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . ENUM_CONSTANT_SUMMARY , this . content , false , indexOfNextSeparator ) ; } if ( indexOfNextSummary == - <NUM_LIT:1> && this . type . isAnnotation ( ) ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY , this . content , false , indexOfNextSeparator ) ; if ( indexOfNextSummary == - <NUM_LIT:1> ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY , this . content , false , indexOfNextSeparator ) ; } } if ( indexOfNextSummary == - <NUM_LIT:1> ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . FIELD_SUMMARY , this . content , false , indexOfNextSeparator ) ; } if ( indexOfNextSummary == - <NUM_LIT:1> ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . CONSTRUCTOR_SUMMARY , this . content , false , indexOfNextSeparator ) ; } if ( indexOfNextSummary == - <NUM_LIT:1> ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . METHOD_SUMMARY , this . content , false , indexOfNextSeparator ) ; } if ( indexOfNextSummary == - <NUM_LIT:1> ) { indexOfNextSummary = CharOperation . indexOf ( JavadocConstants . END_OF_CLASS_DATA , this . content , false , indexOfNextSeparator ) ; } else { this . childrenStart = indexOfNextSummary + <NUM_LIT:1> ; } if ( indexOfNextSummary == - <NUM_LIT:1> ) { this . typeDocRange = UNKNOWN_FORMAT ; return ; } int start = indexOfStartOfClassData + JavadocConstants . START_OF_CLASS_DATA_LENGTH ; int indexOfFirstParagraph = CharOperation . indexOf ( "<STR_LIT>" . toCharArray ( ) , this . content , false , start ) ; if ( indexOfFirstParagraph != - <NUM_LIT:1> && indexOfFirstParagraph < indexOfNextSummary ) { start = indexOfFirstParagraph ; } this . typeDocRange = new int [ ] { start , indexOfNextSummary } ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . BindingKey ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IField ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . IPackageFragment ; 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 . WorkingCopyOwner ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . codeassist . ISelectionRequestor ; import org . eclipse . jdt . internal . codeassist . SelectionEngine ; public abstract class NamedMember extends Member { protected String name ; public NamedMember ( JavaElement parent , String name ) { super ( parent ) ; this . name = name ; } private void appendTypeParameters ( StringBuffer buffer ) throws JavaModelException { ITypeParameter [ ] typeParameters = getTypeParameters ( ) ; int length = typeParameters . length ; if ( length == <NUM_LIT:0> ) return ; buffer . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ITypeParameter typeParameter = typeParameters [ i ] ; buffer . append ( typeParameter . getElementName ( ) ) ; String [ ] bounds = typeParameter . getBounds ( ) ; int boundsLength = bounds . length ; if ( boundsLength > <NUM_LIT:0> ) { buffer . append ( "<STR_LIT>" ) ; for ( int j = <NUM_LIT:0> ; j < boundsLength ; j ++ ) { buffer . append ( bounds [ j ] ) ; if ( j < boundsLength - <NUM_LIT:1> ) buffer . append ( "<STR_LIT>" ) ; } } if ( i < length - <NUM_LIT:1> ) buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } buffer . append ( '<CHAR_LIT:>>' ) ; } public String getElementName ( ) { return this . name ; } protected String getKey ( IField field , boolean forceOpen ) throws JavaModelException { StringBuffer key = new StringBuffer ( ) ; String declaringKey = getKey ( ( IType ) field . getParent ( ) , forceOpen ) ; key . append ( declaringKey ) ; key . append ( '<CHAR_LIT:.>' ) ; key . append ( field . getElementName ( ) ) ; return key . toString ( ) ; } protected String getKey ( IMethod method , boolean forceOpen ) throws JavaModelException { StringBuffer key = new StringBuffer ( ) ; String declaringKey = getKey ( ( IType ) method . getParent ( ) , forceOpen ) ; key . append ( declaringKey ) ; key . append ( '<CHAR_LIT:.>' ) ; String selector = method . getElementName ( ) ; key . append ( selector ) ; if ( forceOpen ) { ITypeParameter [ ] typeParameters = method . getTypeParameters ( ) ; int length = typeParameters . length ; if ( length > <NUM_LIT:0> ) { key . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ITypeParameter typeParameter = typeParameters [ i ] ; String [ ] bounds = typeParameter . getBounds ( ) ; int boundsLength = bounds . length ; char [ ] [ ] boundSignatures = new char [ boundsLength ] [ ] ; for ( int j = <NUM_LIT:0> ; j < boundsLength ; j ++ ) { boundSignatures [ j ] = Signature . createCharArrayTypeSignature ( bounds [ j ] . toCharArray ( ) , method . isBinary ( ) ) ; CharOperation . replace ( boundSignatures [ j ] , '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) ; } char [ ] sig = Signature . createTypeParameterSignature ( typeParameter . getElementName ( ) . toCharArray ( ) , boundSignatures ) ; key . append ( sig ) ; } key . append ( '<CHAR_LIT:>>' ) ; } } key . append ( '<CHAR_LIT:(>' ) ; String [ ] parameters = method . getParameterTypes ( ) ; for ( int i = <NUM_LIT:0> , length = parameters . length ; i < length ; i ++ ) key . append ( parameters [ i ] . replace ( '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) ) ; key . append ( '<CHAR_LIT:)>' ) ; if ( forceOpen ) key . append ( method . getReturnType ( ) . replace ( '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) ) ; else key . append ( '<CHAR_LIT>' ) ; return key . toString ( ) ; } protected String getKey ( IType type , boolean forceOpen ) throws JavaModelException { StringBuffer key = new StringBuffer ( ) ; key . append ( '<CHAR_LIT>' ) ; String packageName = type . getPackageFragment ( ) . getElementName ( ) ; key . append ( packageName . replace ( '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) ) ; if ( packageName . length ( ) > <NUM_LIT:0> ) key . append ( '<CHAR_LIT:/>' ) ; String typeQualifiedName = type . getTypeQualifiedName ( '<CHAR_LIT>' ) ; ICompilationUnit cu = ( ICompilationUnit ) type . getAncestor ( IJavaElement . COMPILATION_UNIT ) ; if ( cu != null ) { String cuName = cu . getElementName ( ) ; String mainTypeName = cuName . substring ( <NUM_LIT:0> , cuName . lastIndexOf ( '<CHAR_LIT:.>' ) ) ; int end = typeQualifiedName . indexOf ( '<CHAR_LIT>' ) ; if ( end == - <NUM_LIT:1> ) end = typeQualifiedName . length ( ) ; String topLevelTypeName = typeQualifiedName . substring ( <NUM_LIT:0> , end ) ; if ( ! mainTypeName . equals ( topLevelTypeName ) ) { key . append ( mainTypeName ) ; key . append ( '<CHAR_LIT>' ) ; } } key . append ( typeQualifiedName ) ; key . append ( '<CHAR_LIT:;>' ) ; return key . toString ( ) ; } protected String getFullyQualifiedParameterizedName ( String fullyQualifiedName , String uniqueKey ) throws JavaModelException { String [ ] typeArguments = new BindingKey ( uniqueKey ) . getTypeArguments ( ) ; int length = typeArguments . length ; if ( length == <NUM_LIT:0> ) return fullyQualifiedName ; StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( fullyQualifiedName ) ; buffer . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { String typeArgument = typeArguments [ i ] ; buffer . append ( Signature . toString ( typeArgument ) ) ; if ( i < length - <NUM_LIT:1> ) buffer . append ( '<CHAR_LIT:U+002C>' ) ; } buffer . append ( '<CHAR_LIT:>>' ) ; return buffer . toString ( ) ; } protected IPackageFragment getPackageFragment ( ) { return null ; } public String getFullyQualifiedName ( char enclosingTypeSeparator , boolean showParameters ) throws JavaModelException { String packageName = getPackageFragment ( ) . getElementName ( ) ; if ( packageName . equals ( IPackageFragment . DEFAULT_PACKAGE_NAME ) ) { return getTypeQualifiedName ( enclosingTypeSeparator , showParameters ) ; } return packageName + '<CHAR_LIT:.>' + getTypeQualifiedName ( enclosingTypeSeparator , showParameters ) ; } public String getTypeQualifiedName ( char enclosingTypeSeparator , boolean showParameters ) throws JavaModelException { NamedMember declaringType ; switch ( this . parent . getElementType ( ) ) { case IJavaElement . COMPILATION_UNIT : if ( showParameters ) { StringBuffer buffer = new StringBuffer ( this . name ) ; appendTypeParameters ( buffer ) ; return buffer . toString ( ) ; } return this . name ; case IJavaElement . CLASS_FILE : String classFileName = this . parent . getElementName ( ) ; String typeName ; if ( classFileName . indexOf ( '<CHAR_LIT>' ) == - <NUM_LIT:1> ) { typeName = this . name ; } else { typeName = classFileName . substring ( <NUM_LIT:0> , classFileName . lastIndexOf ( '<CHAR_LIT:.>' ) ) . replace ( '<CHAR_LIT>' , enclosingTypeSeparator ) ; } if ( showParameters ) { StringBuffer buffer = new StringBuffer ( typeName ) ; appendTypeParameters ( buffer ) ; return buffer . toString ( ) ; } return typeName ; case IJavaElement . TYPE : declaringType = ( NamedMember ) this . parent ; break ; case IJavaElement . FIELD : case IJavaElement . INITIALIZER : case IJavaElement . METHOD : declaringType = ( NamedMember ) ( ( IMember ) this . parent ) . getDeclaringType ( ) ; break ; default : return null ; } StringBuffer buffer = new StringBuffer ( declaringType . getTypeQualifiedName ( enclosingTypeSeparator , showParameters ) ) ; buffer . append ( enclosingTypeSeparator ) ; String simpleName = this . name . length ( ) == <NUM_LIT:0> ? getOccurrenceCountSignature ( ) : this . name ; buffer . append ( simpleName ) ; if ( showParameters ) { appendTypeParameters ( buffer ) ; } return buffer . toString ( ) ; } protected String getOccurrenceCountSignature ( ) { return Integer . toString ( this . occurrenceCount ) ; } protected ITypeParameter [ ] getTypeParameters ( ) throws JavaModelException { return null ; } public String [ ] [ ] resolveType ( String typeName ) throws JavaModelException { return resolveType ( typeName , DefaultWorkingCopyOwner . PRIMARY ) ; } public String [ ] [ ] resolveType ( String typeName , WorkingCopyOwner owner ) throws JavaModelException { JavaProject project = ( JavaProject ) getJavaProject ( ) ; SearchableEnvironment environment = project . newSearchableNameEnvironment ( owner ) ; class TypeResolveRequestor implements ISelectionRequestor { String [ ] [ ] answers = null ; public void acceptType ( char [ ] packageName , char [ ] tName , int modifiers , boolean isDeclaration , char [ ] uniqueKey , int start , int end ) { String [ ] answer = new String [ ] { new String ( packageName ) , new String ( tName ) } ; if ( this . answers == null ) { this . answers = new String [ ] [ ] { answer } ; } else { int length = this . answers . length ; System . arraycopy ( this . answers , <NUM_LIT:0> , this . answers = new String [ length + <NUM_LIT:1> ] [ ] , <NUM_LIT:0> , length ) ; this . answers [ length ] = answer ; } } public void acceptError ( CategorizedProblem error ) { } public void acceptField ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] fieldName , boolean isDeclaration , char [ ] uniqueKey , int start , int end ) { } public void acceptMethod ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , String enclosingDeclaringTypeSignature , char [ ] selector , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , String [ ] parameterSignatures , char [ ] [ ] typeParameterNames , char [ ] [ ] [ ] typeParameterBoundNames , boolean isConstructor , boolean isDeclaration , char [ ] uniqueKey , int start , int end ) { } public void acceptPackage ( char [ ] packageName ) { } public void acceptTypeParameter ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] typeParameterName , boolean isDeclaration , int start , int end ) { } public void acceptMethodTypeParameter ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] selector , int selectorStart , int selcetorEnd , char [ ] typeParameterName , boolean isDeclaration , int start , int end ) { } } TypeResolveRequestor requestor = new TypeResolveRequestor ( ) ; SelectionEngine engine = new SelectionEngine ( environment , requestor , project . getOptions ( true ) , owner ) ; engine . selectType ( typeName . toCharArray ( ) , ( IType ) this ) ; if ( NameLookup . VERBOSE ) { System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInSourcePackage + "<STR_LIT>" ) ; System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInBinaryPackage + "<STR_LIT>" ) ; } return requestor . answers ; } } </s>
|
<s> package org . eclipse . jdt . internal . compiler ; import java . util . HashMap ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Annotation ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; public interface ISourceElementRequestor { public static class TypeInfo { public int declarationStart ; public int modifiers ; public char [ ] name ; public int nameSourceStart ; public int nameSourceEnd ; public char [ ] superclass ; public char [ ] [ ] superinterfaces ; public TypeParameterInfo [ ] typeParameters ; public char [ ] [ ] categories ; public boolean secondary ; public boolean anonymousMember ; public Annotation [ ] annotations ; public int extraFlags ; public TypeDeclaration node ; public HashMap childrenCategories = new HashMap ( ) ; } public static class TypeParameterInfo { public int declarationStart ; public int declarationEnd ; public char [ ] name ; public int nameSourceStart ; public int nameSourceEnd ; public char [ ] [ ] bounds ; } public static class MethodInfo { public boolean isConstructor ; public boolean isAnnotation ; public int declarationStart ; public int modifiers ; public char [ ] returnType ; public char [ ] name ; public int nameSourceStart ; public int nameSourceEnd ; public char [ ] [ ] parameterTypes ; public char [ ] [ ] parameterNames ; public char [ ] [ ] exceptionTypes ; public TypeParameterInfo [ ] typeParameters ; public char [ ] [ ] categories ; public Annotation [ ] annotations ; public char [ ] declaringPackageName ; public int declaringTypeModifiers ; public int extraFlags ; public AbstractMethodDeclaration node ; public ParameterInfo [ ] parameterInfos ; } public static class ParameterInfo { public int modifiers ; public int declarationStart ; public int declarationEnd ; public int nameSourceStart ; public int nameSourceEnd ; public char [ ] name ; } public static class FieldInfo { public int declarationStart ; public int modifiers ; public char [ ] type ; public char [ ] name ; public int nameSourceStart ; public int nameSourceEnd ; public char [ ] [ ] categories ; public Annotation [ ] annotations ; public FieldDeclaration node ; } void acceptAnnotationTypeReference ( char [ ] [ ] annotation , int sourceStart , int sourceEnd ) ; void acceptAnnotationTypeReference ( char [ ] annotation , int sourcePosition ) ; void acceptConstructorReference ( char [ ] typeName , int argCount , int sourcePosition ) ; void acceptFieldReference ( char [ ] fieldName , int sourcePosition ) ; void acceptImport ( int declarationStart , int declarationEnd , int nameStart , int nameEnd , char [ ] [ ] tokens , boolean onDemand , int modifiers ) ; void acceptLineSeparatorPositions ( int [ ] positions ) ; void acceptMethodReference ( char [ ] methodName , int argCount , int sourcePosition ) ; void acceptPackage ( ImportReference importReference ) ; void acceptProblem ( CategorizedProblem problem ) ; void acceptTypeReference ( char [ ] [ ] typeName , int sourceStart , int sourceEnd ) ; void acceptTypeReference ( char [ ] typeName , int sourcePosition ) ; void acceptUnknownReference ( char [ ] [ ] name , int sourceStart , int sourceEnd ) ; void acceptUnknownReference ( char [ ] name , int sourcePosition ) ; void enterCompilationUnit ( ) ; void enterConstructor ( MethodInfo methodInfo ) ; void enterField ( FieldInfo fieldInfo ) ; void enterInitializer ( int declarationStart , int modifiers ) ; void enterMethod ( MethodInfo methodInfo ) ; void enterType ( TypeInfo typeInfo ) ; void exitCompilationUnit ( int declarationEnd ) ; void exitConstructor ( int declarationEnd ) ; void exitField ( int initializationStart , int declarationEnd , int declarationSourceEnd ) ; void exitInitializer ( int declarationEnd ) ; void exitMethod ( int declarationEnd , Expression defaultValue ) ; void exitType ( int declarationEnd ) ; } </s>
|
<s> package org . eclipse . jdt . internal . compiler ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; public interface IDocumentElementRequestor { void acceptImport ( int declarationStart , int declarationEnd , int [ ] javaDocPositions , char [ ] name , int nameStartPosition , boolean onDemand , int modifiers ) ; void acceptInitializer ( int declarationStart , int declarationEnd , int [ ] javaDocPositions , int modifiers , int modifiersStart , int bodyStart , int bodyEnd ) ; void acceptLineSeparatorPositions ( int [ ] positions ) ; void acceptPackage ( int declarationStart , int declarationEnd , int [ ] javaDocPositions , char [ ] name , int nameStartPosition ) ; void acceptProblem ( CategorizedProblem problem ) ; void enterClass ( int declarationStart , int [ ] javaDocPositions , int modifiers , int modifiersStart , int classStart , char [ ] name , int nameStart , int nameEnd , char [ ] superclass , int superclassStart , int superclassEnd , char [ ] [ ] superinterfaces , int [ ] superinterfaceStarts , int [ ] superinterfaceEnds , int bodyStart ) ; void enterCompilationUnit ( ) ; void enterConstructor ( int declarationStart , int [ ] javaDocPositions , int modifiers , int modifiersStart , char [ ] name , int nameStart , int nameEnd , char [ ] [ ] parameterTypes , int [ ] parameterTypeStarts , int [ ] parameterTypeEnds , char [ ] [ ] parameterNames , int [ ] parameterNameStarts , int [ ] parameterNameEnds , int parametersEnd , char [ ] [ ] exceptionTypes , int [ ] exceptionTypeStarts , int [ ] exceptionTypeEnds , int bodyStart ) ; void enterField ( int declarationStart , int [ ] javaDocPositions , int modifiers , int modifiersStart , char [ ] type , int typeStart , int typeEnd , int typeDimensionCount , char [ ] name , int nameStart , int nameEnd , int extendedTypeDimensionCount , int extendedTypeDimensionEnd ) ; void enterInterface ( int declarationStart , int [ ] javaDocPositions , int modifiers , int modifiersStart , int interfaceStart , char [ ] name , int nameStart , int nameEnd , char [ ] [ ] superinterfaces , int [ ] superinterfaceStarts , int [ ] superinterfaceEnds , int bodyStart ) ; void enterMethod ( int declarationStart , int [ ] javaDocPositions , int modifiers , int modifiersStart , char [ ] returnType , int returnTypeStart , int returnTypeEnd , int returnTypeDimensionCount , char [ ] name , int nameStart , int nameEnd , char [ ] [ ] parameterTypes , int [ ] parameterTypeStarts , int [ ] parameterTypeEnds , char [ ] [ ] parameterNames , int [ ] parameterNameStarts , int [ ] parameterNameEnds , int parametersEnd , int extendedReturnTypeDimensionCount , int extendedReturnTypeDimensionEnd , char [ ] [ ] exceptionTypes , int [ ] exceptionTypeStarts , int [ ] exceptionTypeEnds , int bodyStart ) ; void exitClass ( int bodyEnd , int declarationEnd ) ; void exitCompilationUnit ( int declarationEnd ) ; void exitConstructor ( int bodyEnd , int declarationEnd ) ; void exitField ( int bodyEnd , int declarationEnd ) ; void exitInterface ( int bodyEnd , int declarationEnd ) ; void exitMethod ( int bodyEnd , int declarationEnd ) ; } </s>
|
<s> package org . eclipse . jdt . internal . compiler ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . parser . JavadocParser ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; public class SourceJavadocParser extends JavadocParser { int categoriesPtr = - <NUM_LIT:1> ; char [ ] [ ] categories = CharOperation . NO_CHAR_CHAR ; public SourceJavadocParser ( Parser sourceParser ) { super ( sourceParser ) ; this . kind = SOURCE_PARSER | TEXT_VERIF ; } public boolean checkDeprecation ( int commentPtr ) { this . categoriesPtr = - <NUM_LIT:1> ; boolean result = super . checkDeprecation ( commentPtr ) ; if ( this . categoriesPtr > - <NUM_LIT:1> ) { System . arraycopy ( this . categories , <NUM_LIT:0> , this . categories = new char [ this . categoriesPtr + <NUM_LIT:1> ] [ ] , <NUM_LIT:0> , this . categoriesPtr + <NUM_LIT:1> ) ; } else { this . categories = CharOperation . NO_CHAR_CHAR ; } return result ; } protected boolean parseIdentifierTag ( boolean report ) { int end = this . lineEnd + <NUM_LIT:1> ; if ( super . parseIdentifierTag ( report ) && this . index <= end ) { if ( this . tagValue == TAG_CATEGORY_VALUE ) { int length = this . categories . length ; if ( ++ this . categoriesPtr >= length ) { System . arraycopy ( this . categories , <NUM_LIT:0> , this . categories = new char [ length + <NUM_LIT:5> ] [ ] , <NUM_LIT:0> , length ) ; length += <NUM_LIT:5> ; } this . categories [ this . categoriesPtr ] = this . identifierStack [ this . identifierPtr -- ] ; consumeToken ( ) ; while ( this . index < end ) { if ( readTokenSafely ( ) == TerminalTokens . TokenNameIdentifier && ( this . scanner . currentCharacter == '<CHAR_LIT:U+0020>' || ScannerHelper . isWhitespace ( this . scanner . currentCharacter ) ) ) { if ( this . index > ( this . lineEnd + <NUM_LIT:1> ) ) break ; if ( ++ this . categoriesPtr >= length ) { System . arraycopy ( this . categories , <NUM_LIT:0> , this . categories = new char [ length + <NUM_LIT:5> ] [ ] , <NUM_LIT:0> , length ) ; length += <NUM_LIT:5> ; } this . categories [ this . categoriesPtr ] = this . scanner . getCurrentIdentifierSource ( ) ; consumeToken ( ) ; } else { break ; } } this . index = end ; this . scanner . currentPosition = end ; consumeToken ( ) ; } return true ; } return false ; } protected void parseSimpleTag ( ) { char first = this . source [ this . index ++ ] ; if ( first == '<STR_LIT:\\>' && this . source [ this . index ] == '<CHAR_LIT>' ) { int c1 , c2 , c3 , c4 ; int pos = this . index ; this . index ++ ; while ( this . source [ this . index ] == '<CHAR_LIT>' ) this . index ++ ; if ( ! ( ( ( c1 = ScannerHelper . getHexadecimalValue ( this . source [ this . index ++ ] ) ) > <NUM_LIT:15> || c1 < <NUM_LIT:0> ) || ( ( c2 = ScannerHelper . getHexadecimalValue ( this . source [ this . index ++ ] ) ) > <NUM_LIT:15> || c2 < <NUM_LIT:0> ) || ( ( c3 = ScannerHelper . getHexadecimalValue ( this . source [ this . index ++ ] ) ) > <NUM_LIT:15> || c3 < <NUM_LIT:0> ) || ( ( c4 = ScannerHelper . getHexadecimalValue ( this . source [ this . index ++ ] ) ) > <NUM_LIT:15> || c4 < <NUM_LIT:0> ) ) ) { first = ( char ) ( ( ( c1 * <NUM_LIT:16> + c2 ) * <NUM_LIT:16> + c3 ) * <NUM_LIT:16> + c4 ) ; } else { this . index = pos ; } } switch ( first ) { case '<CHAR_LIT>' : if ( ( readChar ( ) == '<CHAR_LIT:e>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT:e>' ) && ( readChar ( ) == '<CHAR_LIT:c>' ) && ( readChar ( ) == '<CHAR_LIT:a>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT:e>' ) && ( readChar ( ) == '<CHAR_LIT>' ) ) { char c = readChar ( ) ; if ( ScannerHelper . isWhitespace ( c ) || c == '<CHAR_LIT>' ) { this . tagValue = TAG_DEPRECATED_VALUE ; this . deprecated = true ; } } break ; case '<CHAR_LIT:c>' : if ( ( readChar ( ) == '<CHAR_LIT:a>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT:e>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT>' ) && ( readChar ( ) == '<CHAR_LIT>' ) ) { char c = readChar ( ) ; if ( ScannerHelper . isWhitespace ( c ) || c == '<CHAR_LIT>' ) { this . tagValue = TAG_CATEGORY_VALUE ; if ( this . scanner . source == null ) { this . scanner . setSource ( this . source ) ; } this . scanner . resetTo ( this . index , this . scanner . eofPosition ) ; parseIdentifierTag ( false ) ; } } break ; } } } </s>
|
<s> package org . eclipse . jdt . internal . compiler ; import java . util . HashMap ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . env . * ; import org . eclipse . jdt . internal . compiler . impl . * ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; import org . eclipse . jdt . internal . compiler . problem . * ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObjectToInt ; import org . eclipse . jdt . internal . core . util . CommentRecorderParser ; import org . eclipse . jdt . internal . core . util . Messages ; public class SourceElementParser extends CommentRecorderParser { ISourceElementRequestor requestor ; boolean reportReferenceInfo ; boolean reportLocalDeclarations ; HashtableOfObjectToInt sourceEnds = new HashtableOfObjectToInt ( ) ; HashMap nodesToCategories = new HashMap ( ) ; boolean useSourceJavadocParser = true ; SourceElementNotifier notifier ; public SourceElementParser ( final ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals ) { this ( requestor , problemFactory , options , reportLocalDeclarations , optimizeStringLiterals , true ) ; } public SourceElementParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) { super ( new ProblemReporter ( DefaultErrorHandlingPolicies . exitAfterAllProblems ( ) , options , problemFactory ) , optimizeStringLiterals ) ; this . reportLocalDeclarations = reportLocalDeclarations ; this . problemReporter = new ProblemReporter ( DefaultErrorHandlingPolicies . exitAfterAllProblems ( ) , options , problemFactory ) { public void record ( CategorizedProblem problem , CompilationResult unitResult , ReferenceContext context , boolean mandatoryError ) { unitResult . record ( problem , context , mandatoryError ) ; SourceElementParser . this . requestor . acceptProblem ( problem ) ; } } ; this . requestor = requestor ; this . options = options ; this . notifier = new SourceElementNotifier ( this . requestor , reportLocalDeclarations ) ; this . useSourceJavadocParser = useSourceJavadocParser ; if ( useSourceJavadocParser ) { this . javadocParser = new SourceJavadocParser ( this ) ; } } private void acceptJavadocTypeReference ( Expression expression ) { if ( expression instanceof JavadocSingleTypeReference ) { JavadocSingleTypeReference singleRef = ( JavadocSingleTypeReference ) expression ; this . requestor . acceptTypeReference ( singleRef . token , singleRef . sourceStart ) ; } else if ( expression instanceof JavadocQualifiedTypeReference ) { JavadocQualifiedTypeReference qualifiedRef = ( JavadocQualifiedTypeReference ) expression ; this . requestor . acceptTypeReference ( qualifiedRef . tokens , qualifiedRef . sourceStart , qualifiedRef . sourceEnd ) ; } } public void addUnknownRef ( NameReference nameRef ) { if ( nameRef instanceof SingleNameReference ) { this . requestor . acceptUnknownReference ( ( ( SingleNameReference ) nameRef ) . token , nameRef . sourceStart ) ; } else { this . requestor . acceptUnknownReference ( ( ( QualifiedNameReference ) nameRef ) . tokens , nameRef . sourceStart , nameRef . sourceEnd ) ; } } public void checkComment ( ) { if ( ! ( this . diet && this . dietInt == <NUM_LIT:0> ) && this . scanner . commentPtr >= <NUM_LIT:0> ) { flushCommentsDefinedPriorTo ( this . endStatementPosition ) ; } int lastComment = this . scanner . commentPtr ; if ( this . modifiersSourceStart >= <NUM_LIT:0> ) { while ( lastComment >= <NUM_LIT:0> ) { int commentSourceStart = this . scanner . commentStarts [ lastComment ] ; if ( commentSourceStart < <NUM_LIT:0> ) commentSourceStart = - commentSourceStart ; if ( commentSourceStart <= this . modifiersSourceStart ) break ; lastComment -- ; } } if ( lastComment >= <NUM_LIT:0> ) { this . modifiersSourceStart = this . scanner . commentStarts [ <NUM_LIT:0> ] ; if ( this . modifiersSourceStart < <NUM_LIT:0> ) this . modifiersSourceStart = - this . modifiersSourceStart ; while ( lastComment >= <NUM_LIT:0> && this . scanner . commentStops [ lastComment ] < <NUM_LIT:0> ) lastComment -- ; if ( lastComment >= <NUM_LIT:0> && this . javadocParser != null ) { int commentEnd = this . scanner . commentStops [ lastComment ] - <NUM_LIT:1> ; if ( this . javadocParser . shouldReportProblems ) { this . javadocParser . reportProblems = this . currentElement == null || commentEnd > this . lastJavadocEnd ; } else { this . javadocParser . reportProblems = false ; } if ( this . javadocParser . checkDeprecation ( lastComment ) ) { checkAndSetModifiers ( ClassFileConstants . AccDeprecated ) ; } this . javadoc = this . javadocParser . docComment ; if ( this . currentElement == null ) this . lastJavadocEnd = commentEnd ; } } if ( this . reportReferenceInfo && this . javadocParser . checkDocComment && this . javadoc != null ) { TypeReference [ ] thrownExceptions = this . javadoc . exceptionReferences ; if ( thrownExceptions != null ) { for ( int i = <NUM_LIT:0> , max = thrownExceptions . length ; i < max ; i ++ ) { TypeReference typeRef = thrownExceptions [ i ] ; if ( typeRef instanceof JavadocSingleTypeReference ) { JavadocSingleTypeReference singleRef = ( JavadocSingleTypeReference ) typeRef ; this . requestor . acceptTypeReference ( singleRef . token , singleRef . sourceStart ) ; } else if ( typeRef instanceof JavadocQualifiedTypeReference ) { JavadocQualifiedTypeReference qualifiedRef = ( JavadocQualifiedTypeReference ) typeRef ; this . requestor . acceptTypeReference ( qualifiedRef . tokens , qualifiedRef . sourceStart , qualifiedRef . sourceEnd ) ; } } } Expression [ ] references = this . javadoc . seeReferences ; if ( references != null ) { for ( int i = <NUM_LIT:0> , max = references . length ; i < max ; i ++ ) { Expression reference = references [ i ] ; acceptJavadocTypeReference ( reference ) ; if ( reference instanceof JavadocFieldReference ) { JavadocFieldReference fieldRef = ( JavadocFieldReference ) reference ; this . requestor . acceptFieldReference ( fieldRef . token , fieldRef . sourceStart ) ; if ( fieldRef . receiver != null && ! fieldRef . receiver . isThis ( ) ) { acceptJavadocTypeReference ( fieldRef . receiver ) ; } } else if ( reference instanceof JavadocMessageSend ) { JavadocMessageSend messageSend = ( JavadocMessageSend ) reference ; int argCount = messageSend . arguments == null ? <NUM_LIT:0> : messageSend . arguments . length ; this . requestor . acceptMethodReference ( messageSend . selector , argCount , messageSend . sourceStart ) ; this . requestor . acceptConstructorReference ( messageSend . selector , argCount , messageSend . sourceStart ) ; if ( messageSend . receiver != null && ! messageSend . receiver . isThis ( ) ) { acceptJavadocTypeReference ( messageSend . receiver ) ; } } else if ( reference instanceof JavadocAllocationExpression ) { JavadocAllocationExpression constructor = ( JavadocAllocationExpression ) reference ; int argCount = constructor . arguments == null ? <NUM_LIT:0> : constructor . arguments . length ; if ( constructor . type != null ) { char [ ] [ ] compoundName = constructor . type . getParameterizedTypeName ( ) ; this . requestor . acceptConstructorReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] , argCount , constructor . sourceStart ) ; if ( ! constructor . type . isThis ( ) ) { acceptJavadocTypeReference ( constructor . type ) ; } } } } } } } protected void classInstanceCreation ( boolean alwaysQualified ) { boolean previousFlag = this . reportReferenceInfo ; this . reportReferenceInfo = false ; super . classInstanceCreation ( alwaysQualified ) ; this . reportReferenceInfo = previousFlag ; if ( this . reportReferenceInfo ) { AllocationExpression alloc = ( AllocationExpression ) this . expressionStack [ this . expressionPtr ] ; TypeReference typeRef = alloc . type ; this . requestor . acceptConstructorReference ( typeRef instanceof SingleTypeReference ? ( ( SingleTypeReference ) typeRef ) . token : CharOperation . concatWith ( alloc . type . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) , alloc . arguments == null ? <NUM_LIT:0> : alloc . arguments . length , alloc . sourceStart ) ; } } protected void consumeAnnotationAsModifier ( ) { super . consumeAnnotationAsModifier ( ) ; Annotation annotation = ( Annotation ) this . expressionStack [ this . expressionPtr ] ; if ( this . reportReferenceInfo ) { this . requestor . acceptAnnotationTypeReference ( annotation . type . getTypeName ( ) , annotation . sourceStart , annotation . sourceEnd ) ; } } protected void consumeClassInstanceCreationExpressionQualifiedWithTypeArguments ( ) { boolean previousFlag = this . reportReferenceInfo ; this . reportReferenceInfo = false ; super . consumeClassInstanceCreationExpressionQualifiedWithTypeArguments ( ) ; this . reportReferenceInfo = previousFlag ; if ( this . reportReferenceInfo ) { AllocationExpression alloc = ( AllocationExpression ) this . expressionStack [ this . expressionPtr ] ; TypeReference typeRef = alloc . type ; this . requestor . acceptConstructorReference ( typeRef instanceof SingleTypeReference ? ( ( SingleTypeReference ) typeRef ) . token : CharOperation . concatWith ( alloc . type . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) , alloc . arguments == null ? <NUM_LIT:0> : alloc . arguments . length , alloc . sourceStart ) ; } } protected void consumeAnnotationTypeDeclarationHeaderName ( ) { int currentAstPtr = this . astPtr ; super . consumeAnnotationTypeDeclarationHeaderName ( ) ; if ( this . astPtr > currentAstPtr ) rememberCategories ( ) ; } protected void consumeAnnotationTypeDeclarationHeaderNameWithTypeParameters ( ) { int currentAstPtr = this . astPtr ; super . consumeAnnotationTypeDeclarationHeaderNameWithTypeParameters ( ) ; if ( this . astPtr > currentAstPtr ) rememberCategories ( ) ; } protected void consumeCatchFormalParameter ( ) { super . consumeCatchFormalParameter ( ) ; flushCommentsDefinedPriorTo ( this . scanner . currentPosition ) ; } protected void consumeClassHeaderName1 ( ) { int currentAstPtr = this . astPtr ; super . consumeClassHeaderName1 ( ) ; if ( this . astPtr > currentAstPtr ) rememberCategories ( ) ; } protected void consumeClassInstanceCreationExpressionWithTypeArguments ( ) { boolean previousFlag = this . reportReferenceInfo ; this . reportReferenceInfo = false ; super . consumeClassInstanceCreationExpressionWithTypeArguments ( ) ; this . reportReferenceInfo = previousFlag ; if ( this . reportReferenceInfo ) { AllocationExpression alloc = ( AllocationExpression ) this . expressionStack [ this . expressionPtr ] ; TypeReference typeRef = alloc . type ; this . requestor . acceptConstructorReference ( typeRef instanceof SingleTypeReference ? ( ( SingleTypeReference ) typeRef ) . token : CharOperation . concatWith ( alloc . type . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) , alloc . arguments == null ? <NUM_LIT:0> : alloc . arguments . length , alloc . sourceStart ) ; } } protected void consumeConstructorHeaderName ( ) { long selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr ] ; int selectorSourceEnd = ( int ) selectorSourcePositions ; int currentAstPtr = this . astPtr ; super . consumeConstructorHeaderName ( ) ; if ( this . astPtr > currentAstPtr ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , selectorSourceEnd ) ; rememberCategories ( ) ; } } protected void consumeConstructorHeaderNameWithTypeParameters ( ) { long selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr ] ; int selectorSourceEnd = ( int ) selectorSourcePositions ; int currentAstPtr = this . astPtr ; super . consumeConstructorHeaderNameWithTypeParameters ( ) ; if ( this . astPtr > currentAstPtr ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , selectorSourceEnd ) ; rememberCategories ( ) ; } } protected void consumeEnumConstantWithClassBody ( ) { super . consumeEnumConstantWithClassBody ( ) ; if ( ( this . currentToken == TokenNameCOMMA || this . currentToken == TokenNameSEMICOLON ) && this . astStack [ this . astPtr ] instanceof FieldDeclaration ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , this . scanner . currentPosition - <NUM_LIT:1> ) ; rememberCategories ( ) ; } } protected void consumeEnumConstantNoClassBody ( ) { super . consumeEnumConstantNoClassBody ( ) ; if ( ( this . currentToken == TokenNameCOMMA || this . currentToken == TokenNameSEMICOLON ) && this . astStack [ this . astPtr ] instanceof FieldDeclaration ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , this . scanner . currentPosition - <NUM_LIT:1> ) ; rememberCategories ( ) ; } } protected void consumeEnumHeaderName ( ) { int currentAstPtr = this . astPtr ; super . consumeEnumHeaderName ( ) ; if ( this . astPtr > currentAstPtr ) rememberCategories ( ) ; } protected void consumeEnumHeaderNameWithTypeParameters ( ) { int currentAstPtr = this . astPtr ; super . consumeEnumHeaderNameWithTypeParameters ( ) ; if ( this . astPtr > currentAstPtr ) rememberCategories ( ) ; } protected void consumeExitVariableWithInitialization ( ) { super . consumeExitVariableWithInitialization ( ) ; if ( ( this . currentToken == TokenNameCOMMA || this . currentToken == TokenNameSEMICOLON ) && this . astStack [ this . astPtr ] instanceof FieldDeclaration ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , this . scanner . currentPosition - <NUM_LIT:1> ) ; rememberCategories ( ) ; } } protected void consumeExitVariableWithoutInitialization ( ) { super . consumeExitVariableWithoutInitialization ( ) ; if ( ( this . currentToken == TokenNameCOMMA || this . currentToken == TokenNameSEMICOLON ) && this . astStack [ this . astPtr ] instanceof FieldDeclaration ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , this . scanner . currentPosition - <NUM_LIT:1> ) ; rememberCategories ( ) ; } } protected void consumeFieldAccess ( boolean isSuperAccess ) { super . consumeFieldAccess ( isSuperAccess ) ; FieldReference fr = ( FieldReference ) this . expressionStack [ this . expressionPtr ] ; if ( this . reportReferenceInfo ) { this . requestor . acceptFieldReference ( fr . token , fr . sourceStart ) ; } } protected void consumeFormalParameter ( boolean isVarArgs ) { super . consumeFormalParameter ( isVarArgs ) ; flushCommentsDefinedPriorTo ( this . scanner . currentPosition ) ; } protected void consumeInterfaceHeaderName1 ( ) { int currentAstPtr = this . astPtr ; super . consumeInterfaceHeaderName1 ( ) ; if ( this . astPtr > currentAstPtr ) rememberCategories ( ) ; } protected void consumeMemberValuePair ( ) { super . consumeMemberValuePair ( ) ; MemberValuePair memberValuepair = ( MemberValuePair ) this . astStack [ this . astPtr ] ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( memberValuepair . name , <NUM_LIT:0> , memberValuepair . sourceStart ) ; } } protected void consumeMarkerAnnotation ( ) { super . consumeMarkerAnnotation ( ) ; Annotation annotation = ( Annotation ) this . expressionStack [ this . expressionPtr ] ; if ( this . reportReferenceInfo ) { this . requestor . acceptAnnotationTypeReference ( annotation . type . getTypeName ( ) , annotation . sourceStart , annotation . sourceEnd ) ; } } protected void consumeMethodHeaderName ( boolean isAnnotationMethod ) { long selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr ] ; int selectorSourceEnd = ( int ) selectorSourcePositions ; int currentAstPtr = this . astPtr ; super . consumeMethodHeaderName ( isAnnotationMethod ) ; if ( this . astPtr > currentAstPtr ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , selectorSourceEnd ) ; rememberCategories ( ) ; } } protected void consumeMethodHeaderNameWithTypeParameters ( boolean isAnnotationMethod ) { long selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr ] ; int selectorSourceEnd = ( int ) selectorSourcePositions ; int currentAstPtr = this . astPtr ; super . consumeMethodHeaderNameWithTypeParameters ( isAnnotationMethod ) ; if ( this . astPtr > currentAstPtr ) this . sourceEnds . put ( this . astStack [ this . astPtr ] , selectorSourceEnd ) ; rememberCategories ( ) ; } protected void consumeMethodInvocationName ( ) { super . consumeMethodInvocationName ( ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; Expression [ ] args = messageSend . arguments ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( messageSend . selector , args == null ? <NUM_LIT:0> : args . length , ( int ) ( messageSend . nameSourcePosition > > > <NUM_LIT:32> ) ) ; } } protected void consumeMethodInvocationNameWithTypeArguments ( ) { super . consumeMethodInvocationNameWithTypeArguments ( ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; Expression [ ] args = messageSend . arguments ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( messageSend . selector , args == null ? <NUM_LIT:0> : args . length , ( int ) ( messageSend . nameSourcePosition > > > <NUM_LIT:32> ) ) ; } } protected void consumeMethodInvocationPrimary ( ) { super . consumeMethodInvocationPrimary ( ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; Expression [ ] args = messageSend . arguments ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( messageSend . selector , args == null ? <NUM_LIT:0> : args . length , ( int ) ( messageSend . nameSourcePosition > > > <NUM_LIT:32> ) ) ; } } protected void consumeMethodInvocationPrimaryWithTypeArguments ( ) { super . consumeMethodInvocationPrimaryWithTypeArguments ( ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; Expression [ ] args = messageSend . arguments ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( messageSend . selector , args == null ? <NUM_LIT:0> : args . length , ( int ) ( messageSend . nameSourcePosition > > > <NUM_LIT:32> ) ) ; } } protected void consumeMethodInvocationSuper ( ) { super . consumeMethodInvocationSuper ( ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; Expression [ ] args = messageSend . arguments ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( messageSend . selector , args == null ? <NUM_LIT:0> : args . length , ( int ) ( messageSend . nameSourcePosition > > > <NUM_LIT:32> ) ) ; } } protected void consumeMethodInvocationSuperWithTypeArguments ( ) { super . consumeMethodInvocationSuperWithTypeArguments ( ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; Expression [ ] args = messageSend . arguments ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( messageSend . selector , args == null ? <NUM_LIT:0> : args . length , ( int ) ( messageSend . nameSourcePosition > > > <NUM_LIT:32> ) ) ; } } protected void consumeNormalAnnotation ( ) { super . consumeNormalAnnotation ( ) ; Annotation annotation = ( Annotation ) this . expressionStack [ this . expressionPtr ] ; if ( this . reportReferenceInfo ) { this . requestor . acceptAnnotationTypeReference ( annotation . type . getTypeName ( ) , annotation . sourceStart , annotation . sourceEnd ) ; } } protected void consumeSingleMemberAnnotation ( ) { super . consumeSingleMemberAnnotation ( ) ; SingleMemberAnnotation member = ( SingleMemberAnnotation ) this . expressionStack [ this . expressionPtr ] ; if ( this . reportReferenceInfo ) { this . requestor . acceptMethodReference ( TypeConstants . VALUE , <NUM_LIT:0> , member . sourceStart ) ; } } protected void consumeSingleStaticImportDeclarationName ( ) { ImportReference impt ; int length ; char [ ] [ ] tokens = new char [ length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ] [ ] ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; pushOnAstStack ( impt = newImportReference ( tokens , positions , false , ClassFileConstants . AccStatic ) ) ; this . modifiers = ClassFileConstants . AccDefault ; this . modifiersSourceStart = - <NUM_LIT:1> ; if ( this . currentToken == TokenNameSEMICOLON ) { impt . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { impt . declarationSourceEnd = impt . sourceEnd ; } impt . declarationEnd = impt . declarationSourceEnd ; impt . declarationSourceStart = this . intStack [ this . intPtr -- ] ; if ( ! this . statementRecoveryActivated && this . options . sourceLevel < ClassFileConstants . JDK1_5 && this . lastErrorEndPositionBeforeRecovery < this . scanner . currentPosition ) { impt . modifiers = ClassFileConstants . AccDefault ; problemReporter ( ) . invalidUsageOfStaticImports ( impt ) ; } if ( this . currentElement != null ) { this . lastCheckPoint = impt . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( impt , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } if ( this . reportReferenceInfo ) { int tokensLength = impt . tokens . length - <NUM_LIT:1> ; int start = ( int ) ( impt . sourcePositions [ tokensLength ] > > > <NUM_LIT:32> ) ; char [ ] last = impt . tokens [ tokensLength ] ; this . requestor . acceptFieldReference ( last , start ) ; this . requestor . acceptMethodReference ( last , <NUM_LIT:0> , start ) ; this . requestor . acceptTypeReference ( last , start ) ; if ( tokensLength > <NUM_LIT:0> ) { char [ ] [ ] compoundName = new char [ tokensLength ] [ ] ; System . arraycopy ( impt . tokens , <NUM_LIT:0> , compoundName , <NUM_LIT:0> , tokensLength ) ; int end = ( int ) impt . sourcePositions [ tokensLength - <NUM_LIT:1> ] ; this . requestor . acceptTypeReference ( compoundName , impt . sourceStart , end ) ; } } } protected void consumeSingleTypeImportDeclarationName ( ) { ImportReference impt ; int length ; char [ ] [ ] tokens = new char [ length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ] [ ] ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; pushOnAstStack ( impt = newImportReference ( tokens , positions , false , ClassFileConstants . AccDefault ) ) ; if ( this . currentToken == TokenNameSEMICOLON ) { impt . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { impt . declarationSourceEnd = impt . sourceEnd ; } impt . declarationEnd = impt . declarationSourceEnd ; impt . declarationSourceStart = this . intStack [ this . intPtr -- ] ; if ( this . currentElement != null ) { this . lastCheckPoint = impt . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( impt , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( impt . tokens , impt . sourceStart , impt . sourceEnd ) ; } } protected void consumeStaticImportOnDemandDeclarationName ( ) { ImportReference impt ; int length ; char [ ] [ ] tokens = new char [ length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ] [ ] ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; pushOnAstStack ( impt = new ImportReference ( tokens , positions , true , ClassFileConstants . AccStatic ) ) ; impt . trailingStarPosition = this . intStack [ this . intPtr -- ] ; this . modifiers = ClassFileConstants . AccDefault ; this . modifiersSourceStart = - <NUM_LIT:1> ; if ( this . currentToken == TokenNameSEMICOLON ) { impt . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { impt . declarationSourceEnd = impt . sourceEnd ; } impt . declarationEnd = impt . declarationSourceEnd ; impt . declarationSourceStart = this . intStack [ this . intPtr -- ] ; if ( ! this . statementRecoveryActivated && this . options . sourceLevel < ClassFileConstants . JDK1_5 && this . lastErrorEndPositionBeforeRecovery < this . scanner . currentPosition ) { impt . modifiers = ClassFileConstants . AccDefault ; problemReporter ( ) . invalidUsageOfStaticImports ( impt ) ; } if ( this . currentElement != null ) { this . lastCheckPoint = impt . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( impt , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( impt . tokens , impt . sourceStart , impt . sourceEnd ) ; } } protected void consumeTypeImportOnDemandDeclarationName ( ) { ImportReference impt ; int length ; char [ ] [ ] tokens = new char [ length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ] [ ] ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; pushOnAstStack ( impt = new ImportReference ( tokens , positions , true , ClassFileConstants . AccDefault ) ) ; impt . trailingStarPosition = this . intStack [ this . intPtr -- ] ; if ( this . currentToken == TokenNameSEMICOLON ) { impt . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { impt . declarationSourceEnd = impt . sourceEnd ; } impt . declarationEnd = impt . declarationSourceEnd ; impt . declarationSourceStart = this . intStack [ this . intPtr -- ] ; if ( this . currentElement != null ) { this . lastCheckPoint = impt . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( impt , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } if ( this . reportReferenceInfo ) { this . requestor . acceptUnknownReference ( impt . tokens , impt . sourceStart , impt . sourceEnd ) ; } } public MethodDeclaration convertToMethodDeclaration ( ConstructorDeclaration c , CompilationResult compilationResult ) { MethodDeclaration methodDeclaration = super . convertToMethodDeclaration ( c , compilationResult ) ; int selectorSourceEnd = this . sourceEnds . removeKey ( c ) ; if ( selectorSourceEnd != - <NUM_LIT:1> ) this . sourceEnds . put ( methodDeclaration , selectorSourceEnd ) ; char [ ] [ ] categories = ( char [ ] [ ] ) this . nodesToCategories . remove ( c ) ; if ( categories != null ) this . nodesToCategories . put ( methodDeclaration , categories ) ; return methodDeclaration ; } protected CompilationUnitDeclaration endParse ( int act ) { if ( this . scanner . recordLineSeparator ) { this . requestor . acceptLineSeparatorPositions ( this . scanner . getLineEnds ( ) ) ; } if ( this . compilationUnit != null ) { CompilationUnitDeclaration result = super . endParse ( act ) ; return result ; } else { return null ; } } public TypeReference getTypeReference ( int dim ) { int length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ; if ( length < <NUM_LIT:0> ) { TypeReference ref = TypeReference . baseTypeReference ( - length , dim ) ; ref . sourceStart = this . intStack [ this . intPtr -- ] ; if ( dim == <NUM_LIT:0> ) { ref . sourceEnd = this . intStack [ this . intPtr -- ] ; } else { this . intPtr -- ; ref . sourceEnd = this . endPosition ; } if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( ref . getParameterizedTypeName ( ) , ref . sourceStart , ref . sourceEnd ) ; } return ref ; } else { int numberOfIdentifiers = this . genericsIdentifiersLengthStack [ this . genericsIdentifiersLengthPtr -- ] ; if ( length != numberOfIdentifiers || this . genericsLengthStack [ this . genericsLengthPtr ] != <NUM_LIT:0> ) { TypeReference ref = getTypeReferenceForGenericType ( dim , length , numberOfIdentifiers ) ; if ( this . reportReferenceInfo ) { if ( length == <NUM_LIT:1> && numberOfIdentifiers == <NUM_LIT:1> ) { ParameterizedSingleTypeReference parameterizedSingleTypeReference = ( ParameterizedSingleTypeReference ) ref ; this . requestor . acceptTypeReference ( parameterizedSingleTypeReference . token , parameterizedSingleTypeReference . sourceStart ) ; } else { ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference = ( ParameterizedQualifiedTypeReference ) ref ; this . requestor . acceptTypeReference ( parameterizedQualifiedTypeReference . tokens , parameterizedQualifiedTypeReference . sourceStart , parameterizedQualifiedTypeReference . sourceEnd ) ; } } return ref ; } else if ( length == <NUM_LIT:1> ) { this . genericsLengthPtr -- ; if ( dim == <NUM_LIT:0> ) { SingleTypeReference ref = new SingleTypeReference ( this . identifierStack [ this . identifierPtr ] , this . identifierPositionStack [ this . identifierPtr -- ] ) ; if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( ref . token , ref . sourceStart ) ; } return ref ; } else { ArrayTypeReference ref = new ArrayTypeReference ( this . identifierStack [ this . identifierPtr ] , dim , this . identifierPositionStack [ this . identifierPtr -- ] ) ; ref . sourceEnd = this . endPosition ; if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( ref . token , ref . sourceStart ) ; } return ref ; } } else { this . genericsLengthPtr -- ; char [ ] [ ] tokens = new char [ length ] [ ] ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; if ( dim == <NUM_LIT:0> ) { QualifiedTypeReference ref = new QualifiedTypeReference ( tokens , positions ) ; if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( ref . tokens , ref . sourceStart , ref . sourceEnd ) ; } return ref ; } else { ArrayQualifiedTypeReference ref = new ArrayQualifiedTypeReference ( tokens , dim , positions ) ; ref . sourceEnd = this . endPosition ; if ( this . reportReferenceInfo ) { this . requestor . acceptTypeReference ( ref . tokens , ref . sourceStart , ref . sourceEnd ) ; } return ref ; } } } } public NameReference getUnspecifiedReference ( ) { int length ; if ( ( length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ) == <NUM_LIT:1> ) { SingleNameReference ref = newSingleNameReference ( this . identifierStack [ this . identifierPtr ] , this . identifierPositionStack [ this . identifierPtr -- ] ) ; if ( this . reportReferenceInfo ) { addUnknownRef ( ref ) ; } return ref ; } else { char [ ] [ ] tokens = new char [ length ] [ ] ; this . identifierPtr -= length ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; QualifiedNameReference ref = newQualifiedNameReference ( tokens , positions , ( int ) ( this . identifierPositionStack [ this . identifierPtr + <NUM_LIT:1> ] > > <NUM_LIT:32> ) , ( int ) this . identifierPositionStack [ this . identifierPtr + length ] ) ; if ( this . reportReferenceInfo ) { addUnknownRef ( ref ) ; } return ref ; } } public NameReference getUnspecifiedReferenceOptimized ( ) { int length ; if ( ( length = this . identifierLengthStack [ this . identifierLengthPtr -- ] ) == <NUM_LIT:1> ) { SingleNameReference ref = newSingleNameReference ( this . identifierStack [ this . identifierPtr ] , this . identifierPositionStack [ this . identifierPtr -- ] ) ; ref . bits &= ~ ASTNode . RestrictiveFlagMASK ; ref . bits |= Binding . LOCAL | Binding . FIELD ; if ( this . reportReferenceInfo ) { addUnknownRef ( ref ) ; } return ref ; } char [ ] [ ] tokens = new char [ length ] [ ] ; this . identifierPtr -= length ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; QualifiedNameReference ref = newQualifiedNameReference ( tokens , positions , ( int ) ( this . identifierPositionStack [ this . identifierPtr + <NUM_LIT:1> ] > > <NUM_LIT:32> ) , ( int ) this . identifierPositionStack [ this . identifierPtr + length ] ) ; ref . bits &= ~ ASTNode . RestrictiveFlagMASK ; ref . bits |= Binding . LOCAL | Binding . FIELD ; if ( this . reportReferenceInfo ) { addUnknownRef ( ref ) ; } return ref ; } protected ImportReference newImportReference ( char [ ] [ ] tokens , long [ ] positions , boolean onDemand , int mod ) { return new ImportReference ( tokens , positions , onDemand , mod ) ; } protected QualifiedNameReference newQualifiedNameReference ( char [ ] [ ] tokens , long [ ] positions , int sourceStart , int sourceEnd ) { return new QualifiedNameReference ( tokens , positions , sourceStart , sourceEnd ) ; } protected SingleNameReference newSingleNameReference ( char [ ] source , long positions ) { return new SingleNameReference ( source , positions ) ; } public CompilationUnitDeclaration parseCompilationUnit ( ICompilationUnit unit , boolean fullParse , IProgressMonitor pm ) { boolean old = this . diet ; CompilationUnitDeclaration parsedUnit = null ; try { this . diet = true ; this . reportReferenceInfo = fullParse ; CompilationResult compilationUnitResult = new CompilationResult ( unit , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) ; parsedUnit = parse ( unit , compilationUnitResult ) ; if ( pm != null && pm . isCanceled ( ) ) throw new OperationCanceledException ( Messages . operation_cancelled ) ; if ( this . scanner . recordLineSeparator ) { this . requestor . acceptLineSeparatorPositions ( compilationUnitResult . getLineSeparatorPositions ( ) ) ; } int initialStart = this . scanner . initialPosition ; int initialEnd = this . scanner . eofPosition ; if ( this . reportLocalDeclarations || fullParse ) { this . diet = false ; getMethodBodies ( parsedUnit ) ; } this . scanner . resetTo ( initialStart , initialEnd ) ; this . notifier . notifySourceElementRequestor ( parsedUnit , this . scanner . initialPosition , this . scanner . eofPosition , this . reportReferenceInfo , this . sourceEnds , this . nodesToCategories ) ; return parsedUnit ; } catch ( AbortCompilation e ) { } finally { this . diet = old ; reset ( ) ; } return parsedUnit ; } private void rememberCategories ( ) { if ( this . useSourceJavadocParser ) { SourceJavadocParser sourceJavadocParser = ( SourceJavadocParser ) this . javadocParser ; char [ ] [ ] categories = sourceJavadocParser . categories ; if ( categories . length > <NUM_LIT:0> ) { this . nodesToCategories . put ( this . astStack [ this . astPtr ] , categories ) ; sourceJavadocParser . categories = CharOperation . NO_CHAR_CHAR ; } } } public void reset ( ) { this . sourceEnds = new HashtableOfObjectToInt ( ) ; this . nodesToCategories = new HashMap ( ) ; } public void setRequestor ( ISourceElementRequestor requestor ) { this . requestor = requestor ; this . notifier . requestor = requestor ; } } </s>
|
<s> package org . eclipse . jdt . internal . compiler ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; public class SourceElementRequestorAdapter implements ISourceElementRequestor { public void acceptAnnotationTypeReference ( char [ ] [ ] typeName , int sourceStart , int sourceEnd ) { } public void acceptAnnotationTypeReference ( char [ ] typeName , int sourcePosition ) { } public void acceptConstructorReference ( char [ ] typeName , int argCount , int sourcePosition ) { } public void acceptFieldReference ( char [ ] fieldName , int sourcePosition ) { } public void acceptImport ( int declarationStart , int declarationEnd , int nameStart , int nameEnd , char [ ] [ ] tokens , boolean onDemand , int modifiers ) { } public void acceptLineSeparatorPositions ( int [ ] positions ) { } public void acceptMethodReference ( char [ ] methodName , int argCount , int sourcePosition ) { } public void acceptPackage ( ImportReference importReference ) { } public void acceptProblem ( CategorizedProblem problem ) { } public void acceptTypeReference ( char [ ] [ ] typeName , int sourceStart , int sourceEnd ) { } public void acceptTypeReference ( char [ ] typeName , int sourcePosition ) { } public void acceptUnknownReference ( char [ ] [ ] name , int sourceStart , int sourceEnd ) { } public void acceptUnknownReference ( char [ ] name , int sourcePosition ) { } public void enterCompilationUnit ( ) { } public void enterConstructor ( MethodInfo methodInfo ) { } public void enterField ( FieldInfo fieldInfo ) { } public void enterInitializer ( int declarationStart , int modifiers ) { } public void enterMethod ( MethodInfo methodInfo ) { } public void enterType ( TypeInfo typeInfo ) { } public void exitCompilationUnit ( int declarationEnd ) { } public void exitConstructor ( int declarationEnd ) { } public void exitField ( int initializationStart , int declarationEnd , int declarationSourceEnd ) { } public void exitInitializer ( int declarationEnd ) { } public void exitMethod ( int declarationEnd , Expression defaultValue ) { } public void exitType ( int declarationEnd ) { } } </s>
|
<s> package org . eclipse . jdt . internal . compiler ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . env . * ; import org . eclipse . jdt . internal . compiler . impl . * ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . parser . * ; import org . eclipse . jdt . internal . compiler . problem . * ; public class DocumentElementParser extends Parser { IDocumentElementRequestor requestor ; private int localIntPtr ; private int lastFieldEndPosition ; private int lastFieldBodyEndPosition ; private int typeStartPosition ; private long selectorSourcePositions ; private int typeDims ; private int extendsDim ; private int declarationSourceStart ; int [ ] [ ] intArrayStack ; int intArrayPtr ; public DocumentElementParser ( final IDocumentElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options ) { super ( new ProblemReporter ( DefaultErrorHandlingPolicies . exitAfterAllProblems ( ) , options , problemFactory ) , false ) ; this . requestor = requestor ; this . intArrayStack = new int [ <NUM_LIT:30> ] [ ] ; this . options = options ; this . javadocParser . checkDocComment = false ; setMethodsFullRecovery ( false ) ; setStatementsRecovery ( false ) ; } public void checkComment ( ) { pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; boolean deprecated = false ; int lastCommentIndex = - <NUM_LIT:1> ; int commentPtr = this . scanner . commentPtr ; nextComment : for ( lastCommentIndex = this . scanner . commentPtr ; lastCommentIndex >= <NUM_LIT:0> ; lastCommentIndex -- ) { int commentSourceStart = this . scanner . commentStarts [ lastCommentIndex ] ; if ( commentSourceStart < <NUM_LIT:0> || this . scanner . commentStops [ lastCommentIndex ] < <NUM_LIT:0> || ( this . modifiersSourceStart != - <NUM_LIT:1> && this . modifiersSourceStart < commentSourceStart ) ) { continue nextComment ; } deprecated = this . javadocParser . checkDeprecation ( lastCommentIndex ) ; break nextComment ; } if ( deprecated ) { checkAndSetModifiers ( ClassFileConstants . AccDeprecated ) ; } if ( commentPtr >= <NUM_LIT:0> ) { this . declarationSourceStart = this . scanner . commentStarts [ <NUM_LIT:0> ] ; if ( this . declarationSourceStart < <NUM_LIT:0> ) this . declarationSourceStart = - this . declarationSourceStart ; } } protected void consumeCatchFormalParameter ( ) { this . identifierLengthPtr -- ; char [ ] parameterName = this . identifierStack [ this . identifierPtr ] ; long namePositions = this . identifierPositionStack [ this . identifierPtr -- ] ; this . intPtr -- ; TypeReference type = ( TypeReference ) this . astStack [ this . astPtr -- ] ; this . intPtr -= <NUM_LIT:3> ; Argument arg = new Argument ( parameterName , namePositions , type , this . intStack [ this . intPtr + <NUM_LIT:1> ] ) ; arg . bits &= ~ ASTNode . IsArgument ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , arg . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } pushOnAstStack ( arg ) ; this . intArrayPtr -- ; } protected void consumeClassBodyDeclaration ( ) { super . consumeClassBodyDeclaration ( ) ; Initializer initializer = ( Initializer ) this . astStack [ this . astPtr ] ; this . requestor . acceptInitializer ( initializer . declarationSourceStart , initializer . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , <NUM_LIT:0> , this . modifiersSourceStart , initializer . block . sourceStart , initializer . block . sourceEnd ) ; } protected void consumeClassDeclaration ( ) { super . consumeClassDeclaration ( ) ; if ( isLocalDeclaration ( ) ) { return ; } this . requestor . exitClass ( this . endStatementPosition , ( ( TypeDeclaration ) this . astStack [ this . astPtr ] ) . declarationSourceEnd ) ; } protected void consumeClassHeader ( ) { super . consumeClassHeader ( ) ; if ( isLocalDeclaration ( ) ) { this . intArrayPtr -- ; return ; } TypeDeclaration typeDecl = ( TypeDeclaration ) this . astStack [ this . astPtr ] ; TypeReference [ ] superInterfaces = typeDecl . superInterfaces ; char [ ] [ ] interfaceNames = null ; int [ ] interfaceNameStarts = null ; int [ ] interfaceNameEnds = null ; if ( superInterfaces != null ) { int superInterfacesLength = superInterfaces . length ; interfaceNames = new char [ superInterfacesLength ] [ ] ; interfaceNameStarts = new int [ superInterfacesLength ] ; interfaceNameEnds = new int [ superInterfacesLength ] ; for ( int i = <NUM_LIT:0> ; i < superInterfacesLength ; i ++ ) { TypeReference superInterface = superInterfaces [ i ] ; interfaceNames [ i ] = CharOperation . concatWith ( superInterface . getTypeName ( ) , '<CHAR_LIT:.>' ) ; interfaceNameStarts [ i ] = superInterface . sourceStart ; interfaceNameEnds [ i ] = superInterface . sourceEnd ; } } this . scanner . commentPtr = - <NUM_LIT:1> ; TypeReference superclass = typeDecl . superclass ; if ( superclass == null ) { this . requestor . enterClass ( typeDecl . declarationSourceStart , this . intArrayStack [ this . intArrayPtr -- ] , typeDecl . modifiers , typeDecl . modifiersSourceStart , this . typeStartPosition , typeDecl . name , typeDecl . sourceStart , typeDecl . sourceEnd , null , - <NUM_LIT:1> , - <NUM_LIT:1> , interfaceNames , interfaceNameStarts , interfaceNameEnds , this . scanner . currentPosition - <NUM_LIT:1> ) ; } else { this . requestor . enterClass ( typeDecl . declarationSourceStart , this . intArrayStack [ this . intArrayPtr -- ] , typeDecl . modifiers , typeDecl . modifiersSourceStart , this . typeStartPosition , typeDecl . name , typeDecl . sourceStart , typeDecl . sourceEnd , CharOperation . concatWith ( superclass . getTypeName ( ) , '<CHAR_LIT:.>' ) , superclass . sourceStart , superclass . sourceEnd , interfaceNames , interfaceNameStarts , interfaceNameEnds , this . scanner . currentPosition - <NUM_LIT:1> ) ; } } protected void consumeClassHeaderName1 ( ) { TypeDeclaration typeDecl = new TypeDeclaration ( this . compilationUnit . compilationResult ) ; if ( this . nestedMethod [ this . nestedType ] == <NUM_LIT:0> ) { if ( this . nestedType != <NUM_LIT:0> ) { typeDecl . bits |= ASTNode . IsMemberType ; } } else { typeDecl . bits |= ASTNode . IsLocalType ; markEnclosingMemberWithLocalType ( ) ; blockReal ( ) ; } long pos = this . identifierPositionStack [ this . identifierPtr ] ; typeDecl . sourceEnd = ( int ) pos ; typeDecl . sourceStart = ( int ) ( pos > > > <NUM_LIT:32> ) ; typeDecl . name = this . identifierStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; this . typeStartPosition = typeDecl . declarationSourceStart = this . intStack [ this . intPtr -- ] ; this . intPtr -- ; int declSourceStart = this . intStack [ this . intPtr -- ] ; typeDecl . modifiersSourceStart = this . intStack [ this . intPtr -- ] ; typeDecl . modifiers = this . intStack [ this . intPtr -- ] ; if ( typeDecl . declarationSourceStart > declSourceStart ) { typeDecl . declarationSourceStart = declSourceStart ; } int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , typeDecl . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } typeDecl . bodyStart = typeDecl . sourceEnd + <NUM_LIT:1> ; pushOnAstStack ( typeDecl ) ; typeDecl . javadoc = this . javadoc ; this . javadoc = null ; } protected void consumeCompilationUnit ( ) { this . requestor . exitCompilationUnit ( this . scanner . source . length - <NUM_LIT:1> ) ; } protected void consumeConstructorDeclaration ( ) { super . consumeConstructorDeclaration ( ) ; if ( isLocalDeclaration ( ) ) { return ; } ConstructorDeclaration cd = ( ConstructorDeclaration ) this . astStack [ this . astPtr ] ; this . requestor . exitConstructor ( this . endStatementPosition , cd . declarationSourceEnd ) ; } protected void consumeConstructorHeader ( ) { super . consumeConstructorHeader ( ) ; if ( isLocalDeclaration ( ) ) { this . intArrayPtr -- ; return ; } ConstructorDeclaration cd = ( ConstructorDeclaration ) this . astStack [ this . astPtr ] ; Argument [ ] arguments = cd . arguments ; char [ ] [ ] argumentTypes = null ; char [ ] [ ] argumentNames = null ; int [ ] argumentTypeStarts = null ; int [ ] argumentTypeEnds = null ; int [ ] argumentNameStarts = null ; int [ ] argumentNameEnds = null ; if ( arguments != null ) { int argumentLength = arguments . length ; argumentTypes = new char [ argumentLength ] [ ] ; argumentNames = new char [ argumentLength ] [ ] ; argumentNameStarts = new int [ argumentLength ] ; argumentNameEnds = new int [ argumentLength ] ; argumentTypeStarts = new int [ argumentLength ] ; argumentTypeEnds = new int [ argumentLength ] ; for ( int i = <NUM_LIT:0> ; i < argumentLength ; i ++ ) { Argument argument = arguments [ i ] ; TypeReference argumentType = argument . type ; argumentTypes [ i ] = returnTypeName ( argumentType ) ; argumentNames [ i ] = argument . name ; argumentNameStarts [ i ] = argument . sourceStart ; argumentNameEnds [ i ] = argument . sourceEnd ; argumentTypeStarts [ i ] = argumentType . sourceStart ; argumentTypeEnds [ i ] = argumentType . sourceEnd ; } } TypeReference [ ] thrownExceptions = cd . thrownExceptions ; char [ ] [ ] exceptionTypes = null ; int [ ] exceptionTypeStarts = null ; int [ ] exceptionTypeEnds = null ; if ( thrownExceptions != null ) { int thrownExceptionLength = thrownExceptions . length ; exceptionTypes = new char [ thrownExceptionLength ] [ ] ; exceptionTypeStarts = new int [ thrownExceptionLength ] ; exceptionTypeEnds = new int [ thrownExceptionLength ] ; for ( int i = <NUM_LIT:0> ; i < thrownExceptionLength ; i ++ ) { TypeReference exception = thrownExceptions [ i ] ; exceptionTypes [ i ] = CharOperation . concatWith ( exception . getTypeName ( ) , '<CHAR_LIT:.>' ) ; exceptionTypeStarts [ i ] = exception . sourceStart ; exceptionTypeEnds [ i ] = exception . sourceEnd ; } } this . requestor . enterConstructor ( cd . declarationSourceStart , this . intArrayStack [ this . intArrayPtr -- ] , cd . modifiers , cd . modifiersSourceStart , cd . selector , cd . sourceStart , ( int ) ( this . selectorSourcePositions & <NUM_LIT> ) , argumentTypes , argumentTypeStarts , argumentTypeEnds , argumentNames , argumentNameStarts , argumentNameEnds , this . rParenPos , exceptionTypes , exceptionTypeStarts , exceptionTypeEnds , this . scanner . currentPosition - <NUM_LIT:1> ) ; } protected void consumeConstructorHeaderName ( ) { ConstructorDeclaration cd = new ConstructorDeclaration ( this . compilationUnit . compilationResult ) ; cd . selector = this . identifierStack [ this . identifierPtr ] ; this . selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; cd . declarationSourceStart = this . intStack [ this . intPtr -- ] ; cd . modifiersSourceStart = this . intStack [ this . intPtr -- ] ; cd . modifiers = this . intStack [ this . intPtr -- ] ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , cd . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } cd . javadoc = this . javadoc ; this . javadoc = null ; cd . sourceStart = ( int ) ( this . selectorSourcePositions > > > <NUM_LIT:32> ) ; pushOnAstStack ( cd ) ; cd . sourceEnd = this . lParenPos ; cd . bodyStart = this . lParenPos + <NUM_LIT:1> ; } protected void consumeDefaultModifiers ( ) { checkComment ( ) ; pushOnIntStack ( this . modifiers ) ; pushOnIntStack ( - <NUM_LIT:1> ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . scanner . startPosition ) ; resetModifiers ( ) ; pushOnExpressionStackLengthStack ( <NUM_LIT:0> ) ; } protected void consumeDiet ( ) { super . consumeDiet ( ) ; pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; } protected void consumeEnterCompilationUnit ( ) { this . requestor . enterCompilationUnit ( ) ; } protected void consumeEnterVariable ( ) { boolean isLocalDeclaration = isLocalDeclaration ( ) ; if ( ! isLocalDeclaration && ( this . variablesCounter [ this . nestedType ] != <NUM_LIT:0> ) ) { this . requestor . exitField ( this . lastFieldBodyEndPosition , this . lastFieldEndPosition ) ; } char [ ] varName = this . identifierStack [ this . identifierPtr ] ; long namePosition = this . identifierPositionStack [ this . identifierPtr -- ] ; int extendedTypeDimension = this . intStack [ this . intPtr -- ] ; AbstractVariableDeclaration declaration ; if ( this . nestedMethod [ this . nestedType ] != <NUM_LIT:0> ) { declaration = new LocalDeclaration ( varName , ( int ) ( namePosition > > > <NUM_LIT:32> ) , ( int ) namePosition ) ; } else { declaration = new FieldDeclaration ( varName , ( int ) ( namePosition > > > <NUM_LIT:32> ) , ( int ) namePosition ) ; } this . identifierLengthPtr -- ; TypeReference type ; int variableIndex = this . variablesCounter [ this . nestedType ] ; int typeDim = <NUM_LIT:0> ; if ( variableIndex == <NUM_LIT:0> ) { if ( this . nestedMethod [ this . nestedType ] != <NUM_LIT:0> ) { declaration . declarationSourceStart = this . intStack [ this . intPtr -- ] ; declaration . modifiersSourceStart = this . intStack [ this . intPtr -- ] ; declaration . modifiers = this . intStack [ this . intPtr -- ] ; type = getTypeReference ( typeDim = this . intStack [ this . intPtr -- ] ) ; pushOnAstStack ( type ) ; } else { type = getTypeReference ( typeDim = this . intStack [ this . intPtr -- ] ) ; pushOnAstStack ( type ) ; declaration . declarationSourceStart = this . intStack [ this . intPtr -- ] ; declaration . modifiersSourceStart = this . intStack [ this . intPtr -- ] ; declaration . modifiers = this . intStack [ this . intPtr -- ] ; } int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , declaration . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } } else { type = ( TypeReference ) this . astStack [ this . astPtr - variableIndex ] ; typeDim = type . dimensions ( ) ; AbstractVariableDeclaration previousVariable = ( AbstractVariableDeclaration ) this . astStack [ this . astPtr ] ; declaration . declarationSourceStart = previousVariable . declarationSourceStart ; declaration . modifiers = previousVariable . modifiers ; declaration . modifiersSourceStart = previousVariable . modifiersSourceStart ; final Annotation [ ] annotations = previousVariable . annotations ; if ( annotations != null ) { final int annotationsLength = annotations . length ; System . arraycopy ( annotations , <NUM_LIT:0> , declaration . annotations = new Annotation [ annotationsLength ] , <NUM_LIT:0> , annotationsLength ) ; } } this . localIntPtr = this . intPtr ; if ( extendedTypeDimension == <NUM_LIT:0> ) { declaration . type = type ; } else { int dimension = typeDim + extendedTypeDimension ; declaration . type = copyDims ( type , dimension ) ; } this . variablesCounter [ this . nestedType ] ++ ; this . nestedMethod [ this . nestedType ] ++ ; pushOnAstStack ( declaration ) ; int [ ] javadocPositions = this . intArrayStack [ this . intArrayPtr ] ; if ( ! isLocalDeclaration ) { this . requestor . enterField ( declaration . declarationSourceStart , javadocPositions , declaration . modifiers , declaration . modifiersSourceStart , returnTypeName ( declaration . type ) , type . sourceStart , type . sourceEnd , this . typeDims , varName , ( int ) ( namePosition > > > <NUM_LIT:32> ) , ( int ) namePosition , extendedTypeDimension , extendedTypeDimension == <NUM_LIT:0> ? - <NUM_LIT:1> : this . endPosition ) ; } } protected void consumeExitVariableWithInitialization ( ) { super . consumeExitVariableWithInitialization ( ) ; this . nestedMethod [ this . nestedType ] -- ; this . lastFieldEndPosition = this . scanner . currentPosition - <NUM_LIT:1> ; this . lastFieldBodyEndPosition = ( ( AbstractVariableDeclaration ) this . astStack [ this . astPtr ] ) . initialization . sourceEnd ; } protected void consumeExitVariableWithoutInitialization ( ) { super . consumeExitVariableWithoutInitialization ( ) ; this . nestedMethod [ this . nestedType ] -- ; this . lastFieldEndPosition = this . scanner . currentPosition - <NUM_LIT:1> ; this . lastFieldBodyEndPosition = this . scanner . startPosition - <NUM_LIT:1> ; } protected void consumeFieldDeclaration ( ) { int variableIndex = this . variablesCounter [ this . nestedType ] ; super . consumeFieldDeclaration ( ) ; this . intArrayPtr -- ; if ( isLocalDeclaration ( ) ) return ; if ( variableIndex != <NUM_LIT:0> ) { this . requestor . exitField ( this . lastFieldBodyEndPosition , this . lastFieldEndPosition ) ; } } protected void consumeFormalParameter ( boolean isVarArgs ) { this . identifierLengthPtr -- ; char [ ] parameterName = this . identifierStack [ this . identifierPtr ] ; long namePositions = this . identifierPositionStack [ this . identifierPtr -- ] ; int extendedDimensions = this . intStack [ this . intPtr -- ] ; int endOfEllipsis = <NUM_LIT:0> ; if ( isVarArgs ) { endOfEllipsis = this . intStack [ this . intPtr -- ] ; } int firstDimensions = this . intStack [ this . intPtr -- ] ; final int typeDimensions = firstDimensions + extendedDimensions ; TypeReference type = getTypeReference ( typeDimensions ) ; if ( isVarArgs ) { type = copyDims ( type , typeDimensions + <NUM_LIT:1> ) ; if ( extendedDimensions == <NUM_LIT:0> ) { type . sourceEnd = endOfEllipsis ; } type . bits |= ASTNode . IsVarArgs ; } this . intPtr -= <NUM_LIT:3> ; Argument arg = new Argument ( parameterName , namePositions , type , this . intStack [ this . intPtr + <NUM_LIT:1> ] ) ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , arg . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; RecoveredType currentRecoveryType = this . currentRecoveryType ( ) ; if ( currentRecoveryType != null ) currentRecoveryType . annotationsConsumed ( arg . annotations ) ; } pushOnAstStack ( arg ) ; this . intArrayPtr -- ; } protected void consumeInterfaceDeclaration ( ) { super . consumeInterfaceDeclaration ( ) ; if ( isLocalDeclaration ( ) ) { return ; } this . requestor . exitInterface ( this . endStatementPosition , ( ( TypeDeclaration ) this . astStack [ this . astPtr ] ) . declarationSourceEnd ) ; } protected void consumeInterfaceHeader ( ) { super . consumeInterfaceHeader ( ) ; if ( isLocalDeclaration ( ) ) { this . intArrayPtr -- ; return ; } TypeDeclaration typeDecl = ( TypeDeclaration ) this . astStack [ this . astPtr ] ; TypeReference [ ] superInterfaces = typeDecl . superInterfaces ; char [ ] [ ] interfaceNames = null ; int [ ] interfaceNameStarts = null ; int [ ] interfacenameEnds = null ; int superInterfacesLength = <NUM_LIT:0> ; if ( superInterfaces != null ) { superInterfacesLength = superInterfaces . length ; interfaceNames = new char [ superInterfacesLength ] [ ] ; interfaceNameStarts = new int [ superInterfacesLength ] ; interfacenameEnds = new int [ superInterfacesLength ] ; } if ( superInterfaces != null ) { for ( int i = <NUM_LIT:0> ; i < superInterfacesLength ; i ++ ) { TypeReference superInterface = superInterfaces [ i ] ; interfaceNames [ i ] = CharOperation . concatWith ( superInterface . getTypeName ( ) , '<CHAR_LIT:.>' ) ; interfaceNameStarts [ i ] = superInterface . sourceStart ; interfacenameEnds [ i ] = superInterface . sourceEnd ; } } this . scanner . commentPtr = - <NUM_LIT:1> ; this . requestor . enterInterface ( typeDecl . declarationSourceStart , this . intArrayStack [ this . intArrayPtr -- ] , typeDecl . modifiers , typeDecl . modifiersSourceStart , this . typeStartPosition , typeDecl . name , typeDecl . sourceStart , typeDecl . sourceEnd , interfaceNames , interfaceNameStarts , interfacenameEnds , this . scanner . currentPosition - <NUM_LIT:1> ) ; } protected void consumeInterfaceHeaderName1 ( ) { TypeDeclaration typeDecl = new TypeDeclaration ( this . compilationUnit . compilationResult ) ; if ( this . nestedMethod [ this . nestedType ] == <NUM_LIT:0> ) { if ( this . nestedType != <NUM_LIT:0> ) { typeDecl . bits |= ASTNode . IsMemberType ; } } else { typeDecl . bits |= ASTNode . IsLocalType ; markEnclosingMemberWithLocalType ( ) ; blockReal ( ) ; } long pos = this . identifierPositionStack [ this . identifierPtr ] ; typeDecl . sourceEnd = ( int ) pos ; typeDecl . sourceStart = ( int ) ( pos > > > <NUM_LIT:32> ) ; typeDecl . name = this . identifierStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; this . typeStartPosition = typeDecl . declarationSourceStart = this . intStack [ this . intPtr -- ] ; this . intPtr -- ; int declSourceStart = this . intStack [ this . intPtr -- ] ; typeDecl . modifiersSourceStart = this . intStack [ this . intPtr -- ] ; typeDecl . modifiers = this . intStack [ this . intPtr -- ] | ClassFileConstants . AccInterface ; if ( typeDecl . declarationSourceStart > declSourceStart ) { typeDecl . declarationSourceStart = declSourceStart ; } int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , typeDecl . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } typeDecl . bodyStart = typeDecl . sourceEnd + <NUM_LIT:1> ; pushOnAstStack ( typeDecl ) ; typeDecl . javadoc = this . javadoc ; this . javadoc = null ; } protected void consumeInternalCompilationUnit ( ) { } protected void consumeInternalCompilationUnitWithTypes ( ) { int length ; if ( ( length = this . astLengthStack [ this . astLengthPtr -- ] ) != <NUM_LIT:0> ) { this . compilationUnit . types = new TypeDeclaration [ length ] ; this . astPtr -= length ; System . arraycopy ( this . astStack , this . astPtr + <NUM_LIT:1> , this . compilationUnit . types , <NUM_LIT:0> , length ) ; } } protected void consumeLocalVariableDeclaration ( ) { super . consumeLocalVariableDeclaration ( ) ; this . intArrayPtr -- ; } protected void consumeMethodDeclaration ( boolean isNotAbstract ) { super . consumeMethodDeclaration ( isNotAbstract ) ; if ( isLocalDeclaration ( ) ) { return ; } MethodDeclaration md = ( MethodDeclaration ) this . astStack [ this . astPtr ] ; this . requestor . exitMethod ( this . endStatementPosition , md . declarationSourceEnd ) ; } protected void consumeMethodHeader ( ) { super . consumeMethodHeader ( ) ; if ( isLocalDeclaration ( ) ) { this . intArrayPtr -- ; return ; } MethodDeclaration md = ( MethodDeclaration ) this . astStack [ this . astPtr ] ; TypeReference returnType = md . returnType ; char [ ] returnTypeName = returnTypeName ( returnType ) ; Argument [ ] arguments = md . arguments ; char [ ] [ ] argumentTypes = null ; char [ ] [ ] argumentNames = null ; int [ ] argumentTypeStarts = null ; int [ ] argumentTypeEnds = null ; int [ ] argumentNameStarts = null ; int [ ] argumentNameEnds = null ; if ( arguments != null ) { int argumentLength = arguments . length ; argumentTypes = new char [ argumentLength ] [ ] ; argumentNames = new char [ argumentLength ] [ ] ; argumentNameStarts = new int [ argumentLength ] ; argumentNameEnds = new int [ argumentLength ] ; argumentTypeStarts = new int [ argumentLength ] ; argumentTypeEnds = new int [ argumentLength ] ; for ( int i = <NUM_LIT:0> ; i < argumentLength ; i ++ ) { Argument argument = arguments [ i ] ; TypeReference argumentType = argument . type ; argumentTypes [ i ] = returnTypeName ( argumentType ) ; argumentNames [ i ] = argument . name ; argumentNameStarts [ i ] = argument . sourceStart ; argumentNameEnds [ i ] = argument . sourceEnd ; argumentTypeStarts [ i ] = argumentType . sourceStart ; argumentTypeEnds [ i ] = argumentType . sourceEnd ; } } TypeReference [ ] thrownExceptions = md . thrownExceptions ; char [ ] [ ] exceptionTypes = null ; int [ ] exceptionTypeStarts = null ; int [ ] exceptionTypeEnds = null ; if ( thrownExceptions != null ) { int thrownExceptionLength = thrownExceptions . length ; exceptionTypeStarts = new int [ thrownExceptionLength ] ; exceptionTypeEnds = new int [ thrownExceptionLength ] ; exceptionTypes = new char [ thrownExceptionLength ] [ ] ; for ( int i = <NUM_LIT:0> ; i < thrownExceptionLength ; i ++ ) { TypeReference exception = thrownExceptions [ i ] ; exceptionTypes [ i ] = CharOperation . concatWith ( exception . getTypeName ( ) , '<CHAR_LIT:.>' ) ; exceptionTypeStarts [ i ] = exception . sourceStart ; exceptionTypeEnds [ i ] = exception . sourceEnd ; } } this . requestor . enterMethod ( md . declarationSourceStart , this . intArrayStack [ this . intArrayPtr -- ] , md . modifiers , md . modifiersSourceStart , returnTypeName , returnType . sourceStart , returnType . sourceEnd , this . typeDims , md . selector , md . sourceStart , ( int ) ( this . selectorSourcePositions & <NUM_LIT> ) , argumentTypes , argumentTypeStarts , argumentTypeEnds , argumentNames , argumentNameStarts , argumentNameEnds , this . rParenPos , this . extendsDim , this . extendsDim == <NUM_LIT:0> ? - <NUM_LIT:1> : this . endPosition , exceptionTypes , exceptionTypeStarts , exceptionTypeEnds , this . scanner . currentPosition - <NUM_LIT:1> ) ; } protected void consumeMethodHeaderExtendedDims ( ) { MethodDeclaration md = ( MethodDeclaration ) this . astStack [ this . astPtr ] ; int extendedDims = this . intStack [ this . intPtr -- ] ; this . extendsDim = extendedDims ; if ( extendedDims != <NUM_LIT:0> ) { TypeReference returnType = md . returnType ; md . sourceEnd = this . endPosition ; int dims = returnType . dimensions ( ) + extendedDims ; md . returnType = copyDims ( returnType , dims ) ; if ( this . currentToken == TokenNameLBRACE ) { md . bodyStart = this . endPosition + <NUM_LIT:1> ; } } } protected void consumeMethodHeaderName ( boolean isAnnotationMethod ) { MethodDeclaration md = null ; if ( isAnnotationMethod ) { md = new AnnotationMethodDeclaration ( this . compilationUnit . compilationResult ) ; } else { md = new MethodDeclaration ( this . compilationUnit . compilationResult ) ; } md . selector = this . identifierStack [ this . identifierPtr ] ; this . selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; md . returnType = getTypeReference ( this . typeDims = this . intStack [ this . intPtr -- ] ) ; md . declarationSourceStart = this . intStack [ this . intPtr -- ] ; md . modifiersSourceStart = this . intStack [ this . intPtr -- ] ; md . modifiers = this . intStack [ this . intPtr -- ] ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , md . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } md . javadoc = this . javadoc ; this . javadoc = null ; md . sourceStart = ( int ) ( this . selectorSourcePositions > > > <NUM_LIT:32> ) ; pushOnAstStack ( md ) ; md . bodyStart = this . scanner . currentPosition - <NUM_LIT:1> ; } protected void consumeModifiers ( ) { checkComment ( ) ; pushOnIntStack ( this . modifiers ) ; pushOnIntStack ( this . modifiersSourceStart ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . modifiersSourceStart ) ; resetModifiers ( ) ; } protected void consumePackageComment ( ) { if ( this . options . sourceLevel >= ClassFileConstants . JDK1_5 ) { checkComment ( ) ; } else { pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; } resetModifiers ( ) ; } protected void consumePackageDeclarationName ( ) { super . consumePackageDeclarationName ( ) ; ImportReference importReference = this . compilationUnit . currentPackage ; this . requestor . acceptPackage ( importReference . declarationSourceStart , importReference . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) , importReference . sourceStart ) ; } protected void consumePackageDeclarationNameWithModifiers ( ) { super . consumePackageDeclarationNameWithModifiers ( ) ; ImportReference importReference = this . compilationUnit . currentPackage ; this . requestor . acceptPackage ( importReference . declarationSourceStart , importReference . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) , importReference . sourceStart ) ; } protected void consumePushModifiers ( ) { checkComment ( ) ; pushOnIntStack ( this . modifiers ) ; if ( this . modifiersSourceStart < <NUM_LIT:0> ) { pushOnIntStack ( - <NUM_LIT:1> ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . scanner . startPosition ) ; } else { pushOnIntStack ( this . modifiersSourceStart ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . modifiersSourceStart ) ; } resetModifiers ( ) ; pushOnExpressionStackLengthStack ( <NUM_LIT:0> ) ; } protected void consumePushRealModifiers ( ) { checkComment ( ) ; pushOnIntStack ( this . modifiers ) ; if ( this . modifiersSourceStart < <NUM_LIT:0> ) { pushOnIntStack ( - <NUM_LIT:1> ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . scanner . startPosition ) ; } else { pushOnIntStack ( this . modifiersSourceStart ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . modifiersSourceStart ) ; } resetModifiers ( ) ; } protected void consumeSingleStaticImportDeclarationName ( ) { pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; super . consumeSingleStaticImportDeclarationName ( ) ; ImportReference importReference = ( ImportReference ) this . astStack [ this . astPtr ] ; this . requestor . acceptImport ( importReference . declarationSourceStart , importReference . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) , importReference . sourceStart , false , ClassFileConstants . AccStatic ) ; } protected void consumeSingleTypeImportDeclarationName ( ) { pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; super . consumeSingleTypeImportDeclarationName ( ) ; ImportReference importReference = ( ImportReference ) this . astStack [ this . astPtr ] ; this . requestor . acceptImport ( importReference . declarationSourceStart , importReference . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) , importReference . sourceStart , false , ClassFileConstants . AccDefault ) ; } protected void consumeStaticImportOnDemandDeclarationName ( ) { pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; super . consumeStaticImportOnDemandDeclarationName ( ) ; ImportReference importReference = ( ImportReference ) this . astStack [ this . astPtr ] ; this . requestor . acceptImport ( importReference . declarationSourceStart , importReference . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) , importReference . sourceStart , true , ClassFileConstants . AccStatic ) ; } protected void consumeStaticInitializer ( ) { super . consumeStaticInitializer ( ) ; Initializer initializer = ( Initializer ) this . astStack [ this . astPtr ] ; this . requestor . acceptInitializer ( initializer . declarationSourceStart , initializer . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , ClassFileConstants . AccStatic , this . intStack [ this . intPtr -- ] , initializer . block . sourceStart , initializer . declarationSourceEnd ) ; } protected void consumeStaticOnly ( ) { checkComment ( ) ; pushOnIntStack ( this . modifiersSourceStart ) ; pushOnIntStack ( this . scanner . currentPosition ) ; pushOnIntStack ( this . declarationSourceStart >= <NUM_LIT:0> ? this . declarationSourceStart : this . modifiersSourceStart ) ; jumpOverMethodBody ( ) ; this . nestedMethod [ this . nestedType ] ++ ; resetModifiers ( ) ; } protected void consumeTypeImportOnDemandDeclarationName ( ) { pushOnIntArrayStack ( getJavaDocPositions ( ) ) ; super . consumeTypeImportOnDemandDeclarationName ( ) ; ImportReference importReference = ( ImportReference ) this . astStack [ this . astPtr ] ; this . requestor . acceptImport ( importReference . declarationSourceStart , importReference . declarationSourceEnd , this . intArrayStack [ this . intArrayPtr -- ] , CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) , importReference . sourceStart , true , ClassFileConstants . AccDefault ) ; } public int flushCommentsDefinedPriorTo ( int position ) { return this . lastFieldEndPosition = super . flushCommentsDefinedPriorTo ( position ) ; } public CompilationUnitDeclaration endParse ( int act ) { if ( this . scanner . recordLineSeparator ) { this . requestor . acceptLineSeparatorPositions ( this . scanner . getLineEnds ( ) ) ; } return super . endParse ( act ) ; } public void initialize ( boolean initializeNLS ) { super . initialize ( initializeNLS ) ; this . intArrayPtr = - <NUM_LIT:1> ; } public void initialize ( ) { super . initialize ( ) ; this . intArrayPtr = - <NUM_LIT:1> ; } private boolean isLocalDeclaration ( ) { int nestedDepth = this . nestedType ; while ( nestedDepth >= <NUM_LIT:0> ) { if ( this . nestedMethod [ nestedDepth ] != <NUM_LIT:0> ) { return true ; } nestedDepth -- ; } return false ; } protected void parse ( ) { this . diet = true ; super . parse ( ) ; } public void parseCompilationUnit ( ICompilationUnit unit ) { char [ ] regionSource = unit . getContents ( ) ; try { initialize ( true ) ; goForCompilationUnit ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( unit , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parseConstructor ( char [ ] regionSource ) { try { initialize ( ) ; goForClassBodyDeclarations ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parseField ( char [ ] regionSource ) { try { initialize ( ) ; goForFieldDeclaration ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parseImport ( char [ ] regionSource ) { try { initialize ( ) ; goForImportDeclaration ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parseInitializer ( char [ ] regionSource ) { try { initialize ( ) ; goForInitializer ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parseMethod ( char [ ] regionSource ) { try { initialize ( ) ; goForGenericMethodDeclaration ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parsePackage ( char [ ] regionSource ) { try { initialize ( ) ; goForPackageDeclaration ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public void parseType ( char [ ] regionSource ) { try { initialize ( ) ; goForTypeDeclaration ( ) ; this . referenceContext = this . compilationUnit = new CompilationUnitDeclaration ( problemReporter ( ) , new CompilationResult ( regionSource , <NUM_LIT:0> , <NUM_LIT:0> , this . options . maxProblemsPerUnit ) , regionSource . length ) ; this . scanner . resetTo ( <NUM_LIT:0> , regionSource . length ) ; this . scanner . setSource ( regionSource ) ; parse ( ) ; } catch ( AbortCompilation ex ) { } } public ProblemReporter problemReporter ( ) { this . problemReporter . referenceContext = this . referenceContext ; return this . problemReporter ; } protected void pushOnIntArrayStack ( int [ ] positions ) { int stackLength = this . intArrayStack . length ; if ( ++ this . intArrayPtr >= stackLength ) { System . arraycopy ( this . intArrayStack , <NUM_LIT:0> , this . intArrayStack = new int [ stackLength + StackIncrement ] [ ] , <NUM_LIT:0> , stackLength ) ; } this . intArrayStack [ this . intArrayPtr ] = positions ; } protected void resetModifiers ( ) { super . resetModifiers ( ) ; this . declarationSourceStart = - <NUM_LIT:1> ; } protected boolean resumeOnSyntaxError ( ) { return false ; } private char [ ] returnTypeName ( TypeReference type ) { int dimension = type . dimensions ( ) ; if ( dimension != <NUM_LIT:0> ) { char [ ] dimensionsArray = new char [ dimension * <NUM_LIT:2> ] ; for ( int i = <NUM_LIT:0> ; i < dimension ; i ++ ) { dimensionsArray [ i * <NUM_LIT:2> ] = '<CHAR_LIT:[>' ; dimensionsArray [ ( i * <NUM_LIT:2> ) + <NUM_LIT:1> ] = '<CHAR_LIT:]>' ; } return CharOperation . concat ( CharOperation . concatWith ( type . getTypeName ( ) , '<CHAR_LIT:.>' ) , dimensionsArray ) ; } return CharOperation . concatWith ( type . getTypeName ( ) , '<CHAR_LIT:.>' ) ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( "<STR_LIT>" + this . intArrayPtr + "<STR_LIT:n>" ) ; buffer . append ( super . toString ( ) ) ; return buffer . toString ( ) ; } protected TypeReference typeReference ( int dim , int localIdentifierPtr , int localIdentifierLengthPtr ) { int length ; TypeReference ref ; if ( ( length = this . identifierLengthStack [ localIdentifierLengthPtr ] ) == <NUM_LIT:1> ) { if ( dim == <NUM_LIT:0> ) { ref = new SingleTypeReference ( this . identifierStack [ localIdentifierPtr ] , this . identifierPositionStack [ localIdentifierPtr -- ] ) ; } else { ref = new ArrayTypeReference ( this . identifierStack [ localIdentifierPtr ] , dim , this . identifierPositionStack [ localIdentifierPtr -- ] ) ; ref . sourceEnd = this . endPosition ; } } else { if ( length < <NUM_LIT:0> ) { ref = TypeReference . baseTypeReference ( - length , dim ) ; ref . sourceStart = this . intStack [ this . localIntPtr -- ] ; if ( dim == <NUM_LIT:0> ) { ref . sourceEnd = this . intStack [ this . localIntPtr -- ] ; } else { this . localIntPtr -- ; ref . sourceEnd = this . endPosition ; } } else { char [ ] [ ] tokens = new char [ length ] [ ] ; localIdentifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierStack , localIdentifierPtr + <NUM_LIT:1> , tokens , <NUM_LIT:0> , length ) ; System . arraycopy ( this . identifierPositionStack , localIdentifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; if ( dim == <NUM_LIT:0> ) ref = new QualifiedTypeReference ( tokens , positions ) ; else ref = new ArrayQualifiedTypeReference ( tokens , dim , positions ) ; } } return ref ; } } </s>
|
<s> package org . eclipse . jdt . internal . compiler . parser ; import java . util . ArrayList ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . ArrayQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ArrayTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedSingleTypeReference ; import org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . SingleTypeReference ; import org . eclipse . jdt . internal . compiler . ast . TypeParameter ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . ast . Wildcard ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; public abstract class TypeConverter { int namePos ; protected ProblemReporter problemReporter ; protected boolean has1_5Compliance ; private char memberTypeSeparator ; protected TypeConverter ( ProblemReporter problemReporter , char memberTypeSeparator ) { this . problemReporter = problemReporter ; this . has1_5Compliance = problemReporter . options . originalComplianceLevel >= ClassFileConstants . JDK1_5 ; this . memberTypeSeparator = memberTypeSeparator ; } private void addIdentifiers ( String typeSignature , int start , int endExclusive , int identCount , ArrayList fragments ) { if ( identCount == <NUM_LIT:1> ) { char [ ] identifier ; typeSignature . getChars ( start , endExclusive , identifier = new char [ endExclusive - start ] , <NUM_LIT:0> ) ; fragments . add ( identifier ) ; } else fragments . add ( extractIdentifiers ( typeSignature , start , endExclusive - <NUM_LIT:1> , identCount ) ) ; } protected ImportReference createImportReference ( String [ ] importName , int start , int end , boolean onDemand , int modifiers ) { int length = importName . length ; long [ ] positions = new long [ length ] ; long position = ( ( long ) start << <NUM_LIT:32> ) + end ; char [ ] [ ] qImportName = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { qImportName [ i ] = importName [ i ] . toCharArray ( ) ; positions [ i ] = position ; } return new ImportReference ( qImportName , positions , onDemand , modifiers ) ; } protected TypeParameter createTypeParameter ( char [ ] typeParameterName , char [ ] [ ] typeParameterBounds , int start , int end ) { TypeParameter parameter = new TypeParameter ( ) ; parameter . name = typeParameterName ; parameter . sourceStart = start ; parameter . sourceEnd = end ; if ( typeParameterBounds != null ) { int length = typeParameterBounds . length ; if ( length > <NUM_LIT:0> ) { parameter . type = createTypeReference ( typeParameterBounds [ <NUM_LIT:0> ] , start , end ) ; if ( length > <NUM_LIT:1> ) { parameter . bounds = new TypeReference [ length - <NUM_LIT:1> ] ; for ( int i = <NUM_LIT:1> ; i < length ; i ++ ) { TypeReference bound = createTypeReference ( typeParameterBounds [ i ] , start , end ) ; bound . bits |= ASTNode . IsSuperType ; parameter . bounds [ i - <NUM_LIT:1> ] = bound ; } } } } return parameter ; } protected TypeReference createTypeReference ( char [ ] typeName , int start , int end , boolean includeGenericsAnyway ) { int length = typeName . length ; this . namePos = <NUM_LIT:0> ; return decodeType ( typeName , length , start , end , true ) ; } protected TypeReference createTypeReference ( char [ ] typeName , int start , int end ) { int length = typeName . length ; this . namePos = <NUM_LIT:0> ; return decodeType ( typeName , length , start , end , false ) ; } protected TypeReference createTypeReference ( String typeSignature , int start , int end ) { int length = typeSignature . length ( ) ; this . namePos = <NUM_LIT:0> ; return decodeType ( typeSignature , length , start , end ) ; } private TypeReference decodeType ( String typeSignature , int length , int start , int end ) { int identCount = <NUM_LIT:1> ; int dim = <NUM_LIT:0> ; int nameFragmentStart = this . namePos , nameFragmentEnd = - <NUM_LIT:1> ; boolean nameStarted = false ; ArrayList fragments = null ; typeLoop : while ( this . namePos < length ) { char currentChar = typeSignature . charAt ( this . namePos ) ; switch ( currentChar ) { case Signature . C_BOOLEAN : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . BOOLEAN . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . BOOLEAN . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_BYTE : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . BYTE . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . BYTE . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_CHAR : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . CHAR . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . CHAR . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_DOUBLE : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . DOUBLE . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . DOUBLE . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_FLOAT : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . FLOAT . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . FLOAT . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_INT : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . INT . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . INT . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_LONG : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . LONG . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . LONG . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_SHORT : if ( ! nameStarted ) { this . namePos ++ ; if ( dim == <NUM_LIT:0> ) return new SingleTypeReference ( TypeBinding . SHORT . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; else return new ArrayTypeReference ( TypeBinding . SHORT . simpleName , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_VOID : if ( ! nameStarted ) { this . namePos ++ ; return new SingleTypeReference ( TypeBinding . VOID . simpleName , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } break ; case Signature . C_RESOLVED : case Signature . C_UNRESOLVED : case Signature . C_TYPE_VARIABLE : if ( ! nameStarted ) { nameFragmentStart = this . namePos + <NUM_LIT:1> ; nameStarted = true ; } break ; case Signature . C_STAR : this . namePos ++ ; Wildcard result = new Wildcard ( Wildcard . UNBOUND ) ; result . sourceStart = start ; result . sourceEnd = end ; return result ; case Signature . C_EXTENDS : this . namePos ++ ; result = new Wildcard ( Wildcard . EXTENDS ) ; result . bound = decodeType ( typeSignature , length , start , end ) ; result . sourceStart = start ; result . sourceEnd = end ; return result ; case Signature . C_SUPER : this . namePos ++ ; result = new Wildcard ( Wildcard . SUPER ) ; result . bound = decodeType ( typeSignature , length , start , end ) ; result . sourceStart = start ; result . sourceEnd = end ; return result ; case Signature . C_ARRAY : dim ++ ; break ; case Signature . C_GENERIC_END : case Signature . C_SEMICOLON : nameFragmentEnd = this . namePos - <NUM_LIT:1> ; this . namePos ++ ; break typeLoop ; case Signature . C_DOLLAR : if ( this . memberTypeSeparator != Signature . C_DOLLAR ) break ; case Signature . C_DOT : if ( ! nameStarted ) { nameFragmentStart = this . namePos + <NUM_LIT:1> ; nameStarted = true ; } else if ( this . namePos > nameFragmentStart ) identCount ++ ; break ; case Signature . C_GENERIC_START : nameFragmentEnd = this . namePos - <NUM_LIT:1> ; if ( ! this . has1_5Compliance ) break typeLoop ; if ( fragments == null ) fragments = new ArrayList ( <NUM_LIT:2> ) ; addIdentifiers ( typeSignature , nameFragmentStart , nameFragmentEnd + <NUM_LIT:1> , identCount , fragments ) ; this . namePos ++ ; TypeReference [ ] arguments = decodeTypeArguments ( typeSignature , length , start , end ) ; fragments . add ( arguments ) ; identCount = <NUM_LIT:1> ; nameStarted = false ; break ; } this . namePos ++ ; } if ( fragments == null ) { if ( identCount == <NUM_LIT:1> ) { if ( dim == <NUM_LIT:0> ) { char [ ] nameFragment = new char [ nameFragmentEnd - nameFragmentStart + <NUM_LIT:1> ] ; typeSignature . getChars ( nameFragmentStart , nameFragmentEnd + <NUM_LIT:1> , nameFragment , <NUM_LIT:0> ) ; return new SingleTypeReference ( nameFragment , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } else { char [ ] nameFragment = new char [ nameFragmentEnd - nameFragmentStart + <NUM_LIT:1> ] ; typeSignature . getChars ( nameFragmentStart , nameFragmentEnd + <NUM_LIT:1> , nameFragment , <NUM_LIT:0> ) ; return new ArrayTypeReference ( nameFragment , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } } else { long [ ] positions = new long [ identCount ] ; long pos = ( ( long ) start << <NUM_LIT:32> ) + end ; for ( int i = <NUM_LIT:0> ; i < identCount ; i ++ ) { positions [ i ] = pos ; } char [ ] [ ] identifiers = extractIdentifiers ( typeSignature , nameFragmentStart , nameFragmentEnd , identCount ) ; if ( dim == <NUM_LIT:0> ) { return new QualifiedTypeReference ( identifiers , positions ) ; } else { return new ArrayQualifiedTypeReference ( identifiers , dim , positions ) ; } } } else { if ( nameStarted ) { addIdentifiers ( typeSignature , nameFragmentStart , nameFragmentEnd + <NUM_LIT:1> , identCount , fragments ) ; } int fragmentLength = fragments . size ( ) ; if ( fragmentLength == <NUM_LIT:2> ) { Object firstFragment = fragments . get ( <NUM_LIT:0> ) ; if ( firstFragment instanceof char [ ] ) { return new ParameterizedSingleTypeReference ( ( char [ ] ) firstFragment , ( TypeReference [ ] ) fragments . get ( <NUM_LIT:1> ) , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } } identCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < fragmentLength ; i ++ ) { Object element = fragments . get ( i ) ; if ( element instanceof char [ ] [ ] ) { identCount += ( ( char [ ] [ ] ) element ) . length ; } else if ( element instanceof char [ ] ) identCount ++ ; } char [ ] [ ] tokens = new char [ identCount ] [ ] ; TypeReference [ ] [ ] arguments = new TypeReference [ identCount ] [ ] ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < fragmentLength ; i ++ ) { Object element = fragments . get ( i ) ; if ( element instanceof char [ ] [ ] ) { char [ ] [ ] fragmentTokens = ( char [ ] [ ] ) element ; int fragmentTokenLength = fragmentTokens . length ; System . arraycopy ( fragmentTokens , <NUM_LIT:0> , tokens , index , fragmentTokenLength ) ; index += fragmentTokenLength ; } else if ( element instanceof char [ ] ) { tokens [ index ++ ] = ( char [ ] ) element ; } else { arguments [ index - <NUM_LIT:1> ] = ( TypeReference [ ] ) element ; } } long [ ] positions = new long [ identCount ] ; long pos = ( ( long ) start << <NUM_LIT:32> ) + end ; for ( int i = <NUM_LIT:0> ; i < identCount ; i ++ ) { positions [ i ] = pos ; } return new ParameterizedQualifiedTypeReference ( tokens , arguments , dim , positions ) ; } } private TypeReference decodeType ( char [ ] typeName , int length , int start , int end , boolean includeGenericsAnyway ) { int identCount = <NUM_LIT:1> ; int dim = <NUM_LIT:0> ; int nameFragmentStart = this . namePos , nameFragmentEnd = - <NUM_LIT:1> ; ArrayList fragments = null ; typeLoop : while ( this . namePos < length ) { char currentChar = typeName [ this . namePos ] ; switch ( currentChar ) { case '<CHAR_LIT>' : this . namePos ++ ; while ( typeName [ this . namePos ] == '<CHAR_LIT:U+0020>' ) this . namePos ++ ; switch ( typeName [ this . namePos ] ) { case '<CHAR_LIT>' : checkSuper : { int max = TypeConstants . WILDCARD_SUPER . length - <NUM_LIT:1> ; for ( int ahead = <NUM_LIT:1> ; ahead < max ; ahead ++ ) { if ( typeName [ this . namePos + ahead ] != TypeConstants . WILDCARD_SUPER [ ahead + <NUM_LIT:1> ] ) { break checkSuper ; } } this . namePos += max ; Wildcard result = new Wildcard ( Wildcard . SUPER ) ; result . bound = decodeType ( typeName , length , start , end , includeGenericsAnyway ) ; result . sourceStart = start ; result . sourceEnd = end ; return result ; } break ; case '<CHAR_LIT:e>' : checkExtends : { int max = TypeConstants . WILDCARD_EXTENDS . length - <NUM_LIT:1> ; for ( int ahead = <NUM_LIT:1> ; ahead < max ; ahead ++ ) { if ( typeName [ this . namePos + ahead ] != TypeConstants . WILDCARD_EXTENDS [ ahead + <NUM_LIT:1> ] ) { break checkExtends ; } } this . namePos += max ; Wildcard result = new Wildcard ( Wildcard . EXTENDS ) ; result . bound = decodeType ( typeName , length , start , end , includeGenericsAnyway ) ; result . sourceStart = start ; result . sourceEnd = end ; return result ; } break ; } Wildcard result = new Wildcard ( Wildcard . UNBOUND ) ; result . sourceStart = start ; result . sourceEnd = end ; return result ; case '<CHAR_LIT:[>' : if ( dim == <NUM_LIT:0> && nameFragmentEnd < <NUM_LIT:0> ) nameFragmentEnd = this . namePos - <NUM_LIT:1> ; dim ++ ; break ; case '<CHAR_LIT:]>' : break ; case '<CHAR_LIT:>>' : case '<CHAR_LIT:U+002C>' : break typeLoop ; case '<CHAR_LIT:.>' : if ( nameFragmentStart < <NUM_LIT:0> ) nameFragmentStart = this . namePos + <NUM_LIT:1> ; identCount ++ ; break ; case '<CHAR_LIT>' : if ( this . has1_5Compliance || includeGenericsAnyway ) { if ( fragments == null ) fragments = new ArrayList ( <NUM_LIT:2> ) ; } nameFragmentEnd = this . namePos - <NUM_LIT:1> ; if ( this . has1_5Compliance || includeGenericsAnyway ) { char [ ] [ ] identifiers = CharOperation . splitOn ( '<CHAR_LIT:.>' , typeName , nameFragmentStart , this . namePos ) ; fragments . add ( identifiers ) ; } this . namePos ++ ; TypeReference [ ] arguments = decodeTypeArguments ( typeName , length , start , end , includeGenericsAnyway ) ; if ( this . has1_5Compliance || includeGenericsAnyway ) { fragments . add ( arguments ) ; identCount = <NUM_LIT:0> ; nameFragmentStart = - <NUM_LIT:1> ; nameFragmentEnd = - <NUM_LIT:1> ; } break ; } this . namePos ++ ; } if ( nameFragmentEnd < <NUM_LIT:0> ) nameFragmentEnd = this . namePos - <NUM_LIT:1> ; if ( fragments == null ) { if ( identCount == <NUM_LIT:1> ) { if ( dim == <NUM_LIT:0> ) { char [ ] nameFragment ; if ( nameFragmentStart != <NUM_LIT:0> || nameFragmentEnd >= <NUM_LIT:0> ) { int nameFragmentLength = nameFragmentEnd - nameFragmentStart + <NUM_LIT:1> ; System . arraycopy ( typeName , nameFragmentStart , nameFragment = new char [ nameFragmentLength ] , <NUM_LIT:0> , nameFragmentLength ) ; } else { nameFragment = typeName ; } return new SingleTypeReference ( nameFragment , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } else { int nameFragmentLength = nameFragmentEnd - nameFragmentStart + <NUM_LIT:1> ; char [ ] nameFragment = new char [ nameFragmentLength ] ; System . arraycopy ( typeName , nameFragmentStart , nameFragment , <NUM_LIT:0> , nameFragmentLength ) ; return new ArrayTypeReference ( nameFragment , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } } else { long [ ] positions = new long [ identCount ] ; long pos = ( ( long ) start << <NUM_LIT:32> ) + end ; for ( int i = <NUM_LIT:0> ; i < identCount ; i ++ ) { positions [ i ] = pos ; } char [ ] [ ] identifiers = CharOperation . splitOn ( '<CHAR_LIT:.>' , typeName , nameFragmentStart , nameFragmentEnd + <NUM_LIT:1> ) ; if ( dim == <NUM_LIT:0> ) { return new QualifiedTypeReference ( identifiers , positions ) ; } else { return new ArrayQualifiedTypeReference ( identifiers , dim , positions ) ; } } } else { if ( nameFragmentStart > <NUM_LIT:0> && nameFragmentStart < length ) { char [ ] [ ] identifiers = CharOperation . splitOn ( '<CHAR_LIT:.>' , typeName , nameFragmentStart , nameFragmentEnd + <NUM_LIT:1> ) ; fragments . add ( identifiers ) ; } int fragmentLength = fragments . size ( ) ; if ( fragmentLength == <NUM_LIT:2> ) { char [ ] [ ] firstFragment = ( char [ ] [ ] ) fragments . get ( <NUM_LIT:0> ) ; if ( firstFragment . length == <NUM_LIT:1> ) { return new ParameterizedSingleTypeReference ( firstFragment [ <NUM_LIT:0> ] , ( TypeReference [ ] ) fragments . get ( <NUM_LIT:1> ) , dim , ( ( long ) start << <NUM_LIT:32> ) + end ) ; } } identCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < fragmentLength ; i ++ ) { Object element = fragments . get ( i ) ; if ( element instanceof char [ ] [ ] ) { identCount += ( ( char [ ] [ ] ) element ) . length ; } } char [ ] [ ] tokens = new char [ identCount ] [ ] ; TypeReference [ ] [ ] arguments = new TypeReference [ identCount ] [ ] ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < fragmentLength ; i ++ ) { Object element = fragments . get ( i ) ; if ( element instanceof char [ ] [ ] ) { char [ ] [ ] fragmentTokens = ( char [ ] [ ] ) element ; int fragmentTokenLength = fragmentTokens . length ; System . arraycopy ( fragmentTokens , <NUM_LIT:0> , tokens , index , fragmentTokenLength ) ; index += fragmentTokenLength ; } else { arguments [ index - <NUM_LIT:1> ] = ( TypeReference [ ] ) element ; } } long [ ] positions = new long [ identCount ] ; long pos = ( ( long ) start << <NUM_LIT:32> ) + end ; for ( int i = <NUM_LIT:0> ; i < identCount ; i ++ ) { positions [ i ] = pos ; } return new ParameterizedQualifiedTypeReference ( tokens , arguments , dim , positions ) ; } } private TypeReference [ ] decodeTypeArguments ( char [ ] typeName , int length , int start , int end , boolean includeGenericsAnyway ) { ArrayList argumentList = new ArrayList ( <NUM_LIT:1> ) ; int count = <NUM_LIT:0> ; argumentsLoop : while ( this . namePos < length ) { TypeReference argument = decodeType ( typeName , length , start , end , includeGenericsAnyway ) ; count ++ ; argumentList . add ( argument ) ; if ( this . namePos >= length ) break argumentsLoop ; if ( typeName [ this . namePos ] == '<CHAR_LIT:>>' ) { break argumentsLoop ; } this . namePos ++ ; } TypeReference [ ] typeArguments = new TypeReference [ count ] ; argumentList . toArray ( typeArguments ) ; return typeArguments ; } private TypeReference [ ] decodeTypeArguments ( String typeSignature , int length , int start , int end ) { ArrayList argumentList = new ArrayList ( <NUM_LIT:1> ) ; int count = <NUM_LIT:0> ; argumentsLoop : while ( this . namePos < length ) { TypeReference argument = decodeType ( typeSignature , length , start , end ) ; count ++ ; argumentList . add ( argument ) ; if ( this . namePos >= length ) break argumentsLoop ; if ( typeSignature . charAt ( this . namePos ) == Signature . C_GENERIC_END ) { break argumentsLoop ; } } TypeReference [ ] typeArguments = new TypeReference [ count ] ; argumentList . toArray ( typeArguments ) ; return typeArguments ; } private char [ ] [ ] extractIdentifiers ( String typeSignature , int start , int endInclusive , int identCount ) { char [ ] [ ] result = new char [ identCount ] [ ] ; int charIndex = start ; int i = <NUM_LIT:0> ; while ( charIndex < endInclusive ) { char currentChar ; if ( ( currentChar = typeSignature . charAt ( charIndex ) ) == this . memberTypeSeparator || currentChar == Signature . C_DOT ) { typeSignature . getChars ( start , charIndex , result [ i ++ ] = new char [ charIndex - start ] , <NUM_LIT:0> ) ; start = ++ charIndex ; } else charIndex ++ ; } typeSignature . getChars ( start , charIndex + <NUM_LIT:1> , result [ i ++ ] = new char [ charIndex - start + <NUM_LIT:1> ] , <NUM_LIT:0> ) ; return result ; } } </s>
|
<s> package org . eclipse . jdt . internal . compiler . parser ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . jdt . core . IAnnotatable ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . IImportDeclaration ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . ILocalVariable ; import org . eclipse . jdt . core . ISourceRange ; 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 . * ; import org . eclipse . jdt . internal . compiler . ast . Annotation ; import org . eclipse . jdt . internal . compiler . ast . Initializer ; import org . eclipse . jdt . internal . compiler . ast . TypeParameter ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . env . * ; import org . eclipse . jdt . internal . compiler . lookup . ExtraCompilerModifiers ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . core . * ; import org . eclipse . jdt . internal . core . util . Util ; public class SourceTypeConverter extends TypeConverter { static class AnonymousMemberFound extends RuntimeException { private static final long serialVersionUID = <NUM_LIT:1L> ; } public static final int FIELD = <NUM_LIT> ; public static final int CONSTRUCTOR = <NUM_LIT> ; public static final int METHOD = <NUM_LIT> ; public static final int MEMBER_TYPE = <NUM_LIT> ; public static final int FIELD_INITIALIZATION = <NUM_LIT> ; public static final int FIELD_AND_METHOD = FIELD | CONSTRUCTOR | METHOD ; public static final int LOCAL_TYPE = <NUM_LIT> ; public static final int NONE = <NUM_LIT:0> ; private int flags ; private CompilationUnitDeclaration unit ; private Parser parser ; private ICompilationUnit cu ; private char [ ] source ; private SourceTypeConverter ( int flags , ProblemReporter problemReporter ) { super ( problemReporter , Signature . C_DOT ) ; this . flags = flags ; } public static CompilationUnitDeclaration buildCompilationUnit ( ISourceType [ ] sourceTypes , int flags , ProblemReporter problemReporter , CompilationResult compilationResult ) { SourceTypeConverter converter = new SourceTypeConverter ( flags , problemReporter ) ; try { return converter . convert ( sourceTypes , compilationResult ) ; } catch ( JavaModelException e ) { return null ; } } private CompilationUnitDeclaration convert ( ISourceType [ ] sourceTypes , CompilationResult compilationResult ) throws JavaModelException { this . unit = LanguageSupportFactory . newCompilationUnitDeclaration ( ( ICompilationUnit ) ( ( SourceTypeElementInfo ) sourceTypes [ <NUM_LIT:0> ] ) . getHandle ( ) . getCompilationUnit ( ) , this . problemReporter , compilationResult , <NUM_LIT:0> ) ; if ( sourceTypes . length == <NUM_LIT:0> ) return this . unit ; SourceTypeElementInfo topLevelTypeInfo = ( SourceTypeElementInfo ) sourceTypes [ <NUM_LIT:0> ] ; org . eclipse . jdt . core . ICompilationUnit cuHandle = topLevelTypeInfo . getHandle ( ) . getCompilationUnit ( ) ; this . cu = ( ICompilationUnit ) cuHandle ; if ( LanguageSupportFactory . isInterestingSourceFile ( new String ( compilationResult . getFileName ( ) ) ) ) { try { return LanguageSupportFactory . getParser ( this , this . problemReporter . options , this . problemReporter , true , <NUM_LIT:3> ) . dietParse ( this . cu , compilationResult ) ; } catch ( Throwable t ) { t . printStackTrace ( ) ; } } if ( this . has1_5Compliance && ( ( CompilationUnitElementInfo ) ( ( JavaElement ) this . cu ) . getElementInfo ( ) ) . annotationNumber > <NUM_LIT:10> ) { if ( ( this . flags & LOCAL_TYPE ) == <NUM_LIT:0> ) { return new Parser ( this . problemReporter , true ) . dietParse ( this . cu , compilationResult ) ; } } int start = topLevelTypeInfo . getNameSourceStart ( ) ; int end = topLevelTypeInfo . getNameSourceEnd ( ) ; String [ ] packageName = ( ( PackageFragment ) cuHandle . getParent ( ) ) . names ; if ( packageName . length > <NUM_LIT:0> ) this . unit . currentPackage = createImportReference ( packageName , start , end , false , ClassFileConstants . AccDefault ) ; IImportDeclaration [ ] importDeclarations = topLevelTypeInfo . getHandle ( ) . getCompilationUnit ( ) . getImports ( ) ; int importCount = importDeclarations . length ; this . unit . imports = new ImportReference [ importCount ] ; for ( int i = <NUM_LIT:0> ; i < importCount ; i ++ ) { ImportDeclaration importDeclaration = ( ImportDeclaration ) importDeclarations [ i ] ; ISourceImport sourceImport = ( ISourceImport ) importDeclaration . getElementInfo ( ) ; String nameWithoutStar = importDeclaration . getNameWithoutStar ( ) ; this . unit . imports [ i ] = createImportReference ( Util . splitOn ( '<CHAR_LIT:.>' , nameWithoutStar , <NUM_LIT:0> , nameWithoutStar . length ( ) ) , sourceImport . getDeclarationSourceStart ( ) , sourceImport . getDeclarationSourceEnd ( ) , importDeclaration . isOnDemand ( ) , sourceImport . getModifiers ( ) ) ; } try { int typeCount = sourceTypes . length ; final TypeDeclaration [ ] types = new TypeDeclaration [ typeCount ] ; for ( int i = <NUM_LIT:0> ; i < typeCount ; i ++ ) { SourceTypeElementInfo typeInfo = ( SourceTypeElementInfo ) sourceTypes [ i ] ; types [ i ] = convert ( ( SourceType ) typeInfo . getHandle ( ) , compilationResult ) ; } this . unit . types = types ; return this . unit ; } catch ( AnonymousMemberFound e ) { return new Parser ( this . problemReporter , true ) . parse ( this . cu , compilationResult ) ; } } private Initializer convert ( InitializerElementInfo initializerInfo , CompilationResult compilationResult ) throws JavaModelException { Block block = new Block ( <NUM_LIT:0> ) ; Initializer initializer = new Initializer ( block , ClassFileConstants . AccDefault ) ; int start = initializerInfo . getDeclarationSourceStart ( ) ; int end = initializerInfo . getDeclarationSourceEnd ( ) ; initializer . sourceStart = initializer . declarationSourceStart = start ; initializer . sourceEnd = initializer . declarationSourceEnd = end ; initializer . modifiers = initializerInfo . getModifiers ( ) ; IJavaElement [ ] children = initializerInfo . getChildren ( ) ; int typesLength = children . length ; if ( typesLength > <NUM_LIT:0> ) { Statement [ ] statements = new Statement [ typesLength ] ; for ( int i = <NUM_LIT:0> ; i < typesLength ; i ++ ) { SourceType type = ( SourceType ) children [ i ] ; TypeDeclaration localType = convert ( type , compilationResult ) ; if ( ( localType . bits & ASTNode . IsAnonymousType ) != <NUM_LIT:0> ) { QualifiedAllocationExpression expression = new QualifiedAllocationExpression ( localType ) ; expression . type = localType . superclass ; localType . superclass = null ; localType . superInterfaces = null ; localType . allocation = expression ; statements [ i ] = expression ; } else { statements [ i ] = localType ; } } block . statements = statements ; } return initializer ; } private FieldDeclaration convert ( SourceField fieldHandle , TypeDeclaration type , CompilationResult compilationResult ) throws JavaModelException { SourceFieldElementInfo fieldInfo = ( SourceFieldElementInfo ) fieldHandle . getElementInfo ( ) ; FieldDeclaration field = new FieldDeclaration ( ) ; int start = fieldInfo . getNameSourceStart ( ) ; int end = fieldInfo . getNameSourceEnd ( ) ; field . name = fieldHandle . getElementName ( ) . toCharArray ( ) ; field . sourceStart = start ; field . sourceEnd = end ; field . declarationSourceStart = fieldInfo . getDeclarationSourceStart ( ) ; field . declarationSourceEnd = fieldInfo . getDeclarationSourceEnd ( ) ; int modifiers = fieldInfo . getModifiers ( ) ; boolean isEnumConstant = ( modifiers & ClassFileConstants . AccEnum ) != <NUM_LIT:0> ; if ( isEnumConstant ) { field . modifiers = modifiers & ~ ClassFileConstants . AccEnum ; } else { field . modifiers = modifiers ; field . type = createTypeReference ( fieldInfo . getTypeName ( ) , start , end ) ; } if ( this . has1_5Compliance ) { field . annotations = convertAnnotations ( fieldHandle ) ; } if ( ( this . flags & FIELD_INITIALIZATION ) != <NUM_LIT:0> ) { char [ ] initializationSource = fieldInfo . getInitializationSource ( ) ; if ( initializationSource != null ) { if ( this . parser == null ) { this . parser = new Parser ( this . problemReporter , true ) ; } this . parser . parse ( field , type , this . unit , initializationSource ) ; } } if ( ( this . flags & LOCAL_TYPE ) != <NUM_LIT:0> ) { IJavaElement [ ] children = fieldInfo . getChildren ( ) ; int childrenLength = children . length ; if ( childrenLength == <NUM_LIT:1> ) { field . initialization = convert ( children [ <NUM_LIT:0> ] , isEnumConstant ? field : null , compilationResult ) ; } else if ( childrenLength > <NUM_LIT:1> ) { ArrayInitializer initializer = new ArrayInitializer ( ) ; field . initialization = initializer ; Expression [ ] expressions = new Expression [ childrenLength ] ; initializer . expressions = expressions ; for ( int i = <NUM_LIT:0> ; i < childrenLength ; i ++ ) { expressions [ i ] = convert ( children [ i ] , isEnumConstant ? field : null , compilationResult ) ; } } } return field ; } private QualifiedAllocationExpression convert ( IJavaElement localType , FieldDeclaration enumConstant , CompilationResult compilationResult ) throws JavaModelException { TypeDeclaration anonymousLocalTypeDeclaration = convert ( ( SourceType ) localType , compilationResult ) ; QualifiedAllocationExpression expression = new QualifiedAllocationExpression ( anonymousLocalTypeDeclaration ) ; expression . type = anonymousLocalTypeDeclaration . superclass ; anonymousLocalTypeDeclaration . superclass = null ; anonymousLocalTypeDeclaration . superInterfaces = null ; anonymousLocalTypeDeclaration . allocation = expression ; if ( enumConstant != null ) { anonymousLocalTypeDeclaration . modifiers &= ~ ClassFileConstants . AccEnum ; expression . enumConstant = enumConstant ; expression . type = null ; } return expression ; } private AbstractMethodDeclaration convert ( SourceMethod methodHandle , SourceMethodElementInfo methodInfo , CompilationResult compilationResult ) throws JavaModelException { AbstractMethodDeclaration method ; int start = methodInfo . getNameSourceStart ( ) ; int end = methodInfo . getNameSourceEnd ( ) ; TypeParameter [ ] typeParams = null ; char [ ] [ ] typeParameterNames = methodInfo . getTypeParameterNames ( ) ; if ( typeParameterNames != null ) { int parameterCount = typeParameterNames . length ; if ( parameterCount > <NUM_LIT:0> ) { char [ ] [ ] [ ] typeParameterBounds = methodInfo . getTypeParameterBounds ( ) ; typeParams = new TypeParameter [ parameterCount ] ; for ( int i = <NUM_LIT:0> ; i < parameterCount ; i ++ ) { typeParams [ i ] = createTypeParameter ( typeParameterNames [ i ] , typeParameterBounds [ i ] , start , end ) ; } } } int modifiers = methodInfo . getModifiers ( ) ; if ( methodInfo . isConstructor ( ) ) { ConstructorDeclaration decl = new ConstructorDeclaration ( compilationResult ) ; decl . bits &= ~ ASTNode . IsDefaultConstructor ; method = decl ; decl . typeParameters = typeParams ; } else { MethodDeclaration decl ; if ( methodInfo . isAnnotationMethod ( ) ) { AnnotationMethodDeclaration annotationMethodDeclaration = new AnnotationMethodDeclaration ( compilationResult ) ; SourceAnnotationMethodInfo annotationMethodInfo = ( SourceAnnotationMethodInfo ) methodInfo ; boolean hasDefaultValue = annotationMethodInfo . defaultValueStart != - <NUM_LIT:1> || annotationMethodInfo . defaultValueEnd != - <NUM_LIT:1> ; if ( ( this . flags & FIELD_INITIALIZATION ) != <NUM_LIT:0> ) { if ( hasDefaultValue ) { char [ ] defaultValueSource = CharOperation . subarray ( getSource ( ) , annotationMethodInfo . defaultValueStart , annotationMethodInfo . defaultValueEnd + <NUM_LIT:1> ) ; if ( defaultValueSource != null ) { Expression expression = parseMemberValue ( defaultValueSource ) ; if ( expression != null ) { annotationMethodDeclaration . defaultValue = expression ; } } else { hasDefaultValue = false ; } } } if ( hasDefaultValue ) modifiers |= ClassFileConstants . AccAnnotationDefault ; decl = annotationMethodDeclaration ; } else { decl = new MethodDeclaration ( compilationResult ) ; } decl . returnType = createTypeReference ( methodInfo . getReturnTypeName ( ) , start , end ) ; decl . typeParameters = typeParams ; method = decl ; } method . selector = methodHandle . getElementName ( ) . toCharArray ( ) ; boolean isVarargs = ( modifiers & ClassFileConstants . AccVarargs ) != <NUM_LIT:0> ; method . modifiers = modifiers & ~ ClassFileConstants . AccVarargs ; method . sourceStart = start ; method . sourceEnd = end ; method . declarationSourceStart = methodInfo . getDeclarationSourceStart ( ) ; method . declarationSourceEnd = methodInfo . getDeclarationSourceEnd ( ) ; if ( this . has1_5Compliance ) { method . annotations = convertAnnotations ( methodHandle ) ; } String [ ] argumentTypeSignatures = methodHandle . getParameterTypes ( ) ; char [ ] [ ] argumentNames = methodInfo . getArgumentNames ( ) ; int argumentCount = argumentTypeSignatures == null ? <NUM_LIT:0> : argumentTypeSignatures . length ; if ( argumentCount > <NUM_LIT:0> ) { ILocalVariable [ ] parameters = methodHandle . getParameters ( ) ; long position = ( ( long ) start << <NUM_LIT:32> ) + end ; method . arguments = new Argument [ argumentCount ] ; for ( int i = <NUM_LIT:0> ; i < argumentCount ; i ++ ) { TypeReference typeReference = createTypeReference ( argumentTypeSignatures [ i ] , start , end ) ; if ( isVarargs && i == argumentCount - <NUM_LIT:1> ) { typeReference . bits |= ASTNode . IsVarArgs ; } method . arguments [ i ] = new Argument ( argumentNames [ i ] , position , typeReference , ClassFileConstants . AccDefault ) ; if ( this . has1_5Compliance ) { method . arguments [ i ] . annotations = convertAnnotations ( parameters [ i ] ) ; } } } char [ ] [ ] exceptionTypeNames = methodInfo . getExceptionTypeNames ( ) ; int exceptionCount = exceptionTypeNames == null ? <NUM_LIT:0> : exceptionTypeNames . length ; if ( exceptionCount > <NUM_LIT:0> ) { method . thrownExceptions = new TypeReference [ exceptionCount ] ; for ( int i = <NUM_LIT:0> ; i < exceptionCount ; i ++ ) { method . thrownExceptions [ i ] = createTypeReference ( exceptionTypeNames [ i ] , start , end ) ; } } if ( ( this . flags & LOCAL_TYPE ) != <NUM_LIT:0> ) { IJavaElement [ ] children = methodInfo . getChildren ( ) ; int typesLength = children . length ; if ( typesLength != <NUM_LIT:0> ) { Statement [ ] statements = new Statement [ typesLength ] ; for ( int i = <NUM_LIT:0> ; i < typesLength ; i ++ ) { SourceType type = ( SourceType ) children [ i ] ; TypeDeclaration localType = convert ( type , compilationResult ) ; if ( ( localType . bits & ASTNode . IsAnonymousType ) != <NUM_LIT:0> ) { QualifiedAllocationExpression expression = new QualifiedAllocationExpression ( localType ) ; expression . type = localType . superclass ; localType . superclass = null ; localType . superInterfaces = null ; localType . allocation = expression ; statements [ i ] = expression ; } else { statements [ i ] = localType ; } } method . statements = statements ; } } return method ; } private TypeDeclaration convert ( SourceType typeHandle , CompilationResult compilationResult ) throws JavaModelException { SourceTypeElementInfo typeInfo = ( SourceTypeElementInfo ) typeHandle . getElementInfo ( ) ; if ( typeInfo . isAnonymousMember ( ) ) throw new AnonymousMemberFound ( ) ; TypeDeclaration type = new TypeDeclaration ( compilationResult ) ; if ( typeInfo . getEnclosingType ( ) == null ) { if ( typeHandle . isAnonymous ( ) ) { type . name = CharOperation . NO_CHAR ; type . bits |= ( ASTNode . IsAnonymousType | ASTNode . IsLocalType ) ; } else { if ( typeHandle . isLocal ( ) ) { type . bits |= ASTNode . IsLocalType ; } } } else { type . bits |= ASTNode . IsMemberType ; } if ( ( type . bits & ASTNode . IsAnonymousType ) == <NUM_LIT:0> ) { type . name = typeInfo . getName ( ) ; } type . name = typeInfo . getName ( ) ; int start , end ; type . sourceStart = start = typeInfo . getNameSourceStart ( ) ; type . sourceEnd = end = typeInfo . getNameSourceEnd ( ) ; type . modifiers = typeInfo . getModifiers ( ) ; type . declarationSourceStart = typeInfo . getDeclarationSourceStart ( ) ; type . declarationSourceEnd = typeInfo . getDeclarationSourceEnd ( ) ; type . bodyEnd = type . declarationSourceEnd ; if ( this . has1_5Compliance ) { type . annotations = convertAnnotations ( typeHandle ) ; } char [ ] [ ] typeParameterNames = typeInfo . getTypeParameterNames ( ) ; if ( typeParameterNames . length > <NUM_LIT:0> ) { int parameterCount = typeParameterNames . length ; char [ ] [ ] [ ] typeParameterBounds = typeInfo . getTypeParameterBounds ( ) ; type . typeParameters = new TypeParameter [ parameterCount ] ; for ( int i = <NUM_LIT:0> ; i < parameterCount ; i ++ ) { type . typeParameters [ i ] = createTypeParameter ( typeParameterNames [ i ] , typeParameterBounds [ i ] , start , end ) ; } } if ( typeInfo . getSuperclassName ( ) != null ) { type . superclass = createTypeReference ( typeInfo . getSuperclassName ( ) , start , end , true ) ; type . superclass . bits |= ASTNode . IsSuperType ; } char [ ] [ ] interfaceNames = typeInfo . getInterfaceNames ( ) ; int interfaceCount = interfaceNames == null ? <NUM_LIT:0> : interfaceNames . length ; if ( interfaceCount > <NUM_LIT:0> ) { type . superInterfaces = new TypeReference [ interfaceCount ] ; for ( int i = <NUM_LIT:0> ; i < interfaceCount ; i ++ ) { type . superInterfaces [ i ] = createTypeReference ( interfaceNames [ i ] , start , end , true ) ; type . superInterfaces [ i ] . bits |= ASTNode . IsSuperType ; } } if ( ( this . flags & MEMBER_TYPE ) != <NUM_LIT:0> ) { SourceType [ ] sourceMemberTypes = typeInfo . getMemberTypeHandles ( ) ; int sourceMemberTypeCount = sourceMemberTypes . length ; type . memberTypes = new TypeDeclaration [ sourceMemberTypeCount ] ; for ( int i = <NUM_LIT:0> ; i < sourceMemberTypeCount ; i ++ ) { type . memberTypes [ i ] = convert ( sourceMemberTypes [ i ] , compilationResult ) ; type . memberTypes [ i ] . enclosingType = type ; } } InitializerElementInfo [ ] initializers = null ; int initializerCount = <NUM_LIT:0> ; if ( ( this . flags & LOCAL_TYPE ) != <NUM_LIT:0> ) { initializers = typeInfo . getInitializers ( ) ; initializerCount = initializers . length ; } SourceField [ ] sourceFields = null ; int sourceFieldCount = <NUM_LIT:0> ; if ( ( this . flags & FIELD ) != <NUM_LIT:0> ) { sourceFields = typeInfo . getFieldHandles ( ) ; sourceFieldCount = sourceFields . length ; } int length = initializerCount + sourceFieldCount ; if ( length > <NUM_LIT:0> ) { type . fields = new FieldDeclaration [ length ] ; for ( int i = <NUM_LIT:0> ; i < initializerCount ; i ++ ) { type . fields [ i ] = convert ( initializers [ i ] , compilationResult ) ; } int index = <NUM_LIT:0> ; for ( int i = initializerCount ; i < length ; i ++ ) { type . fields [ i ] = convert ( sourceFields [ index ++ ] , type , compilationResult ) ; } } boolean needConstructor = ( this . flags & CONSTRUCTOR ) != <NUM_LIT:0> ; boolean needMethod = ( this . flags & METHOD ) != <NUM_LIT:0> ; if ( needConstructor || needMethod ) { SourceMethod [ ] sourceMethods = typeInfo . getMethodHandles ( ) ; int sourceMethodCount = sourceMethods . length ; int extraConstructor = <NUM_LIT:0> ; int methodCount = <NUM_LIT:0> ; int kind = TypeDeclaration . kind ( type . modifiers ) ; boolean isAbstract = kind == TypeDeclaration . INTERFACE_DECL || kind == TypeDeclaration . ANNOTATION_TYPE_DECL ; if ( ! isAbstract ) { extraConstructor = needConstructor ? <NUM_LIT:1> : <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < sourceMethodCount ; i ++ ) { if ( sourceMethods [ i ] . isConstructor ( ) ) { if ( needConstructor ) { extraConstructor = <NUM_LIT:0> ; methodCount ++ ; } } else if ( needMethod ) { methodCount ++ ; } } } else { methodCount = needMethod ? sourceMethodCount : <NUM_LIT:0> ; } type . methods = new AbstractMethodDeclaration [ methodCount + extraConstructor ] ; if ( extraConstructor != <NUM_LIT:0> ) { type . methods [ <NUM_LIT:0> ] = type . createDefaultConstructor ( false , false ) ; } int index = <NUM_LIT:0> ; boolean hasAbstractMethods = false ; for ( int i = <NUM_LIT:0> ; i < sourceMethodCount ; i ++ ) { SourceMethod sourceMethod = sourceMethods [ i ] ; SourceMethodElementInfo methodInfo = ( SourceMethodElementInfo ) sourceMethod . getElementInfo ( ) ; boolean isConstructor = methodInfo . isConstructor ( ) ; if ( ( methodInfo . getModifiers ( ) & ClassFileConstants . AccAbstract ) != <NUM_LIT:0> ) { hasAbstractMethods = true ; } if ( ( isConstructor && needConstructor ) || ( ! isConstructor && needMethod ) ) { AbstractMethodDeclaration method = convert ( sourceMethod , methodInfo , compilationResult ) ; if ( isAbstract || method . isAbstract ( ) ) { method . modifiers |= ExtraCompilerModifiers . AccSemicolonBody ; } type . methods [ extraConstructor + index ++ ] = method ; } } if ( hasAbstractMethods ) type . bits |= ASTNode . HasAbstractMethods ; } return type ; } private Annotation [ ] convertAnnotations ( IAnnotatable element ) throws JavaModelException { IAnnotation [ ] annotations = element . getAnnotations ( ) ; int length = annotations . length ; Annotation [ ] astAnnotations = new Annotation [ length ] ; if ( length > <NUM_LIT:0> ) { char [ ] cuSource = getSource ( ) ; int recordedAnnotations = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ISourceRange positions = annotations [ i ] . getSourceRange ( ) ; int start = positions . getOffset ( ) ; int end = start + positions . getLength ( ) ; char [ ] annotationSource = CharOperation . subarray ( cuSource , start , end ) ; if ( annotationSource != null ) { Expression expression = parseMemberValue ( annotationSource ) ; if ( expression instanceof Annotation ) { astAnnotations [ recordedAnnotations ++ ] = ( Annotation ) expression ; } } } if ( length != recordedAnnotations ) { System . arraycopy ( astAnnotations , <NUM_LIT:0> , ( astAnnotations = new Annotation [ recordedAnnotations ] ) , <NUM_LIT:0> , recordedAnnotations ) ; } } return astAnnotations ; } private char [ ] getSource ( ) { if ( this . source == null ) this . source = this . cu . getContents ( ) ; return this . source ; } private Expression parseMemberValue ( char [ ] memberValue ) { if ( this . parser == null ) { this . parser = new Parser ( this . problemReporter , true ) ; } return this . parser . parseMemberValue ( memberValue , <NUM_LIT:0> , memberValue . length , this . unit ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . compiler ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . env . IBinaryNestedType ; public final class ExtraFlags { public final static int HasNonPrivateStaticMemberTypes = <NUM_LIT> ; public final static int IsMemberType = <NUM_LIT> ; public final static int IsLocalType = <NUM_LIT> ; public final static int ParameterTypesStoredAsSignature = <NUM_LIT> ; public static int getExtraFlags ( ClassFileReader reader ) { int extraFlags = <NUM_LIT:0> ; if ( reader . isNestedType ( ) ) { extraFlags |= ExtraFlags . IsMemberType ; } if ( reader . isLocal ( ) ) { extraFlags |= ExtraFlags . IsLocalType ; } IBinaryNestedType [ ] memberTypes = reader . getMemberTypes ( ) ; int memberTypeCounter = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; if ( memberTypeCounter > <NUM_LIT:0> ) { done : for ( int i = <NUM_LIT:0> ; i < memberTypeCounter ; i ++ ) { int modifiers = memberTypes [ i ] . getModifiers ( ) ; if ( ( modifiers & ClassFileConstants . AccStatic ) != <NUM_LIT:0> && ( modifiers & ClassFileConstants . AccPrivate ) == <NUM_LIT:0> ) { extraFlags |= ExtraFlags . HasNonPrivateStaticMemberTypes ; break done ; } } } return extraFlags ; } public static int getExtraFlags ( IType type ) throws JavaModelException { int extraFlags = <NUM_LIT:0> ; if ( type . isMember ( ) ) { extraFlags |= ExtraFlags . IsMemberType ; } if ( type . isLocal ( ) ) { extraFlags |= ExtraFlags . IsLocalType ; } IType [ ] memberTypes = type . getTypes ( ) ; int memberTypeCounter = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; if ( memberTypeCounter > <NUM_LIT:0> ) { done : for ( int i = <NUM_LIT:0> ; i < memberTypeCounter ; i ++ ) { int flags = memberTypes [ i ] . getFlags ( ) ; if ( ( flags & ClassFileConstants . AccStatic ) != <NUM_LIT:0> && ( flags & ClassFileConstants . AccPrivate ) == <NUM_LIT:0> ) { extraFlags |= ExtraFlags . HasNonPrivateStaticMemberTypes ; break done ; } } } return extraFlags ; } public static int getExtraFlags ( TypeDeclaration typeDeclaration ) { int extraFlags = <NUM_LIT:0> ; if ( typeDeclaration . enclosingType != null ) { extraFlags |= ExtraFlags . IsMemberType ; } TypeDeclaration [ ] memberTypes = typeDeclaration . memberTypes ; int memberTypeCounter = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; if ( memberTypeCounter > <NUM_LIT:0> ) { done : for ( int i = <NUM_LIT:0> ; i < memberTypeCounter ; i ++ ) { int modifiers = memberTypes [ i ] . modifiers ; if ( ( modifiers & ClassFileConstants . AccStatic ) != <NUM_LIT:0> && ( modifiers & ClassFileConstants . AccPrivate ) == <NUM_LIT:0> ) { extraFlags |= ExtraFlags . HasNonPrivateStaticMemberTypes ; break done ; } } } return extraFlags ; } } </s>
|
<s> package org . eclipse . jdt . internal . compiler ; import java . util . ArrayList ; import java . util . Map ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor . ParameterInfo ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor . TypeParameterInfo ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . AbstractVariableDeclaration ; import org . eclipse . jdt . internal . compiler . ast . AllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . Annotation ; import org . eclipse . jdt . internal . compiler . ast . AnnotationMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . ArrayAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . ArrayInitializer ; import org . eclipse . jdt . internal . compiler . ast . ArrayReference ; import org . eclipse . jdt . internal . compiler . ast . Assignment ; import org . eclipse . jdt . internal . compiler . ast . ClassLiteralAccess ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ConstructorDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ExplicitConstructorCall ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . Initializer ; import org . eclipse . jdt . internal . compiler . ast . MessageSend ; import org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . QualifiedAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . ThisReference ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeParameter ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . ExtraCompilerModifiers ; import org . eclipse . jdt . internal . compiler . lookup . MethodScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObjectToInt ; public class SourceElementNotifier { public class LocalDeclarationVisitor extends ASTVisitor { public ImportReference currentPackage ; ArrayList declaringTypes ; public void pushDeclaringType ( TypeDeclaration declaringType ) { if ( this . declaringTypes == null ) { this . declaringTypes = new ArrayList ( ) ; } this . declaringTypes . add ( declaringType ) ; } public void popDeclaringType ( ) { this . declaringTypes . remove ( this . declaringTypes . size ( ) - <NUM_LIT:1> ) ; } public TypeDeclaration peekDeclaringType ( ) { if ( this . declaringTypes == null ) return null ; int size = this . declaringTypes . size ( ) ; if ( size == <NUM_LIT:0> ) return null ; return ( TypeDeclaration ) this . declaringTypes . get ( size - <NUM_LIT:1> ) ; } public boolean visit ( TypeDeclaration typeDeclaration , BlockScope scope ) { notifySourceElementRequestor ( typeDeclaration , true , peekDeclaringType ( ) , this . currentPackage ) ; return false ; } public boolean visit ( TypeDeclaration typeDeclaration , ClassScope scope ) { notifySourceElementRequestor ( typeDeclaration , true , peekDeclaringType ( ) , this . currentPackage ) ; return false ; } } ISourceElementRequestor requestor ; boolean reportReferenceInfo ; char [ ] [ ] typeNames ; char [ ] [ ] superTypeNames ; int nestedTypeIndex ; LocalDeclarationVisitor localDeclarationVisitor = null ; HashtableOfObjectToInt sourceEnds ; Map nodesToCategories ; int initialPosition ; int eofPosition ; public SourceElementNotifier ( ISourceElementRequestor requestor , boolean reportLocalDeclarations ) { this . requestor = requestor ; if ( reportLocalDeclarations ) { this . localDeclarationVisitor = new LocalDeclarationVisitor ( ) ; } this . typeNames = new char [ <NUM_LIT:4> ] [ ] ; this . superTypeNames = new char [ <NUM_LIT:4> ] [ ] ; this . nestedTypeIndex = <NUM_LIT:0> ; } protected Object [ ] [ ] getArgumentInfos ( Argument [ ] arguments ) { int argumentLength = arguments . length ; char [ ] [ ] argumentTypes = new char [ argumentLength ] [ ] ; char [ ] [ ] argumentNames = new char [ argumentLength ] [ ] ; ParameterInfo [ ] parameterInfos = new ParameterInfo [ argumentLength ] ; for ( int i = <NUM_LIT:0> ; i < argumentLength ; i ++ ) { Argument argument = arguments [ i ] ; argumentTypes [ i ] = CharOperation . concatWith ( argument . type . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; char [ ] name = argument . name ; argumentNames [ i ] = name ; ParameterInfo parameterInfo = new ParameterInfo ( ) ; parameterInfo . declarationStart = argument . declarationSourceStart ; parameterInfo . declarationEnd = argument . declarationSourceEnd ; parameterInfo . nameSourceStart = argument . sourceStart ; parameterInfo . nameSourceEnd = argument . sourceEnd ; parameterInfo . modifiers = argument . modifiers ; parameterInfo . name = name ; parameterInfos [ i ] = parameterInfo ; } return new Object [ ] [ ] { parameterInfos , new char [ ] [ ] [ ] { argumentTypes , argumentNames } } ; } protected char [ ] [ ] getInterfaceNames ( TypeDeclaration typeDeclaration ) { char [ ] [ ] interfaceNames = null ; int superInterfacesLength = <NUM_LIT:0> ; TypeReference [ ] superInterfaces = typeDeclaration . superInterfaces ; if ( superInterfaces != null ) { superInterfacesLength = superInterfaces . length ; interfaceNames = new char [ superInterfacesLength ] [ ] ; } else { if ( ( typeDeclaration . bits & ASTNode . IsAnonymousType ) != <NUM_LIT:0> ) { QualifiedAllocationExpression alloc = typeDeclaration . allocation ; if ( alloc != null && alloc . type != null ) { superInterfaces = new TypeReference [ ] { alloc . type } ; superInterfacesLength = <NUM_LIT:1> ; interfaceNames = new char [ <NUM_LIT:1> ] [ ] ; } } } if ( superInterfaces != null ) { for ( int i = <NUM_LIT:0> ; i < superInterfacesLength ; i ++ ) { interfaceNames [ i ] = CharOperation . concatWith ( superInterfaces [ i ] . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; } } return interfaceNames ; } protected char [ ] getSuperclassName ( TypeDeclaration typeDeclaration ) { TypeReference superclass = typeDeclaration . superclass ; return superclass != null ? CharOperation . concatWith ( superclass . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) : null ; } protected char [ ] [ ] getThrownExceptions ( AbstractMethodDeclaration methodDeclaration ) { char [ ] [ ] thrownExceptionTypes = null ; TypeReference [ ] thrownExceptions = methodDeclaration . thrownExceptions ; if ( thrownExceptions != null ) { int thrownExceptionLength = thrownExceptions . length ; thrownExceptionTypes = new char [ thrownExceptionLength ] [ ] ; for ( int i = <NUM_LIT:0> ; i < thrownExceptionLength ; i ++ ) { thrownExceptionTypes [ i ] = CharOperation . concatWith ( thrownExceptions [ i ] . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; } } return thrownExceptionTypes ; } protected char [ ] [ ] getTypeParameterBounds ( TypeParameter typeParameter ) { TypeReference firstBound = typeParameter . type ; TypeReference [ ] otherBounds = typeParameter . bounds ; char [ ] [ ] typeParameterBounds = null ; if ( firstBound != null ) { if ( otherBounds != null ) { int otherBoundsLength = otherBounds . length ; char [ ] [ ] boundNames = new char [ otherBoundsLength + <NUM_LIT:1> ] [ ] ; boundNames [ <NUM_LIT:0> ] = CharOperation . concatWith ( firstBound . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; for ( int j = <NUM_LIT:0> ; j < otherBoundsLength ; j ++ ) { boundNames [ j + <NUM_LIT:1> ] = CharOperation . concatWith ( otherBounds [ j ] . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; } typeParameterBounds = boundNames ; } else { typeParameterBounds = new char [ ] [ ] { CharOperation . concatWith ( firstBound . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) } ; } } else { typeParameterBounds = CharOperation . NO_CHAR_CHAR ; } return typeParameterBounds ; } private TypeParameterInfo [ ] getTypeParameterInfos ( TypeParameter [ ] typeParameters ) { if ( typeParameters == null ) return null ; int typeParametersLength = typeParameters . length ; TypeParameterInfo [ ] result = new TypeParameterInfo [ typeParametersLength ] ; for ( int i = <NUM_LIT:0> ; i < typeParametersLength ; i ++ ) { TypeParameter typeParameter = typeParameters [ i ] ; char [ ] [ ] typeParameterBounds = getTypeParameterBounds ( typeParameter ) ; ISourceElementRequestor . TypeParameterInfo typeParameterInfo = new ISourceElementRequestor . TypeParameterInfo ( ) ; typeParameterInfo . declarationStart = typeParameter . declarationSourceStart ; typeParameterInfo . declarationEnd = typeParameter . declarationSourceEnd ; typeParameterInfo . name = typeParameter . name ; typeParameterInfo . nameSourceStart = typeParameter . sourceStart ; typeParameterInfo . nameSourceEnd = typeParameter . sourceEnd ; typeParameterInfo . bounds = typeParameterBounds ; result [ i ] = typeParameterInfo ; } return result ; } private boolean hasDeprecatedAnnotation ( Annotation [ ] annotations ) { if ( annotations != null ) { for ( int i = <NUM_LIT:0> , length = annotations . length ; i < length ; i ++ ) { Annotation annotation = annotations [ i ] ; if ( CharOperation . equals ( annotation . type . getLastToken ( ) , TypeConstants . JAVA_LANG_DEPRECATED [ <NUM_LIT:2> ] ) ) { return true ; } } } return false ; } protected void notifySourceElementRequestor ( AbstractMethodDeclaration methodDeclaration , TypeDeclaration declaringType , ImportReference currentPackage ) { boolean isInRange = this . initialPosition <= methodDeclaration . declarationSourceStart && this . eofPosition >= methodDeclaration . declarationSourceEnd ; if ( methodDeclaration . isClinit ( ) ) { this . visitIfNeeded ( methodDeclaration ) ; return ; } if ( methodDeclaration . isDefaultConstructor ( ) ) { if ( this . reportReferenceInfo ) { ConstructorDeclaration constructorDeclaration = ( ConstructorDeclaration ) methodDeclaration ; ExplicitConstructorCall constructorCall = constructorDeclaration . constructorCall ; if ( constructorCall != null ) { switch ( constructorCall . accessMode ) { case ExplicitConstructorCall . This : this . requestor . acceptConstructorReference ( this . typeNames [ this . nestedTypeIndex - <NUM_LIT:1> ] , constructorCall . arguments == null ? <NUM_LIT:0> : constructorCall . arguments . length , constructorCall . sourceStart ) ; break ; case ExplicitConstructorCall . Super : case ExplicitConstructorCall . ImplicitSuper : this . requestor . acceptConstructorReference ( this . superTypeNames [ this . nestedTypeIndex - <NUM_LIT:1> ] , constructorCall . arguments == null ? <NUM_LIT:0> : constructorCall . arguments . length , constructorCall . sourceStart ) ; break ; } } } return ; } char [ ] [ ] argumentTypes = null ; char [ ] [ ] argumentNames = null ; boolean isVarArgs = false ; Argument [ ] arguments = methodDeclaration . arguments ; ParameterInfo [ ] parameterInfos = null ; if ( arguments != null ) { Object [ ] [ ] argumentInfos = getArgumentInfos ( arguments ) ; parameterInfos = ( ParameterInfo [ ] ) argumentInfos [ <NUM_LIT:0> ] ; argumentTypes = ( char [ ] [ ] ) argumentInfos [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] ; argumentNames = ( char [ ] [ ] ) argumentInfos [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ; isVarArgs = arguments [ arguments . length - <NUM_LIT:1> ] . isVarArgs ( ) ; } char [ ] [ ] thrownExceptionTypes = getThrownExceptions ( methodDeclaration ) ; int selectorSourceEnd = - <NUM_LIT:1> ; if ( methodDeclaration . isConstructor ( ) ) { selectorSourceEnd = this . sourceEnds . get ( methodDeclaration ) ; if ( isInRange ) { int currentModifiers = methodDeclaration . modifiers ; if ( isVarArgs ) currentModifiers |= ClassFileConstants . AccVarargs ; boolean deprecated = ( currentModifiers & ClassFileConstants . AccDeprecated ) != <NUM_LIT:0> || hasDeprecatedAnnotation ( methodDeclaration . annotations ) ; ISourceElementRequestor . MethodInfo methodInfo = new ISourceElementRequestor . MethodInfo ( ) ; methodInfo . isConstructor = true ; methodInfo . declarationStart = methodDeclaration . declarationSourceStart ; methodInfo . modifiers = deprecated ? ( currentModifiers & ExtraCompilerModifiers . AccJustFlag ) | ClassFileConstants . AccDeprecated : currentModifiers & ExtraCompilerModifiers . AccJustFlag ; methodInfo . name = methodDeclaration . selector ; methodInfo . nameSourceStart = methodDeclaration . sourceStart ; methodInfo . nameSourceEnd = selectorSourceEnd ; methodInfo . parameterTypes = argumentTypes ; methodInfo . parameterNames = argumentNames ; methodInfo . exceptionTypes = thrownExceptionTypes ; methodInfo . typeParameters = getTypeParameterInfos ( methodDeclaration . typeParameters ( ) ) ; methodInfo . parameterInfos = parameterInfos ; methodInfo . categories = ( char [ ] [ ] ) this . nodesToCategories . get ( methodDeclaration ) ; methodInfo . annotations = methodDeclaration . annotations ; methodInfo . declaringPackageName = currentPackage == null ? CharOperation . NO_CHAR : CharOperation . concatWith ( currentPackage . tokens , '<CHAR_LIT:.>' ) ; methodInfo . declaringTypeModifiers = declaringType . modifiers ; methodInfo . extraFlags = ExtraFlags . getExtraFlags ( declaringType ) ; methodInfo . node = methodDeclaration ; this . requestor . enterConstructor ( methodInfo ) ; } if ( this . reportReferenceInfo ) { ConstructorDeclaration constructorDeclaration = ( ConstructorDeclaration ) methodDeclaration ; ExplicitConstructorCall constructorCall = constructorDeclaration . constructorCall ; if ( constructorCall != null ) { switch ( constructorCall . accessMode ) { case ExplicitConstructorCall . This : this . requestor . acceptConstructorReference ( this . typeNames [ this . nestedTypeIndex - <NUM_LIT:1> ] , constructorCall . arguments == null ? <NUM_LIT:0> : constructorCall . arguments . length , constructorCall . sourceStart ) ; break ; case ExplicitConstructorCall . Super : case ExplicitConstructorCall . ImplicitSuper : this . requestor . acceptConstructorReference ( this . superTypeNames [ this . nestedTypeIndex - <NUM_LIT:1> ] , constructorCall . arguments == null ? <NUM_LIT:0> : constructorCall . arguments . length , constructorCall . sourceStart ) ; break ; } } } this . visitIfNeeded ( methodDeclaration ) ; if ( isInRange ) { this . requestor . exitConstructor ( methodDeclaration . declarationSourceEnd ) ; } return ; } selectorSourceEnd = this . sourceEnds . get ( methodDeclaration ) ; if ( isInRange ) { int currentModifiers = methodDeclaration . modifiers ; if ( isVarArgs ) currentModifiers |= ClassFileConstants . AccVarargs ; boolean deprecated = ( currentModifiers & ClassFileConstants . AccDeprecated ) != <NUM_LIT:0> || hasDeprecatedAnnotation ( methodDeclaration . annotations ) ; TypeReference returnType = methodDeclaration instanceof MethodDeclaration ? ( ( MethodDeclaration ) methodDeclaration ) . returnType : null ; ISourceElementRequestor . MethodInfo methodInfo = new ISourceElementRequestor . MethodInfo ( ) ; methodInfo . isAnnotation = methodDeclaration instanceof AnnotationMethodDeclaration ; methodInfo . declarationStart = methodDeclaration . declarationSourceStart ; methodInfo . modifiers = deprecated ? ( currentModifiers & ExtraCompilerModifiers . AccJustFlag ) | ClassFileConstants . AccDeprecated : currentModifiers & ExtraCompilerModifiers . AccJustFlag ; methodInfo . returnType = returnType == null ? null : CharOperation . concatWith ( returnType . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; methodInfo . name = methodDeclaration . selector ; methodInfo . nameSourceStart = methodDeclaration . sourceStart ; methodInfo . nameSourceEnd = selectorSourceEnd ; methodInfo . parameterTypes = argumentTypes ; methodInfo . parameterNames = argumentNames ; methodInfo . exceptionTypes = thrownExceptionTypes ; methodInfo . typeParameters = getTypeParameterInfos ( methodDeclaration . typeParameters ( ) ) ; methodInfo . parameterInfos = parameterInfos ; methodInfo . categories = ( char [ ] [ ] ) this . nodesToCategories . get ( methodDeclaration ) ; methodInfo . annotations = methodDeclaration . annotations ; methodInfo . node = methodDeclaration ; this . requestor . enterMethod ( methodInfo ) ; } this . visitIfNeeded ( methodDeclaration ) ; if ( isInRange ) { if ( methodDeclaration instanceof AnnotationMethodDeclaration ) { AnnotationMethodDeclaration annotationMethodDeclaration = ( AnnotationMethodDeclaration ) methodDeclaration ; Expression expression = annotationMethodDeclaration . defaultValue ; if ( expression != null ) { this . requestor . exitMethod ( methodDeclaration . declarationSourceEnd , expression ) ; return ; } } this . requestor . exitMethod ( methodDeclaration . declarationSourceEnd , null ) ; } } public void notifySourceElementRequestor ( CompilationUnitDeclaration parsedUnit , int sourceStart , int sourceEnd , boolean reportReference , HashtableOfObjectToInt sourceEndsMap , Map nodesToCategoriesMap ) { this . initialPosition = sourceStart ; this . eofPosition = sourceEnd ; this . reportReferenceInfo = reportReference ; this . sourceEnds = sourceEndsMap ; this . nodesToCategories = nodesToCategoriesMap ; try { boolean isInRange = this . initialPosition <= parsedUnit . sourceStart && this . eofPosition >= parsedUnit . sourceEnd ; int length = <NUM_LIT:0> ; ASTNode [ ] nodes = null ; if ( isInRange ) { this . requestor . enterCompilationUnit ( ) ; } ImportReference currentPackage = parsedUnit . currentPackage ; if ( this . localDeclarationVisitor != null ) { this . localDeclarationVisitor . currentPackage = currentPackage ; } ImportReference [ ] imports = parsedUnit . imports ; TypeDeclaration [ ] types = parsedUnit . types ; length = ( currentPackage == null ? <NUM_LIT:0> : <NUM_LIT:1> ) + ( imports == null ? <NUM_LIT:0> : imports . length ) + ( types == null ? <NUM_LIT:0> : types . length ) ; nodes = new ASTNode [ length ] ; int index = <NUM_LIT:0> ; if ( currentPackage != null ) { nodes [ index ++ ] = currentPackage ; } if ( imports != null ) { for ( int i = <NUM_LIT:0> , max = imports . length ; i < max ; i ++ ) { nodes [ index ++ ] = imports [ i ] ; } } if ( types != null ) { for ( int i = <NUM_LIT:0> , max = types . length ; i < max ; i ++ ) { nodes [ index ++ ] = types [ i ] ; } } if ( length > <NUM_LIT:0> ) { quickSort ( nodes , <NUM_LIT:0> , length - <NUM_LIT:1> ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ASTNode node = nodes [ i ] ; if ( node instanceof ImportReference ) { ImportReference importRef = ( ImportReference ) node ; if ( node == parsedUnit . currentPackage ) { notifySourceElementRequestor ( importRef , true ) ; } else { notifySourceElementRequestor ( importRef , false ) ; } } else { notifySourceElementRequestor ( ( TypeDeclaration ) node , true , null , currentPackage ) ; } } } if ( isInRange ) { this . requestor . exitCompilationUnit ( parsedUnit . sourceEnd ) ; } } finally { reset ( ) ; } } protected void notifySourceElementRequestor ( FieldDeclaration fieldDeclaration , TypeDeclaration declaringType ) { boolean isInRange = this . initialPosition <= fieldDeclaration . declarationSourceStart && this . eofPosition >= fieldDeclaration . declarationSourceEnd ; switch ( fieldDeclaration . getKind ( ) ) { case AbstractVariableDeclaration . ENUM_CONSTANT : if ( this . reportReferenceInfo ) { if ( fieldDeclaration . initialization instanceof AllocationExpression ) { AllocationExpression alloc = ( AllocationExpression ) fieldDeclaration . initialization ; this . requestor . acceptConstructorReference ( declaringType . name , alloc . arguments == null ? <NUM_LIT:0> : alloc . arguments . length , alloc . sourceStart ) ; } } case AbstractVariableDeclaration . FIELD : int fieldEndPosition = this . sourceEnds . get ( fieldDeclaration ) ; if ( fieldEndPosition == - <NUM_LIT:1> ) { fieldEndPosition = fieldDeclaration . declarationSourceEnd ; } if ( isInRange ) { int currentModifiers = fieldDeclaration . modifiers ; boolean deprecated = ( currentModifiers & ClassFileConstants . AccDeprecated ) != <NUM_LIT:0> || hasDeprecatedAnnotation ( fieldDeclaration . annotations ) ; char [ ] typeName = null ; if ( fieldDeclaration . type == null ) { typeName = declaringType . name ; currentModifiers |= ClassFileConstants . AccEnum ; } else { typeName = CharOperation . concatWith ( fieldDeclaration . type . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; } ISourceElementRequestor . FieldInfo fieldInfo = new ISourceElementRequestor . FieldInfo ( ) ; fieldInfo . declarationStart = fieldDeclaration . declarationSourceStart ; fieldInfo . name = fieldDeclaration . name ; fieldInfo . modifiers = deprecated ? ( currentModifiers & ExtraCompilerModifiers . AccJustFlag ) | ClassFileConstants . AccDeprecated : currentModifiers & ExtraCompilerModifiers . AccJustFlag ; fieldInfo . type = typeName ; fieldInfo . nameSourceStart = fieldDeclaration . sourceStart ; fieldInfo . nameSourceEnd = fieldDeclaration . sourceEnd ; fieldInfo . categories = ( char [ ] [ ] ) this . nodesToCategories . get ( fieldDeclaration ) ; fieldInfo . annotations = fieldDeclaration . annotations ; fieldInfo . node = fieldDeclaration ; this . requestor . enterField ( fieldInfo ) ; } this . visitIfNeeded ( fieldDeclaration , declaringType ) ; if ( isInRange ) { this . requestor . exitField ( ( fieldDeclaration . initialization == null || fieldDeclaration . initialization instanceof ArrayInitializer || fieldDeclaration . initialization instanceof AllocationExpression || fieldDeclaration . initialization instanceof ArrayAllocationExpression || fieldDeclaration . initialization instanceof Assignment || fieldDeclaration . initialization instanceof ClassLiteralAccess || fieldDeclaration . initialization instanceof MessageSend || fieldDeclaration . initialization instanceof ArrayReference || fieldDeclaration . initialization instanceof ThisReference ) ? - <NUM_LIT:1> : fieldDeclaration . initialization . sourceStart , fieldEndPosition , fieldDeclaration . declarationSourceEnd ) ; } break ; case AbstractVariableDeclaration . INITIALIZER : if ( isInRange ) { this . requestor . enterInitializer ( fieldDeclaration . declarationSourceStart , fieldDeclaration . modifiers ) ; } this . visitIfNeeded ( ( Initializer ) fieldDeclaration ) ; if ( isInRange ) { this . requestor . exitInitializer ( fieldDeclaration . declarationSourceEnd ) ; } break ; } } protected void notifySourceElementRequestor ( ImportReference importReference , boolean isPackage ) { if ( isPackage ) { this . requestor . acceptPackage ( importReference ) ; } else { final boolean onDemand = ( importReference . bits & ASTNode . OnDemand ) != <NUM_LIT:0> ; this . requestor . acceptImport ( importReference . declarationSourceStart , importReference . declarationSourceEnd , importReference . sourceStart , onDemand ? importReference . trailingStarPosition : importReference . sourceEnd , importReference . tokens , onDemand , importReference . modifiers ) ; } } protected void notifySourceElementRequestor ( TypeDeclaration typeDeclaration , boolean notifyTypePresence , TypeDeclaration declaringType , ImportReference currentPackage ) { if ( CharOperation . equals ( TypeConstants . PACKAGE_INFO_NAME , typeDeclaration . name ) ) return ; boolean isInRange = this . initialPosition <= typeDeclaration . declarationSourceStart && this . eofPosition >= typeDeclaration . declarationSourceEnd ; FieldDeclaration [ ] fields = typeDeclaration . fields ; AbstractMethodDeclaration [ ] methods = typeDeclaration . methods ; TypeDeclaration [ ] memberTypes = typeDeclaration . memberTypes ; int fieldCounter = fields == null ? <NUM_LIT:0> : fields . length ; int methodCounter = methods == null ? <NUM_LIT:0> : methods . length ; int memberTypeCounter = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; int fieldIndex = <NUM_LIT:0> ; int methodIndex = <NUM_LIT:0> ; int memberTypeIndex = <NUM_LIT:0> ; if ( notifyTypePresence ) { char [ ] [ ] interfaceNames = getInterfaceNames ( typeDeclaration ) ; int kind = TypeDeclaration . kind ( typeDeclaration . modifiers ) ; char [ ] implicitSuperclassName = TypeConstants . CharArray_JAVA_LANG_OBJECT ; if ( isInRange ) { int currentModifiers = typeDeclaration . modifiers ; boolean deprecated = ( currentModifiers & ClassFileConstants . AccDeprecated ) != <NUM_LIT:0> || hasDeprecatedAnnotation ( typeDeclaration . annotations ) ; boolean isEnumInit = typeDeclaration . allocation != null && typeDeclaration . allocation . enumConstant != null ; char [ ] superclassName ; if ( isEnumInit ) { currentModifiers |= ClassFileConstants . AccEnum ; superclassName = declaringType . name ; } else { superclassName = getSuperclassName ( typeDeclaration ) ; } ISourceElementRequestor . TypeInfo typeInfo = new ISourceElementRequestor . TypeInfo ( ) ; if ( typeDeclaration . allocation == null ) { typeInfo . declarationStart = typeDeclaration . declarationSourceStart ; } else if ( isEnumInit ) { typeInfo . declarationStart = typeDeclaration . allocation . enumConstant . sourceStart ; } else { typeInfo . declarationStart = typeDeclaration . allocation . sourceStart ; } typeInfo . modifiers = deprecated ? ( currentModifiers & ExtraCompilerModifiers . AccJustFlag ) | ClassFileConstants . AccDeprecated : currentModifiers & ExtraCompilerModifiers . AccJustFlag ; typeInfo . name = typeDeclaration . name ; typeInfo . nameSourceStart = isEnumInit ? typeDeclaration . allocation . enumConstant . sourceStart : typeDeclaration . sourceStart ; typeInfo . nameSourceEnd = sourceEnd ( typeDeclaration ) ; typeInfo . superclass = superclassName ; typeInfo . superinterfaces = interfaceNames ; typeInfo . typeParameters = getTypeParameterInfos ( typeDeclaration . typeParameters ) ; typeInfo . categories = ( char [ ] [ ] ) this . nodesToCategories . get ( typeDeclaration ) ; typeInfo . secondary = typeDeclaration . isSecondary ( ) ; typeInfo . anonymousMember = typeDeclaration . allocation != null && typeDeclaration . allocation . enclosingInstance != null ; typeInfo . annotations = typeDeclaration . annotations ; typeInfo . extraFlags = ExtraFlags . getExtraFlags ( typeDeclaration ) ; typeInfo . node = typeDeclaration ; this . requestor . enterType ( typeInfo ) ; switch ( kind ) { case TypeDeclaration . CLASS_DECL : if ( superclassName != null ) implicitSuperclassName = superclassName ; break ; case TypeDeclaration . INTERFACE_DECL : implicitSuperclassName = TypeConstants . CharArray_JAVA_LANG_OBJECT ; break ; case TypeDeclaration . ENUM_DECL : implicitSuperclassName = TypeConstants . CharArray_JAVA_LANG_ENUM ; break ; case TypeDeclaration . ANNOTATION_TYPE_DECL : implicitSuperclassName = TypeConstants . CharArray_JAVA_LANG_ANNOTATION_ANNOTATION ; break ; } } if ( this . nestedTypeIndex == this . typeNames . length ) { System . arraycopy ( this . typeNames , <NUM_LIT:0> , ( this . typeNames = new char [ this . nestedTypeIndex * <NUM_LIT:2> ] [ ] ) , <NUM_LIT:0> , this . nestedTypeIndex ) ; System . arraycopy ( this . superTypeNames , <NUM_LIT:0> , ( this . superTypeNames = new char [ this . nestedTypeIndex * <NUM_LIT:2> ] [ ] ) , <NUM_LIT:0> , this . nestedTypeIndex ) ; } this . typeNames [ this . nestedTypeIndex ] = typeDeclaration . name ; this . superTypeNames [ this . nestedTypeIndex ++ ] = implicitSuperclassName ; } while ( ( fieldIndex < fieldCounter ) || ( memberTypeIndex < memberTypeCounter ) || ( methodIndex < methodCounter ) ) { FieldDeclaration nextFieldDeclaration = null ; AbstractMethodDeclaration nextMethodDeclaration = null ; TypeDeclaration nextMemberDeclaration = null ; int position = Integer . MAX_VALUE ; int nextDeclarationType = - <NUM_LIT:1> ; if ( fieldIndex < fieldCounter ) { nextFieldDeclaration = fields [ fieldIndex ] ; if ( nextFieldDeclaration . declarationSourceStart < position ) { position = nextFieldDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:0> ; } } if ( methodIndex < methodCounter ) { nextMethodDeclaration = methods [ methodIndex ] ; if ( nextMethodDeclaration . declarationSourceStart < position ) { position = nextMethodDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:1> ; } } if ( memberTypeIndex < memberTypeCounter ) { nextMemberDeclaration = memberTypes [ memberTypeIndex ] ; if ( nextMemberDeclaration . declarationSourceStart < position ) { position = nextMemberDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:2> ; } } switch ( nextDeclarationType ) { case <NUM_LIT:0> : fieldIndex ++ ; notifySourceElementRequestor ( nextFieldDeclaration , typeDeclaration ) ; break ; case <NUM_LIT:1> : methodIndex ++ ; notifySourceElementRequestor ( nextMethodDeclaration , typeDeclaration , currentPackage ) ; break ; case <NUM_LIT:2> : memberTypeIndex ++ ; notifySourceElementRequestor ( nextMemberDeclaration , true , null , currentPackage ) ; } } if ( notifyTypePresence ) { if ( isInRange ) { this . requestor . exitType ( typeDeclaration . declarationSourceEnd ) ; } this . nestedTypeIndex -- ; } } private static void quickSort ( ASTNode [ ] sortedCollection , int left , int right ) { int original_left = left ; int original_right = right ; ASTNode mid = sortedCollection [ left + ( right - left ) / <NUM_LIT:2> ] ; do { while ( sortedCollection [ left ] . sourceStart < mid . sourceStart ) { left ++ ; } while ( mid . sourceStart < sortedCollection [ right ] . sourceStart ) { right -- ; } if ( left <= right ) { ASTNode tmp = sortedCollection [ left ] ; sortedCollection [ left ] = sortedCollection [ right ] ; sortedCollection [ right ] = tmp ; left ++ ; right -- ; } } while ( left <= right ) ; if ( original_left < right ) { quickSort ( sortedCollection , original_left , right ) ; } if ( left < original_right ) { quickSort ( sortedCollection , left , original_right ) ; } } private void reset ( ) { this . typeNames = new char [ <NUM_LIT:4> ] [ ] ; this . superTypeNames = new char [ <NUM_LIT:4> ] [ ] ; this . nestedTypeIndex = <NUM_LIT:0> ; this . sourceEnds = null ; } private int sourceEnd ( TypeDeclaration typeDeclaration ) { if ( ( typeDeclaration . bits & ASTNode . IsAnonymousType ) != <NUM_LIT:0> ) { QualifiedAllocationExpression allocation = typeDeclaration . allocation ; if ( allocation . enumConstant != null ) return allocation . enumConstant . sourceEnd ; return allocation . type . sourceEnd ; } else { return typeDeclaration . sourceEnd ; } } private void visitIfNeeded ( AbstractMethodDeclaration method ) { if ( this . localDeclarationVisitor != null && ( method . bits & ASTNode . HasLocalType ) != <NUM_LIT:0> ) { if ( method instanceof ConstructorDeclaration ) { ConstructorDeclaration constructorDeclaration = ( ConstructorDeclaration ) method ; if ( constructorDeclaration . constructorCall != null ) { constructorDeclaration . constructorCall . traverse ( this . localDeclarationVisitor , method . scope ) ; } } if ( method . statements != null ) { int statementsLength = method . statements . length ; for ( int i = <NUM_LIT:0> ; i < statementsLength ; i ++ ) method . statements [ i ] . traverse ( this . localDeclarationVisitor , method . scope ) ; } } } private void visitIfNeeded ( FieldDeclaration field , TypeDeclaration declaringType ) { if ( this . localDeclarationVisitor != null && ( field . bits & ASTNode . HasLocalType ) != <NUM_LIT:0> ) { if ( field . initialization != null ) { try { this . localDeclarationVisitor . pushDeclaringType ( declaringType ) ; field . initialization . traverse ( this . localDeclarationVisitor , ( MethodScope ) null ) ; } finally { this . localDeclarationVisitor . popDeclaringType ( ) ; } } } } private void visitIfNeeded ( Initializer initializer ) { if ( this . localDeclarationVisitor != null && ( initializer . bits & ASTNode . HasLocalType ) != <NUM_LIT:0> ) { if ( initializer . block != null ) { initializer . block . traverse ( this . localDeclarationVisitor , null ) ; } } } } </s>
|
<s> package org . eclipse . jdt . core ; public interface ISourceReference { boolean exists ( ) ; String getSource ( ) throws JavaModelException ; ISourceRange getSourceRange ( ) throws JavaModelException ; ISourceRange getNameRange ( ) throws JavaModelException ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; public final class Flags { public static final int AccDefault = ClassFileConstants . AccDefault ; public static final int AccPublic = ClassFileConstants . AccPublic ; public static final int AccPrivate = ClassFileConstants . AccPrivate ; public static final int AccProtected = ClassFileConstants . AccProtected ; public static final int AccStatic = ClassFileConstants . AccStatic ; public static final int AccFinal = ClassFileConstants . AccFinal ; public static final int AccSynchronized = ClassFileConstants . AccSynchronized ; public static final int AccVolatile = ClassFileConstants . AccVolatile ; public static final int AccTransient = ClassFileConstants . AccTransient ; public static final int AccNative = ClassFileConstants . AccNative ; public static final int AccInterface = ClassFileConstants . AccInterface ; public static final int AccAbstract = ClassFileConstants . AccAbstract ; public static final int AccStrictfp = ClassFileConstants . AccStrictfp ; public static final int AccSuper = ClassFileConstants . AccSuper ; public static final int AccSynthetic = ClassFileConstants . AccSynthetic ; public static final int AccDeprecated = ClassFileConstants . AccDeprecated ; public static final int AccBridge = ClassFileConstants . AccBridge ; public static final int AccVarargs = ClassFileConstants . AccVarargs ; public static final int AccEnum = ClassFileConstants . AccEnum ; public static final int AccAnnotation = ClassFileConstants . AccAnnotation ; private Flags ( ) { } public static boolean isAbstract ( int flags ) { return ( flags & AccAbstract ) != <NUM_LIT:0> ; } public static boolean isDeprecated ( int flags ) { return ( flags & AccDeprecated ) != <NUM_LIT:0> ; } public static boolean isFinal ( int flags ) { return ( flags & AccFinal ) != <NUM_LIT:0> ; } public static boolean isInterface ( int flags ) { return ( flags & AccInterface ) != <NUM_LIT:0> ; } public static boolean isNative ( int flags ) { return ( flags & AccNative ) != <NUM_LIT:0> ; } public static boolean isPackageDefault ( int flags ) { return ( flags & ( AccPublic | AccPrivate | AccProtected ) ) == <NUM_LIT:0> ; } public static boolean isPrivate ( int flags ) { return ( flags & AccPrivate ) != <NUM_LIT:0> ; } public static boolean isProtected ( int flags ) { return ( flags & AccProtected ) != <NUM_LIT:0> ; } public static boolean isPublic ( int flags ) { return ( flags & AccPublic ) != <NUM_LIT:0> ; } public static boolean isStatic ( int flags ) { return ( flags & AccStatic ) != <NUM_LIT:0> ; } public static boolean isSuper ( int flags ) { return ( flags & AccSuper ) != <NUM_LIT:0> ; } public static boolean isStrictfp ( int flags ) { return ( flags & AccStrictfp ) != <NUM_LIT:0> ; } public static boolean isSynchronized ( int flags ) { return ( flags & AccSynchronized ) != <NUM_LIT:0> ; } public static boolean isSynthetic ( int flags ) { return ( flags & AccSynthetic ) != <NUM_LIT:0> ; } public static boolean isTransient ( int flags ) { return ( flags & AccTransient ) != <NUM_LIT:0> ; } public static boolean isVolatile ( int flags ) { return ( flags & AccVolatile ) != <NUM_LIT:0> ; } public static boolean isBridge ( int flags ) { return ( flags & AccBridge ) != <NUM_LIT:0> ; } public static boolean isVarargs ( int flags ) { return ( flags & AccVarargs ) != <NUM_LIT:0> ; } public static boolean isEnum ( int flags ) { return ( flags & AccEnum ) != <NUM_LIT:0> ; } public static boolean isAnnotation ( int flags ) { return ( flags & AccAnnotation ) != <NUM_LIT:0> ; } public static String toString ( int flags ) { StringBuffer sb = new StringBuffer ( ) ; if ( isPublic ( flags ) ) sb . append ( "<STR_LIT>" ) ; if ( isProtected ( flags ) ) sb . append ( "<STR_LIT>" ) ; if ( isPrivate ( flags ) ) sb . append ( "<STR_LIT>" ) ; if ( isStatic ( flags ) ) sb . append ( "<STR_LIT>" ) ; if ( isAbstract ( flags ) ) sb . append ( "<STR_LIT>" ) ; if ( isFinal ( flags ) ) sb . append ( "<STR_LIT>" ) ; if ( isNative ( flags ) ) sb . append ( "<STR_LIT>" ) ; if ( isSynchronized ( flags ) ) sb . append ( "<STR_LIT>" ) ; if ( isTransient ( flags ) ) sb . append ( "<STR_LIT>" ) ; if ( isVolatile ( flags ) ) sb . append ( "<STR_LIT>" ) ; if ( isStrictfp ( flags ) ) sb . append ( "<STR_LIT>" ) ; int len = sb . length ( ) ; if ( len == <NUM_LIT:0> ) return "<STR_LIT>" ; sb . setLength ( len - <NUM_LIT:1> ) ; return sb . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . core ; public interface ISourceRange { int getLength ( ) ; int getOffset ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; public interface ITypeHierarchyChangedListener { void typeHierarchyChanged ( ITypeHierarchy typeHierarchy ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; public interface IPackageFragmentRoot extends IParent , IJavaElement , IOpenable { int K_SOURCE = <NUM_LIT:1> ; int K_BINARY = <NUM_LIT:2> ; String DEFAULT_PACKAGEROOT_PATH = "<STR_LIT>" ; int NO_RESOURCE_MODIFICATION = <NUM_LIT:1> ; int ORIGINATING_PROJECT_CLASSPATH = <NUM_LIT:2> ; int OTHER_REFERRING_PROJECTS_CLASSPATH = <NUM_LIT:4> ; int DESTINATION_PROJECT_CLASSPATH = <NUM_LIT:8> ; int REPLACE = <NUM_LIT:16> ; void attachSource ( IPath sourcePath , IPath rootPath , IProgressMonitor monitor ) throws JavaModelException ; void copy ( IPath destination , int updateResourceFlags , int updateModelFlags , IClasspathEntry sibling , IProgressMonitor monitor ) throws JavaModelException ; IPackageFragment createPackageFragment ( String name , boolean force , IProgressMonitor monitor ) throws JavaModelException ; void delete ( int updateResourceFlags , int updateModelFlags , IProgressMonitor monitor ) throws JavaModelException ; int getKind ( ) throws JavaModelException ; Object [ ] getNonJavaResources ( ) throws JavaModelException ; IPackageFragment getPackageFragment ( String packageName ) ; IClasspathEntry getRawClasspathEntry ( ) throws JavaModelException ; IClasspathEntry getResolvedClasspathEntry ( ) throws JavaModelException ; IPath getSourceAttachmentPath ( ) throws JavaModelException ; IPath getSourceAttachmentRootPath ( ) throws JavaModelException ; public boolean isArchive ( ) ; boolean isExternal ( ) ; void move ( IPath destination , int updateResourceFlags , int updateModelFlags , IClasspathEntry sibling , IProgressMonitor monitor ) throws JavaModelException ; } </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 ; public interface IPackageDeclaration extends IJavaElement , ISourceReference , IAnnotatable { String getElementName ( ) ; } </s>
|
<s> package org . eclipse . jdt . core ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . core . BufferManager ; import org . eclipse . jdt . internal . core . CompilationUnit ; import org . eclipse . jdt . internal . core . DefaultWorkingCopyOwner ; import org . eclipse . jdt . internal . core . ExternalJavaProject ; import org . eclipse . jdt . internal . core . PackageFragment ; import org . eclipse . jdt . internal . core . PackageFragmentRoot ; public abstract class WorkingCopyOwner { public static void setPrimaryBufferProvider ( WorkingCopyOwner primaryBufferProvider ) { DefaultWorkingCopyOwner . PRIMARY . primaryBufferProvider = primaryBufferProvider ; } public IBuffer createBuffer ( ICompilationUnit workingCopy ) { return BufferManager . createBuffer ( workingCopy ) ; } public IProblemRequestor getProblemRequestor ( ICompilationUnit workingCopy ) { return null ; } public String findSource ( String typeName , String packageName ) { return null ; } public boolean isPackage ( String [ ] pkg ) { return false ; } public final ICompilationUnit newWorkingCopy ( String name , IClasspathEntry [ ] classpath , IProblemRequestor problemRequestor , IProgressMonitor monitor ) throws JavaModelException { ExternalJavaProject project = new ExternalJavaProject ( classpath ) ; IPackageFragment parent = ( ( PackageFragmentRoot ) project . getPackageFragmentRoot ( project . getProject ( ) ) ) . getPackageFragment ( CharOperation . NO_STRINGS ) ; CompilationUnit result = LanguageSupportFactory . newCompilationUnit ( ( PackageFragment ) parent , name , this ) ; result . becomeWorkingCopy ( problemRequestor , monitor ) ; return result ; } public final ICompilationUnit newWorkingCopy ( String name , IClasspathEntry [ ] classpath , IProgressMonitor monitor ) throws JavaModelException { ExternalJavaProject project = new ExternalJavaProject ( classpath ) ; IPackageFragment parent = ( ( PackageFragmentRoot ) project . getPackageFragmentRoot ( project . getProject ( ) ) ) . getPackageFragment ( CharOperation . NO_STRINGS ) ; CompilationUnit result = LanguageSupportFactory . newCompilationUnit ( ( PackageFragment ) parent , name , this ) ; result . becomeWorkingCopy ( getProblemRequestor ( result ) , monitor ) ; return result ; } } </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 ; 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 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 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>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.