text
stringlengths 30
1.67M
|
|---|
<s> package org . eclipse . jdt . internal . codeassist . complete ; public interface CompletionOnKeyword { char [ ] getToken ( ) ; char [ ] [ ] getPossibleKeywords ( ) ; boolean canCompleteEmptyToken ( ) ; } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; public class CompletionOnQualifiedNameReference extends QualifiedNameReference { public char [ ] completionIdentifier ; public boolean isInsideAnnotationAttribute ; public CompletionOnQualifiedNameReference ( char [ ] [ ] previousIdentifiers , char [ ] completionIdentifier , long [ ] positions , boolean isInsideAnnotationAttribute ) { super ( previousIdentifiers , positions , ( int ) ( positions [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) , ( int ) positions [ positions . length - <NUM_LIT:1> ] ) ; this . completionIdentifier = completionIdentifier ; this . isInsideAnnotationAttribute = isInsideAnnotationAttribute ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < this . tokens . length ; i ++ ) { output . append ( this . tokens [ i ] ) ; output . append ( '<CHAR_LIT:.>' ) ; } output . append ( this . completionIdentifier ) . append ( '<CHAR_LIT:>>' ) ; return output ; } public TypeBinding resolveType ( BlockScope scope ) { this . binding = scope . getBinding ( this . tokens , this ) ; if ( ! this . binding . isValidBinding ( ) ) { if ( this . binding instanceof ProblemFieldBinding ) { scope . problemReporter ( ) . invalidField ( this , ( FieldBinding ) this . binding ) ; } else if ( this . binding instanceof ProblemReferenceBinding || this . binding instanceof MissingTypeBinding ) { scope . problemReporter ( ) . invalidType ( this , ( TypeBinding ) this . binding ) ; } else { scope . problemReporter ( ) . unresolvableReference ( this , this . binding ) ; } if ( this . binding . problemId ( ) == ProblemReasons . NotFound ) { throw new CompletionNodeFound ( this , this . binding , scope ) ; } throw new CompletionNodeFound ( ) ; } throw new CompletionNodeFound ( this , this . binding , scope ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . JavadocSingleTypeReference ; public class CompletionOnJavadocSingleTypeReference extends JavadocSingleTypeReference implements CompletionOnJavadoc { public int completionFlags = JAVADOC ; public CompletionOnJavadocSingleTypeReference ( char [ ] source , long pos , int tagStart , int tagEnd ) { super ( source , pos , tagStart , tagEnd ) ; } public CompletionOnJavadocSingleTypeReference ( JavadocSingleTypeReference typeRef ) { super ( typeRef . token , ( ( ( long ) typeRef . sourceStart ) << <NUM_LIT:32> ) + typeRef . sourceEnd , typeRef . tagSourceStart , typeRef . tagSourceStart ) ; } public void addCompletionFlags ( int flags ) { this . completionFlags |= flags ; } public boolean completeAnException ( ) { return ( this . completionFlags & EXCEPTION ) != <NUM_LIT:0> ; } public boolean completeInText ( ) { return ( this . completionFlags & TEXT ) != <NUM_LIT:0> ; } public boolean completeBaseTypes ( ) { return ( this . completionFlags & BASE_TYPES ) != <NUM_LIT:0> ; } public boolean completeFormalReference ( ) { return ( this . completionFlags & FORMAL_REFERENCE ) != <NUM_LIT:0> ; } public int getCompletionFlags ( ) { return this . completionFlags ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; super . printExpression ( indent , output ) ; indent ++ ; if ( this . completionFlags > <NUM_LIT:0> ) { output . append ( '<STR_LIT:\n>' ) ; for ( int i = <NUM_LIT:0> ; i < indent ; i ++ ) output . append ( '<STR_LIT:\t>' ) ; output . append ( "<STR_LIT>" ) ; char separator = <NUM_LIT:0> ; if ( completeAnException ( ) ) { output . append ( "<STR_LIT>" ) ; separator = '<CHAR_LIT:U+002C>' ; } if ( completeInText ( ) ) { if ( separator != <NUM_LIT:0> ) output . append ( separator ) ; output . append ( "<STR_LIT:text>" ) ; separator = '<CHAR_LIT:U+002C>' ; } if ( completeBaseTypes ( ) ) { if ( separator != <NUM_LIT:0> ) output . append ( separator ) ; output . append ( "<STR_LIT>" ) ; separator = '<CHAR_LIT:U+002C>' ; } if ( completeFormalReference ( ) ) { if ( separator != <NUM_LIT:0> ) output . append ( separator ) ; output . append ( "<STR_LIT>" ) ; separator = '<CHAR_LIT:U+002C>' ; } output . append ( '<STR_LIT:\n>' ) ; } indent -- ; for ( int i = <NUM_LIT:0> ; i < indent ; i ++ ) output . append ( '<STR_LIT:\t>' ) ; return output . append ( '<CHAR_LIT:>>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; public class CompletionOnMessageSend extends MessageSend { public TypeBinding resolveType ( BlockScope scope ) { if ( this . arguments != null ) { int argsLength = this . arguments . length ; for ( int a = argsLength ; -- a >= <NUM_LIT:0> ; ) this . arguments [ a ] . resolveType ( scope ) ; } if ( this . receiver . isImplicitThis ( ) ) throw new CompletionNodeFound ( this , null , scope ) ; this . actualReceiverType = this . receiver . resolveType ( scope ) ; if ( this . actualReceiverType == null || this . actualReceiverType . isBaseType ( ) ) throw new CompletionNodeFound ( ) ; if ( this . actualReceiverType . isArrayType ( ) ) this . actualReceiverType = scope . getJavaLangObject ( ) ; throw new CompletionNodeFound ( this , this . actualReceiverType , scope ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; if ( ! this . receiver . isImplicitThis ( ) ) this . receiver . printExpression ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:.>' ) ; if ( this . typeArguments != null ) { output . append ( '<CHAR_LIT>' ) ; int max = this . typeArguments . length - <NUM_LIT:1> ; for ( int j = <NUM_LIT:0> ; j < max ; j ++ ) { this . typeArguments [ j ] . print ( <NUM_LIT:0> , output ) ; output . append ( "<STR_LIT:U+002CU+0020>" ) ; } this . typeArguments [ max ] . print ( <NUM_LIT:0> , output ) ; output . append ( '<CHAR_LIT:>>' ) ; } output . append ( this . selector ) . append ( '<CHAR_LIT:(>' ) ; if ( this . arguments != null ) { for ( int i = <NUM_LIT:0> ; i < this . arguments . length ; i ++ ) { if ( i > <NUM_LIT:0> ) output . append ( "<STR_LIT:U+002CU+0020>" ) ; this . arguments [ i ] . printExpression ( <NUM_LIT:0> , output ) ; } } return output . append ( "<STR_LIT>" ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . MarkerAnnotation ; import org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class CompletionOnMarkerAnnotationName extends MarkerAnnotation { public CompletionOnMarkerAnnotationName ( TypeReference type , int sourceStart ) { super ( type , sourceStart ) ; } public TypeBinding resolveType ( BlockScope scope ) { if ( this . type instanceof QualifiedTypeReference ) { QualifiedTypeReference qualifiedTypeReference = ( QualifiedTypeReference ) this . type ; Binding binding = scope . parent . getTypeOrPackage ( qualifiedTypeReference . tokens ) ; if ( ! binding . isValidBinding ( ) ) { scope . problemReporter ( ) . invalidType ( this , ( TypeBinding ) binding ) ; throw new CompletionNodeFound ( ) ; } throw new CompletionNodeFound ( this , binding , scope ) ; } throw new CompletionNodeFound ( this , null , scope ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; public class CompletionOnKeyword2 extends ImportReference implements CompletionOnKeyword { private char [ ] token ; private char [ ] [ ] possibleKeywords ; public CompletionOnKeyword2 ( char [ ] token , long pos , char [ ] [ ] possibleKeywords ) { super ( new char [ ] [ ] { token } , new long [ ] { pos } , false , ClassFileConstants . AccDefault ) ; this . token = token ; this . possibleKeywords = possibleKeywords ; } public boolean canCompleteEmptyToken ( ) { return false ; } public char [ ] getToken ( ) { return this . token ; } public char [ ] [ ] getPossibleKeywords ( ) { return this . possibleKeywords ; } public StringBuffer print ( int indent , StringBuffer output , boolean withOnDemand ) { return printIndent ( indent , output ) . append ( "<STR_LIT>" ) . append ( this . token ) . append ( '<CHAR_LIT:>>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; public class CompletionScanner extends Scanner { public char [ ] completionIdentifier ; public int cursorLocation ; public int endOfEmptyToken = - <NUM_LIT:1> ; public int completedIdentifierStart = <NUM_LIT:0> ; public int completedIdentifierEnd = - <NUM_LIT:1> ; public int unicodeCharSize ; public static final char [ ] EmptyCompletionIdentifier = { } ; public CompletionScanner ( long sourceLevel ) { super ( false , false , false , sourceLevel , null , null , true ) ; } public char [ ] getCurrentIdentifierSource ( ) { if ( this . completionIdentifier == null ) { if ( this . cursorLocation < this . startPosition && this . currentPosition == this . startPosition ) { this . completedIdentifierStart = this . startPosition ; this . completedIdentifierEnd = this . completedIdentifierStart - <NUM_LIT:1> ; return this . completionIdentifier = EmptyCompletionIdentifier ; } if ( this . cursorLocation + <NUM_LIT:1> >= this . startPosition && this . cursorLocation < this . currentPosition ) { this . completedIdentifierStart = this . startPosition ; this . completedIdentifierEnd = this . currentPosition - <NUM_LIT:1> ; if ( this . withoutUnicodePtr != <NUM_LIT:0> ) { int length = this . cursorLocation + <NUM_LIT:1> - this . startPosition - this . unicodeCharSize ; System . arraycopy ( this . withoutUnicodeBuffer , <NUM_LIT:1> , this . completionIdentifier = new char [ length ] , <NUM_LIT:0> , length ) ; } else { int length = this . cursorLocation + <NUM_LIT:1> - this . startPosition ; System . arraycopy ( this . source , this . startPosition , ( this . completionIdentifier = new char [ length ] ) , <NUM_LIT:0> , length ) ; } return this . completionIdentifier ; } } return super . getCurrentIdentifierSource ( ) ; } public char [ ] getCurrentTokenSourceString ( ) { if ( this . completionIdentifier == null ) { if ( this . cursorLocation + <NUM_LIT:1> >= this . startPosition && this . cursorLocation < this . currentPosition ) { this . completedIdentifierStart = this . startPosition ; this . completedIdentifierEnd = this . currentPosition - <NUM_LIT:1> ; if ( this . withoutUnicodePtr != <NUM_LIT:0> ) { int length = this . cursorLocation - this . startPosition - this . unicodeCharSize ; System . arraycopy ( this . withoutUnicodeBuffer , <NUM_LIT:2> , this . completionIdentifier = new char [ length ] , <NUM_LIT:0> , length ) ; } else { int length = this . cursorLocation - this . startPosition ; System . arraycopy ( this . source , this . startPosition + <NUM_LIT:1> , ( this . completionIdentifier = new char [ length ] ) , <NUM_LIT:0> , length ) ; } return this . completionIdentifier ; } } return super . getCurrentTokenSourceString ( ) ; } public int getNextToken ( ) throws InvalidInputException { this . wasAcr = false ; this . unicodeCharSize = <NUM_LIT:0> ; if ( this . diet ) { jumpOverMethodBody ( ) ; this . diet = false ; return this . currentPosition > this . eofPosition ? TokenNameEOF : TokenNameRBRACE ; } int whiteStart = <NUM_LIT:0> ; try { while ( true ) { this . withoutUnicodePtr = <NUM_LIT:0> ; whiteStart = this . currentPosition ; boolean isWhiteSpace , hasWhiteSpaces = false ; int offset = <NUM_LIT:0> ; do { this . startPosition = this . currentPosition ; boolean checkIfUnicode = false ; try { checkIfUnicode = ( ( this . currentCharacter = this . source [ this . currentPosition ++ ] ) == '<STR_LIT:\\>' ) && ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) ; } catch ( IndexOutOfBoundsException e ) { if ( this . tokenizeWhiteSpace && ( whiteStart != this . currentPosition - <NUM_LIT:1> ) ) { this . currentPosition -- ; this . startPosition = whiteStart ; return TokenNameWHITESPACE ; } if ( this . currentPosition > this . eofPosition ) { if ( this . completionIdentifier == null && this . startPosition == this . cursorLocation + <NUM_LIT:1> ) { this . currentPosition = this . startPosition ; return TokenNameIdentifier ; } return TokenNameEOF ; } } if ( checkIfUnicode ) { isWhiteSpace = jumpOverUnicodeWhiteSpace ( ) ; offset = <NUM_LIT:6> ; } else { offset = <NUM_LIT:1> ; if ( ( this . currentCharacter == '<STR_LIT>' ) || ( this . currentCharacter == '<STR_LIT:\n>' ) ) { if ( this . recordLineSeparator ) { pushLineSeparator ( ) ; } } isWhiteSpace = ( this . currentCharacter == '<CHAR_LIT:U+0020>' ) || CharOperation . isWhitespace ( this . currentCharacter ) ; } if ( isWhiteSpace ) { hasWhiteSpaces = true ; } if ( ( whiteStart != this . currentPosition ) && ( this . completionIdentifier == null ) && ( whiteStart <= this . cursorLocation + <NUM_LIT:1> ) && ( this . cursorLocation < this . startPosition ) && ! ScannerHelper . isJavaIdentifierStart ( this . complianceLevel , this . currentCharacter ) ) { this . currentPosition = this . startPosition ; return TokenNameIdentifier ; } } while ( isWhiteSpace ) ; if ( this . tokenizeWhiteSpace && hasWhiteSpaces ) { this . currentPosition -= offset ; this . startPosition = whiteStart ; return TokenNameWHITESPACE ; } if ( this . currentPosition > this . eofPosition ) { if ( this . completionIdentifier == null && this . startPosition == this . cursorLocation + <NUM_LIT:1> ) { int temp = this . eofPosition ; this . eofPosition = this . source . length ; while ( getNextCharAsJavaIdentifierPart ( ) ) { } this . eofPosition = temp ; this . endOfEmptyToken = this . currentPosition - <NUM_LIT:1> ; this . currentPosition = this . startPosition ; return TokenNameIdentifier ; } return TokenNameEOF ; } switch ( this . currentCharacter ) { case '<CHAR_LIT>' : return TokenNameAT ; case '<CHAR_LIT:(>' : return TokenNameLPAREN ; case '<CHAR_LIT:)>' : return TokenNameRPAREN ; case '<CHAR_LIT>' : return TokenNameLBRACE ; case '<CHAR_LIT:}>' : return TokenNameRBRACE ; case '<CHAR_LIT:[>' : return TokenNameLBRACKET ; case '<CHAR_LIT:]>' : return TokenNameRBRACKET ; case '<CHAR_LIT:;>' : return TokenNameSEMICOLON ; case '<CHAR_LIT:U+002C>' : return TokenNameCOMMA ; case '<CHAR_LIT:.>' : if ( this . startPosition <= this . cursorLocation && this . cursorLocation < this . currentPosition ) { return TokenNameDOT ; } if ( getNextCharAsDigit ( ) ) { return scanNumber ( true ) ; } int temp = this . currentPosition ; if ( getNextChar ( '<CHAR_LIT:.>' ) ) { if ( getNextChar ( '<CHAR_LIT:.>' ) ) { return TokenNameELLIPSIS ; } else { this . currentPosition = temp ; return TokenNameDOT ; } } else { this . currentPosition = temp ; return TokenNameDOT ; } case '<CHAR_LIT>' : { int test ; if ( ( test = getNextChar ( '<CHAR_LIT>' , '<CHAR_LIT:=>' ) ) == <NUM_LIT:0> ) return TokenNamePLUS_PLUS ; if ( test > <NUM_LIT:0> ) return TokenNamePLUS_EQUAL ; return TokenNamePLUS ; } case '<CHAR_LIT:->' : { int test ; if ( ( test = getNextChar ( '<CHAR_LIT:->' , '<CHAR_LIT:=>' ) ) == <NUM_LIT:0> ) return TokenNameMINUS_MINUS ; if ( test > <NUM_LIT:0> ) return TokenNameMINUS_EQUAL ; return TokenNameMINUS ; } case '<CHAR_LIT>' : return TokenNameTWIDDLE ; case '<CHAR_LIT>' : if ( getNextChar ( '<CHAR_LIT:=>' ) ) return TokenNameNOT_EQUAL ; return TokenNameNOT ; case '<CHAR_LIT>' : if ( getNextChar ( '<CHAR_LIT:=>' ) ) return TokenNameMULTIPLY_EQUAL ; return TokenNameMULTIPLY ; case '<CHAR_LIT>' : if ( getNextChar ( '<CHAR_LIT:=>' ) ) return TokenNameREMAINDER_EQUAL ; return TokenNameREMAINDER ; case '<CHAR_LIT>' : { int test ; if ( ( test = getNextChar ( '<CHAR_LIT:=>' , '<CHAR_LIT>' ) ) == <NUM_LIT:0> ) return TokenNameLESS_EQUAL ; if ( test > <NUM_LIT:0> ) { if ( getNextChar ( '<CHAR_LIT:=>' ) ) return TokenNameLEFT_SHIFT_EQUAL ; return TokenNameLEFT_SHIFT ; } return TokenNameLESS ; } case '<CHAR_LIT:>>' : { int test ; if ( this . returnOnlyGreater ) { return TokenNameGREATER ; } if ( ( test = getNextChar ( '<CHAR_LIT:=>' , '<CHAR_LIT:>>' ) ) == <NUM_LIT:0> ) return TokenNameGREATER_EQUAL ; if ( test > <NUM_LIT:0> ) { if ( ( test = getNextChar ( '<CHAR_LIT:=>' , '<CHAR_LIT:>>' ) ) == <NUM_LIT:0> ) return TokenNameRIGHT_SHIFT_EQUAL ; if ( test > <NUM_LIT:0> ) { if ( getNextChar ( '<CHAR_LIT:=>' ) ) return TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL ; return TokenNameUNSIGNED_RIGHT_SHIFT ; } return TokenNameRIGHT_SHIFT ; } return TokenNameGREATER ; } case '<CHAR_LIT:=>' : if ( getNextChar ( '<CHAR_LIT:=>' ) ) return TokenNameEQUAL_EQUAL ; return TokenNameEQUAL ; case '<CHAR_LIT>' : { int test ; if ( ( test = getNextChar ( '<CHAR_LIT>' , '<CHAR_LIT:=>' ) ) == <NUM_LIT:0> ) return TokenNameAND_AND ; if ( test > <NUM_LIT:0> ) return TokenNameAND_EQUAL ; return TokenNameAND ; } case '<CHAR_LIT>' : { int test ; if ( ( test = getNextChar ( '<CHAR_LIT>' , '<CHAR_LIT:=>' ) ) == <NUM_LIT:0> ) return TokenNameOR_OR ; if ( test > <NUM_LIT:0> ) return TokenNameOR_EQUAL ; return TokenNameOR ; } case '<CHAR_LIT>' : if ( getNextChar ( '<CHAR_LIT:=>' ) ) return TokenNameXOR_EQUAL ; return TokenNameXOR ; case '<CHAR_LIT>' : return TokenNameQUESTION ; case '<CHAR_LIT::>' : return TokenNameCOLON ; case '<STR_LIT>' : { int test ; if ( ( test = getNextChar ( '<STR_LIT:\n>' , '<STR_LIT>' ) ) == <NUM_LIT:0> ) { throw new InvalidInputException ( INVALID_CHARACTER_CONSTANT ) ; } if ( test > <NUM_LIT:0> ) { for ( int lookAhead = <NUM_LIT:0> ; lookAhead < <NUM_LIT:3> ; lookAhead ++ ) { if ( this . currentPosition + lookAhead == this . eofPosition ) break ; if ( this . source [ this . currentPosition + lookAhead ] == '<STR_LIT:\n>' ) break ; if ( this . source [ this . currentPosition + lookAhead ] == '<STR_LIT>' ) { this . currentPosition += lookAhead + <NUM_LIT:1> ; break ; } } throw new InvalidInputException ( INVALID_CHARACTER_CONSTANT ) ; } } if ( getNextChar ( '<STR_LIT>' ) ) { for ( int lookAhead = <NUM_LIT:0> ; lookAhead < <NUM_LIT:3> ; lookAhead ++ ) { if ( this . currentPosition + lookAhead == this . eofPosition ) break ; if ( this . source [ this . currentPosition + lookAhead ] == '<STR_LIT:\n>' ) break ; if ( this . source [ this . currentPosition + lookAhead ] == '<STR_LIT>' ) { this . currentPosition += lookAhead + <NUM_LIT:1> ; break ; } } throw new InvalidInputException ( INVALID_CHARACTER_CONSTANT ) ; } if ( getNextChar ( '<STR_LIT:\\>' ) ) { if ( this . unicodeAsBackSlash ) { this . unicodeAsBackSlash = false ; if ( ( ( this . currentCharacter = this . source [ this . currentPosition ++ ] ) == '<STR_LIT:\\>' ) && ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) ) { getNextUnicodeChar ( ) ; } else { if ( this . withoutUnicodePtr != <NUM_LIT:0> ) { unicodeStore ( ) ; } } } else { this . currentCharacter = this . source [ this . currentPosition ++ ] ; } scanEscapeCharacter ( ) ; } else { this . unicodeAsBackSlash = false ; boolean checkIfUnicode = false ; try { checkIfUnicode = ( ( this . currentCharacter = this . source [ this . currentPosition ++ ] ) == '<STR_LIT:\\>' ) && ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) ; } catch ( IndexOutOfBoundsException e ) { this . currentPosition -- ; throw new InvalidInputException ( INVALID_CHARACTER_CONSTANT ) ; } if ( checkIfUnicode ) { getNextUnicodeChar ( ) ; } else { if ( this . withoutUnicodePtr != <NUM_LIT:0> ) { unicodeStore ( ) ; } } } if ( getNextChar ( '<STR_LIT>' ) ) return TokenNameCharacterLiteral ; for ( int lookAhead = <NUM_LIT:0> ; lookAhead < <NUM_LIT:20> ; lookAhead ++ ) { if ( this . currentPosition + lookAhead == this . eofPosition ) break ; if ( this . source [ this . currentPosition + lookAhead ] == '<STR_LIT:\n>' ) break ; if ( this . source [ this . currentPosition + lookAhead ] == '<STR_LIT>' ) { this . currentPosition += lookAhead + <NUM_LIT:1> ; break ; } } throw new InvalidInputException ( INVALID_CHARACTER_CONSTANT ) ; case '<CHAR_LIT:">' : try { this . unicodeAsBackSlash = false ; boolean isUnicode = false ; if ( ( ( this . currentCharacter = this . source [ this . currentPosition ++ ] ) == '<STR_LIT:\\>' ) && ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) ) { getNextUnicodeChar ( ) ; isUnicode = true ; } else { if ( this . withoutUnicodePtr != <NUM_LIT:0> ) { unicodeStore ( ) ; } } while ( this . currentCharacter != '<CHAR_LIT:">' ) { if ( ( this . currentCharacter == '<STR_LIT:\n>' ) || ( this . currentCharacter == '<STR_LIT>' ) ) { if ( isUnicode ) { int start = this . currentPosition - <NUM_LIT:5> ; while ( this . source [ start ] != '<STR_LIT:\\>' ) { start -- ; } if ( this . startPosition <= this . cursorLocation && this . cursorLocation <= this . currentPosition - <NUM_LIT:1> ) { this . currentPosition = start ; return TokenNameStringLiteral ; } start = this . currentPosition ; for ( int lookAhead = <NUM_LIT:0> ; lookAhead < <NUM_LIT> ; lookAhead ++ ) { if ( this . currentPosition >= this . eofPosition ) { this . currentPosition = start ; break ; } if ( ( ( this . currentCharacter = this . source [ this . currentPosition ++ ] ) == '<STR_LIT:\\>' ) && ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) ) { isUnicode = true ; getNextUnicodeChar ( ) ; } else { isUnicode = false ; } if ( ! isUnicode && this . currentCharacter == '<STR_LIT:\n>' ) { this . currentPosition -- ; break ; } if ( this . currentCharacter == '<STR_LIT:\">' ) { throw new InvalidInputException ( INVALID_CHAR_IN_STRING ) ; } } } else { this . currentPosition -- ; if ( this . startPosition <= this . cursorLocation && this . cursorLocation <= this . currentPosition - <NUM_LIT:1> ) { return TokenNameStringLiteral ; } } throw new InvalidInputException ( INVALID_CHAR_IN_STRING ) ; } if ( this . currentCharacter == '<STR_LIT:\\>' ) { if ( this . unicodeAsBackSlash ) { this . withoutUnicodePtr -- ; this . unicodeAsBackSlash = false ; if ( ( ( this . currentCharacter = this . source [ this . currentPosition ++ ] ) == '<STR_LIT:\\>' ) && ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) ) { getNextUnicodeChar ( ) ; isUnicode = true ; this . withoutUnicodePtr -- ; } else { isUnicode = false ; } } else { if ( this . withoutUnicodePtr == <NUM_LIT:0> ) { unicodeInitializeBuffer ( this . currentPosition - this . startPosition ) ; } this . withoutUnicodePtr -- ; this . currentCharacter = this . source [ this . currentPosition ++ ] ; } scanEscapeCharacter ( ) ; if ( this . withoutUnicodePtr != <NUM_LIT:0> ) { unicodeStore ( ) ; } } this . unicodeAsBackSlash = false ; if ( ( ( this . currentCharacter = this . source [ this . currentPosition ++ ] ) == '<STR_LIT:\\>' ) && ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) ) { getNextUnicodeChar ( ) ; isUnicode = true ; } else { isUnicode = false ; if ( this . withoutUnicodePtr != <NUM_LIT:0> ) { unicodeStore ( ) ; } } } } catch ( IndexOutOfBoundsException e ) { this . currentPosition -- ; if ( this . startPosition <= this . cursorLocation && this . cursorLocation < this . currentPosition ) { return TokenNameStringLiteral ; } throw new InvalidInputException ( UNTERMINATED_STRING ) ; } catch ( InvalidInputException e ) { if ( e . getMessage ( ) . equals ( INVALID_ESCAPE ) ) { for ( int lookAhead = <NUM_LIT:0> ; lookAhead < <NUM_LIT> ; lookAhead ++ ) { if ( this . currentPosition + lookAhead == this . eofPosition ) break ; if ( this . source [ this . currentPosition + lookAhead ] == '<STR_LIT:\n>' ) break ; if ( this . source [ this . currentPosition + lookAhead ] == '<STR_LIT:\">' ) { this . currentPosition += lookAhead + <NUM_LIT:1> ; break ; } } } throw e ; } return TokenNameStringLiteral ; case '<CHAR_LIT:/>' : { int test ; if ( ( test = getNextChar ( '<CHAR_LIT:/>' , '<CHAR_LIT>' ) ) == <NUM_LIT:0> ) { this . lastCommentLinePosition = this . currentPosition ; try { if ( ( ( this . currentCharacter = this . source [ this . currentPosition ++ ] ) == '<STR_LIT:\\>' ) && ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) ) { int c1 = <NUM_LIT:0> , c2 = <NUM_LIT:0> , c3 = <NUM_LIT:0> , c4 = <NUM_LIT:0> ; this . currentPosition ++ ; while ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) { this . currentPosition ++ ; } if ( ( c1 = ScannerHelper . getHexadecimalValue ( this . source [ this . currentPosition ++ ] ) ) > <NUM_LIT:15> || c1 < <NUM_LIT:0> || ( c2 = ScannerHelper . getHexadecimalValue ( this . source [ this . currentPosition ++ ] ) ) > <NUM_LIT:15> || c2 < <NUM_LIT:0> || ( c3 = ScannerHelper . getHexadecimalValue ( this . source [ this . currentPosition ++ ] ) ) > <NUM_LIT:15> || c3 < <NUM_LIT:0> || ( c4 = ScannerHelper . getHexadecimalValue ( this . source [ this . currentPosition ++ ] ) ) > <NUM_LIT:15> || c4 < <NUM_LIT:0> ) { throw new InvalidInputException ( INVALID_UNICODE_ESCAPE ) ; } else { this . currentCharacter = ( char ) ( ( ( c1 * <NUM_LIT:16> + c2 ) * <NUM_LIT:16> + c3 ) * <NUM_LIT:16> + c4 ) ; } } if ( this . currentCharacter == '<STR_LIT:\\>' ) { if ( this . source [ this . currentPosition ] == '<STR_LIT:\\>' ) this . currentPosition ++ ; } boolean isUnicode = false ; while ( this . currentCharacter != '<STR_LIT>' && this . currentCharacter != '<STR_LIT:\n>' ) { this . lastCommentLinePosition = this . currentPosition ; isUnicode = false ; if ( ( ( this . currentCharacter = this . source [ this . currentPosition ++ ] ) == '<STR_LIT:\\>' ) && ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) ) { isUnicode = true ; int c1 = <NUM_LIT:0> , c2 = <NUM_LIT:0> , c3 = <NUM_LIT:0> , c4 = <NUM_LIT:0> ; this . currentPosition ++ ; while ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) { this . currentPosition ++ ; } if ( ( c1 = ScannerHelper . getHexadecimalValue ( this . source [ this . currentPosition ++ ] ) ) > <NUM_LIT:15> || c1 < <NUM_LIT:0> || ( c2 = ScannerHelper . getHexadecimalValue ( this . source [ this . currentPosition ++ ] ) ) > <NUM_LIT:15> || c2 < <NUM_LIT:0> || ( c3 = ScannerHelper . getHexadecimalValue ( this . source [ this . currentPosition ++ ] ) ) > <NUM_LIT:15> || c3 < <NUM_LIT:0> || ( c4 = ScannerHelper . getHexadecimalValue ( this . source [ this . currentPosition ++ ] ) ) > <NUM_LIT:15> || c4 < <NUM_LIT:0> ) { throw new InvalidInputException ( INVALID_UNICODE_ESCAPE ) ; } else { this . currentCharacter = ( char ) ( ( ( c1 * <NUM_LIT:16> + c2 ) * <NUM_LIT:16> + c3 ) * <NUM_LIT:16> + c4 ) ; } } if ( this . currentCharacter == '<STR_LIT:\\>' ) { if ( this . source [ this . currentPosition ] == '<STR_LIT:\\>' ) this . currentPosition ++ ; } } if ( this . currentCharacter == '<STR_LIT>' && this . eofPosition > this . currentPosition ) { if ( this . source [ this . currentPosition ] == '<STR_LIT:\n>' ) { this . currentPosition ++ ; this . currentCharacter = '<STR_LIT:\n>' ; } else if ( ( this . source [ this . currentPosition ] == '<STR_LIT:\\>' ) && ( this . source [ this . currentPosition + <NUM_LIT:1> ] == '<CHAR_LIT>' ) ) { isUnicode = true ; char unicodeChar ; int index = this . currentPosition + <NUM_LIT:1> ; index ++ ; while ( this . source [ index ] == '<CHAR_LIT>' ) { index ++ ; } int c1 = <NUM_LIT:0> , c2 = <NUM_LIT:0> , c3 = <NUM_LIT:0> , c4 = <NUM_LIT:0> ; if ( ( c1 = ScannerHelper . getHexadecimalValue ( this . source [ index ++ ] ) ) > <NUM_LIT:15> || c1 < <NUM_LIT:0> || ( c2 = ScannerHelper . getHexadecimalValue ( this . source [ index ++ ] ) ) > <NUM_LIT:15> || c2 < <NUM_LIT:0> || ( c3 = ScannerHelper . getHexadecimalValue ( this . source [ index ++ ] ) ) > <NUM_LIT:15> || c3 < <NUM_LIT:0> || ( c4 = ScannerHelper . getHexadecimalValue ( this . source [ index ++ ] ) ) > <NUM_LIT:15> || c4 < <NUM_LIT:0> ) { this . currentPosition = index ; throw new InvalidInputException ( INVALID_UNICODE_ESCAPE ) ; } else { unicodeChar = ( char ) ( ( ( c1 * <NUM_LIT:16> + c2 ) * <NUM_LIT:16> + c3 ) * <NUM_LIT:16> + c4 ) ; } if ( unicodeChar == '<STR_LIT:\n>' ) { this . currentPosition = index ; this . currentCharacter = '<STR_LIT:\n>' ; } } } recordComment ( TokenNameCOMMENT_LINE ) ; if ( this . startPosition <= this . cursorLocation && this . cursorLocation < this . currentPosition - <NUM_LIT:1> ) { throw new InvalidCursorLocation ( InvalidCursorLocation . NO_COMPLETION_INSIDE_COMMENT ) ; } if ( this . taskTags != null ) checkTaskTag ( this . startPosition , this . currentPosition ) ; if ( ( this . currentCharacter == '<STR_LIT>' ) || ( this . currentCharacter == '<STR_LIT:\n>' ) ) { if ( this . recordLineSeparator ) { if ( isUnicode ) { pushUnicodeLineSeparator ( ) ; } else { pushLineSeparator ( ) ; } } } if ( this . tokenizeComments ) { return TokenNameCOMMENT_LINE ; } } catch ( IndexOutOfBoundsException e ) { this . currentPosition -- ; recordComment ( TokenNameCOMMENT_LINE ) ; if ( this . taskTags != null ) checkTaskTag ( this . startPosition , this . currentPosition ) ; if ( this . tokenizeComments ) { return TokenNameCOMMENT_LINE ; } else { this . currentPosition ++ ; } } break ; } if ( test > <NUM_LIT:0> ) { try { boolean isJavadoc = false , star = false ; boolean isUnicode = false ; int previous ; this . unicodeAsBackSlash = false ; if ( ( ( this . currentCharacter = this . source [ this . currentPosition ++ ] ) == '<STR_LIT:\\>' ) && ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) ) { getNextUnicodeChar ( ) ; isUnicode = true ; } else { isUnicode = false ; if ( this . withoutUnicodePtr != <NUM_LIT:0> ) { unicodeStore ( ) ; } } if ( this . currentCharacter == '<CHAR_LIT>' ) { isJavadoc = true ; star = true ; } if ( ( this . currentCharacter == '<STR_LIT>' ) || ( this . currentCharacter == '<STR_LIT:\n>' ) ) { if ( this . recordLineSeparator ) { if ( ! isUnicode ) { pushLineSeparator ( ) ; } } } isUnicode = false ; previous = this . currentPosition ; if ( ( ( this . currentCharacter = this . source [ this . currentPosition ++ ] ) == '<STR_LIT:\\>' ) && ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) ) { getNextUnicodeChar ( ) ; isUnicode = true ; } else { isUnicode = false ; } if ( this . currentCharacter == '<STR_LIT:\\>' ) { if ( this . source [ this . currentPosition ] == '<STR_LIT:\\>' ) this . currentPosition ++ ; } if ( this . currentCharacter == '<CHAR_LIT:/>' ) { isJavadoc = false ; } int firstTag = <NUM_LIT:0> ; while ( ( this . currentCharacter != '<CHAR_LIT:/>' ) || ( ! star ) ) { if ( ( this . currentCharacter == '<STR_LIT>' ) || ( this . currentCharacter == '<STR_LIT:\n>' ) ) { if ( this . recordLineSeparator ) { if ( ! isUnicode ) { pushLineSeparator ( ) ; } } } switch ( this . currentCharacter ) { case '<CHAR_LIT>' : star = true ; break ; case '<CHAR_LIT>' : if ( firstTag == <NUM_LIT:0> && this . isFirstTag ( ) ) { firstTag = previous ; } default : star = false ; } previous = this . currentPosition ; if ( ( ( this . currentCharacter = this . source [ this . currentPosition ++ ] ) == '<STR_LIT:\\>' ) && ( this . source [ this . currentPosition ] == '<CHAR_LIT>' ) ) { getNextUnicodeChar ( ) ; isUnicode = true ; } else { isUnicode = false ; } if ( this . currentCharacter == '<STR_LIT:\\>' ) { if ( this . source [ this . currentPosition ] == '<STR_LIT:\\>' ) this . currentPosition ++ ; } } int token = isJavadoc ? TokenNameCOMMENT_JAVADOC : TokenNameCOMMENT_BLOCK ; recordComment ( token ) ; this . commentTagStarts [ this . commentPtr ] = firstTag ; if ( ! isJavadoc && this . startPosition <= this . cursorLocation && this . cursorLocation < this . currentPosition - <NUM_LIT:1> ) { throw new InvalidCursorLocation ( InvalidCursorLocation . NO_COMPLETION_INSIDE_COMMENT ) ; } if ( this . taskTags != null ) checkTaskTag ( this . startPosition , this . currentPosition ) ; if ( this . tokenizeComments ) { return token ; } } catch ( IndexOutOfBoundsException e ) { this . currentPosition -- ; throw new InvalidInputException ( UNTERMINATED_COMMENT ) ; } break ; } if ( getNextChar ( '<CHAR_LIT:=>' ) ) return TokenNameDIVIDE_EQUAL ; return TokenNameDIVIDE ; } case '<CHAR_LIT>' : if ( atEnd ( ) ) return TokenNameEOF ; throw new InvalidInputException ( "<STR_LIT>" ) ; default : char c = this . currentCharacter ; if ( c < ScannerHelper . MAX_OBVIOUS ) { if ( ( ScannerHelper . OBVIOUS_IDENT_CHAR_NATURES [ c ] & ScannerHelper . C_IDENT_START ) != <NUM_LIT:0> ) { return scanIdentifierOrKeyword ( ) ; } else if ( ( ScannerHelper . OBVIOUS_IDENT_CHAR_NATURES [ c ] & ScannerHelper . C_DIGIT ) != <NUM_LIT:0> ) { return scanNumber ( false ) ; } else { return TokenNameERROR ; } } boolean isJavaIdStart ; if ( c >= HIGH_SURROGATE_MIN_VALUE && c <= HIGH_SURROGATE_MAX_VALUE ) { if ( this . complianceLevel < ClassFileConstants . JDK1_5 ) { throw new InvalidInputException ( INVALID_UNICODE_ESCAPE ) ; } char low = ( char ) getNextChar ( ) ; if ( low < LOW_SURROGATE_MIN_VALUE || low > LOW_SURROGATE_MAX_VALUE ) { throw new InvalidInputException ( INVALID_LOW_SURROGATE ) ; } isJavaIdStart = ScannerHelper . isJavaIdentifierStart ( this . complianceLevel , c , low ) ; } else if ( c >= LOW_SURROGATE_MIN_VALUE && c <= LOW_SURROGATE_MAX_VALUE ) { if ( this . complianceLevel < ClassFileConstants . JDK1_5 ) { throw new InvalidInputException ( INVALID_UNICODE_ESCAPE ) ; } throw new InvalidInputException ( INVALID_HIGH_SURROGATE ) ; } else { isJavaIdStart = Character . isJavaIdentifierStart ( c ) ; } if ( isJavaIdStart ) return scanIdentifierOrKeyword ( ) ; if ( ScannerHelper . isDigit ( this . currentCharacter ) ) { return scanNumber ( false ) ; } return TokenNameERROR ; } } } catch ( IndexOutOfBoundsException e ) { if ( this . tokenizeWhiteSpace && ( whiteStart != this . currentPosition - <NUM_LIT:1> ) ) { this . currentPosition -- ; this . startPosition = whiteStart ; return TokenNameWHITESPACE ; } } if ( this . completionIdentifier == null && this . startPosition == this . cursorLocation + <NUM_LIT:1> ) { this . currentPosition = this . startPosition ; return TokenNameIdentifier ; } return TokenNameEOF ; } public final void getNextUnicodeChar ( ) throws InvalidInputException { int temp = this . currentPosition ; super . getNextUnicodeChar ( ) ; if ( this . cursorLocation > temp ) { this . unicodeCharSize += ( this . currentPosition - temp ) ; } if ( temp < this . cursorLocation && this . cursorLocation < this . currentPosition - <NUM_LIT:1> ) { throw new InvalidCursorLocation ( InvalidCursorLocation . NO_COMPLETION_INSIDE_UNICODE ) ; } } protected boolean isFirstTag ( ) { return getNextChar ( '<CHAR_LIT>' ) && getNextChar ( '<CHAR_LIT:e>' ) && getNextChar ( '<CHAR_LIT>' ) && getNextChar ( '<CHAR_LIT>' ) && getNextChar ( '<CHAR_LIT:e>' ) && getNextChar ( '<CHAR_LIT:c>' ) && getNextChar ( '<CHAR_LIT:a>' ) && getNextChar ( '<CHAR_LIT>' ) && getNextChar ( '<CHAR_LIT:e>' ) && getNextChar ( '<CHAR_LIT>' ) ; } public final void jumpOverBlock ( ) { jumpOverMethodBody ( ) ; } public int scanIdentifierOrKeyword ( ) { int id = super . scanIdentifierOrKeyword ( ) ; if ( this . startPosition <= this . cursorLocation + <NUM_LIT:1> && this . cursorLocation < this . currentPosition ) { if ( this . cursorLocation + <NUM_LIT:1> == this . eofPosition ) { int temp = this . eofPosition ; this . eofPosition = this . source . length ; while ( getNextCharAsJavaIdentifierPart ( ) ) { } this . eofPosition = temp ; } return TokenNameIdentifier ; } return id ; } public int scanNumber ( boolean dotPrefix ) throws InvalidInputException { int token = super . scanNumber ( dotPrefix ) ; if ( this . startPosition <= this . cursorLocation && this . cursorLocation < this . currentPosition ) { throw new InvalidCursorLocation ( InvalidCursorLocation . NO_COMPLETION_INSIDE_NUMBER ) ; } return token ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import java . util . ArrayList ; import java . util . List ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . codeassist . CompletionEngine ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . parser . JavadocParser ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; public class CompletionJavadocParser extends JavadocParser { public final static int INLINE_ALL_TAGS_LENGTH ; public final static int BLOCK_ALL_TAGS_LENGTH ; static { int length = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < INLINE_TAGS_LENGTH ; i ++ ) { length += INLINE_TAGS [ i ] . length ; } INLINE_ALL_TAGS_LENGTH = length ; length = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < BLOCK_TAGS_LENGTH ; i ++ ) { length += BLOCK_TAGS [ i ] . length ; } BLOCK_ALL_TAGS_LENGTH = length ; } char [ ] [ ] [ ] levelTags = new char [ <NUM_LIT:2> ] [ ] [ ] ; int [ ] levelTagsLength = new int [ <NUM_LIT:2> ] ; int cursorLocation ; CompletionOnJavadoc completionNode = null ; boolean pushText = false ; boolean allPossibleTags = false ; public CompletionJavadocParser ( CompletionParser sourceParser ) { super ( sourceParser ) ; this . scanner = new CompletionScanner ( ClassFileConstants . JDK1_3 ) ; this . kind = COMPLETION_PARSER | TEXT_PARSE ; initLevelTags ( ) ; } public boolean checkDeprecation ( int commentPtr ) { boolean isDeprecated = false ; this . cursorLocation = ( ( CompletionParser ) this . sourceParser ) . cursorLocation ; CompletionScanner completionScanner = ( CompletionScanner ) this . scanner ; completionScanner . cursorLocation = this . cursorLocation ; this . javadocStart = this . sourceParser . scanner . commentStarts [ commentPtr ] ; this . javadocEnd = this . sourceParser . scanner . commentStops [ commentPtr ] ; if ( this . javadocStart <= this . cursorLocation && this . cursorLocation <= this . javadocEnd ) { if ( CompletionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" ) ; } completionScanner . completionIdentifier = null ; this . firstTagPosition = <NUM_LIT:1> ; super . checkDeprecation ( commentPtr ) ; } else { if ( this . sourceParser . scanner . commentTagStarts [ commentPtr ] != <NUM_LIT:0> ) { boolean previousValue = this . checkDocComment ; this . checkDocComment = false ; isDeprecated = super . checkDeprecation ( commentPtr ) ; this . checkDocComment = previousValue ; } this . docComment = null ; } return isDeprecated ; } protected boolean commentParse ( ) { this . docComment = new CompletionJavadoc ( this . javadocStart , this . javadocEnd ) ; return super . commentParse ( ) ; } protected Object createArgumentReference ( char [ ] name , int dim , boolean isVarargs , Object typeRef , long [ ] dimPositions , long argNamePos ) throws InvalidInputException { char [ ] argName = name == null ? CharOperation . NO_CHAR : name ; Expression expression = ( Expression ) super . createArgumentReference ( argName , dim , isVarargs , typeRef , dimPositions , argNamePos ) ; int refStart = ( ( TypeReference ) typeRef ) . sourceStart ; int refEnd = ( ( TypeReference ) typeRef ) . sourceEnd ; boolean inCompletion = ( refStart <= this . cursorLocation && this . cursorLocation <= refEnd ) || ( ( refStart == ( refEnd + <NUM_LIT:1> ) && refEnd == this . cursorLocation ) ) ; if ( this . completionNode == null && inCompletion ) { JavadocArgumentExpression javadocArgument = ( JavadocArgumentExpression ) expression ; TypeReference expressionType = javadocArgument . argument . type ; if ( expressionType instanceof JavadocSingleTypeReference ) { this . completionNode = new CompletionOnJavadocSingleTypeReference ( ( JavadocSingleTypeReference ) expressionType ) ; } else if ( expressionType instanceof JavadocQualifiedTypeReference ) { this . completionNode = new CompletionOnJavadocQualifiedTypeReference ( ( JavadocQualifiedTypeReference ) expressionType ) ; } if ( CompletionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . completionNode ) ; } return this . completionNode ; } return expression ; } protected Object createFieldReference ( Object receiver ) throws InvalidInputException { int refStart = ( int ) ( this . identifierPositionStack [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; int refEnd = ( int ) this . identifierPositionStack [ <NUM_LIT:0> ] ; boolean inCompletion = ( refStart <= ( this . cursorLocation + <NUM_LIT:1> ) && this . cursorLocation <= refEnd ) || ( ( refStart == ( refEnd + <NUM_LIT:1> ) && refEnd == this . cursorLocation ) ) || ( this . memberStart == this . cursorLocation ) ; if ( inCompletion ) { JavadocFieldReference fieldRef = ( JavadocFieldReference ) super . createFieldReference ( receiver ) ; char [ ] name = this . sourceParser . compilationUnit . getMainTypeName ( ) ; TypeDeclaration typeDecl = getParsedTypeDeclaration ( ) ; if ( typeDecl != null ) { name = typeDecl . name ; } this . completionNode = new CompletionOnJavadocFieldReference ( fieldRef , this . memberStart , name ) ; if ( CompletionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . completionNode ) ; } return this . completionNode ; } return super . createFieldReference ( receiver ) ; } protected Object createMethodReference ( Object receiver , List arguments ) throws InvalidInputException { int memberPtr = this . identifierLengthStack [ <NUM_LIT:0> ] - <NUM_LIT:1> ; int refStart = ( int ) ( this . identifierPositionStack [ memberPtr ] > > > <NUM_LIT:32> ) ; int refEnd = ( int ) this . identifierPositionStack [ memberPtr ] ; boolean inCompletion = ( refStart <= ( this . cursorLocation + <NUM_LIT:1> ) && this . cursorLocation <= refEnd ) || ( ( refStart == ( refEnd + <NUM_LIT:1> ) && refEnd == this . cursorLocation ) ) || ( this . memberStart == this . cursorLocation ) ; if ( inCompletion ) { ASTNode node = ( ASTNode ) super . createMethodReference ( receiver , arguments ) ; if ( node instanceof JavadocMessageSend ) { JavadocMessageSend messageSend = ( JavadocMessageSend ) node ; int nameStart = ( int ) ( messageSend . nameSourcePosition > > > <NUM_LIT:32> ) ; int nameEnd = ( int ) messageSend . nameSourcePosition ; if ( ( nameStart <= ( this . cursorLocation + <NUM_LIT:1> ) && this . cursorLocation <= nameEnd ) ) { this . completionNode = new CompletionOnJavadocFieldReference ( messageSend , this . memberStart ) ; } else { this . completionNode = new CompletionOnJavadocMessageSend ( messageSend , this . memberStart ) ; } } else if ( node instanceof JavadocAllocationExpression ) { this . completionNode = new CompletionOnJavadocAllocationExpression ( ( JavadocAllocationExpression ) node , this . memberStart ) ; } if ( CompletionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . completionNode ) ; } return this . completionNode ; } return super . createMethodReference ( receiver , arguments ) ; } protected Object createTypeReference ( int primitiveToken ) { int nbIdentifiers = this . identifierLengthStack [ this . identifierLengthPtr ] ; int startPtr = this . identifierPtr - ( nbIdentifiers - <NUM_LIT:1> ) ; int refStart = ( int ) ( this . identifierPositionStack [ startPtr ] > > > <NUM_LIT:32> ) ; int refEnd = ( int ) this . identifierPositionStack [ this . identifierPtr ] ; boolean inCompletion = ( refStart <= ( this . cursorLocation + <NUM_LIT:1> ) && this . cursorLocation <= refEnd ) || ( ( refStart == ( refEnd + <NUM_LIT:1> ) && refEnd == this . cursorLocation ) ) ; if ( ! inCompletion ) { return super . createTypeReference ( primitiveToken ) ; } this . identifierLengthPtr -- ; if ( nbIdentifiers == <NUM_LIT:1> ) { this . completionNode = new CompletionOnJavadocSingleTypeReference ( this . identifierStack [ this . identifierPtr ] , this . identifierPositionStack [ this . identifierPtr ] , this . tagSourceStart , this . tagSourceEnd ) ; } else if ( nbIdentifiers > <NUM_LIT:1> ) { for ( int i = startPtr ; i < this . identifierPtr ; i ++ ) { int start = ( int ) ( this . identifierPositionStack [ i ] > > > <NUM_LIT:32> ) ; int end = ( int ) this . identifierPositionStack [ i ] ; if ( start <= this . cursorLocation && this . cursorLocation <= end ) { if ( i == startPtr ) { this . completionNode = new CompletionOnJavadocSingleTypeReference ( this . identifierStack [ startPtr ] , this . identifierPositionStack [ startPtr ] , this . tagSourceStart , this . tagSourceEnd ) ; } else { char [ ] [ ] tokens = new char [ i ] [ ] ; System . arraycopy ( this . identifierStack , startPtr , tokens , <NUM_LIT:0> , i ) ; long [ ] positions = new long [ i + <NUM_LIT:1> ] ; System . arraycopy ( this . identifierPositionStack , startPtr , positions , <NUM_LIT:0> , i + <NUM_LIT:1> ) ; this . completionNode = new CompletionOnJavadocQualifiedTypeReference ( tokens , this . identifierStack [ i ] , positions , this . tagSourceStart , this . tagSourceEnd ) ; } break ; } } if ( this . completionNode == null ) { char [ ] [ ] tokens = new char [ nbIdentifiers - <NUM_LIT:1> ] [ ] ; System . arraycopy ( this . identifierStack , startPtr , tokens , <NUM_LIT:0> , nbIdentifiers - <NUM_LIT:1> ) ; long [ ] positions = new long [ nbIdentifiers ] ; System . arraycopy ( this . identifierPositionStack , startPtr , positions , <NUM_LIT:0> , nbIdentifiers ) ; this . completionNode = new CompletionOnJavadocQualifiedTypeReference ( tokens , this . identifierStack [ this . identifierPtr ] , positions , this . tagSourceStart , this . tagSourceEnd ) ; } } if ( CompletionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . completionNode ) ; } return this . completionNode ; } private char [ ] [ ] [ ] possibleTags ( char [ ] prefix , boolean newLine ) { char [ ] [ ] [ ] possibleTags = new char [ <NUM_LIT:2> ] [ ] [ ] ; if ( newLine ) { System . arraycopy ( this . levelTags [ BLOCK_IDX ] , <NUM_LIT:0> , possibleTags [ BLOCK_IDX ] = new char [ this . levelTagsLength [ BLOCK_IDX ] ] [ ] , <NUM_LIT:0> , this . levelTagsLength [ BLOCK_IDX ] ) ; } else { possibleTags [ BLOCK_IDX ] = CharOperation . NO_CHAR_CHAR ; } System . arraycopy ( this . levelTags [ INLINE_IDX ] , <NUM_LIT:0> , possibleTags [ INLINE_IDX ] = new char [ this . levelTagsLength [ INLINE_IDX ] ] [ ] , <NUM_LIT:0> , this . levelTagsLength [ INLINE_IDX ] ) ; if ( prefix == null || prefix . length == <NUM_LIT:0> ) return possibleTags ; int kinds = this . levelTags . length ; for ( int k = <NUM_LIT:0> ; k < kinds ; k ++ ) { int length = possibleTags [ k ] . length , size = <NUM_LIT:0> ; int indexes [ ] = new int [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( CharOperation . prefixEquals ( prefix , possibleTags [ k ] [ i ] , false ) ) { indexes [ size ++ ] = i ; } } char [ ] [ ] tags = new char [ size ] [ ] ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { tags [ i ] = possibleTags [ k ] [ indexes [ i ] ] ; } possibleTags [ k ] = tags ; } return possibleTags ; } private CompletionJavadoc getCompletionJavadoc ( ) { return ( CompletionJavadoc ) this . docComment ; } private CompletionParser getCompletionParser ( ) { return ( CompletionParser ) this . sourceParser ; } private void initLevelTags ( ) { int level = ( ( int ) ( this . complianceLevel > > > <NUM_LIT:16> ) ) - ClassFileConstants . MAJOR_VERSION_1_1 + <NUM_LIT:1> ; this . levelTags [ BLOCK_IDX ] = new char [ BLOCK_ALL_TAGS_LENGTH ] [ ] ; this . levelTagsLength [ BLOCK_IDX ] = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i <= level ; i ++ ) { int length = BLOCK_TAGS [ i ] . length ; System . arraycopy ( BLOCK_TAGS [ i ] , <NUM_LIT:0> , this . levelTags [ BLOCK_IDX ] , this . levelTagsLength [ BLOCK_IDX ] , length ) ; this . levelTagsLength [ BLOCK_IDX ] += length ; } if ( this . levelTagsLength [ BLOCK_IDX ] < BLOCK_ALL_TAGS_LENGTH ) { System . arraycopy ( this . levelTags [ BLOCK_IDX ] , <NUM_LIT:0> , this . levelTags [ BLOCK_IDX ] = new char [ this . levelTagsLength [ BLOCK_IDX ] ] [ ] , <NUM_LIT:0> , this . levelTagsLength [ BLOCK_IDX ] ) ; } this . levelTags [ INLINE_IDX ] = new char [ INLINE_ALL_TAGS_LENGTH ] [ ] ; this . levelTagsLength [ INLINE_IDX ] = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i <= level ; i ++ ) { int length = INLINE_TAGS [ i ] . length ; System . arraycopy ( INLINE_TAGS [ i ] , <NUM_LIT:0> , this . levelTags [ INLINE_IDX ] , this . levelTagsLength [ INLINE_IDX ] , length ) ; this . levelTagsLength [ INLINE_IDX ] += length ; } if ( this . levelTagsLength [ INLINE_IDX ] < INLINE_ALL_TAGS_LENGTH ) { System . arraycopy ( this . levelTags [ INLINE_IDX ] , <NUM_LIT:0> , this . levelTags [ INLINE_IDX ] = new char [ this . levelTagsLength [ INLINE_IDX ] ] [ ] , <NUM_LIT:0> , this . levelTagsLength [ INLINE_IDX ] ) ; } } protected Object parseArguments ( Object receiver ) throws InvalidInputException { if ( this . tagSourceStart > this . cursorLocation ) { return super . parseArguments ( receiver ) ; } int modulo = <NUM_LIT:0> ; int iToken = <NUM_LIT:0> ; char [ ] argName = null ; List arguments = new ArrayList ( <NUM_LIT:10> ) ; Object typeRef = null ; int dim = <NUM_LIT:0> ; boolean isVarargs = false ; long [ ] dimPositions = new long [ <NUM_LIT:20> ] ; char [ ] name = null ; long argNamePos = - <NUM_LIT:1> ; nextArg : while ( this . index < this . scanner . eofPosition ) { try { typeRef = parseQualifiedName ( false ) ; if ( this . abort ) return null ; } catch ( InvalidInputException e ) { break nextArg ; } boolean firstArg = modulo == <NUM_LIT:0> ; if ( firstArg ) { if ( iToken != <NUM_LIT:0> ) break nextArg ; } else if ( ( iToken % modulo ) != <NUM_LIT:0> ) { break nextArg ; } if ( typeRef == null ) { if ( firstArg && getCurrentTokenType ( ) == TerminalTokens . TokenNameRPAREN ) { this . lineStarted = true ; return createMethodReference ( receiver , null ) ; } Object methodRef = createMethodReference ( receiver , arguments ) ; return syntaxRecoverEmptyArgumentType ( methodRef ) ; } if ( this . index >= this . scanner . eofPosition ) { int argumentStart = ( ( ASTNode ) typeRef ) . sourceStart ; Object argument = createArgumentReference ( this . scanner . getCurrentIdentifierSource ( ) , <NUM_LIT:0> , false , typeRef , null , ( ( ( long ) argumentStart ) << <NUM_LIT:32> ) + this . tokenPreviousPosition - <NUM_LIT:1> ) ; return syntaxRecoverArgumentType ( receiver , arguments , argument ) ; } if ( this . index >= this . cursorLocation ) { if ( this . completionNode instanceof CompletionOnJavadocSingleTypeReference ) { CompletionOnJavadocSingleTypeReference singleTypeReference = ( CompletionOnJavadocSingleTypeReference ) this . completionNode ; if ( singleTypeReference . token == null || singleTypeReference . token . length == <NUM_LIT:0> ) { Object methodRef = createMethodReference ( receiver , arguments ) ; return syntaxRecoverEmptyArgumentType ( methodRef ) ; } } if ( this . completionNode instanceof CompletionOnJavadocQualifiedTypeReference ) { CompletionOnJavadocQualifiedTypeReference qualifiedTypeReference = ( CompletionOnJavadocQualifiedTypeReference ) this . completionNode ; if ( qualifiedTypeReference . tokens == null || qualifiedTypeReference . tokens . length < qualifiedTypeReference . sourcePositions . length ) { Object methodRef = createMethodReference ( receiver , arguments ) ; return syntaxRecoverEmptyArgumentType ( methodRef ) ; } } } iToken ++ ; dim = <NUM_LIT:0> ; isVarargs = false ; if ( readToken ( ) == TerminalTokens . TokenNameLBRACKET ) { int dimStart = this . scanner . getCurrentTokenStartPosition ( ) ; while ( readToken ( ) == TerminalTokens . TokenNameLBRACKET ) { consumeToken ( ) ; if ( readToken ( ) != TerminalTokens . TokenNameRBRACKET ) { break nextArg ; } consumeToken ( ) ; dimPositions [ dim ++ ] = ( ( ( long ) dimStart ) << <NUM_LIT:32> ) + this . scanner . getCurrentTokenEndPosition ( ) ; } } else if ( readToken ( ) == TerminalTokens . TokenNameELLIPSIS ) { int dimStart = this . scanner . getCurrentTokenStartPosition ( ) ; dimPositions [ dim ++ ] = ( ( ( long ) dimStart ) << <NUM_LIT:32> ) + this . scanner . getCurrentTokenEndPosition ( ) ; consumeToken ( ) ; isVarargs = true ; } argNamePos = - <NUM_LIT:1> ; if ( readToken ( ) == TerminalTokens . TokenNameIdentifier ) { consumeToken ( ) ; if ( firstArg ) { if ( iToken != <NUM_LIT:1> ) break nextArg ; } else if ( ( iToken % modulo ) != <NUM_LIT:1> ) { break nextArg ; } if ( argName == null ) { if ( ! firstArg ) { break nextArg ; } } argName = this . scanner . getCurrentIdentifierSource ( ) ; argNamePos = ( ( ( long ) this . scanner . getCurrentTokenStartPosition ( ) ) << <NUM_LIT:32> ) + this . scanner . getCurrentTokenEndPosition ( ) ; iToken ++ ; } else if ( argName != null ) { break nextArg ; } if ( firstArg ) { modulo = iToken + <NUM_LIT:1> ; } else { if ( ( iToken % modulo ) != ( modulo - <NUM_LIT:1> ) ) { break nextArg ; } } int token = readToken ( ) ; name = argName == null ? CharOperation . NO_CHAR : argName ; if ( token == TerminalTokens . TokenNameCOMMA ) { Object argument = createArgumentReference ( name , dim , isVarargs , typeRef , dimPositions , argNamePos ) ; if ( this . abort ) return null ; arguments . add ( argument ) ; consumeToken ( ) ; iToken ++ ; } else if ( token == TerminalTokens . TokenNameRPAREN ) { Object argument = createArgumentReference ( name , dim , isVarargs , typeRef , dimPositions , argNamePos ) ; if ( this . abort ) return null ; arguments . add ( argument ) ; consumeToken ( ) ; return createMethodReference ( receiver , arguments ) ; } else { Object argument = createArgumentReference ( name , dim , isVarargs , typeRef , dimPositions , argNamePos ) ; return syntaxRecoverArgumentType ( receiver , arguments , argument ) ; } } throw new InvalidInputException ( ) ; } protected boolean parseParam ( ) throws InvalidInputException { int startPosition = this . index ; int endPosition = this . index ; long namePosition = ( ( ( long ) startPosition ) << <NUM_LIT:32> ) + endPosition ; this . identifierPtr = - <NUM_LIT:1> ; boolean valid = super . parseParam ( ) ; if ( this . identifierPtr > <NUM_LIT:2> ) return valid ; char [ ] name = null ; CompletionScanner completionScanner = ( CompletionScanner ) this . scanner ; boolean isTypeParam = false ; if ( this . identifierPtr >= <NUM_LIT:0> ) { char [ ] identifier = null ; switch ( this . identifierPtr ) { case <NUM_LIT:2> : if ( ! valid && completionScanner . completionIdentifier != null && completionScanner . completionIdentifier . length == <NUM_LIT:0> ) { valid = pushParamName ( true ) ; } case <NUM_LIT:1> : isTypeParam = this . identifierStack [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] == '<CHAR_LIT>' ; identifier = this . identifierStack [ <NUM_LIT:1> ] ; namePosition = this . identifierPositionStack [ <NUM_LIT:1> ] ; break ; case <NUM_LIT:0> : identifier = this . identifierStack [ <NUM_LIT:0> ] ; namePosition = this . identifierPositionStack [ <NUM_LIT:0> ] ; isTypeParam = identifier . length > <NUM_LIT:0> && identifier [ <NUM_LIT:0> ] == '<CHAR_LIT>' ; break ; } if ( identifier != null && identifier . length > <NUM_LIT:0> && ScannerHelper . isJavaIdentifierPart ( this . complianceLevel , identifier [ <NUM_LIT:0> ] ) ) { name = identifier ; } startPosition = ( int ) ( this . identifierPositionStack [ <NUM_LIT:0> ] > > <NUM_LIT:32> ) ; endPosition = ( int ) this . identifierPositionStack [ this . identifierPtr ] ; } boolean inCompletion = ( startPosition <= ( this . cursorLocation + <NUM_LIT:1> ) && this . cursorLocation <= endPosition ) || ( ( startPosition == ( endPosition + <NUM_LIT:1> ) && endPosition == this . cursorLocation ) ) ; if ( inCompletion ) { if ( this . completionNode == null ) { if ( isTypeParam ) { this . completionNode = new CompletionOnJavadocTypeParamReference ( name , namePosition , startPosition , endPosition ) ; } else { this . completionNode = new CompletionOnJavadocParamNameReference ( name , namePosition , startPosition , endPosition ) ; } if ( CompletionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . completionNode ) ; } } else if ( this . completionNode instanceof CompletionOnJavadocParamNameReference ) { CompletionOnJavadocParamNameReference paramNameRef = ( CompletionOnJavadocParamNameReference ) this . completionNode ; int nameStart = ( int ) ( namePosition > > <NUM_LIT:32> ) ; paramNameRef . sourceStart = nameStart ; int nameEnd = ( int ) namePosition ; if ( nameStart < this . cursorLocation && this . cursorLocation < nameEnd ) { paramNameRef . sourceEnd = this . cursorLocation + <NUM_LIT:1> ; } else { paramNameRef . sourceEnd = nameEnd ; } paramNameRef . tagSourceStart = startPosition ; paramNameRef . tagSourceEnd = endPosition ; } else if ( this . completionNode instanceof CompletionOnJavadocTypeParamReference ) { CompletionOnJavadocTypeParamReference typeParamRef = ( CompletionOnJavadocTypeParamReference ) this . completionNode ; int nameStart = ( int ) ( namePosition > > <NUM_LIT:32> ) ; typeParamRef . sourceStart = nameStart ; int nameEnd = ( int ) namePosition ; if ( nameStart < this . cursorLocation && this . cursorLocation < nameEnd ) { typeParamRef . sourceEnd = this . cursorLocation + <NUM_LIT:1> ; } else { typeParamRef . sourceEnd = nameEnd ; } typeParamRef . tagSourceStart = startPosition ; typeParamRef . tagSourceEnd = endPosition ; } } return valid ; } protected boolean parseReference ( ) throws InvalidInputException { boolean completed = this . completionNode != null ; boolean valid = super . parseReference ( ) ; if ( ! completed && this . completionNode != null ) { this . completionNode . addCompletionFlags ( CompletionOnJavadoc . FORMAL_REFERENCE ) ; } return valid ; } protected boolean parseTag ( int previousPosition ) throws InvalidInputException { int startPosition = this . inlineTagStarted ? this . inlineTagStart : previousPosition ; boolean newLine = ! this . lineStarted ; boolean valid = super . parseTag ( previousPosition ) ; boolean inCompletion = ( this . tagSourceStart <= ( this . cursorLocation + <NUM_LIT:1> ) && this . cursorLocation <= this . tagSourceEnd ) || ( ( this . tagSourceStart == ( this . tagSourceEnd + <NUM_LIT:1> ) && this . tagSourceEnd == this . cursorLocation ) ) ; if ( inCompletion ) { int end = this . tagSourceEnd ; if ( this . inlineTagStarted && this . scanner . currentCharacter == '<CHAR_LIT:}>' ) { end = this . scanner . currentPosition ; } long position = ( ( ( long ) startPosition ) << <NUM_LIT:32> ) + end ; int length = this . cursorLocation + <NUM_LIT:1> - this . tagSourceStart ; char [ ] tag = new char [ length ] ; System . arraycopy ( this . source , this . tagSourceStart , tag , <NUM_LIT:0> , length ) ; char [ ] [ ] [ ] tags = possibleTags ( tag , newLine ) ; if ( tags != null ) { this . completionNode = new CompletionOnJavadocTag ( tag , position , startPosition , end , tags , this . allPossibleTags ) ; } } return valid ; } protected boolean parseThrows ( ) { try { Object typeRef = parseQualifiedName ( true ) ; if ( this . completionNode != null ) { this . completionNode . addCompletionFlags ( CompletionOnJavadoc . EXCEPTION ) ; } return pushThrowName ( typeRef ) ; } catch ( InvalidInputException ex ) { } return false ; } protected boolean pushParamName ( boolean isTypeParam ) { if ( super . pushParamName ( isTypeParam ) ) { Expression expression = ( Expression ) this . astStack [ this . astPtr ] ; if ( expression . sourceStart <= ( this . cursorLocation + <NUM_LIT:1> ) && this . cursorLocation <= expression . sourceEnd ) { if ( isTypeParam ) { this . completionNode = new CompletionOnJavadocTypeParamReference ( ( JavadocSingleTypeReference ) expression ) ; } else { this . completionNode = new CompletionOnJavadocParamNameReference ( ( JavadocSingleNameReference ) expression ) ; } if ( CompletionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . completionNode ) ; } } return true ; } return false ; } protected void pushText ( int start , int end ) { if ( start <= this . cursorLocation && this . cursorLocation <= end ) { this . scanner . resetTo ( start , end ) ; boolean tokenizeWhiteSpace = this . scanner . tokenizeWhiteSpace ; this . scanner . tokenizeWhiteSpace = true ; try { Object typeRef = null ; this . pushText = true ; int previousToken = TerminalTokens . TokenNameWHITESPACE ; while ( ! this . scanner . atEnd ( ) && this . completionNode == null && ! this . abort ) { int token = readTokenSafely ( ) ; switch ( token ) { case TerminalTokens . TokenNameStringLiteral : int strStart = <NUM_LIT:0> , strEnd = <NUM_LIT:0> ; if ( ( strStart = this . scanner . getCurrentTokenStartPosition ( ) + <NUM_LIT:1> ) <= this . cursorLocation && this . cursorLocation <= ( strEnd = this . scanner . getCurrentTokenEndPosition ( ) - <NUM_LIT:1> ) ) { this . scanner . resetTo ( strStart , strEnd ) ; } consumeToken ( ) ; break ; case TerminalTokens . TokenNameERROR : consumeToken ( ) ; if ( this . scanner . currentCharacter == '<CHAR_LIT>' ) { Object member = null ; try { this . scanner . tokenizeWhiteSpace = false ; member = parseMember ( typeRef ) ; } catch ( InvalidInputException e ) { consumeToken ( ) ; } this . scanner . tokenizeWhiteSpace = true ; if ( this . completionNode != null ) { int flags = this . inlineTagStarted ? <NUM_LIT:0> : CompletionOnJavadoc . TEXT | CompletionOnJavadoc . ONLY_INLINE_TAG ; if ( member instanceof JavadocMessageSend ) { JavadocMessageSend msgSend = ( JavadocMessageSend ) member ; this . completionNode = new CompletionOnJavadocMessageSend ( msgSend , this . memberStart , flags ) ; if ( CompletionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . completionNode ) ; } } else if ( member instanceof JavadocAllocationExpression ) { JavadocAllocationExpression alloc = ( JavadocAllocationExpression ) member ; this . completionNode = new CompletionOnJavadocAllocationExpression ( alloc , this . memberStart , flags ) ; if ( CompletionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . completionNode ) ; } } else { this . completionNode . addCompletionFlags ( flags ) ; } } } break ; case TerminalTokens . TokenNameIdentifier : try { this . scanner . tokenizeWhiteSpace = false ; typeRef = parseQualifiedName ( true ) ; if ( this . completionNode == null ) { consumeToken ( ) ; this . scanner . resetTo ( this . tokenPreviousPosition , end ) ; this . index = this . tokenPreviousPosition ; } } catch ( InvalidInputException e ) { consumeToken ( ) ; } finally { this . scanner . tokenizeWhiteSpace = true ; } if ( previousToken != TerminalTokens . TokenNameWHITESPACE ) { typeRef = null ; this . completionNode = null ; } break ; case TerminalTokens . TokenNameAT : consumeToken ( ) ; try { this . scanner . tokenizeWhiteSpace = false ; int startPosition = this . scanner . getCurrentTokenStartPosition ( ) ; parseTag ( startPosition ) ; if ( this . completionNode != null ) { if ( this . inlineTagStarted ) { } else { } } } catch ( InvalidInputException e ) { consumeToken ( ) ; } this . scanner . tokenizeWhiteSpace = true ; break ; default : consumeToken ( ) ; typeRef = null ; break ; } previousToken = token ; } } finally { this . scanner . tokenizeWhiteSpace = tokenizeWhiteSpace ; this . pushText = false ; } this . index = end ; this . scanner . currentPosition = end ; consumeToken ( ) ; if ( this . completionNode != null ) { if ( this . inlineTagStarted ) { this . completionNode . addCompletionFlags ( CompletionOnJavadoc . FORMAL_REFERENCE ) ; } else { this . completionNode . addCompletionFlags ( CompletionOnJavadoc . TEXT ) ; } } } } protected int readToken ( ) throws InvalidInputException { int token = super . readToken ( ) ; if ( token == TerminalTokens . TokenNameIdentifier && this . scanner . currentPosition == this . scanner . startPosition ) { this . scanner . getCurrentIdentifierSource ( ) ; } return token ; } protected Object syntaxRecoverQualifiedName ( int primitiveToken ) throws InvalidInputException { if ( this . cursorLocation == ( ( int ) this . identifierPositionStack [ this . identifierPtr ] ) ) { return createTypeReference ( primitiveToken ) ; } int idLength = this . identifierLengthStack [ this . identifierLengthPtr ] ; char [ ] [ ] tokens = new char [ idLength ] [ ] ; int startPtr = this . identifierPtr - idLength + <NUM_LIT:1> ; System . arraycopy ( this . identifierStack , startPtr , tokens , <NUM_LIT:0> , idLength ) ; long [ ] positions = new long [ idLength + <NUM_LIT:1> ] ; System . arraycopy ( this . identifierPositionStack , startPtr , positions , <NUM_LIT:0> , idLength ) ; positions [ idLength ] = ( ( ( long ) this . tokenPreviousPosition ) << <NUM_LIT:32> ) + this . tokenPreviousPosition ; this . completionNode = new CompletionOnJavadocQualifiedTypeReference ( tokens , CharOperation . NO_CHAR , positions , this . tagSourceStart , this . tagSourceEnd ) ; if ( CompletionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . completionNode ) ; } return this . completionNode ; } protected Object syntaxRecoverArgumentType ( Object receiver , List arguments , Object argument ) throws InvalidInputException { if ( this . completionNode != null && ! this . pushText ) { this . completionNode . addCompletionFlags ( CompletionOnJavadoc . BASE_TYPES ) ; if ( this . completionNode instanceof CompletionOnJavadocSingleTypeReference ) { char [ ] token = ( ( CompletionOnJavadocSingleTypeReference ) this . completionNode ) . token ; if ( token != null && token . length > <NUM_LIT:0> ) { return this . completionNode ; } } else { return this . completionNode ; } } if ( this . completionNode instanceof CompletionOnJavadocSingleTypeReference ) { CompletionOnJavadocSingleTypeReference singleTypeReference = ( CompletionOnJavadocSingleTypeReference ) this . completionNode ; if ( singleTypeReference . token != null && singleTypeReference . token . length > <NUM_LIT:0> ) { arguments . add ( argument ) ; } } else if ( this . completionNode instanceof CompletionOnJavadocQualifiedTypeReference ) { CompletionOnJavadocQualifiedTypeReference qualifiedTypeReference = ( CompletionOnJavadocQualifiedTypeReference ) this . completionNode ; if ( qualifiedTypeReference . tokens != null && qualifiedTypeReference . tokens . length == qualifiedTypeReference . sourcePositions . length ) { arguments . add ( argument ) ; } } else { arguments . add ( argument ) ; } Object methodRef = super . createMethodReference ( receiver , arguments ) ; if ( methodRef instanceof JavadocMessageSend ) { JavadocMessageSend msgSend = ( JavadocMessageSend ) methodRef ; if ( this . index > this . cursorLocation ) { msgSend . sourceEnd = this . tokenPreviousPosition - <NUM_LIT:1> ; } int nameStart = ( int ) ( msgSend . nameSourcePosition > > > <NUM_LIT:32> ) ; int nameEnd = ( int ) msgSend . nameSourcePosition ; if ( ( nameStart <= ( this . cursorLocation + <NUM_LIT:1> ) && this . cursorLocation <= nameEnd ) ) { this . completionNode = new CompletionOnJavadocFieldReference ( msgSend , this . memberStart ) ; } else { this . completionNode = new CompletionOnJavadocMessageSend ( msgSend , this . memberStart ) ; } } else if ( methodRef instanceof JavadocAllocationExpression ) { JavadocAllocationExpression allocExp = ( JavadocAllocationExpression ) methodRef ; if ( this . index > this . cursorLocation ) { allocExp . sourceEnd = this . tokenPreviousPosition - <NUM_LIT:1> ; } this . completionNode = new CompletionOnJavadocAllocationExpression ( allocExp , this . memberStart ) ; } if ( CompletionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . completionNode ) ; } return this . completionNode ; } protected Object syntaxRecoverEmptyArgumentType ( Object methodRef ) throws InvalidInputException { if ( methodRef instanceof JavadocMessageSend ) { JavadocMessageSend msgSend = ( JavadocMessageSend ) methodRef ; if ( this . index > this . cursorLocation ) { msgSend . sourceEnd = this . tokenPreviousPosition - <NUM_LIT:1> ; } this . completionNode = new CompletionOnJavadocMessageSend ( msgSend , this . memberStart ) ; } else if ( methodRef instanceof JavadocAllocationExpression ) { JavadocAllocationExpression allocExp = ( JavadocAllocationExpression ) methodRef ; if ( this . index > this . cursorLocation ) { allocExp . sourceEnd = this . tokenPreviousPosition - <NUM_LIT:1> ; } this . completionNode = new CompletionOnJavadocAllocationExpression ( allocExp , this . memberStart ) ; } if ( CompletionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . completionNode ) ; } return this . completionNode ; } protected void updateDocComment ( ) { super . updateDocComment ( ) ; if ( this . completionNode instanceof Expression ) { getCompletionParser ( ) . assistNodeParent = this . docComment ; getCompletionParser ( ) . assistNode = ( ASTNode ) this . completionNode ; getCompletionJavadoc ( ) . completionNode = ( Expression ) this . completionNode ; } } protected boolean verifySpaceOrEndComment ( ) { CompletionScanner completionScanner = ( CompletionScanner ) this . scanner ; if ( completionScanner . completionIdentifier != null && completionScanner . completedIdentifierStart <= this . cursorLocation && this . cursorLocation <= completionScanner . completedIdentifierEnd ) { return true ; } return super . verifySpaceOrEndComment ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . BranchStatement ; import org . eclipse . jdt . internal . compiler . flow . FlowContext ; import org . eclipse . jdt . internal . compiler . flow . FlowInfo ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; public class CompletionOnBranchStatementLabel extends BranchStatement { public static final int BREAK = <NUM_LIT:1> ; public static final int CONTINUE = <NUM_LIT:2> ; private int kind ; public char [ ] [ ] possibleLabels ; public CompletionOnBranchStatementLabel ( int kind , char [ ] l , int s , int e , char [ ] [ ] possibleLabels ) { super ( l , s , e ) ; this . kind = kind ; this . possibleLabels = possibleLabels ; } public FlowInfo analyseCode ( BlockScope currentScope , FlowContext flowContext , FlowInfo flowInfo ) { return null ; } public void resolve ( BlockScope scope ) { throw new CompletionNodeFound ( this , scope ) ; } public StringBuffer printStatement ( int indent , StringBuffer output ) { printIndent ( indent , output ) ; if ( this . kind == CONTINUE ) { output . append ( "<STR_LIT>" ) ; } else { output . append ( "<STR_LIT>" ) ; } output . append ( "<STR_LIT>" ) ; output . append ( this . label ) ; return output . append ( "<STR_LIT>" ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; public class InvalidCursorLocation extends RuntimeException { public String irritant ; public static final String NO_COMPLETION_INSIDE_UNICODE = "<STR_LIT>" ; public static final String NO_COMPLETION_INSIDE_COMMENT = "<STR_LIT>" ; public static final String NO_COMPLETION_INSIDE_STRING = "<STR_LIT>" ; public static final String NO_COMPLETION_INSIDE_NUMBER = "<STR_LIT>" ; private static final long serialVersionUID = - <NUM_LIT> ; public InvalidCursorLocation ( String irritant ) { this . irritant = irritant ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; public class CompletionOnMemberAccess extends FieldReference { public boolean isInsideAnnotation ; public CompletionOnMemberAccess ( char [ ] source , long pos , boolean isInsideAnnotation ) { super ( source , pos ) ; this . isInsideAnnotation = isInsideAnnotation ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; return super . printExpression ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:>>' ) ; } public TypeBinding resolveType ( BlockScope scope ) { this . actualReceiverType = this . receiver . resolveType ( scope ) ; if ( ( this . actualReceiverType == null || ! this . actualReceiverType . isValidBinding ( ) ) && this . receiver instanceof MessageSend ) { MessageSend messageSend = ( MessageSend ) this . receiver ; if ( messageSend . receiver instanceof ThisReference ) { Expression [ ] arguments = messageSend . arguments ; int length = arguments == null ? <NUM_LIT:0> : arguments . length ; TypeBinding [ ] argBindings = new TypeBinding [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { argBindings [ i ] = arguments [ i ] . resolvedType ; if ( argBindings [ i ] == null || ! argBindings [ i ] . isValidBinding ( ) ) { throw new CompletionNodeFound ( ) ; } } ProblemMethodBinding problemMethodBinding = new ProblemMethodBinding ( messageSend . selector , argBindings , ProblemReasons . NotFound ) ; throw new CompletionNodeFound ( this , problemMethodBinding , scope ) ; } } if ( this . actualReceiverType == null || this . actualReceiverType . isBaseType ( ) || ! this . actualReceiverType . isValidBinding ( ) ) throw new CompletionNodeFound ( ) ; else throw new CompletionNodeFound ( this , this . actualReceiverType , scope ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . SingleNameReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class CompletionOnKeyword3 extends SingleNameReference implements CompletionOnKeyword { private char [ ] [ ] possibleKeywords ; public CompletionOnKeyword3 ( char [ ] token , long pos , char [ ] possibleKeyword ) { this ( token , pos , new char [ ] [ ] { possibleKeyword } ) ; } public CompletionOnKeyword3 ( char [ ] token , long pos , char [ ] [ ] possibleKeywords ) { super ( token , pos ) ; this . token = token ; this . possibleKeywords = possibleKeywords ; } public boolean canCompleteEmptyToken ( ) { return false ; } public char [ ] getToken ( ) { return this . token ; } public char [ ] [ ] getPossibleKeywords ( ) { return this . possibleKeywords ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { return output . append ( "<STR_LIT>" ) . append ( this . token ) . append ( '<CHAR_LIT:>>' ) ; } public TypeBinding resolveType ( BlockScope scope ) { throw new CompletionNodeFound ( this , scope ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . ast . JavadocSingleNameReference ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; 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 . compiler . parser . JavadocTagConstants ; public class CompletionOnJavadocTag extends JavadocSingleNameReference implements JavadocTagConstants , CompletionOnJavadoc { public int completionFlags = JAVADOC ; public final static char [ ] [ ] [ ] NO_CHAR_CHAR_CHAR = new char [ <NUM_LIT:0> ] [ ] [ ] ; private char [ ] [ ] [ ] possibleTags = NO_CHAR_CHAR_CHAR ; public CompletionOnJavadocTag ( char [ ] source , long pos , int tagStart , int tagEnd , char [ ] [ ] [ ] possibleTags , boolean orphan ) { super ( source , pos , tagStart , tagEnd ) ; this . possibleTags = possibleTags ; if ( orphan ) this . completionFlags |= ALL_POSSIBLE_TAGS ; } public void addCompletionFlags ( int flags ) { this . completionFlags |= flags ; } public int getCompletionFlags ( ) { return this . completionFlags ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; output . append ( '<CHAR_LIT>' ) ; if ( this . token != null ) super . printExpression ( indent , output ) ; char [ ] [ ] blockTags = this . possibleTags [ BLOCK_IDX ] ; if ( blockTags != null ) { int length = blockTags . length ; if ( length > <NUM_LIT:0> ) { output . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { output . append ( "<STR_LIT>" ) ; output . append ( blockTags [ i ] ) ; } output . append ( '<STR_LIT:\n>' ) ; } } char [ ] [ ] inlineTags = this . possibleTags [ INLINE_IDX ] ; if ( inlineTags != null ) { int length = inlineTags . length ; if ( length > <NUM_LIT:0> ) { output . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { output . append ( "<STR_LIT>" ) ; output . append ( inlineTags [ i ] ) ; } output . append ( '<STR_LIT:\n>' ) ; } } return output . append ( '<CHAR_LIT:>>' ) ; } public void filterPossibleTags ( Scope scope ) { if ( this . possibleTags == null || this . possibleTags . length == <NUM_LIT:0> || ( this . completionFlags & ALL_POSSIBLE_TAGS ) != <NUM_LIT:0> ) { return ; } int kind = scope . kind ; char [ ] [ ] specifiedTags = null ; switch ( kind ) { case Scope . COMPILATION_UNIT_SCOPE : CompilationUnitDeclaration compilationUnit = scope . referenceCompilationUnit ( ) ; if ( compilationUnit != null && ( compilationUnit . types . length > <NUM_LIT:0> && compilationUnit . types [ <NUM_LIT:0> ] . name == CompletionParser . FAKE_TYPE_NAME ) ) { specifiedTags = CLASS_TAGS ; } else { specifiedTags = COMPILATION_UNIT_TAGS ; } break ; case Scope . CLASS_SCOPE : specifiedTags = CLASS_TAGS ; break ; case Scope . METHOD_SCOPE : MethodScope methodScope = ( MethodScope ) scope ; if ( methodScope . referenceMethod ( ) == null ) { if ( methodScope . initializedField == null ) { specifiedTags = PACKAGE_TAGS ; } else { specifiedTags = FIELD_TAGS ; } } else { specifiedTags = METHOD_TAGS ; } break ; default : return ; } int kinds = this . possibleTags . length ; for ( int k = <NUM_LIT:0> ; k < kinds ; k ++ ) { int length = this . possibleTags [ k ] . length ; int specLenth = specifiedTags . length ; char [ ] [ ] filteredTags = new char [ length ] [ ] ; int size = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char [ ] possibleTag = this . possibleTags [ k ] [ i ] ; for ( int j = <NUM_LIT:0> ; j < specLenth ; j ++ ) { if ( possibleTag [ <NUM_LIT:0> ] == specifiedTags [ j ] [ <NUM_LIT:0> ] && CharOperation . equals ( possibleTag , specifiedTags [ j ] ) ) { if ( possibleTag == TAG_PARAM ) { switch ( scope . kind ) { case Scope . CLASS_SCOPE : if ( scope . compilerOptions ( ) . sourceLevel >= ClassFileConstants . JDK1_5 ) { if ( ( ( ClassScope ) scope ) . referenceContext . binding . isGenericType ( ) ) { filteredTags [ size ++ ] = possibleTag ; } } break ; case Scope . COMPILATION_UNIT_SCOPE : if ( scope . compilerOptions ( ) . sourceLevel >= ClassFileConstants . JDK1_5 ) { filteredTags [ size ++ ] = possibleTag ; } break ; default : filteredTags [ size ++ ] = possibleTag ; break ; } } else { filteredTags [ size ++ ] = possibleTag ; } break ; } } } if ( size < length ) { System . arraycopy ( filteredTags , <NUM_LIT:0> , this . possibleTags [ k ] = new char [ size ] [ ] , <NUM_LIT:0> , size ) ; } } } public char [ ] [ ] getPossibleBlockTags ( ) { return this . possibleTags [ BLOCK_IDX ] ; } public char [ ] [ ] getPossibleInlineTags ( ) { return this . possibleTags [ INLINE_IDX ] ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class CompletionOnParameterizedQualifiedTypeReference extends ParameterizedQualifiedTypeReference { public static final int K_TYPE = <NUM_LIT:0> ; public static final int K_CLASS = <NUM_LIT:1> ; public static final int K_INTERFACE = <NUM_LIT:2> ; public static final int K_EXCEPTION = <NUM_LIT:3> ; private int kind = K_TYPE ; public char [ ] completionIdentifier ; public CompletionOnParameterizedQualifiedTypeReference ( char [ ] [ ] tokens , TypeReference [ ] [ ] typeArguments , char [ ] completionIdentifier , long [ ] positions ) { this ( tokens , typeArguments , completionIdentifier , positions , K_TYPE ) ; } public CompletionOnParameterizedQualifiedTypeReference ( char [ ] [ ] tokens , TypeReference [ ] [ ] typeArguments , char [ ] completionIdentifier , long [ ] positions , int kind ) { super ( tokens , typeArguments , <NUM_LIT:0> , positions ) ; this . completionIdentifier = completionIdentifier ; this . kind = kind ; } public boolean isClass ( ) { return this . kind == K_CLASS ; } public boolean isInterface ( ) { return this . kind == K_INTERFACE ; } public boolean isException ( ) { return this . kind == K_EXCEPTION ; } public boolean isSuperType ( ) { return this . kind == K_CLASS || this . kind == K_INTERFACE ; } public TypeBinding resolveType ( BlockScope scope , boolean checkBounds ) { super . resolveType ( scope , checkBounds ) ; throw new CompletionNodeFound ( this , this . resolvedType , scope ) ; } public TypeBinding resolveType ( ClassScope scope ) { super . resolveType ( scope ) ; throw new CompletionNodeFound ( this , this . resolvedType , scope ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { switch ( this . kind ) { case K_CLASS : output . append ( "<STR_LIT>" ) ; break ; case K_INTERFACE : output . append ( "<STR_LIT>" ) ; break ; case K_EXCEPTION : output . append ( "<STR_LIT>" ) ; break ; default : output . append ( "<STR_LIT>" ) ; break ; } int length = this . tokens . length ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) { output . append ( this . tokens [ i ] ) ; TypeReference [ ] typeArgument = this . typeArguments [ i ] ; if ( typeArgument != null ) { output . append ( '<CHAR_LIT>' ) ; int max = typeArgument . length - <NUM_LIT:1> ; for ( int j = <NUM_LIT:0> ; j < max ; j ++ ) { typeArgument [ j ] . print ( <NUM_LIT:0> , output ) ; output . append ( "<STR_LIT:U+002CU+0020>" ) ; } typeArgument [ max ] . print ( <NUM_LIT:0> , output ) ; output . append ( '<CHAR_LIT:>>' ) ; } output . append ( '<CHAR_LIT:.>' ) ; } output . append ( this . tokens [ length - <NUM_LIT:1> ] ) ; TypeReference [ ] typeArgument = this . typeArguments [ length - <NUM_LIT:1> ] ; if ( typeArgument != null ) { output . append ( '<CHAR_LIT>' ) ; int max = typeArgument . length - <NUM_LIT:1> ; for ( int j = <NUM_LIT:0> ; j < max ; j ++ ) { typeArgument [ j ] . print ( <NUM_LIT:0> , output ) ; output . append ( "<STR_LIT:U+002CU+0020>" ) ; } typeArgument [ max ] . print ( <NUM_LIT:0> , output ) ; output . append ( '<CHAR_LIT:>>' ) ; } output . append ( '<CHAR_LIT:.>' ) . append ( this . completionIdentifier ) . append ( '<CHAR_LIT:>>' ) ; return output ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; public class CompletionOnSingleTypeReference extends SingleTypeReference { public static final int K_TYPE = <NUM_LIT:0> ; public static final int K_CLASS = <NUM_LIT:1> ; public static final int K_INTERFACE = <NUM_LIT:2> ; public static final int K_EXCEPTION = <NUM_LIT:3> ; private int kind = K_TYPE ; public boolean isCompletionNode ; public boolean isConstructorType ; public CompletionOnFieldType fieldTypeCompletionNode ; public CompletionOnSingleTypeReference ( char [ ] source , long pos ) { this ( source , pos , K_TYPE ) ; } public CompletionOnSingleTypeReference ( char [ ] source , long pos , int kind ) { super ( source , pos ) ; this . isCompletionNode = true ; this . kind = kind ; } public void aboutToResolve ( Scope scope ) { getTypeBinding ( scope ) ; } public TypeReference copyDims ( int dim ) { return this ; } protected TypeBinding getTypeBinding ( Scope scope ) { if ( this . fieldTypeCompletionNode != null ) { throw new CompletionNodeFound ( this . fieldTypeCompletionNode , scope ) ; } if ( this . isCompletionNode ) { throw new CompletionNodeFound ( this , scope ) ; } else { return super . getTypeBinding ( scope ) ; } } public boolean isClass ( ) { return this . kind == K_CLASS ; } public boolean isInterface ( ) { return this . kind == K_INTERFACE ; } public boolean isException ( ) { return this . kind == K_EXCEPTION ; } public boolean isSuperType ( ) { return this . kind == K_CLASS || this . kind == K_INTERFACE ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { switch ( this . kind ) { case K_CLASS : output . append ( "<STR_LIT>" ) ; break ; case K_INTERFACE : output . append ( "<STR_LIT>" ) ; break ; case K_EXCEPTION : output . append ( "<STR_LIT>" ) ; break ; default : output . append ( "<STR_LIT>" ) ; break ; } return output . append ( this . token ) . append ( '<CHAR_LIT:>>' ) ; } public TypeBinding resolveTypeEnclosing ( BlockScope scope , ReferenceBinding enclosingType ) { if ( this . fieldTypeCompletionNode != null ) { throw new CompletionNodeFound ( this . fieldTypeCompletionNode , scope ) ; } if ( this . isCompletionNode ) { throw new CompletionNodeFound ( this , enclosingType , scope ) ; } else { return super . resolveTypeEnclosing ( scope , enclosingType ) ; } } public void setKind ( int kind ) { this . kind = kind ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . SingleTypeReference ; import org . eclipse . jdt . internal . compiler . lookup . Scope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class CompletionOnKeyword1 extends SingleTypeReference implements CompletionOnKeyword { private char [ ] [ ] possibleKeywords ; public boolean canCompleteEmptyToken ; public CompletionOnKeyword1 ( char [ ] token , long pos , char [ ] possibleKeyword ) { this ( token , pos , new char [ ] [ ] { possibleKeyword } ) ; } public CompletionOnKeyword1 ( char [ ] token , long pos , char [ ] [ ] possibleKeywords ) { super ( token , pos ) ; this . possibleKeywords = possibleKeywords ; } public boolean canCompleteEmptyToken ( ) { return this . canCompleteEmptyToken ; } public char [ ] getToken ( ) { return this . token ; } public char [ ] [ ] getPossibleKeywords ( ) { return this . possibleKeywords ; } public void aboutToResolve ( Scope scope ) { getTypeBinding ( scope ) ; } protected TypeBinding getTypeBinding ( Scope scope ) { throw new CompletionNodeFound ( this , scope ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { return output . append ( "<STR_LIT>" ) . append ( this . token ) . append ( '<CHAR_LIT:>>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . * ; public class CompletionOnImportReference extends ImportReference { public CompletionOnImportReference ( char [ ] [ ] tokens , long [ ] positions , int modifiers ) { super ( tokens , positions , false , modifiers ) ; } public StringBuffer print ( int indent , StringBuffer output , boolean withOnDemand ) { printIndent ( indent , output ) . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < this . tokens . length ; i ++ ) { if ( i > <NUM_LIT:0> ) output . append ( '<CHAR_LIT:.>' ) ; output . append ( this . tokens [ i ] ) ; } return output . append ( '<CHAR_LIT:>>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . lookup . MethodScope ; public class CompletionOnFieldName extends FieldDeclaration { private static final char [ ] FAKENAMESUFFIX = "<STR_LIT:U+0020>" . toCharArray ( ) ; public char [ ] realName ; public CompletionOnFieldName ( char [ ] name , int sourceStart , int sourceEnd ) { super ( CharOperation . concat ( name , FAKENAMESUFFIX ) , sourceStart , sourceEnd ) ; this . realName = name ; } public StringBuffer printStatement ( int tab , StringBuffer output ) { printIndent ( tab , output ) . append ( "<STR_LIT>" ) ; if ( this . type != null ) this . type . print ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:U+0020>' ) ; output . append ( this . realName ) ; if ( this . initialization != null ) { output . append ( "<STR_LIT:U+0020=U+0020>" ) ; this . initialization . printExpression ( <NUM_LIT:0> , output ) ; } return output . append ( "<STR_LIT>" ) ; } public void resolve ( MethodScope initializationScope ) { super . resolve ( initializationScope ) ; throw new CompletionNodeFound ( this , initializationScope ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . JavadocSingleTypeReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class CompletionOnJavadocTypeParamReference extends JavadocSingleTypeReference implements CompletionOnJavadoc { public int completionFlags = JAVADOC ; public char [ ] [ ] missingParams ; public CompletionOnJavadocTypeParamReference ( char [ ] name , long pos , int start , int end ) { super ( name , pos , start , end ) ; } public CompletionOnJavadocTypeParamReference ( JavadocSingleTypeReference typeRef ) { super ( typeRef . token , ( ( ( long ) typeRef . sourceStart ) << <NUM_LIT:32> ) + typeRef . sourceEnd , typeRef . tagSourceStart , typeRef . tagSourceStart ) ; } public void addCompletionFlags ( int flags ) { this . completionFlags |= flags ; } public int getCompletionFlags ( ) { return this . completionFlags ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; if ( this . token != null ) super . printExpression ( indent , output ) ; return output . append ( '<CHAR_LIT:>>' ) ; } public TypeBinding reportError ( BlockScope scope ) { return null ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . JavadocFieldReference ; import org . eclipse . jdt . internal . compiler . ast . JavadocMessageSend ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . Scope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class CompletionOnJavadocFieldReference extends JavadocFieldReference implements CompletionOnJavadoc { public int completionFlags = JAVADOC ; public int separatorPosition ; public CompletionOnJavadocFieldReference ( Expression receiver , int tag , int position , int separatorPos , char [ ] name ) { super ( null , ( ( ( long ) position ) << <NUM_LIT:32> ) + position - <NUM_LIT:1> ) ; this . receiver = receiver ; this . tagSourceStart = position ; this . tagSourceEnd = position ; this . tagValue = tag ; this . separatorPosition = separatorPos ; } public CompletionOnJavadocFieldReference ( JavadocFieldReference fieldRef , int position , char [ ] name ) { super ( fieldRef . token , fieldRef . nameSourcePosition ) ; this . receiver = fieldRef . receiver ; this . separatorPosition = position ; this . tagSourceStart = fieldRef . tagSourceStart ; this . tagSourceEnd = fieldRef . tagSourceEnd ; this . tagValue = fieldRef . tagValue ; } public CompletionOnJavadocFieldReference ( JavadocMessageSend msgSend , int position ) { super ( msgSend . selector , ( ( msgSend . nameSourcePosition > > <NUM_LIT:32> ) << <NUM_LIT:32> ) + msgSend . sourceEnd ) ; this . receiver = msgSend . receiver ; this . separatorPosition = position ; this . tagSourceStart = msgSend . tagSourceStart ; this . tagSourceEnd = msgSend . tagSourceEnd ; this . tagValue = msgSend . tagValue ; } public void addCompletionFlags ( int flags ) { this . completionFlags |= flags ; } public boolean completeAnException ( ) { return ( this . completionFlags & EXCEPTION ) != <NUM_LIT:0> ; } public boolean completeInText ( ) { return ( this . completionFlags & TEXT ) != <NUM_LIT:0> ; } public boolean completeBaseTypes ( ) { return ( this . completionFlags & BASE_TYPES ) != <NUM_LIT:0> ; } public boolean completeFormalReference ( ) { return ( this . completionFlags & FORMAL_REFERENCE ) != <NUM_LIT:0> ; } public int getCompletionFlags ( ) { return this . completionFlags ; } protected TypeBinding internalResolveType ( Scope scope ) { if ( this . token != null ) { return super . internalResolveType ( scope ) ; } if ( this . receiver == null ) { this . actualReceiverType = scope . enclosingSourceType ( ) ; } else if ( scope . kind == Scope . CLASS_SCOPE ) { this . actualReceiverType = this . receiver . resolveType ( ( ClassScope ) scope ) ; } else { this . actualReceiverType = this . receiver . resolveType ( ( BlockScope ) scope ) ; } return null ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; super . printExpression ( indent , output ) ; indent ++ ; if ( this . completionFlags > <NUM_LIT:0> ) { output . append ( '<STR_LIT:\n>' ) ; for ( int i = <NUM_LIT:0> ; i < indent ; i ++ ) output . append ( '<STR_LIT:\t>' ) ; output . append ( "<STR_LIT>" ) ; char separator = <NUM_LIT:0> ; if ( completeAnException ( ) ) { output . append ( "<STR_LIT>" ) ; separator = '<CHAR_LIT:U+002C>' ; } if ( completeInText ( ) ) { if ( separator != <NUM_LIT:0> ) output . append ( separator ) ; output . append ( "<STR_LIT:text>" ) ; separator = '<CHAR_LIT:U+002C>' ; } if ( completeBaseTypes ( ) ) { if ( separator != <NUM_LIT:0> ) output . append ( separator ) ; output . append ( "<STR_LIT>" ) ; separator = '<CHAR_LIT:U+002C>' ; } if ( completeFormalReference ( ) ) { if ( separator != <NUM_LIT:0> ) output . append ( separator ) ; output . append ( "<STR_LIT>" ) ; separator = '<CHAR_LIT:U+002C>' ; } output . append ( '<STR_LIT:\n>' ) ; } indent -- ; for ( int i = <NUM_LIT:0> ; i < indent ; i ++ ) output . append ( '<STR_LIT:\t>' ) ; return output . append ( '<CHAR_LIT:>>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; public class CompletionOnPackageReference extends ImportReference { public CompletionOnPackageReference ( char [ ] [ ] tokens , long [ ] positions ) { super ( tokens , positions , false , ClassFileConstants . AccDefault ) ; } public StringBuffer print ( int indent , StringBuffer output , boolean withOnDemand ) { printIndent ( indent , output ) . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < this . tokens . length ; i ++ ) { if ( i > <NUM_LIT:0> ) output . append ( '<CHAR_LIT:.>' ) ; output . append ( this . tokens [ i ] ) ; } return output . append ( '<CHAR_LIT:>>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeParameter ; public class CompletionOnMethodTypeParameter extends MethodDeclaration { public CompletionOnMethodTypeParameter ( TypeParameter [ ] typeParameters , CompilationResult compilationResult ) { super ( compilationResult ) ; this . selector = CharOperation . NO_CHAR ; this . typeParameters = typeParameters ; this . sourceStart = typeParameters [ <NUM_LIT:0> ] . sourceStart ; this . sourceEnd = typeParameters [ typeParameters . length - <NUM_LIT:1> ] . sourceEnd ; } public void resolveStatements ( ) { throw new CompletionNodeFound ( this , this . scope ) ; } public StringBuffer print ( int tab , StringBuffer output ) { printIndent ( tab , output ) ; output . append ( '<CHAR_LIT>' ) ; int max = this . typeParameters . length - <NUM_LIT:1> ; for ( int j = <NUM_LIT:0> ; j < max ; j ++ ) { this . typeParameters [ j ] . print ( <NUM_LIT:0> , output ) ; output . append ( "<STR_LIT:U+002CU+0020>" ) ; } this . typeParameters [ max ] . print ( <NUM_LIT:0> , output ) ; output . append ( '<CHAR_LIT:>>' ) ; return output ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; public class CompletionOnClassLiteralAccess extends ClassLiteralAccess { public char [ ] completionIdentifier ; public int classStart ; public CompletionOnClassLiteralAccess ( long pos , TypeReference t ) { super ( ( int ) pos , t ) ; this . classStart = ( int ) ( pos > > > <NUM_LIT:32> ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; return this . type . print ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:.>' ) . append ( this . completionIdentifier ) . append ( '<CHAR_LIT:>>' ) ; } public TypeBinding resolveType ( BlockScope scope ) { if ( super . resolveType ( scope ) == null ) throw new CompletionNodeFound ( ) ; else throw new CompletionNodeFound ( this , this . targetType , scope ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; public class CompletionOnQualifiedTypeReference extends QualifiedTypeReference { public static final int K_TYPE = <NUM_LIT:0> ; public static final int K_CLASS = <NUM_LIT:1> ; public static final int K_INTERFACE = <NUM_LIT:2> ; public static final int K_EXCEPTION = <NUM_LIT:3> ; private int kind = K_TYPE ; public char [ ] completionIdentifier ; public boolean isConstructorType ; public CompletionOnQualifiedTypeReference ( char [ ] [ ] previousIdentifiers , char [ ] completionIdentifier , long [ ] positions ) { this ( previousIdentifiers , completionIdentifier , positions , K_TYPE ) ; } public CompletionOnQualifiedTypeReference ( char [ ] [ ] previousIdentifiers , char [ ] completionIdentifier , long [ ] positions , int kind ) { super ( previousIdentifiers , positions ) ; this . completionIdentifier = completionIdentifier ; this . kind = kind ; } public void aboutToResolve ( Scope scope ) { getTypeBinding ( scope ) ; } public TypeReference copyDims ( int dim ) { return this ; } protected TypeBinding getTypeBinding ( Scope scope ) { Binding binding = scope . parent . getTypeOrPackage ( this . tokens ) ; if ( ! binding . isValidBinding ( ) ) { scope . problemReporter ( ) . invalidType ( this , ( TypeBinding ) binding ) ; if ( binding . problemId ( ) == ProblemReasons . NotFound ) { throw new CompletionNodeFound ( this , binding , scope ) ; } throw new CompletionNodeFound ( ) ; } throw new CompletionNodeFound ( this , binding , scope ) ; } public boolean isClass ( ) { return this . kind == K_CLASS ; } public boolean isInterface ( ) { return this . kind == K_INTERFACE ; } public boolean isException ( ) { return this . kind == K_EXCEPTION ; } public boolean isSuperType ( ) { return this . kind == K_CLASS || this . kind == K_INTERFACE ; } public void setKind ( int kind ) { this . kind = kind ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { switch ( this . kind ) { case K_CLASS : output . append ( "<STR_LIT>" ) ; break ; case K_INTERFACE : output . append ( "<STR_LIT>" ) ; break ; case K_EXCEPTION : output . append ( "<STR_LIT>" ) ; break ; default : output . append ( "<STR_LIT>" ) ; break ; } for ( int i = <NUM_LIT:0> ; i < this . tokens . length ; i ++ ) { output . append ( this . tokens [ i ] ) ; output . append ( '<CHAR_LIT:.>' ) ; } output . append ( this . completionIdentifier ) . append ( '<CHAR_LIT:>>' ) ; return output ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . MessageSend ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class CompletionOnMessageSendName extends MessageSend { public CompletionOnMessageSendName ( char [ ] selector , int start , int end ) { super ( ) ; this . selector = selector ; this . sourceStart = start ; this . sourceEnd = end ; this . nameSourcePosition = end ; } public TypeBinding resolveType ( BlockScope scope ) { if ( this . receiver . isImplicitThis ( ) ) throw new CompletionNodeFound ( ) ; this . actualReceiverType = this . receiver . resolveType ( scope ) ; if ( this . actualReceiverType == null || this . actualReceiverType . isBaseType ( ) || this . actualReceiverType . isArrayType ( ) ) throw new CompletionNodeFound ( ) ; if ( this . typeArguments != null ) { int length = this . typeArguments . length ; this . genericTypeArguments = new TypeBinding [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { this . genericTypeArguments [ i ] = this . typeArguments [ i ] . resolveType ( scope , true ) ; } } throw new CompletionNodeFound ( this , this . actualReceiverType , scope ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; if ( ! this . receiver . isImplicitThis ( ) ) this . receiver . printExpression ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:.>' ) ; if ( this . typeArguments != null ) { output . append ( '<CHAR_LIT>' ) ; int max = this . typeArguments . length - <NUM_LIT:1> ; for ( int j = <NUM_LIT:0> ; j < max ; j ++ ) { this . typeArguments [ j ] . print ( <NUM_LIT:0> , output ) ; output . append ( "<STR_LIT:U+002CU+0020>" ) ; } this . typeArguments [ max ] . print ( <NUM_LIT:0> , output ) ; output . append ( '<CHAR_LIT:>>' ) ; } output . append ( this . selector ) . append ( '<CHAR_LIT:(>' ) ; return output . append ( "<STR_LIT>" ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . * ; public class CompletionOnFieldType extends FieldDeclaration { public boolean isLocalVariable ; public CompletionOnFieldType ( TypeReference type , boolean isLocalVariable ) { super ( ) ; this . sourceStart = type . sourceStart ; this . sourceEnd = type . sourceEnd ; this . type = type ; this . name = CharOperation . NO_CHAR ; this . isLocalVariable = isLocalVariable ; if ( type instanceof CompletionOnSingleTypeReference ) { ( ( CompletionOnSingleTypeReference ) type ) . fieldTypeCompletionNode = this ; } } public StringBuffer printStatement ( int tab , StringBuffer output ) { return this . type . print ( tab , output ) . append ( '<CHAR_LIT:;>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; public class CompletionOnLocalName extends LocalDeclaration { private static final char [ ] FAKENAMESUFFIX = "<STR_LIT:U+0020>" . toCharArray ( ) ; public char [ ] realName ; public CompletionOnLocalName ( char [ ] name , int sourceStart , int sourceEnd ) { super ( CharOperation . concat ( name , FAKENAMESUFFIX ) , sourceStart , sourceEnd ) ; this . realName = name ; } public void resolve ( BlockScope scope ) { super . resolve ( scope ) ; throw new CompletionNodeFound ( this , scope ) ; } public StringBuffer printAsExpression ( int indent , StringBuffer output ) { printIndent ( indent , output ) ; output . append ( "<STR_LIT>" ) ; if ( this . type != null ) this . type . print ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:U+0020>' ) ; output . append ( this . realName ) ; if ( this . initialization != null ) { output . append ( "<STR_LIT:U+0020=U+0020>" ) ; this . initialization . printExpression ( <NUM_LIT:0> , output ) ; } return output . append ( '<CHAR_LIT:>>' ) ; } public StringBuffer printStatement ( int indent , StringBuffer output ) { printAsExpression ( indent , output ) ; return output . append ( '<CHAR_LIT:;>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . MethodScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class CompletionOnArgumentName extends Argument { private static final char [ ] FAKENAMESUFFIX = "<STR_LIT:U+0020>" . toCharArray ( ) ; public char [ ] realName ; public boolean isCatchArgument = false ; public CompletionOnArgumentName ( char [ ] name , long posNom , TypeReference tr , int modifiers ) { super ( CharOperation . concat ( name , FAKENAMESUFFIX ) , posNom , tr , modifiers ) ; this . realName = name ; } public void bind ( MethodScope scope , TypeBinding typeBinding , boolean used ) { super . bind ( scope , typeBinding , used ) ; throw new CompletionNodeFound ( this , scope ) ; } public StringBuffer print ( int indent , StringBuffer output ) { printIndent ( indent , output ) ; output . append ( "<STR_LIT>" ) ; if ( this . type != null ) this . type . print ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:U+0020>' ) ; output . append ( this . realName ) ; if ( this . initialization != null ) { output . append ( "<STR_LIT:U+0020=U+0020>" ) ; this . initialization . printExpression ( <NUM_LIT:0> , output ) ; } return output . append ( '<CHAR_LIT:>>' ) ; } public void resolve ( BlockScope scope ) { super . resolve ( scope ) ; throw new CompletionNodeFound ( this , scope ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . JavadocSingleNameReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class CompletionOnJavadocParamNameReference extends JavadocSingleNameReference implements CompletionOnJavadoc { public int completionFlags = JAVADOC ; public char [ ] [ ] missingParams ; public char [ ] [ ] missingTypeParams ; public CompletionOnJavadocParamNameReference ( char [ ] name , long pos , int start , int end ) { super ( name , pos , start , end ) ; } public CompletionOnJavadocParamNameReference ( JavadocSingleNameReference nameRef ) { super ( nameRef . token , ( ( ( long ) nameRef . sourceStart ) << <NUM_LIT:32> ) + nameRef . sourceEnd , nameRef . tagSourceStart , nameRef . tagSourceStart ) ; } public void addCompletionFlags ( int flags ) { this . completionFlags |= flags ; } public int getCompletionFlags ( ) { return this . completionFlags ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; if ( this . token != null ) super . printExpression ( indent , output ) ; return output . append ( '<CHAR_LIT:>>' ) ; } public TypeBinding reportError ( BlockScope scope ) { return null ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . * ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; public class CompletionNodeDetector extends ASTVisitor { private ASTNode searchedNode ; private ASTNode parent ; private boolean result ; public CompletionNodeDetector ( ASTNode searchedNode , ASTNode visitedAst ) { this . searchedNode = searchedNode ; this . result = false ; if ( searchedNode != null && visitedAst != null ) { visitedAst . traverse ( this , null ) ; } } public boolean containsCompletionNode ( ) { return this . result ; } public ASTNode getCompletionNodeParent ( ) { return this . parent ; } public void endVisit ( AllocationExpression allocationExpression , BlockScope scope ) { endVisit ( allocationExpression ) ; } public void endVisit ( AND_AND_Expression and_and_Expression , BlockScope scope ) { endVisit ( and_and_Expression ) ; } public void endVisit ( ArrayAllocationExpression arrayAllocationExpression , BlockScope scope ) { endVisit ( arrayAllocationExpression ) ; } public void endVisit ( ArrayInitializer arrayInitializer , BlockScope scope ) { endVisit ( arrayInitializer ) ; } public void endVisit ( ArrayQualifiedTypeReference arrayQualifiedTypeReference , BlockScope scope ) { endVisit ( arrayQualifiedTypeReference ) ; } public void endVisit ( ArrayQualifiedTypeReference arrayQualifiedTypeReference , ClassScope scope ) { endVisit ( arrayQualifiedTypeReference ) ; } public void endVisit ( ArrayReference arrayReference , BlockScope scope ) { endVisit ( arrayReference ) ; } public void endVisit ( ArrayTypeReference arrayTypeReference , BlockScope scope ) { endVisit ( arrayTypeReference ) ; } public void endVisit ( ArrayTypeReference arrayTypeReference , ClassScope scope ) { endVisit ( arrayTypeReference ) ; } public void endVisit ( Assignment assignment , BlockScope scope ) { endVisit ( assignment ) ; } public void endVisit ( BinaryExpression binaryExpression , BlockScope scope ) { endVisit ( binaryExpression ) ; } public void endVisit ( CastExpression castExpression , BlockScope scope ) { endVisit ( castExpression ) ; } public void endVisit ( CompoundAssignment compoundAssignment , BlockScope scope ) { endVisit ( compoundAssignment ) ; } public void endVisit ( ConditionalExpression conditionalExpression , BlockScope scope ) { endVisit ( conditionalExpression ) ; } public void endVisit ( EqualExpression equalExpression , BlockScope scope ) { endVisit ( equalExpression ) ; } public void endVisit ( ExplicitConstructorCall explicitConstructor , BlockScope scope ) { endVisit ( explicitConstructor ) ; } public void endVisit ( FieldReference fieldReference , BlockScope scope ) { endVisit ( fieldReference ) ; } public void endVisit ( InstanceOfExpression instanceOfExpression , BlockScope scope ) { endVisit ( instanceOfExpression ) ; } public void endVisit ( MessageSend messageSend , BlockScope scope ) { endVisit ( messageSend ) ; } public void endVisit ( OR_OR_Expression or_or_Expression , BlockScope scope ) { endVisit ( or_or_Expression ) ; } public void endVisit ( ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference , BlockScope scope ) { endVisit ( parameterizedQualifiedTypeReference ) ; } public void endVisit ( ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference , ClassScope scope ) { endVisit ( parameterizedQualifiedTypeReference ) ; } public void endVisit ( ParameterizedSingleTypeReference parameterizedSingleTypeReference , BlockScope scope ) { endVisit ( parameterizedSingleTypeReference ) ; } public void endVisit ( ParameterizedSingleTypeReference parameterizedSingleTypeReference , ClassScope scope ) { endVisit ( parameterizedSingleTypeReference ) ; } public void endVisit ( PostfixExpression postfixExpression , BlockScope scope ) { endVisit ( postfixExpression ) ; } public void endVisit ( PrefixExpression prefixExpression , BlockScope scope ) { endVisit ( prefixExpression ) ; } public void endVisit ( QualifiedAllocationExpression qualifiedAllocationExpression , BlockScope scope ) { endVisit ( qualifiedAllocationExpression ) ; } public void endVisit ( QualifiedNameReference qualifiedNameReference , BlockScope scope ) { endVisit ( qualifiedNameReference ) ; } public void endVisit ( QualifiedSuperReference qualifiedSuperReference , BlockScope scope ) { endVisit ( qualifiedSuperReference ) ; } public void endVisit ( QualifiedThisReference qualifiedThisReference , BlockScope scope ) { endVisit ( qualifiedThisReference ) ; } public void endVisit ( QualifiedTypeReference qualifiedTypeReference , BlockScope scope ) { endVisit ( qualifiedTypeReference ) ; } public void endVisit ( QualifiedTypeReference qualifiedTypeReference , ClassScope scope ) { endVisit ( qualifiedTypeReference ) ; } public void endVisit ( SingleNameReference singleNameReference , BlockScope scope ) { endVisit ( singleNameReference ) ; } public void endVisit ( SingleTypeReference singleTypeReference , BlockScope scope ) { endVisit ( singleTypeReference ) ; } public void endVisit ( SingleTypeReference singleTypeReference , ClassScope scope ) { endVisit ( singleTypeReference ) ; } public void endVisit ( SuperReference superReference , BlockScope scope ) { endVisit ( superReference ) ; } public void endVisit ( ThisReference thisReference , BlockScope scope ) { endVisit ( thisReference ) ; } public void endVisit ( UnaryExpression unaryExpression , BlockScope scope ) { endVisit ( unaryExpression ) ; } public void endVisit ( MemberValuePair pair , BlockScope scope ) { endVisit ( pair ) ; } public void endVisit ( MemberValuePair pair , CompilationUnitScope scope ) { endVisit ( pair ) ; } public boolean visit ( AllocationExpression allocationExpression , BlockScope scope ) { return this . visit ( allocationExpression ) ; } public boolean visit ( AND_AND_Expression and_and_Expression , BlockScope scope ) { return this . visit ( and_and_Expression ) ; } public boolean visit ( ArrayAllocationExpression arrayAllocationExpression , BlockScope scope ) { return this . visit ( arrayAllocationExpression ) ; } public boolean visit ( ArrayInitializer arrayInitializer , BlockScope scope ) { return this . visit ( arrayInitializer ) ; } public boolean visit ( ArrayQualifiedTypeReference arrayQualifiedTypeReference , BlockScope scope ) { return this . visit ( arrayQualifiedTypeReference ) ; } public boolean visit ( ArrayQualifiedTypeReference arrayQualifiedTypeReference , ClassScope scope ) { return this . visit ( arrayQualifiedTypeReference ) ; } public boolean visit ( ArrayReference arrayReference , BlockScope scope ) { return this . visit ( arrayReference ) ; } public boolean visit ( ArrayTypeReference arrayTypeReference , BlockScope scope ) { return this . visit ( arrayTypeReference ) ; } public boolean visit ( ArrayTypeReference arrayTypeReference , ClassScope scope ) { return this . visit ( arrayTypeReference ) ; } public boolean visit ( Assignment assignment , BlockScope scope ) { return this . visit ( assignment ) ; } public boolean visit ( BinaryExpression binaryExpression , BlockScope scope ) { return this . visit ( binaryExpression ) ; } public boolean visit ( CastExpression castExpression , BlockScope scope ) { return this . visit ( castExpression ) ; } public boolean visit ( CompoundAssignment compoundAssignment , BlockScope scope ) { return this . visit ( compoundAssignment ) ; } public boolean visit ( ConditionalExpression conditionalExpression , BlockScope scope ) { return this . visit ( conditionalExpression ) ; } public boolean visit ( EqualExpression equalExpression , BlockScope scope ) { return this . visit ( equalExpression ) ; } public boolean visit ( ExplicitConstructorCall explicitConstructor , BlockScope scope ) { return this . visit ( explicitConstructor ) ; } public boolean visit ( FieldReference fieldReference , BlockScope scope ) { return this . visit ( fieldReference ) ; } public boolean visit ( InstanceOfExpression instanceOfExpression , BlockScope scope ) { return this . visit ( instanceOfExpression ) ; } public boolean visit ( MessageSend messageSend , BlockScope scope ) { return this . visit ( messageSend ) ; } public boolean visit ( OR_OR_Expression or_or_Expression , BlockScope scope ) { return this . visit ( or_or_Expression ) ; } public boolean visit ( ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference , BlockScope scope ) { return this . visit ( parameterizedQualifiedTypeReference ) ; } public boolean visit ( ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference , ClassScope scope ) { return this . visit ( parameterizedQualifiedTypeReference ) ; } public boolean visit ( ParameterizedSingleTypeReference parameterizedSingleTypeReference , BlockScope scope ) { return this . visit ( parameterizedSingleTypeReference ) ; } public boolean visit ( ParameterizedSingleTypeReference parameterizedSingleTypeReference , ClassScope scope ) { return this . visit ( parameterizedSingleTypeReference ) ; } public boolean visit ( PostfixExpression postfixExpression , BlockScope scope ) { return this . visit ( postfixExpression ) ; } public boolean visit ( PrefixExpression prefixExpression , BlockScope scope ) { return this . visit ( prefixExpression ) ; } public boolean visit ( QualifiedAllocationExpression qualifiedAllocationExpression , BlockScope scope ) { return this . visit ( qualifiedAllocationExpression ) ; } public boolean visit ( QualifiedNameReference qualifiedNameReference , BlockScope scope ) { return this . visit ( qualifiedNameReference ) ; } public boolean visit ( QualifiedSuperReference qualifiedSuperReference , BlockScope scope ) { return this . visit ( qualifiedSuperReference ) ; } public boolean visit ( QualifiedThisReference qualifiedThisReference , BlockScope scope ) { return this . visit ( qualifiedThisReference ) ; } public boolean visit ( QualifiedTypeReference qualifiedTypeReference , BlockScope scope ) { return this . visit ( qualifiedTypeReference ) ; } public boolean visit ( QualifiedTypeReference qualifiedTypeReference , ClassScope scope ) { return this . visit ( qualifiedTypeReference ) ; } public boolean visit ( SingleNameReference singleNameReference , BlockScope scope ) { return this . visit ( singleNameReference ) ; } public boolean visit ( SingleTypeReference singleTypeReference , BlockScope scope ) { return this . visit ( singleTypeReference ) ; } public boolean visit ( SingleTypeReference singleTypeReference , ClassScope scope ) { return this . visit ( singleTypeReference ) ; } public boolean visit ( StringLiteral stringLiteral , BlockScope scope ) { return this . visit ( stringLiteral ) ; } public boolean visit ( SuperReference superReference , BlockScope scope ) { return this . visit ( superReference ) ; } public boolean visit ( ThisReference thisReference , BlockScope scope ) { return this . visit ( thisReference ) ; } public boolean visit ( UnaryExpression unaryExpression , BlockScope scope ) { return this . visit ( unaryExpression ) ; } public boolean visit ( MemberValuePair pair , BlockScope scope ) { return this . visit ( pair ) ; } public boolean visit ( MemberValuePair pair , CompilationUnitScope scope ) { return this . visit ( pair ) ; } private void endVisit ( ASTNode astNode ) { if ( this . result && this . parent == null && astNode != this . searchedNode ) { if ( ! ( astNode instanceof AllocationExpression && ( ( AllocationExpression ) astNode ) . type == this . searchedNode ) && ! ( astNode instanceof ConditionalExpression && ( ( ConditionalExpression ) astNode ) . valueIfTrue == this . searchedNode ) && ! ( astNode instanceof ConditionalExpression && ( ( ConditionalExpression ) astNode ) . valueIfFalse == this . searchedNode ) ) { this . parent = astNode ; } } } private boolean visit ( ASTNode astNode ) { if ( astNode == this . searchedNode ) { this . result = true ; } return ! this . result ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; public class CompletionOnMethodName extends MethodDeclaration { public int selectorEnd ; public CompletionOnMethodName ( CompilationResult compilationResult ) { super ( compilationResult ) ; } public StringBuffer print ( int indent , StringBuffer output ) { printIndent ( indent , output ) ; output . append ( "<STR_LIT>" ) ; printModifiers ( this . modifiers , output ) ; printReturnType ( <NUM_LIT:0> , output ) ; output . append ( this . selector ) . append ( '<CHAR_LIT:(>' ) ; if ( this . arguments != null ) { for ( int i = <NUM_LIT:0> ; i < this . arguments . length ; i ++ ) { if ( i > <NUM_LIT:0> ) output . append ( "<STR_LIT:U+002CU+0020>" ) ; this . arguments [ i ] . print ( <NUM_LIT:0> , output ) ; } } output . append ( '<CHAR_LIT:)>' ) ; if ( this . thrownExceptions != null ) { output . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < this . thrownExceptions . length ; i ++ ) { if ( i > <NUM_LIT:0> ) output . append ( "<STR_LIT:U+002CU+0020>" ) ; this . thrownExceptions [ i ] . print ( <NUM_LIT:0> , output ) ; } } return output . append ( '<CHAR_LIT:>>' ) ; } public void resolve ( ClassScope upperScope ) { super . resolve ( upperScope ) ; throw new CompletionNodeFound ( this , upperScope ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . MemberValuePair ; import org . eclipse . jdt . internal . compiler . ast . NormalAnnotation ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class CompletionOnAnnotationMemberValuePair extends NormalAnnotation { public MemberValuePair completedMemberValuePair ; public CompletionOnAnnotationMemberValuePair ( TypeReference type , int sourceStart , MemberValuePair [ ] memberValuePairs , MemberValuePair completedMemberValuePair ) { super ( type , sourceStart ) ; this . memberValuePairs = memberValuePairs ; this . completedMemberValuePair = completedMemberValuePair ; } public TypeBinding resolveType ( BlockScope scope ) { super . resolveType ( scope ) ; if ( this . resolvedType == null || ! this . resolvedType . isValidBinding ( ) ) { throw new CompletionNodeFound ( ) ; } else { throw new CompletionNodeFound ( this . completedMemberValuePair , scope ) ; } } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( '<CHAR_LIT>' ) ; this . type . printExpression ( <NUM_LIT:0> , output ) ; output . append ( '<CHAR_LIT:(>' ) ; if ( this . memberValuePairs != null ) { for ( int i = <NUM_LIT:0> , max = this . memberValuePairs . length ; i < max ; i ++ ) { if ( i > <NUM_LIT:0> ) { output . append ( '<CHAR_LIT:U+002C>' ) ; } this . memberValuePairs [ i ] . print ( indent , output ) ; } output . append ( '<CHAR_LIT:U+002C>' ) ; } this . completedMemberValuePair . print ( indent , output ) ; output . append ( '<CHAR_LIT:)>' ) ; return output ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; public class CompletionOnMethodReturnType extends MethodDeclaration { public CompletionOnMethodReturnType ( TypeReference returnType , CompilationResult compilationResult ) { super ( compilationResult ) ; this . returnType = returnType ; this . sourceStart = returnType . sourceStart ; this . sourceEnd = returnType . sourceEnd ; } public void resolveStatements ( ) { throw new CompletionNodeFound ( this , this . scope ) ; } public StringBuffer print ( int tab , StringBuffer output ) { return this . returnType . print ( tab , output ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . JavadocAllocationExpression ; public class CompletionOnJavadocAllocationExpression extends JavadocAllocationExpression implements CompletionOnJavadoc { public int completionFlags = JAVADOC ; public int separatorPosition ; public CompletionOnJavadocAllocationExpression ( JavadocAllocationExpression allocation , int position ) { super ( allocation . sourceStart , allocation . sourceEnd ) ; this . arguments = allocation . arguments ; this . type = allocation . type ; this . tagValue = allocation . tagValue ; this . sourceEnd = allocation . sourceEnd ; this . separatorPosition = position ; this . qualification = allocation . qualification ; } public CompletionOnJavadocAllocationExpression ( JavadocAllocationExpression allocation , int position , int flags ) { this ( allocation , position ) ; this . completionFlags |= flags ; } public void addCompletionFlags ( int flags ) { this . completionFlags |= flags ; } public boolean completeAnException ( ) { return ( this . completionFlags & EXCEPTION ) != <NUM_LIT:0> ; } public boolean completeInText ( ) { return ( this . completionFlags & TEXT ) != <NUM_LIT:0> ; } public boolean completeBaseTypes ( ) { return ( this . completionFlags & BASE_TYPES ) != <NUM_LIT:0> ; } public boolean completeFormalReference ( ) { return ( this . completionFlags & FORMAL_REFERENCE ) != <NUM_LIT:0> ; } public int getCompletionFlags ( ) { return this . completionFlags ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; super . printExpression ( indent , output ) ; indent ++ ; if ( this . completionFlags > <NUM_LIT:0> ) { output . append ( '<STR_LIT:\n>' ) ; for ( int i = <NUM_LIT:0> ; i < indent ; i ++ ) output . append ( '<STR_LIT:\t>' ) ; output . append ( "<STR_LIT>" ) ; char separator = <NUM_LIT:0> ; if ( completeAnException ( ) ) { output . append ( "<STR_LIT>" ) ; separator = '<CHAR_LIT:U+002C>' ; } if ( completeInText ( ) ) { if ( separator != <NUM_LIT:0> ) output . append ( separator ) ; output . append ( "<STR_LIT:text>" ) ; separator = '<CHAR_LIT:U+002C>' ; } if ( completeBaseTypes ( ) ) { if ( separator != <NUM_LIT:0> ) output . append ( separator ) ; output . append ( "<STR_LIT>" ) ; separator = '<CHAR_LIT:U+002C>' ; } if ( completeFormalReference ( ) ) { if ( separator != <NUM_LIT:0> ) output . append ( separator ) ; output . append ( "<STR_LIT>" ) ; separator = '<CHAR_LIT:U+002C>' ; } output . append ( '<STR_LIT:\n>' ) ; } indent -- ; for ( int i = <NUM_LIT:0> ; i < indent ; i ++ ) output . append ( '<STR_LIT:\t>' ) ; return output . append ( '<CHAR_LIT:>>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import java . util . HashSet ; import 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 . ast . * ; import org . eclipse . jdt . internal . compiler . parser . * ; import org . eclipse . jdt . internal . compiler . problem . * ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObjectToInt ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . codeassist . impl . * ; public class CompletionParser extends AssistParser { protected static final int COMPLETION_PARSER = <NUM_LIT> ; protected static final int COMPLETION_OR_ASSIST_PARSER = ASSIST_PARSER + COMPLETION_PARSER ; protected static final int K_BLOCK_DELIMITER = COMPLETION_PARSER + <NUM_LIT:1> ; protected static final int K_SELECTOR_INVOCATION_TYPE = COMPLETION_PARSER + <NUM_LIT:2> ; protected static final int K_SELECTOR_QUALIFIER = COMPLETION_PARSER + <NUM_LIT:3> ; protected static final int K_BETWEEN_CATCH_AND_RIGHT_PAREN = COMPLETION_PARSER + <NUM_LIT:4> ; protected static final int K_NEXT_TYPEREF_IS_CLASS = COMPLETION_PARSER + <NUM_LIT:5> ; protected static final int K_NEXT_TYPEREF_IS_INTERFACE = COMPLETION_PARSER + <NUM_LIT:6> ; protected static final int K_NEXT_TYPEREF_IS_EXCEPTION = COMPLETION_PARSER + <NUM_LIT:7> ; protected static final int K_BETWEEN_NEW_AND_LEFT_BRACKET = COMPLETION_PARSER + <NUM_LIT:8> ; protected static final int K_INSIDE_THROW_STATEMENT = COMPLETION_PARSER + <NUM_LIT:9> ; protected static final int K_INSIDE_RETURN_STATEMENT = COMPLETION_PARSER + <NUM_LIT:10> ; protected static final int K_CAST_STATEMENT = COMPLETION_PARSER + <NUM_LIT:11> ; protected static final int K_LOCAL_INITIALIZER_DELIMITER = COMPLETION_PARSER + <NUM_LIT:12> ; protected static final int K_ARRAY_INITIALIZER = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_ARRAY_CREATION = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_UNARY_OPERATOR = COMPLETION_PARSER + <NUM_LIT:15> ; protected static final int K_BINARY_OPERATOR = COMPLETION_PARSER + <NUM_LIT:16> ; protected static final int K_ASSISGNMENT_OPERATOR = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_CONDITIONAL_OPERATOR = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_BETWEEN_IF_AND_RIGHT_PAREN = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_BETWEEN_WHILE_AND_RIGHT_PAREN = COMPLETION_PARSER + <NUM_LIT:20> ; protected static final int K_BETWEEN_FOR_AND_RIGHT_PAREN = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_BETWEEN_SWITCH_AND_RIGHT_PAREN = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_BETWEEN_SYNCHRONIZED_AND_RIGHT_PAREN = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_INSIDE_ASSERT_STATEMENT = COMPLETION_PARSER + <NUM_LIT:24> ; protected static final int K_SWITCH_LABEL = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_BETWEEN_CASE_AND_COLON = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_BETWEEN_DEFAULT_AND_COLON = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_BETWEEN_LEFT_AND_RIGHT_BRACKET = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_EXTENDS_KEYWORD = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_PARAMETERIZED_METHOD_INVOCATION = COMPLETION_PARSER + <NUM_LIT:30> ; protected static final int K_PARAMETERIZED_ALLOCATION = COMPLETION_PARSER + <NUM_LIT:31> ; protected static final int K_PARAMETERIZED_CAST = COMPLETION_PARSER + <NUM_LIT:32> ; protected static final int K_BETWEEN_ANNOTATION_NAME_AND_RPAREN = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_INSIDE_BREAK_STATEMENT = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_INSIDE_CONTINUE_STATEMENT = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_LABEL = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_MEMBER_VALUE_ARRAY_INITIALIZER = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_CONTROL_STATEMENT_DELIMITER = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_INSIDE_ASSERT_EXCEPTION = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_INSIDE_FOR_CONDITIONAL = COMPLETION_PARSER + <NUM_LIT> ; protected static final int K_BETWEEN_INSTANCEOF_AND_RPAREN = COMPLETION_PARSER + <NUM_LIT> ; public final static char [ ] FAKE_TYPE_NAME = new char [ ] { '<CHAR_LIT:U+0020>' } ; public final static char [ ] FAKE_METHOD_NAME = new char [ ] { '<CHAR_LIT:U+0020>' } ; public final static char [ ] FAKE_ARGUMENT_NAME = new char [ ] { '<CHAR_LIT:U+0020>' } ; public final static char [ ] VALUE = new char [ ] { '<CHAR_LIT>' , '<CHAR_LIT:a>' , '<CHAR_LIT>' , '<CHAR_LIT>' , '<CHAR_LIT:e>' } ; public int cursorLocation ; public ASTNode assistNodeParent ; public ASTNode enclosingNode ; static final int IF = <NUM_LIT:1> ; static final int TRY = <NUM_LIT:2> ; static final int CATCH = <NUM_LIT:3> ; static final int WHILE = <NUM_LIT:4> ; static final int SWITCH = <NUM_LIT:5> ; static final int FOR = <NUM_LIT:6> ; static final int DO = <NUM_LIT:7> ; static final int SYNCHRONIZED = <NUM_LIT:8> ; static final int DEFAULT = <NUM_LIT:1> ; static final int EXPLICIT_RECEIVER = <NUM_LIT:0> ; static final int NO_RECEIVER = - <NUM_LIT:1> ; static final int SUPER_RECEIVER = - <NUM_LIT:2> ; static final int NAME_RECEIVER = - <NUM_LIT:3> ; static final int ALLOCATION = - <NUM_LIT:4> ; static final int QUALIFIED_ALLOCATION = - <NUM_LIT:5> ; static final int QUESTION = <NUM_LIT:1> ; static final int COLON = <NUM_LIT:2> ; static final int LPAREN_NOT_CONSUMED = <NUM_LIT:1> ; static final int LPAREN_CONSUMED = <NUM_LIT:2> ; static final int ANNOTATION_NAME_COMPLETION = <NUM_LIT:4> ; static final int INSIDE_NAME = <NUM_LIT:1> ; int invocationType ; int qualifier ; boolean hasUnusedModifiers ; int canBeExplicitConstructor = NO ; static final int NO = <NUM_LIT:0> ; static final int NEXTTOKEN = <NUM_LIT:1> ; static final int YES = <NUM_LIT:2> ; protected static final int LabelStackIncrement = <NUM_LIT:10> ; char [ ] [ ] labelStack = new char [ LabelStackIncrement ] [ ] ; int labelPtr = - <NUM_LIT:1> ; boolean isAlreadyAttached ; public boolean record = false ; public boolean skipRecord = false ; public int recordFrom ; public int recordTo ; public int potentialVariableNamesPtr ; public char [ ] [ ] potentialVariableNames ; public int [ ] potentialVariableNameStarts ; public int [ ] potentialVariableNameEnds ; CompletionOnAnnotationOfType pendingAnnotation ; private boolean storeSourceEnds ; public HashtableOfObjectToInt sourceEnds ; public CompletionParser ( ProblemReporter problemReporter , boolean storeExtraSourceEnds ) { super ( problemReporter ) ; this . reportSyntaxErrorIsRequired = false ; this . javadocParser . checkDocComment = true ; this . annotationRecoveryActivated = false ; if ( storeExtraSourceEnds ) { this . storeSourceEnds = true ; this . sourceEnds = new HashtableOfObjectToInt ( ) ; } } private void addPotentialName ( char [ ] potentialVariableName , int start , int end ) { int length = this . potentialVariableNames . length ; if ( this . potentialVariableNamesPtr >= length - <NUM_LIT:1> ) { System . arraycopy ( this . potentialVariableNames , <NUM_LIT:0> , this . potentialVariableNames = new char [ length * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , length ) ; System . arraycopy ( this . potentialVariableNameStarts , <NUM_LIT:0> , this . potentialVariableNameStarts = new int [ length * <NUM_LIT:2> ] , <NUM_LIT:0> , length ) ; System . arraycopy ( this . potentialVariableNameEnds , <NUM_LIT:0> , this . potentialVariableNameEnds = new int [ length * <NUM_LIT:2> ] , <NUM_LIT:0> , length ) ; } this . potentialVariableNames [ ++ this . potentialVariableNamesPtr ] = potentialVariableName ; this . potentialVariableNameStarts [ this . potentialVariableNamesPtr ] = start ; this . potentialVariableNameEnds [ this . potentialVariableNamesPtr ] = end ; } public void startRecordingIdentifiers ( int from , int to ) { this . record = true ; this . skipRecord = false ; this . recordFrom = from ; this . recordTo = to ; this . potentialVariableNamesPtr = - <NUM_LIT:1> ; this . potentialVariableNames = new char [ <NUM_LIT:10> ] [ ] ; this . potentialVariableNameStarts = new int [ <NUM_LIT:10> ] ; this . potentialVariableNameEnds = new int [ <NUM_LIT:10> ] ; } public void stopRecordingIdentifiers ( ) { this . record = true ; this . skipRecord = false ; } public char [ ] assistIdentifier ( ) { return ( ( CompletionScanner ) this . scanner ) . completionIdentifier ; } protected void attachOrphanCompletionNode ( ) { if ( this . assistNode == null || this . isAlreadyAttached ) return ; this . isAlreadyAttached = true ; if ( this . isOrphanCompletionNode ) { ASTNode orphan = this . assistNode ; this . isOrphanCompletionNode = false ; if ( this . currentElement instanceof RecoveredUnit ) { if ( orphan instanceof ImportReference ) { this . currentElement . add ( ( ImportReference ) orphan , <NUM_LIT:0> ) ; } } if ( this . currentElement instanceof RecoveredType ) { RecoveredType recoveredType = ( RecoveredType ) this . currentElement ; if ( recoveredType . foundOpeningBrace ) { if ( orphan instanceof TypeReference ) { TypeReference fieldType ; int kind = topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ; int info = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) ; if ( kind == K_BINARY_OPERATOR && info == LESS && this . identifierPtr > - <NUM_LIT:1> ) { if ( this . genericsLengthStack [ this . genericsLengthPtr ] > <NUM_LIT:0> ) { consumeTypeArguments ( ) ; } pushOnGenericsStack ( orphan ) ; consumeTypeArguments ( ) ; fieldType = getTypeReference ( <NUM_LIT:0> ) ; this . assistNodeParent = fieldType ; } else { fieldType = ( TypeReference ) orphan ; } CompletionOnFieldType fieldDeclaration = new CompletionOnFieldType ( fieldType , false ) ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr ] ) != <NUM_LIT:0> && this . expressionStack [ this . expressionPtr ] instanceof Annotation ) { System . arraycopy ( this . expressionStack , this . expressionPtr - length + <NUM_LIT:1> , fieldDeclaration . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } if ( this . intPtr >= <NUM_LIT:2> && this . intStack [ this . intPtr - <NUM_LIT:1> ] == this . lastModifiersStart && this . intStack [ this . intPtr - <NUM_LIT:2> ] == this . lastModifiers ) { fieldDeclaration . modifiersSourceStart = this . intStack [ this . intPtr - <NUM_LIT:1> ] ; fieldDeclaration . modifiers = this . intStack [ this . intPtr - <NUM_LIT:2> ] ; } this . currentElement = this . currentElement . add ( fieldDeclaration , <NUM_LIT:0> ) ; return ; } } } if ( this . currentElement instanceof RecoveredMethod ) { RecoveredMethod recoveredMethod = ( RecoveredMethod ) this . currentElement ; if ( ! recoveredMethod . foundOpeningBrace ) { if ( orphan instanceof TypeReference ) { this . currentElement = this . currentElement . parent . add ( new CompletionOnFieldType ( ( TypeReference ) orphan , true ) , <NUM_LIT:0> ) ; return ; } if ( orphan instanceof Annotation ) { CompletionOnAnnotationOfType fakeType = new CompletionOnAnnotationOfType ( FAKE_TYPE_NAME , this . compilationUnit . compilationResult ( ) , ( Annotation ) orphan ) ; fakeType . isParameter = true ; this . currentElement . parent . add ( fakeType , <NUM_LIT:0> ) ; this . pendingAnnotation = fakeType ; return ; } } } if ( orphan instanceof MemberValuePair ) { buildMoreAnnotationCompletionContext ( ( MemberValuePair ) orphan ) ; return ; } if ( orphan instanceof Annotation ) { popUntilCompletedAnnotationIfNecessary ( ) ; CompletionOnAnnotationOfType fakeType = new CompletionOnAnnotationOfType ( FAKE_TYPE_NAME , this . compilationUnit . compilationResult ( ) , ( Annotation ) orphan ) ; this . currentElement . add ( fakeType , <NUM_LIT:0> ) ; if ( ! isInsideAnnotation ( ) ) { this . pendingAnnotation = fakeType ; } return ; } if ( ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BETWEEN_CATCH_AND_RIGHT_PAREN ) ) { if ( this . assistNode instanceof CompletionOnSingleTypeReference && ( ( CompletionOnSingleTypeReference ) this . assistNode ) . isException ( ) ) { buildMoreTryStatementCompletionContext ( ( TypeReference ) this . assistNode ) ; return ; } else if ( this . assistNode instanceof CompletionOnQualifiedTypeReference && ( ( CompletionOnQualifiedTypeReference ) this . assistNode ) . isException ( ) ) { buildMoreTryStatementCompletionContext ( ( TypeReference ) this . assistNode ) ; return ; } else if ( this . assistNode instanceof CompletionOnParameterizedQualifiedTypeReference && ( ( CompletionOnParameterizedQualifiedTypeReference ) this . assistNode ) . isException ( ) ) { buildMoreTryStatementCompletionContext ( ( TypeReference ) this . assistNode ) ; return ; } } if ( orphan instanceof Statement ) { RecoveredMethod method = this . currentElement . enclosingMethod ( ) ; if ( method != null ) { AbstractMethodDeclaration methodDecl = method . methodDeclaration ; if ( ( methodDecl . bodyStart == methodDecl . sourceEnd + <NUM_LIT:1> ) && ( Util . getLineNumber ( orphan . sourceStart , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) == Util . getLineNumber ( methodDecl . sourceEnd , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) ) ) { return ; } } this . currentElement = this . currentElement . add ( ( Statement ) orphan , <NUM_LIT:0> ) ; return ; } } if ( isInsideAnnotation ( ) ) { Expression expression ; if ( this . expressionPtr > - <NUM_LIT:1> ) { expression = this . expressionStack [ this . expressionPtr ] ; if ( expression == this . assistNode ) { if ( this . topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_MEMBER_VALUE_ARRAY_INITIALIZER ) { ArrayInitializer arrayInitializer = new ArrayInitializer ( ) ; arrayInitializer . expressions = new Expression [ ] { expression } ; MemberValuePair valuePair = new MemberValuePair ( VALUE , expression . sourceStart , expression . sourceEnd , arrayInitializer ) ; buildMoreAnnotationCompletionContext ( valuePair ) ; } else if ( this . topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BETWEEN_ANNOTATION_NAME_AND_RPAREN ) { if ( expression instanceof SingleNameReference ) { SingleNameReference nameReference = ( SingleNameReference ) expression ; CompletionOnMemberValueName memberValueName = new CompletionOnMemberValueName ( nameReference . token , nameReference . sourceStart , nameReference . sourceEnd ) ; buildMoreAnnotationCompletionContext ( memberValueName ) ; return ; } else if ( expression instanceof QualifiedNameReference || expression instanceof StringLiteral ) { MemberValuePair valuePair = new MemberValuePair ( VALUE , expression . sourceStart , expression . sourceEnd , expression ) ; buildMoreAnnotationCompletionContext ( valuePair ) ; } } else { int index ; if ( ( index = lastIndexOfElement ( K_ATTRIBUTE_VALUE_DELIMITER ) ) != - <NUM_LIT:1> ) { int attributeIndentifierPtr = this . elementInfoStack [ index ] ; int identLengthPtr = this . identifierLengthPtr ; int identPtr = this . identifierPtr ; while ( attributeIndentifierPtr < identPtr ) { identPtr -= this . identifierLengthStack [ identLengthPtr -- ] ; } if ( attributeIndentifierPtr != identPtr ) return ; this . identifierLengthPtr = identLengthPtr ; this . identifierPtr = identPtr ; this . identifierLengthPtr -- ; MemberValuePair memberValuePair = new MemberValuePair ( this . identifierStack [ this . identifierPtr -- ] , expression . sourceStart , expression . sourceEnd , expression ) ; buildMoreAnnotationCompletionContext ( memberValuePair ) ; return ; } } } else { CompletionNodeDetector detector = new CompletionNodeDetector ( this . assistNode , expression ) ; if ( detector . containsCompletionNode ( ) ) { MemberValuePair valuePair = new MemberValuePair ( VALUE , expression . sourceStart , expression . sourceEnd , expression ) ; buildMoreAnnotationCompletionContext ( valuePair ) ; } } } if ( this . astPtr > - <NUM_LIT:1> ) { ASTNode node = this . astStack [ this . astPtr ] ; if ( node instanceof MemberValuePair ) { MemberValuePair memberValuePair = ( MemberValuePair ) node ; CompletionNodeDetector detector = new CompletionNodeDetector ( this . assistNode , memberValuePair ) ; if ( detector . containsCompletionNode ( ) ) { buildMoreAnnotationCompletionContext ( memberValuePair ) ; this . assistNodeParent = detector . getCompletionNodeParent ( ) ; return ; } } } } if ( this . genericsPtr > - <NUM_LIT:1> ) { ASTNode node = this . genericsStack [ this . genericsPtr ] ; if ( node instanceof Wildcard && ( ( Wildcard ) node ) . bound == this . assistNode ) { int kind = topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ; if ( kind == K_BINARY_OPERATOR ) { int info = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) ; if ( info == LESS ) { buildMoreGenericsCompletionContext ( node , true ) ; return ; } } if ( this . identifierLengthPtr > - <NUM_LIT:1> && this . identifierLengthStack [ this . identifierLengthPtr ] != <NUM_LIT:0> ) { this . pushOnElementStack ( K_BINARY_OPERATOR , LESS ) ; buildMoreGenericsCompletionContext ( node , false ) ; return ; } } } if ( this . currentElement instanceof RecoveredType || this . currentElement instanceof RecoveredMethod ) { if ( this . currentElement instanceof RecoveredType ) { RecoveredType recoveredType = ( RecoveredType ) this . currentElement ; if ( recoveredType . foundOpeningBrace && this . genericsPtr > - <NUM_LIT:1> ) { if ( this . genericsStack [ this . genericsPtr ] instanceof TypeParameter ) { TypeParameter typeParameter = ( TypeParameter ) this . genericsStack [ this . genericsPtr ] ; CompletionNodeDetector detector = new CompletionNodeDetector ( this . assistNode , typeParameter ) ; if ( detector . containsCompletionNode ( ) ) { this . currentElement . add ( new CompletionOnMethodTypeParameter ( new TypeParameter [ ] { typeParameter } , this . compilationUnit . compilationResult ( ) ) , <NUM_LIT:0> ) ; } return ; } } } if ( ( ! isInsideMethod ( ) && ! isInsideFieldInitialization ( ) ) ) { if ( this . genericsPtr > - <NUM_LIT:1> && this . genericsLengthPtr > - <NUM_LIT:1> && this . genericsIdentifiersLengthPtr > - <NUM_LIT:1> ) { int kind = topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ; int info = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) ; if ( kind == K_BINARY_OPERATOR && info == LESS ) { consumeTypeArguments ( ) ; } int numberOfIdentifiers = this . genericsIdentifiersLengthStack [ this . genericsIdentifiersLengthPtr ] ; int genPtr = this . genericsPtr ; done : for ( int i = <NUM_LIT:0> ; i <= this . identifierLengthPtr && numberOfIdentifiers > <NUM_LIT:0> ; i ++ ) { int identifierLength = this . identifierLengthStack [ this . identifierLengthPtr - i ] ; int length = this . genericsLengthStack [ this . genericsLengthPtr - i ] ; for ( int j = <NUM_LIT:0> ; j < length ; j ++ ) { ASTNode node = this . genericsStack [ genPtr - j ] ; CompletionNodeDetector detector = new CompletionNodeDetector ( this . assistNode , node ) ; if ( detector . containsCompletionNode ( ) ) { if ( node == this . assistNode ) { if ( this . identifierLengthPtr > - <NUM_LIT:1> && this . identifierLengthStack [ this . identifierLengthPtr ] != <NUM_LIT:0> ) { TypeReference ref = this . getTypeReference ( <NUM_LIT:0> ) ; this . assistNodeParent = ref ; } } else { this . assistNodeParent = detector . getCompletionNodeParent ( ) ; } break done ; } } genPtr -= length ; numberOfIdentifiers -= identifierLength ; } if ( this . assistNodeParent != null && this . assistNodeParent instanceof TypeReference ) { if ( this . currentElement instanceof RecoveredType ) { this . currentElement = this . currentElement . add ( new CompletionOnFieldType ( ( TypeReference ) this . assistNodeParent , false ) , <NUM_LIT:0> ) ; } else { this . currentElement = this . currentElement . add ( ( TypeReference ) this . assistNodeParent , <NUM_LIT:0> ) ; } } } } } if ( ( ! isInsideMethod ( ) && ! isInsideFieldInitialization ( ) && ! isInsideAttributeValue ( ) ) ) { return ; } if ( this . genericsPtr > - <NUM_LIT:1> ) { ASTNode node = this . genericsStack [ this . genericsPtr ] ; CompletionNodeDetector detector = new CompletionNodeDetector ( this . assistNode , node ) ; if ( detector . containsCompletionNode ( ) ) { RecoveredMethod method = this . currentElement . enclosingMethod ( ) ; if ( method != null ) { AbstractMethodDeclaration methodDecl = method . methodDeclaration ; if ( ( methodDecl . bodyStart == methodDecl . sourceEnd + <NUM_LIT:1> ) && ( Util . getLineNumber ( node . sourceStart , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) == Util . getLineNumber ( methodDecl . sourceEnd , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) ) ) { return ; } } if ( node == this . assistNode ) { buildMoreGenericsCompletionContext ( node , true ) ; } } } Expression expression ; if ( this . expressionPtr > - <NUM_LIT:1> ) { expression = this . expressionStack [ this . expressionPtr ] ; CompletionNodeDetector detector = new CompletionNodeDetector ( this . assistNode , expression ) ; if ( detector . containsCompletionNode ( ) ) { RecoveredMethod method = this . currentElement . enclosingMethod ( ) ; if ( method != null ) { AbstractMethodDeclaration methodDecl = method . methodDeclaration ; if ( ( methodDecl . bodyStart == methodDecl . sourceEnd + <NUM_LIT:1> ) && ( Util . getLineNumber ( expression . sourceStart , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) == Util . getLineNumber ( methodDecl . sourceEnd , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) ) ) { return ; } } if ( expression == this . assistNode || ( expression instanceof Assignment && ( ( Assignment ) expression ) . expression == this . assistNode && ( ( this . expressionPtr > <NUM_LIT:0> && stackHasInstanceOfExpression ( this . expressionStack , this . expressionPtr - <NUM_LIT:1> ) ) || ( this . elementPtr >= <NUM_LIT:0> && stackHasInstanceOfExpression ( this . elementObjectInfoStack , this . elementPtr ) ) ) ) || ( expression instanceof AllocationExpression && ( ( AllocationExpression ) expression ) . type == this . assistNode ) || ( expression instanceof AND_AND_Expression && ( this . elementPtr >= <NUM_LIT:0> && this . elementObjectInfoStack [ this . elementPtr ] instanceof InstanceOfExpression ) ) ) { buildMoreCompletionContext ( expression ) ; if ( this . assistNodeParent == null && expression instanceof Assignment ) { this . assistNodeParent = detector . getCompletionNodeParent ( ) ; } return ; } else { this . assistNodeParent = detector . getCompletionNodeParent ( ) ; if ( this . assistNodeParent != null ) { this . currentElement = this . currentElement . add ( ( Statement ) this . assistNodeParent , <NUM_LIT:0> ) ; } else { this . currentElement = this . currentElement . add ( expression , <NUM_LIT:0> ) ; } return ; } } } if ( this . astPtr > - <NUM_LIT:1> && this . astStack [ this . astPtr ] instanceof LocalDeclaration ) { LocalDeclaration local = ( LocalDeclaration ) this . astStack [ this . astPtr ] ; if ( local . initialization == this . assistNode ) { Statement enclosing = buildMoreCompletionEnclosingContext ( local ) ; if ( enclosing instanceof IfStatement ) { if ( this . currentElement instanceof RecoveredBlock ) { RecoveredBlock recoveredBlock = ( RecoveredBlock ) this . currentElement ; recoveredBlock . statements [ -- recoveredBlock . statementCount ] = null ; this . currentElement = this . currentElement . add ( enclosing , <NUM_LIT:0> ) ; } } } } } public Object becomeSimpleParser ( ) { CompletionScanner completionScanner = ( CompletionScanner ) this . scanner ; int [ ] parserState = new int [ ] { this . cursorLocation , completionScanner . cursorLocation } ; this . cursorLocation = Integer . MAX_VALUE ; completionScanner . cursorLocation = Integer . MAX_VALUE ; return parserState ; } private void buildMoreAnnotationCompletionContext ( MemberValuePair memberValuePair ) { if ( this . identifierPtr < <NUM_LIT:0> || this . identifierLengthPtr < <NUM_LIT:0> ) return ; TypeReference typeReference = getAnnotationType ( ) ; int nodesToRemove = this . astPtr > - <NUM_LIT:1> && this . astStack [ this . astPtr ] == memberValuePair ? <NUM_LIT:1> : <NUM_LIT:0> ; NormalAnnotation annotation ; if ( memberValuePair instanceof CompletionOnMemberValueName ) { MemberValuePair [ ] memberValuePairs = null ; int length ; if ( this . astLengthPtr > - <NUM_LIT:1> && ( length = this . astLengthStack [ this . astLengthPtr -- ] ) > nodesToRemove ) { if ( this . astStack [ this . astPtr ] instanceof MemberValuePair ) { System . arraycopy ( this . astStack , ( this . astPtr -= length ) + <NUM_LIT:1> , memberValuePairs = new MemberValuePair [ length - nodesToRemove ] , <NUM_LIT:0> , length - nodesToRemove ) ; } } annotation = new CompletionOnAnnotationMemberValuePair ( typeReference , this . intStack [ this . intPtr -- ] , memberValuePairs , memberValuePair ) ; this . assistNode = memberValuePair ; this . assistNodeParent = annotation ; if ( memberValuePair . sourceEnd >= this . lastCheckPoint ) { this . lastCheckPoint = memberValuePair . sourceEnd + <NUM_LIT:1> ; } } else { MemberValuePair [ ] memberValuePairs = null ; int length = <NUM_LIT:0> ; if ( this . astLengthPtr > - <NUM_LIT:1> && ( length = this . astLengthStack [ this . astLengthPtr -- ] ) > nodesToRemove ) { if ( this . astStack [ this . astPtr ] instanceof MemberValuePair ) { System . arraycopy ( this . astStack , ( this . astPtr -= length ) + <NUM_LIT:1> , memberValuePairs = new MemberValuePair [ length - nodesToRemove + <NUM_LIT:1> ] , <NUM_LIT:0> , length - nodesToRemove ) ; } if ( memberValuePairs != null ) { memberValuePairs [ length - nodesToRemove ] = memberValuePair ; } else { memberValuePairs = new MemberValuePair [ ] { memberValuePair } ; } } else { memberValuePairs = new MemberValuePair [ ] { memberValuePair } ; } annotation = new NormalAnnotation ( typeReference , this . intStack [ this . intPtr -- ] ) ; annotation . memberValuePairs = memberValuePairs ; } CompletionOnAnnotationOfType fakeType = new CompletionOnAnnotationOfType ( FAKE_TYPE_NAME , this . compilationUnit . compilationResult ( ) , annotation ) ; this . currentElement . add ( fakeType , <NUM_LIT:0> ) ; this . pendingAnnotation = fakeType ; } private void buildMoreCompletionContext ( Expression expression ) { Statement statement = expression ; int kind = topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ; if ( kind != <NUM_LIT:0> ) { int info = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) ; nextElement : switch ( kind ) { case K_SELECTOR_QUALIFIER : int selector = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:2> ) ; if ( selector == THIS_CONSTRUCTOR || selector == SUPER_CONSTRUCTOR ) { ExplicitConstructorCall call = new ExplicitConstructorCall ( ( selector == THIS_CONSTRUCTOR ) ? ExplicitConstructorCall . This : ExplicitConstructorCall . Super ) ; call . arguments = new Expression [ ] { expression } ; call . sourceStart = expression . sourceStart ; call . sourceEnd = expression . sourceEnd ; this . assistNodeParent = call ; } else { int invocType = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) ; int qualifierExprPtr = info ; int length = this . expressionLengthStack [ this . expressionLengthPtr ] ; if ( this . expressionPtr > <NUM_LIT:0> && this . expressionLengthPtr > <NUM_LIT:0> && length == <NUM_LIT:1> ) { int start = ( int ) ( this . identifierPositionStack [ selector ] > > > <NUM_LIT:32> ) ; if ( this . expressionStack [ this . expressionPtr - <NUM_LIT:1> ] != null && this . expressionStack [ this . expressionPtr - <NUM_LIT:1> ] . sourceStart > start ) { length += this . expressionLengthStack [ this . expressionLengthPtr - <NUM_LIT:1> ] ; } } Expression [ ] arguments = null ; if ( length != <NUM_LIT:0> ) { arguments = new Expression [ length ] ; this . expressionPtr -= length ; System . arraycopy ( this . expressionStack , this . expressionPtr + <NUM_LIT:1> , arguments , <NUM_LIT:0> , length - <NUM_LIT:1> ) ; arguments [ length - <NUM_LIT:1> ] = expression ; } if ( invocType != ALLOCATION && invocType != QUALIFIED_ALLOCATION ) { MessageSend messageSend = new MessageSend ( ) ; messageSend . selector = this . identifierStack [ selector ] ; messageSend . arguments = arguments ; switch ( invocType ) { case NO_RECEIVER : messageSend . receiver = ThisReference . implicitThis ( ) ; break ; case NAME_RECEIVER : while ( this . identifierLengthPtr >= <NUM_LIT:0> && this . identifierLengthStack [ this . identifierLengthPtr ] < <NUM_LIT:0> ) { this . identifierLengthPtr -- ; } this . identifierPtr -- ; if ( this . genericsPtr > - <NUM_LIT:1> && this . genericsLengthPtr > - <NUM_LIT:1> && this . genericsLengthStack [ this . genericsLengthPtr ] > <NUM_LIT:0> ) { this . identifierLengthPtr -- ; } else { this . identifierLengthStack [ this . identifierLengthPtr ] -- ; } int identifierLength = this . identifierLengthStack [ this . identifierLengthPtr ] ; if ( this . identifierPtr > - <NUM_LIT:1> && identifierLength > <NUM_LIT:0> && this . identifierPtr + <NUM_LIT:1> >= identifierLength ) { messageSend . receiver = getUnspecifiedReference ( ) ; } else { messageSend = null ; } break ; case SUPER_RECEIVER : messageSend . receiver = new SuperReference ( <NUM_LIT:0> , <NUM_LIT:0> ) ; break ; case EXPLICIT_RECEIVER : messageSend . receiver = this . expressionStack [ qualifierExprPtr ] ; break ; default : messageSend . receiver = ThisReference . implicitThis ( ) ; break ; } this . assistNodeParent = messageSend ; } else { if ( invocType == ALLOCATION ) { AllocationExpression allocationExpr = new AllocationExpression ( ) ; allocationExpr . arguments = arguments ; pushOnGenericsIdentifiersLengthStack ( this . identifierLengthStack [ this . identifierLengthPtr ] ) ; pushOnGenericsLengthStack ( <NUM_LIT:0> ) ; allocationExpr . type = getTypeReference ( <NUM_LIT:0> ) ; this . assistNodeParent = allocationExpr ; } else { QualifiedAllocationExpression allocationExpr = new QualifiedAllocationExpression ( ) ; allocationExpr . enclosingInstance = this . expressionStack [ qualifierExprPtr ] ; allocationExpr . arguments = arguments ; pushOnGenericsIdentifiersLengthStack ( this . identifierLengthStack [ this . identifierLengthPtr ] ) ; pushOnGenericsLengthStack ( <NUM_LIT:0> ) ; allocationExpr . type = getTypeReference ( <NUM_LIT:0> ) ; this . assistNodeParent = allocationExpr ; } } } break nextElement ; case K_INSIDE_RETURN_STATEMENT : if ( info == this . bracketDepth ) { ReturnStatement returnStatement = new ReturnStatement ( expression , expression . sourceStart , expression . sourceEnd ) ; this . assistNodeParent = returnStatement ; } break nextElement ; case K_CAST_STATEMENT : Expression castType ; if ( this . expressionPtr > <NUM_LIT:0> && ( ( castType = this . expressionStack [ this . expressionPtr - <NUM_LIT:1> ] ) instanceof TypeReference ) ) { CastExpression cast = new CastExpression ( expression , ( TypeReference ) castType ) ; cast . sourceStart = castType . sourceStart ; cast . sourceEnd = expression . sourceEnd ; this . assistNodeParent = cast ; } break nextElement ; case K_UNARY_OPERATOR : if ( this . expressionPtr > - <NUM_LIT:1> ) { Expression operatorExpression = null ; switch ( info ) { case PLUS_PLUS : operatorExpression = new PrefixExpression ( expression , IntLiteral . One , PLUS , expression . sourceStart ) ; break ; case MINUS_MINUS : operatorExpression = new PrefixExpression ( expression , IntLiteral . One , MINUS , expression . sourceStart ) ; break ; default : operatorExpression = new UnaryExpression ( expression , info ) ; break ; } this . assistNodeParent = operatorExpression ; } break nextElement ; case K_BINARY_OPERATOR : if ( this . expressionPtr > - <NUM_LIT:1> ) { Expression operatorExpression = null ; Expression left = null ; if ( this . expressionPtr == <NUM_LIT:0> ) { if ( this . identifierPtr > - <NUM_LIT:1> ) { left = getUnspecifiedReferenceOptimized ( ) ; } } else { left = this . expressionStack [ this . expressionPtr - <NUM_LIT:1> ] ; if ( this . identifierPtr > - <NUM_LIT:1> ) { int start = ( int ) ( this . identifierPositionStack [ this . identifierPtr ] > > > <NUM_LIT:32> ) ; if ( left . sourceStart < start ) { left = getUnspecifiedReferenceOptimized ( ) ; } } } if ( left != null ) { switch ( info ) { case AND_AND : operatorExpression = new AND_AND_Expression ( left , expression , info ) ; break ; case OR_OR : operatorExpression = new OR_OR_Expression ( left , expression , info ) ; break ; case EQUAL_EQUAL : case NOT_EQUAL : operatorExpression = new EqualExpression ( left , expression , info ) ; break ; default : operatorExpression = new BinaryExpression ( left , expression , info ) ; break ; } } if ( operatorExpression != null ) { this . assistNodeParent = operatorExpression ; } } break nextElement ; case K_ARRAY_INITIALIZER : ArrayInitializer arrayInitializer = new ArrayInitializer ( ) ; arrayInitializer . expressions = new Expression [ ] { expression } ; this . expressionPtr -= this . expressionLengthStack [ this . expressionLengthPtr -- ] ; if ( this . expressionLengthPtr > - <NUM_LIT:1> && this . expressionPtr > - <NUM_LIT:1> && this . expressionStack [ this . expressionPtr ] != null && this . expressionStack [ this . expressionPtr ] . sourceStart > info ) { this . expressionLengthPtr -- ; } if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) == K_ARRAY_CREATION ) { ArrayAllocationExpression allocationExpression = new ArrayAllocationExpression ( ) ; pushOnGenericsLengthStack ( <NUM_LIT:0> ) ; pushOnGenericsIdentifiersLengthStack ( this . identifierLengthStack [ this . identifierLengthPtr ] ) ; allocationExpression . type = getTypeReference ( <NUM_LIT:0> ) ; allocationExpression . type . bits |= ASTNode . IgnoreRawTypeCheck ; int length = this . expressionLengthStack [ this . expressionLengthPtr ] ; allocationExpression . dimensions = new Expression [ length ] ; allocationExpression . initializer = arrayInitializer ; this . assistNodeParent = allocationExpression ; } else if ( this . currentElement instanceof RecoveredField && ! ( this . currentElement instanceof RecoveredInitializer ) ) { RecoveredField recoveredField = ( RecoveredField ) this . currentElement ; if ( recoveredField . fieldDeclaration . type . dimensions ( ) == <NUM_LIT:0> ) { Block block = new Block ( <NUM_LIT:0> ) ; block . sourceStart = info ; this . currentElement = this . currentElement . add ( block , <NUM_LIT:1> ) ; } else { statement = arrayInitializer ; } } else if ( this . currentElement instanceof RecoveredLocalVariable ) { RecoveredLocalVariable recoveredLocalVariable = ( RecoveredLocalVariable ) this . currentElement ; if ( recoveredLocalVariable . localDeclaration . type . dimensions ( ) == <NUM_LIT:0> ) { Block block = new Block ( <NUM_LIT:0> ) ; block . sourceStart = info ; this . currentElement = this . currentElement . add ( block , <NUM_LIT:1> ) ; } else { statement = arrayInitializer ; } } else { statement = arrayInitializer ; } break nextElement ; case K_ARRAY_CREATION : ArrayAllocationExpression allocationExpression = new ArrayAllocationExpression ( ) ; allocationExpression . type = getTypeReference ( <NUM_LIT:0> ) ; allocationExpression . dimensions = new Expression [ ] { expression } ; this . assistNodeParent = allocationExpression ; break nextElement ; case K_ASSISGNMENT_OPERATOR : if ( this . expressionPtr > <NUM_LIT:0> && this . expressionStack [ this . expressionPtr - <NUM_LIT:1> ] != null ) { Assignment assignment ; if ( info == EQUAL ) { assignment = new Assignment ( this . expressionStack [ this . expressionPtr - <NUM_LIT:1> ] , expression , expression . sourceEnd ) ; } else { assignment = new CompoundAssignment ( this . expressionStack [ this . expressionPtr - <NUM_LIT:1> ] , expression , info , expression . sourceEnd ) ; } this . assistNodeParent = assignment ; } break nextElement ; case K_CONDITIONAL_OPERATOR : if ( info == QUESTION ) { if ( this . expressionPtr > <NUM_LIT:0> ) { this . expressionPtr -- ; this . expressionLengthPtr -- ; this . expressionStack [ this . expressionPtr ] = this . expressionStack [ this . expressionPtr + <NUM_LIT:1> ] ; popElement ( K_CONDITIONAL_OPERATOR ) ; buildMoreCompletionContext ( expression ) ; return ; } } else { if ( this . expressionPtr > <NUM_LIT:1> ) { this . expressionPtr = this . expressionPtr - <NUM_LIT:2> ; this . expressionLengthPtr = this . expressionLengthPtr - <NUM_LIT:2> ; this . expressionStack [ this . expressionPtr ] = this . expressionStack [ this . expressionPtr + <NUM_LIT:2> ] ; popElement ( K_CONDITIONAL_OPERATOR ) ; buildMoreCompletionContext ( expression ) ; return ; } } break nextElement ; case K_BETWEEN_LEFT_AND_RIGHT_BRACKET : ArrayReference arrayReference ; if ( this . identifierPtr < <NUM_LIT:0> && this . expressionPtr > <NUM_LIT:0> && this . expressionStack [ this . expressionPtr ] == expression ) { arrayReference = new ArrayReference ( this . expressionStack [ this . expressionPtr - <NUM_LIT:1> ] , expression ) ; } else { arrayReference = new ArrayReference ( getUnspecifiedReferenceOptimized ( ) , expression ) ; } this . assistNodeParent = arrayReference ; break ; case K_BETWEEN_CASE_AND_COLON : if ( this . expressionPtr > <NUM_LIT:0> ) { SwitchStatement switchStatement = new SwitchStatement ( ) ; switchStatement . expression = this . expressionStack [ this . expressionPtr - <NUM_LIT:1> ] ; if ( this . astLengthPtr > - <NUM_LIT:1> && this . astPtr > - <NUM_LIT:1> ) { int length = this . astLengthStack [ this . astLengthPtr ] ; int newAstPtr = this . astPtr - length ; ASTNode firstNode = this . astStack [ newAstPtr + <NUM_LIT:1> ] ; if ( length != <NUM_LIT:0> && firstNode . sourceStart > switchStatement . expression . sourceEnd ) { switchStatement . statements = new Statement [ length + <NUM_LIT:1> ] ; System . arraycopy ( this . astStack , newAstPtr + <NUM_LIT:1> , switchStatement . statements , <NUM_LIT:0> , length ) ; } } CaseStatement caseStatement = new CaseStatement ( expression , expression . sourceStart , expression . sourceEnd ) ; if ( switchStatement . statements == null ) { switchStatement . statements = new Statement [ ] { caseStatement } ; } else { switchStatement . statements [ switchStatement . statements . length - <NUM_LIT:1> ] = caseStatement ; } this . assistNodeParent = switchStatement ; } break ; case K_BETWEEN_IF_AND_RIGHT_PAREN : IfStatement ifStatement = new IfStatement ( expression , new EmptyStatement ( expression . sourceEnd , expression . sourceEnd ) , expression . sourceStart , expression . sourceEnd ) ; this . assistNodeParent = ifStatement ; break nextElement ; case K_BETWEEN_WHILE_AND_RIGHT_PAREN : WhileStatement whileStatement = new WhileStatement ( expression , new EmptyStatement ( expression . sourceEnd , expression . sourceEnd ) , expression . sourceStart , expression . sourceEnd ) ; this . assistNodeParent = whileStatement ; break nextElement ; case K_INSIDE_FOR_CONDITIONAL : ForStatement forStatement = new ForStatement ( new Statement [ <NUM_LIT:0> ] , expression , new Statement [ <NUM_LIT:0> ] , new EmptyStatement ( expression . sourceEnd , expression . sourceEnd ) , false , expression . sourceStart , expression . sourceEnd ) ; this . assistNodeParent = forStatement ; break nextElement ; case K_BETWEEN_SWITCH_AND_RIGHT_PAREN : SwitchStatement switchStatement = new SwitchStatement ( ) ; switchStatement . expression = expression ; switchStatement . statements = new Statement [ <NUM_LIT:0> ] ; this . assistNodeParent = switchStatement ; break nextElement ; case K_BETWEEN_SYNCHRONIZED_AND_RIGHT_PAREN : SynchronizedStatement synchronizedStatement = new SynchronizedStatement ( expression , new Block ( <NUM_LIT:0> ) , expression . sourceStart , expression . sourceEnd ) ; this . assistNodeParent = synchronizedStatement ; break nextElement ; case K_INSIDE_THROW_STATEMENT : if ( info == this . bracketDepth ) { ThrowStatement throwStatement = new ThrowStatement ( expression , expression . sourceStart , expression . sourceEnd ) ; this . assistNodeParent = throwStatement ; } break nextElement ; case K_INSIDE_ASSERT_STATEMENT : if ( info == this . bracketDepth ) { AssertStatement assertStatement = new AssertStatement ( expression , expression . sourceStart ) ; this . assistNodeParent = assertStatement ; } break nextElement ; case K_INSIDE_ASSERT_EXCEPTION : if ( info == this . bracketDepth ) { AssertStatement assertStatement = new AssertStatement ( expression , new TrueLiteral ( expression . sourceStart , expression . sourceStart ) , expression . sourceStart ) ; this . assistNodeParent = assertStatement ; } break nextElement ; } } if ( this . assistNodeParent != null ) { this . currentElement = this . currentElement . add ( buildMoreCompletionEnclosingContext ( ( Statement ) this . assistNodeParent ) , <NUM_LIT:0> ) ; } else { if ( this . currentElement instanceof RecoveredField && ! ( this . currentElement instanceof RecoveredInitializer ) && ( ( RecoveredField ) this . currentElement ) . fieldDeclaration . initialization == null ) { this . assistNodeParent = ( ( RecoveredField ) this . currentElement ) . fieldDeclaration ; this . currentElement = this . currentElement . add ( buildMoreCompletionEnclosingContext ( statement ) , <NUM_LIT:0> ) ; } else if ( this . currentElement instanceof RecoveredLocalVariable && ( ( RecoveredLocalVariable ) this . currentElement ) . localDeclaration . initialization == null ) { this . assistNodeParent = ( ( RecoveredLocalVariable ) this . currentElement ) . localDeclaration ; this . currentElement = this . currentElement . add ( buildMoreCompletionEnclosingContext ( statement ) , <NUM_LIT:0> ) ; } else { this . currentElement = this . currentElement . add ( buildMoreCompletionEnclosingContext ( expression ) , <NUM_LIT:0> ) ; } } } private Statement buildMoreCompletionEnclosingContext ( Statement statement ) { IfStatement ifStatement = null ; int blockIndex = lastIndexOfElement ( K_BLOCK_DELIMITER ) ; int controlIndex = lastIndexOfElement ( K_CONTROL_STATEMENT_DELIMITER ) ; int index ; if ( controlIndex != - <NUM_LIT:1> ) { index = blockIndex != - <NUM_LIT:1> && controlIndex < blockIndex ? blockIndex : controlIndex ; } else { int instanceOfIndex = lastIndexOfElement ( K_BETWEEN_INSTANCEOF_AND_RPAREN ) ; index = blockIndex != - <NUM_LIT:1> && instanceOfIndex < blockIndex ? blockIndex : instanceOfIndex ; } while ( index >= <NUM_LIT:0> ) { if ( index != - <NUM_LIT:1> && this . elementInfoStack [ index ] == IF && this . elementObjectInfoStack [ index ] != null ) { Expression condition = ( Expression ) this . elementObjectInfoStack [ index ] ; if ( this . currentElement instanceof RecoveredLocalVariable && this . currentElement . parent instanceof RecoveredBlock ) { RecoveredLocalVariable recoveredLocalVariable = ( RecoveredLocalVariable ) this . currentElement ; if ( recoveredLocalVariable . localDeclaration . initialization == null && statement instanceof Expression && condition . sourceStart < recoveredLocalVariable . localDeclaration . sourceStart ) { this . currentElement . add ( statement , <NUM_LIT:0> ) ; statement = recoveredLocalVariable . updatedStatement ( <NUM_LIT:0> , new HashSet ( ) ) ; RecoveredBlock recoveredBlock = ( RecoveredBlock ) recoveredLocalVariable . parent ; recoveredBlock . statements [ -- recoveredBlock . statementCount ] = null ; this . currentElement = recoveredBlock ; } } if ( statement instanceof AND_AND_Expression && this . assistNode instanceof Statement ) { statement = ( Statement ) this . assistNode ; } ifStatement = new IfStatement ( condition , statement , condition . sourceStart , statement . sourceEnd ) ; index -- ; break ; } index -- ; } if ( ifStatement == null ) { return statement ; } while ( index >= <NUM_LIT:0> ) { if ( this . elementInfoStack [ index ] == IF && this . elementObjectInfoStack [ index ] instanceof InstanceOfExpression ) { InstanceOfExpression condition = ( InstanceOfExpression ) this . elementObjectInfoStack [ index ] ; ifStatement = new IfStatement ( condition , ifStatement , condition . sourceStart , ifStatement . sourceEnd ) ; } index -- ; } this . enclosingNode = ifStatement ; return ifStatement ; } private void buildMoreGenericsCompletionContext ( ASTNode node , boolean consumeTypeArguments ) { int kind = topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ; if ( kind != <NUM_LIT:0> ) { int info = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) ; nextElement : switch ( kind ) { case K_BINARY_OPERATOR : int prevKind = topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) ; switch ( prevKind ) { case K_PARAMETERIZED_ALLOCATION : if ( this . invocationType == ALLOCATION || this . invocationType == QUALIFIED_ALLOCATION ) { this . currentElement = this . currentElement . add ( ( TypeReference ) node , <NUM_LIT:0> ) ; } break nextElement ; case K_PARAMETERIZED_METHOD_INVOCATION : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) == <NUM_LIT:0> ) { this . currentElement = this . currentElement . add ( ( TypeReference ) node , <NUM_LIT:0> ) ; break nextElement ; } } if ( info == LESS && node instanceof TypeReference ) { if ( this . identifierLengthPtr > - <NUM_LIT:1> && this . identifierLengthStack [ this . identifierLengthPtr ] != <NUM_LIT:0> ) { if ( consumeTypeArguments ) consumeTypeArguments ( ) ; TypeReference ref = this . getTypeReference ( <NUM_LIT:0> ) ; if ( prevKind == K_PARAMETERIZED_CAST ) { ref = computeQualifiedGenericsFromRightSide ( ref , <NUM_LIT:0> ) ; } if ( this . currentElement instanceof RecoveredType ) { this . currentElement = this . currentElement . add ( new CompletionOnFieldType ( ref , false ) , <NUM_LIT:0> ) ; } else { if ( prevKind == K_BETWEEN_NEW_AND_LEFT_BRACKET ) { AllocationExpression exp ; if ( this . expressionPtr > - <NUM_LIT:1> && this . expressionStack [ this . expressionPtr ] instanceof AllocationExpression && this . invocationType == QUALIFIED_ALLOCATION ) { exp = new QualifiedAllocationExpression ( ) ; exp . type = ref ; ( ( QualifiedAllocationExpression ) exp ) . enclosingInstance = this . expressionStack [ this . expressionPtr ] ; } else { exp = new AllocationExpression ( ) ; exp . type = ref ; } if ( isInsideReturn ( ) ) { ReturnStatement returnStatement = new ReturnStatement ( exp , exp . sourceStart , exp . sourceEnd ) ; this . enclosingNode = returnStatement ; this . currentElement = this . currentElement . add ( returnStatement , <NUM_LIT:0> ) ; } else if ( this . currentElement instanceof RecoveredLocalVariable ) { if ( ( ( RecoveredLocalVariable ) this . currentElement ) . localDeclaration . initialization == null ) { this . enclosingNode = ( ( RecoveredLocalVariable ) this . currentElement ) . localDeclaration ; this . currentElement = this . currentElement . add ( exp , <NUM_LIT:0> ) ; } } else if ( this . currentElement instanceof RecoveredField ) { if ( ( ( RecoveredField ) this . currentElement ) . fieldDeclaration . initialization == null ) { this . enclosingNode = ( ( RecoveredField ) this . currentElement ) . fieldDeclaration ; this . currentElement = this . currentElement . add ( exp , <NUM_LIT:0> ) ; } } else { this . currentElement = this . currentElement . add ( ref , <NUM_LIT:0> ) ; } } else { this . currentElement = this . currentElement . add ( ref , <NUM_LIT:0> ) ; } } } else if ( this . currentElement . enclosingMethod ( ) != null && this . currentElement . enclosingMethod ( ) . methodDeclaration . isConstructor ( ) ) { this . currentElement = this . currentElement . add ( ( TypeReference ) node , <NUM_LIT:0> ) ; } } break ; } } } private void buildMoreTryStatementCompletionContext ( TypeReference exceptionRef ) { if ( this . astLengthPtr > <NUM_LIT:0> && this . astPtr > <NUM_LIT:2> && this . astStack [ this . astPtr - <NUM_LIT:1> ] instanceof Block && this . astStack [ this . astPtr - <NUM_LIT:2> ] instanceof Argument ) { TryStatement tryStatement = new TryStatement ( ) ; int newAstPtr = this . astPtr - <NUM_LIT:1> ; int length = this . astLengthStack [ this . astLengthPtr - <NUM_LIT:1> ] ; Block [ ] bks = ( tryStatement . catchBlocks = new Block [ length + <NUM_LIT:1> ] ) ; Argument [ ] args = ( tryStatement . catchArguments = new Argument [ length + <NUM_LIT:1> ] ) ; if ( length != <NUM_LIT:0> ) { while ( length -- > <NUM_LIT:0> ) { bks [ length ] = ( Block ) this . astStack [ newAstPtr -- ] ; bks [ length ] . statements = null ; args [ length ] = ( Argument ) this . astStack [ newAstPtr -- ] ; } } bks [ bks . length - <NUM_LIT:1> ] = new Block ( <NUM_LIT:0> ) ; if ( this . astStack [ this . astPtr ] instanceof UnionTypeReference ) { UnionTypeReference unionTypeReference = ( UnionTypeReference ) this . astStack [ this . astPtr ] ; args [ args . length - <NUM_LIT:1> ] = new Argument ( FAKE_ARGUMENT_NAME , <NUM_LIT:0> , unionTypeReference , <NUM_LIT:0> ) ; } else { args [ args . length - <NUM_LIT:1> ] = new Argument ( FAKE_ARGUMENT_NAME , <NUM_LIT:0> , exceptionRef , <NUM_LIT:0> ) ; } tryStatement . tryBlock = ( Block ) this . astStack [ newAstPtr -- ] ; this . assistNodeParent = tryStatement ; this . currentElement . add ( tryStatement , <NUM_LIT:0> ) ; } else if ( this . astLengthPtr > - <NUM_LIT:1> && this . astPtr > <NUM_LIT:0> && this . astStack [ this . astPtr - <NUM_LIT:1> ] instanceof Block ) { TryStatement tryStatement = new TryStatement ( ) ; int newAstPtr = this . astPtr - <NUM_LIT:1> ; Block [ ] bks = ( tryStatement . catchBlocks = new Block [ <NUM_LIT:1> ] ) ; Argument [ ] args = ( tryStatement . catchArguments = new Argument [ <NUM_LIT:1> ] ) ; bks [ <NUM_LIT:0> ] = new Block ( <NUM_LIT:0> ) ; if ( this . astStack [ this . astPtr ] instanceof UnionTypeReference ) { UnionTypeReference unionTypeReference = ( UnionTypeReference ) this . astStack [ this . astPtr ] ; args [ <NUM_LIT:0> ] = new Argument ( FAKE_ARGUMENT_NAME , <NUM_LIT:0> , unionTypeReference , <NUM_LIT:0> ) ; } else { args [ <NUM_LIT:0> ] = new Argument ( FAKE_ARGUMENT_NAME , <NUM_LIT:0> , exceptionRef , <NUM_LIT:0> ) ; } tryStatement . tryBlock = ( Block ) this . astStack [ newAstPtr -- ] ; this . assistNodeParent = tryStatement ; this . currentElement . add ( tryStatement , <NUM_LIT:0> ) ; } else { this . currentElement = this . currentElement . add ( exceptionRef , <NUM_LIT:0> ) ; } } public int bodyEnd ( AbstractMethodDeclaration method ) { return this . cursorLocation ; } public int bodyEnd ( Initializer initializer ) { return this . cursorLocation ; } protected void checkAndSetModifiers ( int flag ) { super . checkAndSetModifiers ( flag ) ; if ( isInsideMethod ( ) ) { this . hasUnusedModifiers = true ; } } private boolean checkClassInstanceCreation ( ) { if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BETWEEN_NEW_AND_LEFT_BRACKET ) { int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; int numberOfIdentifiers = this . genericsIdentifiersLengthStack [ this . genericsIdentifiersLengthPtr ] ; if ( length != numberOfIdentifiers || this . genericsLengthStack [ this . genericsLengthPtr ] != <NUM_LIT:0> ) { return true ; } TypeReference type ; if ( this . invocationType == ALLOCATION ) { AllocationExpression allocExpr = new AllocationExpression ( ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) == K_INSIDE_THROW_STATEMENT && topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) == this . bracketDepth ) { pushOnElementStack ( K_NEXT_TYPEREF_IS_EXCEPTION ) ; type = getTypeReference ( <NUM_LIT:0> ) ; popElement ( K_NEXT_TYPEREF_IS_EXCEPTION ) ; } else { type = getTypeReference ( <NUM_LIT:0> ) ; } if ( type instanceof CompletionOnSingleTypeReference ) { ( ( CompletionOnSingleTypeReference ) type ) . isConstructorType = true ; } else if ( type instanceof CompletionOnQualifiedTypeReference ) { ( ( CompletionOnQualifiedTypeReference ) type ) . isConstructorType = true ; } allocExpr . type = type ; allocExpr . sourceStart = type . sourceStart ; allocExpr . sourceEnd = type . sourceEnd ; pushOnExpressionStack ( allocExpr ) ; this . isOrphanCompletionNode = false ; } else { QualifiedAllocationExpression allocExpr = new QualifiedAllocationExpression ( ) ; pushOnGenericsIdentifiersLengthStack ( this . identifierLengthStack [ this . identifierLengthPtr ] ) ; pushOnGenericsLengthStack ( <NUM_LIT:0> ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) == K_INSIDE_THROW_STATEMENT && topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) == this . bracketDepth ) { pushOnElementStack ( K_NEXT_TYPEREF_IS_EXCEPTION ) ; type = getTypeReference ( <NUM_LIT:0> ) ; popElement ( K_NEXT_TYPEREF_IS_EXCEPTION ) ; } else { type = getTypeReference ( <NUM_LIT:0> ) ; } if ( type instanceof CompletionOnSingleTypeReference ) { ( ( CompletionOnSingleTypeReference ) type ) . isConstructorType = true ; } allocExpr . type = type ; allocExpr . enclosingInstance = this . expressionStack [ this . qualifier ] ; allocExpr . sourceStart = this . intStack [ this . intPtr -- ] ; allocExpr . sourceEnd = type . sourceEnd ; this . expressionStack [ this . qualifier ] = allocExpr ; this . isOrphanCompletionNode = false ; } this . assistNode = type ; this . lastCheckPoint = type . sourceEnd + <NUM_LIT:1> ; popElement ( K_BETWEEN_NEW_AND_LEFT_BRACKET ) ; return true ; } return false ; } private boolean checkClassLiteralAccess ( ) { if ( this . identifierLengthPtr >= <NUM_LIT:1> && this . previousToken == TokenNameDOT ) { int length ; if ( ( length = this . identifierLengthStack [ this . identifierLengthPtr - <NUM_LIT:1> ] ) < <NUM_LIT:0> ) { int dim = isAfterArrayType ( ) ? this . intStack [ this . intPtr -- ] : <NUM_LIT:0> ; SingleTypeReference typeRef = ( SingleTypeReference ) TypeReference . baseTypeReference ( - length , dim ) ; typeRef . sourceStart = this . intStack [ this . intPtr -- ] ; if ( dim == <NUM_LIT:0> ) { typeRef . sourceEnd = this . intStack [ this . intPtr -- ] ; } else { this . intPtr -- ; typeRef . sourceEnd = this . endPosition ; } char [ ] source = this . identifierStack [ this . identifierPtr ] ; long pos = this . identifierPositionStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; CompletionOnClassLiteralAccess access = new CompletionOnClassLiteralAccess ( pos , typeRef ) ; access . completionIdentifier = source ; this . identifierLengthPtr -- ; this . assistNode = access ; this . isOrphanCompletionNode = true ; return true ; } if ( isAfterArrayType ( ) ) { char [ ] source = this . identifierStack [ this . identifierPtr ] ; long pos = this . identifierPositionStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; pushOnGenericsIdentifiersLengthStack ( this . identifierLengthStack [ this . identifierLengthPtr ] ) ; pushOnGenericsLengthStack ( <NUM_LIT:0> ) ; TypeReference typeRef = getTypeReference ( this . intStack [ this . intPtr -- ] ) ; CompletionOnClassLiteralAccess access = new CompletionOnClassLiteralAccess ( pos , typeRef ) ; access . completionIdentifier = source ; this . assistNode = access ; this . isOrphanCompletionNode = true ; return true ; } } return false ; } private boolean checkKeyword ( ) { if ( this . currentElement instanceof RecoveredUnit ) { RecoveredUnit unit = ( RecoveredUnit ) this . currentElement ; int index = - <NUM_LIT:1> ; if ( ( index = this . indexOfAssistIdentifier ( ) ) > - <NUM_LIT:1> ) { int ptr = this . identifierPtr - this . identifierLengthStack [ this . identifierLengthPtr ] + index + <NUM_LIT:1> ; char [ ] ident = this . identifierStack [ ptr ] ; long pos = this . identifierPositionStack [ ptr ] ; char [ ] [ ] keywords = new char [ Keywords . COUNT ] [ ] ; int count = <NUM_LIT:0> ; if ( unit . typeCount == <NUM_LIT:0> && ( ! this . compilationUnit . isPackageInfo ( ) || this . compilationUnit . currentPackage != null ) && this . lastModifiers == ClassFileConstants . AccDefault ) { keywords [ count ++ ] = Keywords . IMPORT ; } if ( unit . typeCount == <NUM_LIT:0> && unit . importCount == <NUM_LIT:0> && this . lastModifiers == ClassFileConstants . AccDefault && this . compilationUnit . currentPackage == null ) { keywords [ count ++ ] = Keywords . PACKAGE ; } if ( ! this . compilationUnit . isPackageInfo ( ) ) { if ( ( this . lastModifiers & ClassFileConstants . AccPublic ) == <NUM_LIT:0> ) { boolean hasNoPublicType = true ; for ( int i = <NUM_LIT:0> ; i < unit . typeCount ; i ++ ) { if ( ( unit . types [ i ] . typeDeclaration . modifiers & ClassFileConstants . AccPublic ) != <NUM_LIT:0> ) { hasNoPublicType = false ; } } if ( hasNoPublicType ) { keywords [ count ++ ] = Keywords . PUBLIC ; } } if ( ( this . lastModifiers & ClassFileConstants . AccAbstract ) == <NUM_LIT:0> && ( this . lastModifiers & ClassFileConstants . AccFinal ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . ABSTRACT ; } if ( ( this . lastModifiers & ClassFileConstants . AccAbstract ) == <NUM_LIT:0> && ( this . lastModifiers & ClassFileConstants . AccFinal ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . FINAL ; } keywords [ count ++ ] = Keywords . CLASS ; if ( this . options . complianceLevel >= ClassFileConstants . JDK1_5 ) { keywords [ count ++ ] = Keywords . ENUM ; } if ( ( this . lastModifiers & ClassFileConstants . AccFinal ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . INTERFACE ; } } if ( count != <NUM_LIT:0> ) { System . arraycopy ( keywords , <NUM_LIT:0> , keywords = new char [ count ] [ ] , <NUM_LIT:0> , count ) ; this . assistNode = new CompletionOnKeyword2 ( ident , pos , keywords ) ; this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } } } return false ; } private boolean checkInstanceofKeyword ( ) { if ( isInsideMethod ( ) ) { int kind = topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ; int index ; if ( kind != K_BLOCK_DELIMITER && ( index = indexOfAssistIdentifier ( ) ) > - <NUM_LIT:1> && this . expressionPtr > - <NUM_LIT:1> && this . expressionLengthStack [ this . expressionPtr ] == <NUM_LIT:1> ) { int ptr = this . identifierPtr - this . identifierLengthStack [ this . identifierLengthPtr ] + index + <NUM_LIT:1> ; if ( this . identifierStack [ ptr ] . length > <NUM_LIT:0> && CharOperation . prefixEquals ( this . identifierStack [ ptr ] , Keywords . INSTANCEOF ) ) { this . assistNode = new CompletionOnKeyword3 ( this . identifierStack [ ptr ] , this . identifierPositionStack [ ptr ] , Keywords . INSTANCEOF ) ; this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } } } return false ; } private boolean checkInvocation ( ) { Expression topExpression = this . expressionPtr >= <NUM_LIT:0> ? this . expressionStack [ this . expressionPtr ] : null ; boolean isEmptyNameCompletion = false ; boolean isEmptyAssistIdentifier = false ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_SELECTOR_QUALIFIER && ( ( isEmptyNameCompletion = topExpression == this . assistNode && isEmptyNameCompletion ( ) ) || ( isEmptyAssistIdentifier = this . indexOfAssistIdentifier ( ) >= <NUM_LIT:0> && this . identifierStack [ this . identifierPtr ] . length == <NUM_LIT:0> ) ) ) { if ( isEmptyNameCompletion ) { this . expressionPtr -- ; this . expressionLengthStack [ this . expressionLengthPtr ] -- ; } else if ( isEmptyAssistIdentifier ) { this . identifierPtr -- ; this . identifierLengthPtr -- ; } int invocType = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) ; int qualifierExprPtr = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) ; int numArgs = this . expressionPtr - qualifierExprPtr ; int argStart = qualifierExprPtr + <NUM_LIT:1> ; Expression [ ] arguments = null ; if ( numArgs > <NUM_LIT:0> ) { arguments = new Expression [ numArgs ] ; System . arraycopy ( this . expressionStack , argStart , arguments , <NUM_LIT:0> , numArgs ) ; this . expressionPtr -= numArgs ; int count = numArgs ; while ( count > <NUM_LIT:0> ) { count -= this . expressionLengthStack [ this . expressionLengthPtr -- ] ; } } if ( invocType != ALLOCATION && invocType != QUALIFIED_ALLOCATION ) { CompletionOnMessageSend messageSend = new CompletionOnMessageSend ( ) ; messageSend . arguments = arguments ; switch ( invocType ) { case NO_RECEIVER : messageSend . receiver = ThisReference . implicitThis ( ) ; break ; case NAME_RECEIVER : while ( this . identifierLengthPtr >= <NUM_LIT:0> && this . identifierLengthStack [ this . identifierLengthPtr ] < <NUM_LIT:0> ) { this . identifierLengthPtr -- ; } this . identifierPtr -- ; if ( this . genericsPtr > - <NUM_LIT:1> && this . genericsLengthPtr > - <NUM_LIT:1> && this . genericsLengthStack [ this . genericsLengthPtr ] > <NUM_LIT:0> ) { this . identifierLengthPtr -- ; } else { this . identifierLengthStack [ this . identifierLengthPtr ] -- ; } messageSend . receiver = getUnspecifiedReference ( ) ; break ; case SUPER_RECEIVER : messageSend . receiver = new SuperReference ( <NUM_LIT:0> , <NUM_LIT:0> ) ; break ; case EXPLICIT_RECEIVER : messageSend . receiver = this . expressionStack [ qualifierExprPtr ] ; } int selectorPtr = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:2> ) ; messageSend . selector = this . identifierStack [ selectorPtr ] ; if ( this . identifierLengthPtr >= <NUM_LIT:0> && this . identifierLengthStack [ this . identifierLengthPtr ] == <NUM_LIT:1> ) { this . identifierPtr -- ; this . identifierLengthPtr -- ; } messageSend . sourceStart = ( int ) ( this . identifierPositionStack [ selectorPtr ] > > <NUM_LIT:32> ) ; messageSend . sourceEnd = this . cursorLocation ; this . assistNode = messageSend ; this . lastCheckPoint = messageSend . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } else { int selectorPtr = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:2> ) ; if ( selectorPtr == THIS_CONSTRUCTOR || selectorPtr == SUPER_CONSTRUCTOR ) { CompletionOnExplicitConstructorCall call = new CompletionOnExplicitConstructorCall ( ( selectorPtr == THIS_CONSTRUCTOR ) ? ExplicitConstructorCall . This : ExplicitConstructorCall . Super ) ; call . arguments = arguments ; if ( invocType == QUALIFIED_ALLOCATION ) { call . qualification = this . expressionStack [ qualifierExprPtr ] ; } call . sourceStart = this . cursorLocation + <NUM_LIT:1> ; call . sourceEnd = this . cursorLocation ; this . assistNode = call ; this . lastCheckPoint = call . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } else { CompletionOnQualifiedAllocationExpression allocExpr = new CompletionOnQualifiedAllocationExpression ( ) ; allocExpr . arguments = arguments ; if ( this . genericsLengthPtr < <NUM_LIT:0> ) { pushOnGenericsLengthStack ( <NUM_LIT:0> ) ; pushOnGenericsIdentifiersLengthStack ( this . identifierLengthStack [ this . identifierLengthPtr ] ) ; } allocExpr . type = super . getTypeReference ( <NUM_LIT:0> ) ; if ( invocType == QUALIFIED_ALLOCATION ) { allocExpr . enclosingInstance = this . expressionStack [ qualifierExprPtr ] ; } allocExpr . sourceStart = this . cursorLocation + <NUM_LIT:1> ; allocExpr . sourceEnd = this . cursorLocation ; this . assistNode = allocExpr ; this . lastCheckPoint = allocExpr . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } } } return false ; } private boolean checkLabelStatement ( ) { if ( isInsideMethod ( ) || isInsideFieldInitialization ( ) ) { int kind = this . topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ; if ( kind != K_INSIDE_BREAK_STATEMENT && kind != K_INSIDE_CONTINUE_STATEMENT ) return false ; if ( indexOfAssistIdentifier ( ) != <NUM_LIT:0> ) return false ; char [ ] [ ] labels = new char [ this . labelPtr + <NUM_LIT:1> ] [ ] ; int labelCount = <NUM_LIT:0> ; int labelKind = kind ; int index = <NUM_LIT:1> ; while ( labelKind != <NUM_LIT:0> && labelKind != K_METHOD_DELIMITER ) { labelKind = this . topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER , index ) ; if ( labelKind == K_LABEL ) { int ptr = this . topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER , index ) ; labels [ labelCount ++ ] = this . labelStack [ ptr ] ; } index ++ ; } System . arraycopy ( labels , <NUM_LIT:0> , labels = new char [ labelCount ] [ ] , <NUM_LIT:0> , labelCount ) ; long position = this . identifierPositionStack [ this . identifierPtr ] ; CompletionOnBranchStatementLabel statementLabel = new CompletionOnBranchStatementLabel ( kind == K_INSIDE_BREAK_STATEMENT ? CompletionOnBranchStatementLabel . BREAK : CompletionOnBranchStatementLabel . CONTINUE , this . identifierStack [ this . identifierPtr -- ] , ( int ) ( position > > > <NUM_LIT:32> ) , ( int ) position , labels ) ; this . assistNode = statementLabel ; this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } return false ; } private boolean checkMemberAccess ( ) { if ( this . previousToken == TokenNameDOT && this . qualifier > - <NUM_LIT:1> && this . expressionPtr == this . qualifier ) { if ( this . identifierLengthPtr > <NUM_LIT:1> && this . identifierLengthStack [ this . identifierLengthPtr - <NUM_LIT:1> ] < <NUM_LIT:0> ) { return false ; } pushCompletionOnMemberAccessOnExpressionStack ( false ) ; return true ; } return false ; } private boolean checkNameCompletion ( ) { this . assistNode = getUnspecifiedReferenceOptimized ( ) ; this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; if ( this . hasUnusedModifiers && this . assistNode instanceof CompletionOnSingleNameReference ) { ( ( CompletionOnSingleNameReference ) this . assistNode ) . isPrecededByModifiers = true ; } return true ; } private boolean checkParemeterizedMethodName ( ) { if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_PARAMETERIZED_METHOD_INVOCATION && topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == INSIDE_NAME ) { if ( this . identifierLengthPtr > - <NUM_LIT:1> && this . genericsLengthPtr > - <NUM_LIT:1> && this . genericsIdentifiersLengthPtr == - <NUM_LIT:1> ) { CompletionOnMessageSendName m = null ; switch ( this . invocationType ) { case EXPLICIT_RECEIVER : case NO_RECEIVER : if ( this . expressionPtr > - <NUM_LIT:1> && this . expressionLengthStack [ this . expressionLengthPtr ] == <NUM_LIT:1> ) { char [ ] selector = this . identifierStack [ this . identifierPtr ] ; long position = this . identifierPositionStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; int end = ( int ) position ; int start = ( int ) ( position > > > <NUM_LIT:32> ) ; m = new CompletionOnMessageSendName ( selector , start , end ) ; int length = this . genericsLengthStack [ this . genericsLengthPtr -- ] ; this . genericsPtr -= length ; System . arraycopy ( this . genericsStack , this . genericsPtr + <NUM_LIT:1> , m . typeArguments = new TypeReference [ length ] , <NUM_LIT:0> , length ) ; this . intPtr -- ; m . receiver = this . expressionStack [ this . expressionPtr -- ] ; this . expressionLengthPtr -- ; } break ; case NAME_RECEIVER : if ( this . identifierPtr > <NUM_LIT:0> ) { char [ ] selector = this . identifierStack [ this . identifierPtr ] ; long position = this . identifierPositionStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; int end = ( int ) position ; int start = ( int ) ( position > > > <NUM_LIT:32> ) ; m = new CompletionOnMessageSendName ( selector , start , end ) ; int length = this . genericsLengthStack [ this . genericsLengthPtr -- ] ; this . genericsPtr -= length ; System . arraycopy ( this . genericsStack , this . genericsPtr + <NUM_LIT:1> , m . typeArguments = new TypeReference [ length ] , <NUM_LIT:0> , length ) ; this . intPtr -- ; m . receiver = getUnspecifiedReference ( ) ; } break ; case SUPER_RECEIVER : char [ ] selector = this . identifierStack [ this . identifierPtr ] ; long position = this . identifierPositionStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; int end = ( int ) position ; int start = ( int ) ( position > > > <NUM_LIT:32> ) ; m = new CompletionOnMessageSendName ( selector , start , end ) ; int length = this . genericsLengthStack [ this . genericsLengthPtr -- ] ; this . genericsPtr -= length ; System . arraycopy ( this . genericsStack , this . genericsPtr + <NUM_LIT:1> , m . typeArguments = new TypeReference [ length ] , <NUM_LIT:0> , length ) ; this . intPtr -- ; m . receiver = new SuperReference ( start , end ) ; break ; } if ( m != null ) { pushOnExpressionStack ( m ) ; this . assistNode = m ; this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } } } return false ; } private boolean checkParemeterizedType ( ) { if ( this . identifierLengthPtr > - <NUM_LIT:1> && this . genericsLengthPtr > - <NUM_LIT:1> && this . genericsIdentifiersLengthPtr > - <NUM_LIT:1> ) { int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; int numberOfIdentifiers = this . genericsIdentifiersLengthStack [ this . genericsIdentifiersLengthPtr ] ; if ( length != numberOfIdentifiers || this . genericsLengthStack [ this . genericsLengthPtr ] != <NUM_LIT:0> ) { this . genericsIdentifiersLengthPtr -- ; this . identifierLengthPtr -- ; this . assistNode = getAssistTypeReferenceForGenericType ( <NUM_LIT:0> , length , numberOfIdentifiers ) ; this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } else if ( this . genericsPtr > - <NUM_LIT:1> && this . genericsStack [ this . genericsPtr ] instanceof TypeReference ) { numberOfIdentifiers ++ ; this . genericsIdentifiersLengthPtr -- ; this . identifierLengthPtr -- ; this . assistNode = getAssistTypeReferenceForGenericType ( <NUM_LIT:0> , length , numberOfIdentifiers ) ; this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } } return false ; } private boolean checkRecoveredMethod ( ) { if ( this . currentElement instanceof RecoveredMethod ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) return false ; if ( this . lastErrorEndPosition <= this . cursorLocation && Util . getLineNumber ( this . lastErrorEndPosition , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) == Util . getLineNumber ( ( ( CompletionScanner ) this . scanner ) . completedIdentifierStart , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) ) { return false ; } RecoveredMethod recoveredMethod = ( RecoveredMethod ) this . currentElement ; if ( ! recoveredMethod . foundOpeningBrace && this . lastIgnoredToken == - <NUM_LIT:1> ) { this . assistNode = this . getTypeReference ( <NUM_LIT:0> ) ; this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } } return false ; } private boolean checkMemberValueName ( ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) return false ; if ( this . topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) != K_BETWEEN_ANNOTATION_NAME_AND_RPAREN ) return false ; if ( this . identifierPtr > - <NUM_LIT:1> && this . identifierLengthPtr > - <NUM_LIT:1> && this . identifierLengthStack [ this . identifierLengthPtr ] == <NUM_LIT:1> ) { char [ ] simpleName = this . identifierStack [ this . identifierPtr ] ; long position = this . identifierPositionStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; int end = ( int ) position ; int start = ( int ) ( position > > > <NUM_LIT:32> ) ; CompletionOnMemberValueName memberValueName = new CompletionOnMemberValueName ( simpleName , start , end ) ; this . assistNode = memberValueName ; this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } return false ; } private boolean checkRecoveredType ( ) { if ( this . currentElement instanceof RecoveredType ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) return false ; if ( this . lastErrorEndPosition <= this . cursorLocation && ( ( RecoveredType ) this . currentElement ) . lastMemberEnd ( ) < this . lastErrorEndPosition && Util . getLineNumber ( this . lastErrorEndPosition , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) == Util . getLineNumber ( ( ( CompletionScanner ) this . scanner ) . completedIdentifierStart , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) ) { return false ; } RecoveredType recoveredType = ( RecoveredType ) this . currentElement ; if ( recoveredType . foundOpeningBrace ) { if ( ( this . genericsIdentifiersLengthPtr < <NUM_LIT:0> && this . identifierPtr > - <NUM_LIT:1> ) || ( this . genericsIdentifiersLengthStack [ this . genericsIdentifiersLengthPtr ] <= this . identifierPtr ) ) { pushOnGenericsIdentifiersLengthStack ( this . identifierLengthStack [ this . identifierLengthPtr ] ) ; pushOnGenericsLengthStack ( <NUM_LIT:0> ) ; } this . assistNode = this . getTypeReference ( <NUM_LIT:0> ) ; this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } else { if ( recoveredType . typeDeclaration . superclass == null && this . topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_EXTENDS_KEYWORD ) { consumeClassOrInterfaceName ( ) ; this . pushOnElementStack ( K_NEXT_TYPEREF_IS_CLASS ) ; this . assistNode = this . getTypeReference ( <NUM_LIT:0> ) ; popElement ( K_NEXT_TYPEREF_IS_CLASS ) ; this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } } } return false ; } private void classHeaderExtendsOrImplements ( boolean isInterface ) { if ( this . currentElement != null && this . currentToken == TokenNameIdentifier && this . cursorLocation + <NUM_LIT:1> >= this . scanner . startPosition && this . cursorLocation < this . scanner . currentPosition ) { this . pushIdentifier ( ) ; int index = - <NUM_LIT:1> ; if ( ( index = this . indexOfAssistIdentifier ( ) ) > - <NUM_LIT:1> ) { int ptr = this . identifierPtr - this . identifierLengthStack [ this . identifierLengthPtr ] + index + <NUM_LIT:1> ; RecoveredType recoveredType = ( RecoveredType ) this . currentElement ; if ( ! recoveredType . foundOpeningBrace ) { TypeDeclaration type = recoveredType . typeDeclaration ; if ( ! isInterface ) { char [ ] [ ] keywords = new char [ Keywords . COUNT ] [ ] ; int count = <NUM_LIT:0> ; if ( type . superInterfaces == null ) { if ( type . superclass == null ) { keywords [ count ++ ] = Keywords . EXTENDS ; } keywords [ count ++ ] = Keywords . IMPLEMENTS ; } System . arraycopy ( keywords , <NUM_LIT:0> , keywords = new char [ count ] [ ] , <NUM_LIT:0> , count ) ; if ( count > <NUM_LIT:0> ) { CompletionOnKeyword1 completionOnKeyword = new CompletionOnKeyword1 ( this . identifierStack [ ptr ] , this . identifierPositionStack [ ptr ] , keywords ) ; completionOnKeyword . canCompleteEmptyToken = true ; type . superclass = completionOnKeyword ; type . superclass . bits |= ASTNode . IsSuperType ; this . assistNode = completionOnKeyword ; this . lastCheckPoint = completionOnKeyword . sourceEnd + <NUM_LIT:1> ; } } else { if ( type . superInterfaces == null ) { CompletionOnKeyword1 completionOnKeyword = new CompletionOnKeyword1 ( this . identifierStack [ ptr ] , this . identifierPositionStack [ ptr ] , Keywords . EXTENDS ) ; completionOnKeyword . canCompleteEmptyToken = true ; type . superInterfaces = new TypeReference [ ] { completionOnKeyword } ; type . superInterfaces [ <NUM_LIT:0> ] . bits |= ASTNode . IsSuperType ; this . assistNode = completionOnKeyword ; this . lastCheckPoint = completionOnKeyword . sourceEnd + <NUM_LIT:1> ; } } } } } } public void completionIdentifierCheck ( ) { if ( checkMemberValueName ( ) ) return ; if ( checkKeyword ( ) ) return ; if ( checkRecoveredType ( ) ) return ; if ( checkRecoveredMethod ( ) ) return ; if ( ! ( isInsideMethod ( ) && ! this . diet ) && ! isIndirectlyInsideFieldInitialization ( ) && ! isInsideAttributeValue ( ) ) return ; if ( assistIdentifier ( ) == null && this . currentToken == TokenNameIdentifier ) { if ( this . cursorLocation < this . scanner . startPosition && this . scanner . currentPosition == this . scanner . startPosition ) { this . pushIdentifier ( ) ; } else if ( this . cursorLocation + <NUM_LIT:1> >= this . scanner . startPosition && this . cursorLocation < this . scanner . currentPosition ) { this . pushIdentifier ( ) ; } } if ( this . assistNode != null ) { if ( ! isEmptyNameCompletion ( ) || checkInvocation ( ) ) return ; } if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) return ; if ( checkClassInstanceCreation ( ) ) return ; if ( checkMemberAccess ( ) ) return ; if ( checkClassLiteralAccess ( ) ) return ; if ( checkInstanceofKeyword ( ) ) return ; if ( checkInvocation ( ) ) return ; if ( checkParemeterizedType ( ) ) return ; if ( checkParemeterizedMethodName ( ) ) return ; if ( checkLabelStatement ( ) ) return ; if ( checkNameCompletion ( ) ) return ; } protected void consumeArrayCreationExpressionWithInitializer ( ) { super . consumeArrayCreationExpressionWithInitializer ( ) ; popElement ( K_ARRAY_CREATION ) ; } protected void consumeArrayCreationExpressionWithoutInitializer ( ) { super . consumeArrayCreationExpressionWithoutInitializer ( ) ; popElement ( K_ARRAY_CREATION ) ; } protected void consumeArrayCreationHeader ( ) { } protected void consumeAssignment ( ) { popElement ( K_ASSISGNMENT_OPERATOR ) ; super . consumeAssignment ( ) ; } protected void consumeAssignmentOperator ( int pos ) { super . consumeAssignmentOperator ( pos ) ; pushOnElementStack ( K_ASSISGNMENT_OPERATOR , pos ) ; } protected void consumeBinaryExpression ( int op ) { super . consumeBinaryExpression ( op ) ; popElement ( K_BINARY_OPERATOR ) ; if ( this . expressionStack [ this . expressionPtr ] instanceof BinaryExpression ) { BinaryExpression exp = ( BinaryExpression ) this . expressionStack [ this . expressionPtr ] ; if ( this . assistNode != null && exp . right == this . assistNode ) { this . assistNodeParent = exp ; } } } protected void consumeBinaryExpressionWithName ( int op ) { super . consumeBinaryExpressionWithName ( op ) ; popElement ( K_BINARY_OPERATOR ) ; if ( this . expressionStack [ this . expressionPtr ] instanceof BinaryExpression ) { BinaryExpression exp = ( BinaryExpression ) this . expressionStack [ this . expressionPtr ] ; if ( this . assistNode != null && exp . right == this . assistNode ) { this . assistNodeParent = exp ; } } } protected void consumeCaseLabel ( ) { super . consumeCaseLabel ( ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) != K_SWITCH_LABEL ) { pushOnElementStack ( K_SWITCH_LABEL ) ; } } protected void consumeCastExpressionWithPrimitiveType ( ) { popElement ( K_CAST_STATEMENT ) ; Expression exp ; Expression cast ; TypeReference castType ; this . expressionPtr -- ; this . expressionLengthPtr -- ; this . expressionStack [ this . expressionPtr ] = cast = new CastExpression ( exp = this . expressionStack [ this . expressionPtr + <NUM_LIT:1> ] , castType = ( TypeReference ) this . expressionStack [ this . expressionPtr ] ) ; cast . sourceStart = castType . sourceStart - <NUM_LIT:1> ; cast . sourceEnd = exp . sourceEnd ; } protected void consumeCastExpressionWithGenericsArray ( ) { popElement ( K_CAST_STATEMENT ) ; Expression exp ; Expression cast ; TypeReference castType ; this . expressionPtr -- ; this . expressionLengthPtr -- ; this . expressionStack [ this . expressionPtr ] = cast = new CastExpression ( exp = this . expressionStack [ this . expressionPtr + <NUM_LIT:1> ] , castType = ( TypeReference ) this . expressionStack [ this . expressionPtr ] ) ; cast . sourceStart = castType . sourceStart - <NUM_LIT:1> ; cast . sourceEnd = exp . sourceEnd ; } protected void consumeCastExpressionWithQualifiedGenericsArray ( ) { popElement ( K_CAST_STATEMENT ) ; Expression exp ; Expression cast ; TypeReference castType ; this . expressionPtr -- ; this . expressionLengthPtr -- ; this . expressionStack [ this . expressionPtr ] = cast = new CastExpression ( exp = this . expressionStack [ this . expressionPtr + <NUM_LIT:1> ] , castType = ( TypeReference ) this . expressionStack [ this . expressionPtr ] ) ; cast . sourceStart = castType . sourceStart - <NUM_LIT:1> ; cast . sourceEnd = exp . sourceEnd ; } protected void consumeCastExpressionWithNameArray ( ) { popElement ( K_CAST_STATEMENT ) ; Expression exp ; Expression cast ; TypeReference castType ; this . expressionPtr -- ; this . expressionLengthPtr -- ; this . expressionStack [ this . expressionPtr ] = cast = new CastExpression ( exp = this . expressionStack [ this . expressionPtr + <NUM_LIT:1> ] , castType = ( TypeReference ) this . expressionStack [ this . expressionPtr ] ) ; cast . sourceStart = castType . sourceStart - <NUM_LIT:1> ; cast . sourceEnd = exp . sourceEnd ; } protected void consumeCastExpressionLL1 ( ) { popElement ( K_CAST_STATEMENT ) ; super . consumeCastExpressionLL1 ( ) ; } protected void consumeCatchFormalParameter ( ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { super . consumeCatchFormalParameter ( ) ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } } else { this . identifierLengthPtr -- ; char [ ] identifierName = this . identifierStack [ this . identifierPtr ] ; long namePositions = this . identifierPositionStack [ this . identifierPtr -- ] ; this . intPtr -- ; TypeReference type = ( TypeReference ) this . astStack [ this . astPtr -- ] ; this . intPtr -= <NUM_LIT:2> ; CompletionOnArgumentName arg = new CompletionOnArgumentName ( identifierName , namePositions , type , this . intStack [ this . intPtr + <NUM_LIT:1> ] & ~ ClassFileConstants . AccDeprecated ) ; 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 ) ; } arg . isCatchArgument = topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BETWEEN_CATCH_AND_RIGHT_PAREN ; pushOnAstStack ( arg ) ; this . assistNode = arg ; this . lastCheckPoint = ( int ) namePositions ; this . isOrphanCompletionNode = true ; this . listLength ++ ; } } protected void consumeClassBodyDeclaration ( ) { popElement ( K_BLOCK_DELIMITER ) ; super . consumeClassBodyDeclaration ( ) ; this . pendingAnnotation = null ; } protected void consumeClassBodyopt ( ) { popElement ( K_SELECTOR_QUALIFIER ) ; popElement ( K_SELECTOR_INVOCATION_TYPE ) ; super . consumeClassBodyopt ( ) ; } protected void consumeClassDeclaration ( ) { if ( this . astPtr >= <NUM_LIT:0> ) { int length = this . astLengthStack [ this . astLengthPtr ] ; TypeDeclaration typeDeclaration = ( TypeDeclaration ) this . astStack [ this . astPtr - length ] ; this . javadoc = null ; CompletionJavadocParser completionJavadocParser = ( CompletionJavadocParser ) this . javadocParser ; completionJavadocParser . allPossibleTags = true ; checkComment ( ) ; if ( this . javadoc != null && this . cursorLocation > this . javadoc . sourceStart && this . cursorLocation < this . javadoc . sourceEnd ) { typeDeclaration . javadoc = this . javadoc ; } completionJavadocParser . allPossibleTags = false ; } super . consumeClassDeclaration ( ) ; } protected void consumeClassHeaderName1 ( ) { super . consumeClassHeaderName1 ( ) ; this . hasUnusedModifiers = false ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } classHeaderExtendsOrImplements ( false ) ; } protected void consumeClassHeaderExtends ( ) { pushOnElementStack ( K_NEXT_TYPEREF_IS_CLASS ) ; super . consumeClassHeaderExtends ( ) ; if ( this . assistNode != null && this . assistNodeParent == null ) { TypeDeclaration typeDecl = ( TypeDeclaration ) this . astStack [ this . astPtr ] ; if ( typeDecl != null && typeDecl . superclass == this . assistNode ) this . assistNodeParent = typeDecl ; } popElement ( K_NEXT_TYPEREF_IS_CLASS ) ; popElement ( K_EXTENDS_KEYWORD ) ; if ( this . currentElement != null && this . currentToken == TokenNameIdentifier && this . cursorLocation + <NUM_LIT:1> >= this . scanner . startPosition && this . cursorLocation < this . scanner . currentPosition ) { this . pushIdentifier ( ) ; int index = - <NUM_LIT:1> ; if ( ( index = this . indexOfAssistIdentifier ( ) ) > - <NUM_LIT:1> ) { int ptr = this . identifierPtr - this . identifierLengthStack [ this . identifierLengthPtr ] + index + <NUM_LIT:1> ; RecoveredType recoveredType = ( RecoveredType ) this . currentElement ; if ( ! recoveredType . foundOpeningBrace ) { TypeDeclaration type = recoveredType . typeDeclaration ; if ( type . superInterfaces == null ) { type . superclass = new CompletionOnKeyword1 ( this . identifierStack [ ptr ] , this . identifierPositionStack [ ptr ] , Keywords . IMPLEMENTS ) ; type . superclass . bits |= ASTNode . IsSuperType ; this . assistNode = type . superclass ; this . lastCheckPoint = type . superclass . sourceEnd + <NUM_LIT:1> ; } } } } } protected void consumeClassHeaderImplements ( ) { super . consumeClassHeaderImplements ( ) ; if ( this . assistNode != null && this . assistNodeParent == null ) { TypeDeclaration typeDecl = ( TypeDeclaration ) this . astStack [ this . astPtr ] ; if ( typeDecl != null ) { TypeReference [ ] superInterfaces = typeDecl . superInterfaces ; int length = superInterfaces == null ? <NUM_LIT:0> : superInterfaces . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( superInterfaces [ i ] == this . assistNode ) { this . assistNodeParent = typeDecl ; } } } } } protected void consumeClassTypeElt ( ) { pushOnElementStack ( K_NEXT_TYPEREF_IS_EXCEPTION ) ; super . consumeClassTypeElt ( ) ; popElement ( K_NEXT_TYPEREF_IS_EXCEPTION ) ; } protected void consumeCompilationUnit ( ) { this . javadoc = null ; checkComment ( ) ; if ( this . javadoc != null && this . cursorLocation > this . javadoc . sourceStart && this . cursorLocation < this . javadoc . sourceEnd ) { this . compilationUnit . javadoc = this . javadoc ; if ( this . compilationUnit . types == null ) { this . compilationUnit . types = new TypeDeclaration [ <NUM_LIT:1> ] ; TypeDeclaration declaration = new TypeDeclaration ( this . compilationUnit . compilationResult ) ; declaration . name = FAKE_TYPE_NAME ; declaration . modifiers = ClassFileConstants . AccDefault | ClassFileConstants . AccInterface ; this . compilationUnit . types [ <NUM_LIT:0> ] = declaration ; } } super . consumeCompilationUnit ( ) ; } protected void consumeConditionalExpression ( int op ) { popElement ( K_CONDITIONAL_OPERATOR ) ; super . consumeConditionalExpression ( op ) ; } protected void consumeConditionalExpressionWithName ( int op ) { popElement ( K_CONDITIONAL_OPERATOR ) ; super . consumeConditionalExpressionWithName ( op ) ; } protected void consumeConstructorBody ( ) { popElement ( K_BLOCK_DELIMITER ) ; super . consumeConstructorBody ( ) ; } protected void consumeConstructorHeader ( ) { super . consumeConstructorHeader ( ) ; pushOnElementStack ( K_BLOCK_DELIMITER ) ; } protected void consumeConstructorHeaderName ( ) { if ( indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { long selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr ] ; int selectorSourceEnd = ( int ) selectorSourcePositions ; int currentAstPtr = this . astPtr ; if ( this . currentElement != null && this . lastIgnoredToken == TokenNamenew ) { super . consumeConstructorHeaderName ( ) ; } else { super . consumeConstructorHeaderName ( ) ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } } if ( this . sourceEnds != null && this . astPtr > currentAstPtr ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , selectorSourceEnd ) ; } return ; } if ( this . currentElement == null ) { this . hasReportedError = true ; } pushOnGenericsIdentifiersLengthStack ( this . identifierLengthStack [ this . identifierLengthPtr ] ) ; pushOnGenericsLengthStack ( <NUM_LIT:0> ) ; this . restartRecovery = true ; } protected void consumeConstructorHeaderNameWithTypeParameters ( ) { long selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr ] ; int selectorSourceEnd = ( int ) selectorSourcePositions ; int currentAstPtr = this . astPtr ; if ( this . currentElement != null && this . lastIgnoredToken == TokenNamenew ) { super . consumeConstructorHeaderNameWithTypeParameters ( ) ; } else { super . consumeConstructorHeaderNameWithTypeParameters ( ) ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } } if ( this . sourceEnds != null && this . astPtr > currentAstPtr ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , selectorSourceEnd ) ; } } protected void consumeDefaultLabel ( ) { super . consumeDefaultLabel ( ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_SWITCH_LABEL ) { popElement ( K_SWITCH_LABEL ) ; } pushOnElementStack ( K_SWITCH_LABEL , DEFAULT ) ; } protected void consumeDimWithOrWithOutExpr ( ) { pushOnExpressionStack ( null ) ; } protected void consumeEnhancedForStatement ( ) { super . consumeEnhancedForStatement ( ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_CONTROL_STATEMENT_DELIMITER ) { popElement ( K_CONTROL_STATEMENT_DELIMITER ) ; } } protected void consumeEnhancedForStatementHeaderInit ( boolean hasModifiers ) { super . consumeEnhancedForStatementHeaderInit ( hasModifiers ) ; this . hasUnusedModifiers = false ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } } protected void consumeEnterAnonymousClassBody ( boolean qualified ) { popElement ( K_SELECTOR_QUALIFIER ) ; popElement ( K_SELECTOR_INVOCATION_TYPE ) ; super . consumeEnterAnonymousClassBody ( qualified ) ; } protected void consumeEnterVariable ( ) { this . identifierPtr -- ; this . identifierLengthPtr -- ; boolean isLocalDeclaration = this . nestedMethod [ this . nestedType ] != <NUM_LIT:0> ; int variableIndex = this . variablesCounter [ this . nestedType ] ; this . hasUnusedModifiers = false ; if ( isLocalDeclaration || indexOfAssistIdentifier ( ) < <NUM_LIT:0> || variableIndex != <NUM_LIT:0> ) { this . identifierPtr ++ ; this . identifierLengthPtr ++ ; if ( this . pendingAnnotation != null && this . assistNode != null && this . currentElement != null && this . currentElement instanceof RecoveredMethod && ! this . currentElement . foundOpeningBrace && ( ( RecoveredMethod ) this . currentElement ) . methodDeclaration . declarationSourceEnd == <NUM_LIT:0> ) { super . consumeEnterVariable ( ) ; this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation . isParameter = true ; this . pendingAnnotation = null ; } else { super . consumeEnterVariable ( ) ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } } } else { this . restartRecovery = true ; if ( this . currentElement != null ) { if ( ! checkKeyword ( ) && ! ( this . currentElement instanceof RecoveredUnit && ( ( RecoveredUnit ) this . currentElement ) . typeCount == <NUM_LIT:0> ) ) { int nameSourceStart = ( int ) ( this . identifierPositionStack [ this . identifierPtr ] > > > <NUM_LIT:32> ) ; this . intPtr -- ; TypeReference type = getTypeReference ( this . intStack [ this . intPtr -- ] ) ; this . intPtr -- ; if ( ! ( this . currentElement instanceof RecoveredType ) && ( this . currentToken == TokenNameDOT || ( Util . getLineNumber ( type . sourceStart , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) != Util . getLineNumber ( nameSourceStart , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) ) ) ) { this . lastCheckPoint = nameSourceStart ; this . restartRecovery = true ; return ; } FieldDeclaration completionFieldDecl = new CompletionOnFieldType ( type , false ) ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , completionFieldDecl . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } completionFieldDecl . modifiers = this . intStack [ this . intPtr -- ] ; this . assistNode = completionFieldDecl ; this . lastCheckPoint = type . sourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( completionFieldDecl , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; } } } } protected void consumeEnumConstantHeaderName ( ) { if ( this . currentElement != null ) { if ( ! ( this . currentElement instanceof RecoveredType || ( this . currentElement instanceof RecoveredField && ( ( RecoveredField ) this . currentElement ) . fieldDeclaration . type == null ) ) || ( this . lastIgnoredToken == TokenNameDOT ) ) { super . consumeEnumConstantHeaderName ( ) ; return ; } } super . consumeEnumConstantHeaderName ( ) ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } } protected void consumeEnumConstantNoClassBody ( ) { super . consumeEnumConstantNoClassBody ( ) ; if ( ( this . currentToken == TokenNameCOMMA || this . currentToken == TokenNameSEMICOLON ) && this . astStack [ this . astPtr ] instanceof FieldDeclaration ) { if ( this . sourceEnds != null ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , this . scanner . currentPosition - <NUM_LIT:1> ) ; } } } protected void consumeEnumConstantWithClassBody ( ) { super . consumeEnumConstantWithClassBody ( ) ; if ( ( this . currentToken == TokenNameCOMMA || this . currentToken == TokenNameSEMICOLON ) && this . astStack [ this . astPtr ] instanceof FieldDeclaration ) { if ( this . sourceEnds != null ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , this . scanner . currentPosition - <NUM_LIT:1> ) ; } } } protected void consumeEnumHeaderName ( ) { super . consumeEnumHeaderName ( ) ; this . hasUnusedModifiers = false ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } } protected void consumeEnumHeaderNameWithTypeParameters ( ) { super . consumeEnumHeaderNameWithTypeParameters ( ) ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } } protected void consumeEqualityExpression ( int op ) { super . consumeEqualityExpression ( op ) ; popElement ( K_BINARY_OPERATOR ) ; BinaryExpression exp = ( BinaryExpression ) this . expressionStack [ this . expressionPtr ] ; if ( this . assistNode != null && exp . right == this . assistNode ) { this . assistNodeParent = exp ; } } protected void consumeEqualityExpressionWithName ( int op ) { super . consumeEqualityExpressionWithName ( op ) ; popElement ( K_BINARY_OPERATOR ) ; BinaryExpression exp = ( BinaryExpression ) this . expressionStack [ this . expressionPtr ] ; if ( this . assistNode != null && exp . right == this . assistNode ) { this . assistNodeParent = exp ; } } protected void consumeExitVariableWithInitialization ( ) { super . consumeExitVariableWithInitialization ( ) ; if ( ( this . currentToken == TokenNameCOMMA || this . currentToken == TokenNameSEMICOLON ) && this . astStack [ this . astPtr ] instanceof FieldDeclaration ) { if ( this . sourceEnds != null ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , this . scanner . currentPosition - <NUM_LIT:1> ) ; } } AbstractVariableDeclaration variable = ( AbstractVariableDeclaration ) this . astStack [ this . astPtr ] ; if ( this . cursorLocation + <NUM_LIT:1> < variable . initialization . sourceStart || this . cursorLocation > variable . initialization . sourceEnd ) { variable . initialization = null ; } else if ( this . assistNode != null && this . assistNode == variable . initialization ) { this . assistNodeParent = variable ; } } protected void consumeExitVariableWithoutInitialization ( ) { super . consumeExitVariableWithoutInitialization ( ) ; if ( ( this . currentToken == TokenNameCOMMA || this . currentToken == TokenNameSEMICOLON ) && this . astStack [ this . astPtr ] instanceof FieldDeclaration ) { if ( this . sourceEnds != null ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , this . scanner . currentPosition - <NUM_LIT:1> ) ; } } } protected void consumeExplicitConstructorInvocation ( int flag , int recFlag ) { popElement ( K_SELECTOR_QUALIFIER ) ; popElement ( K_SELECTOR_INVOCATION_TYPE ) ; super . consumeExplicitConstructorInvocation ( flag , recFlag ) ; } protected void consumeFieldAccess ( boolean isSuperAccess ) { this . invocationType = NO_RECEIVER ; this . qualifier = - <NUM_LIT:1> ; if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { super . consumeFieldAccess ( isSuperAccess ) ; } else { pushCompletionOnMemberAccessOnExpressionStack ( isSuperAccess ) ; } } protected void consumeForceNoDiet ( ) { super . consumeForceNoDiet ( ) ; if ( isInsideMethod ( ) ) { pushOnElementStack ( K_LOCAL_INITIALIZER_DELIMITER ) ; } } protected void consumeFormalParameter ( boolean isVarArgs ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { super . consumeFormalParameter ( isVarArgs ) ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } } else { this . identifierLengthPtr -- ; char [ ] identifierName = 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:2> ; CompletionOnArgumentName arg = new CompletionOnArgumentName ( identifierName , namePositions , type , this . intStack [ this . intPtr + <NUM_LIT:1> ] & ~ ClassFileConstants . AccDeprecated ) ; 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 ) ; } arg . isCatchArgument = topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BETWEEN_CATCH_AND_RIGHT_PAREN ; pushOnAstStack ( arg ) ; this . assistNode = arg ; this . lastCheckPoint = ( int ) namePositions ; this . isOrphanCompletionNode = true ; this . listLength ++ ; } } protected void consumeGenericTypeWithDiamond ( ) { super . consumeGenericTypeWithDiamond ( ) ; popElement ( K_BINARY_OPERATOR ) ; popElement ( K_BINARY_OPERATOR ) ; } protected void consumeStatementFor ( ) { super . consumeStatementFor ( ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_CONTROL_STATEMENT_DELIMITER ) { popElement ( K_CONTROL_STATEMENT_DELIMITER ) ; } } protected void consumeStatementIfNoElse ( ) { super . consumeStatementIfNoElse ( ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_CONTROL_STATEMENT_DELIMITER ) { popElement ( K_CONTROL_STATEMENT_DELIMITER ) ; } } protected void consumeStatementIfWithElse ( ) { super . consumeStatementIfWithElse ( ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_CONTROL_STATEMENT_DELIMITER ) { popElement ( K_CONTROL_STATEMENT_DELIMITER ) ; } } protected void consumeInsideCastExpression ( ) { int end = this . intStack [ this . intPtr -- ] ; boolean isParameterized = ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_PARAMETERIZED_CAST ) ; if ( isParameterized ) { popElement ( K_PARAMETERIZED_CAST ) ; if ( this . identifierLengthStack [ this . identifierLengthPtr ] > <NUM_LIT:0> ) { pushOnGenericsIdentifiersLengthStack ( this . identifierLengthStack [ this . identifierLengthPtr ] ) ; } } else { if ( this . identifierLengthStack [ this . identifierLengthPtr ] > <NUM_LIT:0> ) { pushOnGenericsIdentifiersLengthStack ( this . identifierLengthStack [ this . identifierLengthPtr ] ) ; pushOnGenericsLengthStack ( <NUM_LIT:0> ) ; } } Expression castType = getTypeReference ( this . intStack [ this . intPtr -- ] ) ; if ( isParameterized ) { this . intPtr -- ; } castType . sourceEnd = end - <NUM_LIT:1> ; castType . sourceStart = this . intStack [ this . intPtr -- ] + <NUM_LIT:1> ; pushOnExpressionStack ( castType ) ; pushOnElementStack ( K_CAST_STATEMENT ) ; } protected void consumeInsideCastExpressionLL1 ( ) { if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_PARAMETERIZED_CAST ) { popElement ( K_PARAMETERIZED_CAST ) ; } if ( ! this . record ) { super . consumeInsideCastExpressionLL1 ( ) ; } else { boolean temp = this . skipRecord ; try { this . skipRecord = true ; super . consumeInsideCastExpressionLL1 ( ) ; if ( this . record ) { Expression typeReference = this . expressionStack [ this . expressionPtr ] ; if ( ! isAlreadyPotentialName ( typeReference . sourceStart ) ) { addPotentialName ( null , typeReference . sourceStart , typeReference . sourceEnd ) ; } } } finally { this . skipRecord = temp ; } } pushOnElementStack ( K_CAST_STATEMENT ) ; } protected void consumeInsideCastExpressionWithQualifiedGenerics ( ) { popElement ( K_PARAMETERIZED_CAST ) ; Expression castType ; int end = this . intStack [ this . intPtr -- ] ; int dim = this . intStack [ this . intPtr -- ] ; TypeReference rightSide = getTypeReference ( <NUM_LIT:0> ) ; castType = computeQualifiedGenericsFromRightSide ( rightSide , dim ) ; this . intPtr -- ; castType . sourceEnd = end - <NUM_LIT:1> ; castType . sourceStart = this . intStack [ this . intPtr -- ] + <NUM_LIT:1> ; pushOnExpressionStack ( castType ) ; pushOnElementStack ( K_CAST_STATEMENT ) ; } protected void consumeInstanceOfExpression ( ) { super . consumeInstanceOfExpression ( ) ; popElement ( K_BINARY_OPERATOR ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BETWEEN_IF_AND_RIGHT_PAREN ) { pushOnElementStack ( K_BETWEEN_INSTANCEOF_AND_RPAREN , IF , this . expressionStack [ this . expressionPtr ] ) ; } InstanceOfExpression exp = ( InstanceOfExpression ) this . expressionStack [ this . expressionPtr ] ; if ( this . assistNode != null && exp . type == this . assistNode ) { this . assistNodeParent = exp ; } } protected void consumeInstanceOfExpressionWithName ( ) { super . consumeInstanceOfExpressionWithName ( ) ; popElement ( K_BINARY_OPERATOR ) ; InstanceOfExpression exp = ( InstanceOfExpression ) this . expressionStack [ this . expressionPtr ] ; if ( this . assistNode != null && exp . type == this . assistNode ) { this . assistNodeParent = exp ; } } protected void consumeInterfaceHeaderName1 ( ) { super . consumeInterfaceHeaderName1 ( ) ; this . hasUnusedModifiers = false ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } classHeaderExtendsOrImplements ( true ) ; } protected void consumeInterfaceHeaderExtends ( ) { super . consumeInterfaceHeaderExtends ( ) ; popElement ( K_EXTENDS_KEYWORD ) ; } protected void consumeInterfaceType ( ) { pushOnElementStack ( K_NEXT_TYPEREF_IS_INTERFACE ) ; super . consumeInterfaceType ( ) ; popElement ( K_NEXT_TYPEREF_IS_INTERFACE ) ; } protected void consumeMethodInvocationName ( ) { popElement ( K_SELECTOR_QUALIFIER ) ; popElement ( K_SELECTOR_INVOCATION_TYPE ) ; super . consumeMethodInvocationName ( ) ; } protected void consumeMethodInvocationNameWithTypeArguments ( ) { popElement ( K_SELECTOR_QUALIFIER ) ; popElement ( K_SELECTOR_INVOCATION_TYPE ) ; super . consumeMethodInvocationNameWithTypeArguments ( ) ; } protected void consumeMethodInvocationPrimary ( ) { popElement ( K_SELECTOR_QUALIFIER ) ; popElement ( K_SELECTOR_INVOCATION_TYPE ) ; super . consumeMethodInvocationPrimary ( ) ; } protected void consumeMethodInvocationPrimaryWithTypeArguments ( ) { popElement ( K_SELECTOR_QUALIFIER ) ; popElement ( K_SELECTOR_INVOCATION_TYPE ) ; super . consumeMethodInvocationPrimaryWithTypeArguments ( ) ; } protected void consumeMethodInvocationSuper ( ) { popElement ( K_SELECTOR_QUALIFIER ) ; popElement ( K_SELECTOR_INVOCATION_TYPE ) ; super . consumeMethodInvocationSuper ( ) ; } protected void consumeMethodInvocationSuperWithTypeArguments ( ) { popElement ( K_SELECTOR_QUALIFIER ) ; popElement ( K_SELECTOR_INVOCATION_TYPE ) ; super . consumeMethodInvocationSuperWithTypeArguments ( ) ; } protected void consumeMethodHeaderName ( boolean isAnnotationMethod ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { this . identifierPtr -- ; this . identifierLengthPtr -- ; if ( this . indexOfAssistIdentifier ( ) != <NUM_LIT:0> || this . identifierLengthStack [ this . identifierLengthPtr ] != this . genericsIdentifiersLengthStack [ this . genericsIdentifiersLengthPtr ] ) { this . identifierPtr ++ ; this . identifierLengthPtr ++ ; long selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr ] ; int selectorSourceEnd = ( int ) selectorSourcePositions ; int currentAstPtr = this . astPtr ; super . consumeMethodHeaderName ( isAnnotationMethod ) ; if ( this . sourceEnds != null && this . astPtr > currentAstPtr ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , selectorSourceEnd ) ; } if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } } else { this . restartRecovery = true ; if ( this . currentElement != null ) { char [ ] selector = this . identifierStack [ this . identifierPtr + <NUM_LIT:1> ] ; long selectorSource = this . identifierPositionStack [ this . identifierPtr + <NUM_LIT:1> ] ; TypeReference type = getTypeReference ( this . intStack [ this . intPtr -- ] ) ; ( ( CompletionOnSingleTypeReference ) type ) . isCompletionNode = false ; int declarationSourceStart = this . intStack [ this . intPtr -- ] ; int mod = this . intStack [ this . intPtr -- ] ; if ( Util . getLineNumber ( type . sourceStart , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) != Util . getLineNumber ( ( int ) ( selectorSource > > > <NUM_LIT:32> ) , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) ) { FieldDeclaration completionFieldDecl = new CompletionOnFieldType ( type , false ) ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , completionFieldDecl . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } completionFieldDecl . modifiers = mod ; this . assistNode = completionFieldDecl ; this . lastCheckPoint = type . sourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( completionFieldDecl , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; } else { CompletionOnMethodReturnType md = new CompletionOnMethodReturnType ( type , this . compilationUnit . compilationResult ) ; 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 . selector = selector ; md . declarationSourceStart = declarationSourceStart ; md . modifiers = mod ; md . bodyStart = this . lParenPos + <NUM_LIT:1> ; this . listLength = <NUM_LIT:0> ; this . assistNode = md ; this . lastCheckPoint = md . bodyStart ; this . currentElement = this . currentElement . add ( md , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; md . javadoc = this . javadoc ; this . javadoc = null ; } } } } else { CompletionOnMethodName md = new CompletionOnMethodName ( this . compilationUnit . compilationResult ) ; md . selector = this . identifierStack [ this . identifierPtr ] ; long selectorSource = this . identifierPositionStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; md . returnType = getTypeReference ( this . intStack [ this . intPtr -- ] ) ; md . declarationSourceStart = 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 ) ( selectorSource > > > <NUM_LIT:32> ) ; md . selectorEnd = ( int ) selectorSource ; pushOnAstStack ( md ) ; md . sourceEnd = this . lParenPos ; md . bodyStart = this . lParenPos + <NUM_LIT:1> ; this . listLength = <NUM_LIT:0> ; this . assistNode = md ; this . lastCheckPoint = md . sourceEnd ; if ( this . currentElement != null ) { if ( this . currentElement instanceof RecoveredType || ( Util . getLineNumber ( md . returnType . sourceStart , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) == Util . getLineNumber ( md . sourceStart , this . scanner . lineEnds , <NUM_LIT:0> , this . scanner . linePtr ) ) ) { this . lastCheckPoint = md . bodyStart ; this . currentElement = this . currentElement . add ( md , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; } else { this . lastCheckPoint = md . sourceStart ; this . restartRecovery = true ; } } } } protected void consumeMethodHeaderNameWithTypeParameters ( boolean isAnnotationMethod ) { long selectorSourcePositions = this . identifierPositionStack [ this . identifierPtr ] ; int selectorSourceEnd = ( int ) selectorSourcePositions ; int currentAstPtr = this . astPtr ; super . consumeMethodHeaderNameWithTypeParameters ( isAnnotationMethod ) ; if ( this . sourceEnds != null && this . astPtr > currentAstPtr ) { this . sourceEnds . put ( this . astStack [ this . astPtr ] , selectorSourceEnd ) ; } if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } } protected void consumeMethodHeaderRightParen ( ) { super . consumeMethodHeaderRightParen ( ) ; if ( this . currentElement != null && this . currentToken == TokenNameIdentifier && this . cursorLocation + <NUM_LIT:1> >= this . scanner . startPosition && this . cursorLocation < this . scanner . currentPosition ) { this . pushIdentifier ( ) ; int index = - <NUM_LIT:1> ; if ( ( index = this . indexOfAssistIdentifier ( ) ) > - <NUM_LIT:1> ) { int ptr = this . identifierPtr - this . identifierLengthStack [ this . identifierLengthPtr ] + index + <NUM_LIT:1> ; if ( this . currentElement instanceof RecoveredMethod ) { RecoveredMethod recoveredMethod = ( RecoveredMethod ) this . currentElement ; if ( ! recoveredMethod . foundOpeningBrace ) { AbstractMethodDeclaration method = recoveredMethod . methodDeclaration ; if ( method . thrownExceptions == null ) { CompletionOnKeyword1 completionOnKeyword = new CompletionOnKeyword1 ( this . identifierStack [ ptr ] , this . identifierPositionStack [ ptr ] , Keywords . THROWS ) ; method . thrownExceptions = new TypeReference [ ] { completionOnKeyword } ; recoveredMethod . foundOpeningBrace = true ; this . assistNode = completionOnKeyword ; this . lastCheckPoint = completionOnKeyword . sourceEnd + <NUM_LIT:1> ; } } } } } } protected void consumeMethodHeaderExtendedDims ( ) { super . consumeMethodHeaderExtendedDims ( ) ; if ( this . currentElement != null && this . currentToken == TokenNameIdentifier && this . cursorLocation + <NUM_LIT:1> >= this . scanner . startPosition && this . cursorLocation < this . scanner . currentPosition ) { this . pushIdentifier ( ) ; int index = - <NUM_LIT:1> ; if ( ( index = this . indexOfAssistIdentifier ( ) ) > - <NUM_LIT:1> ) { int ptr = this . identifierPtr - this . identifierLengthStack [ this . identifierLengthPtr ] + index + <NUM_LIT:1> ; RecoveredMethod recoveredMethod = ( RecoveredMethod ) this . currentElement ; if ( ! recoveredMethod . foundOpeningBrace ) { AbstractMethodDeclaration method = recoveredMethod . methodDeclaration ; if ( method . thrownExceptions == null ) { CompletionOnKeyword1 completionOnKeyword = new CompletionOnKeyword1 ( this . identifierStack [ ptr ] , this . identifierPositionStack [ ptr ] , Keywords . THROWS ) ; method . thrownExceptions = new TypeReference [ ] { completionOnKeyword } ; recoveredMethod . foundOpeningBrace = true ; this . assistNode = completionOnKeyword ; this . lastCheckPoint = completionOnKeyword . sourceEnd + <NUM_LIT:1> ; } } } } } protected void consumeAnnotationAsModifier ( ) { super . consumeAnnotationAsModifier ( ) ; if ( isInsideMethod ( ) ) { this . hasUnusedModifiers = true ; } } protected void consumeAdditionalBound ( ) { super . consumeAdditionalBound ( ) ; ASTNode node = this . genericsStack [ this . genericsPtr ] ; if ( node instanceof CompletionOnSingleTypeReference ) { ( ( CompletionOnSingleTypeReference ) node ) . setKind ( CompletionOnQualifiedTypeReference . K_INTERFACE ) ; } else if ( node instanceof CompletionOnQualifiedTypeReference ) { ( ( CompletionOnQualifiedTypeReference ) node ) . setKind ( CompletionOnQualifiedTypeReference . K_INTERFACE ) ; } } protected void consumeAdditionalBound1 ( ) { super . consumeAdditionalBound1 ( ) ; ASTNode node = this . genericsStack [ this . genericsPtr ] ; if ( node instanceof CompletionOnSingleTypeReference ) { ( ( CompletionOnSingleTypeReference ) node ) . setKind ( CompletionOnQualifiedTypeReference . K_INTERFACE ) ; } else if ( node instanceof CompletionOnQualifiedTypeReference ) { ( ( CompletionOnQualifiedTypeReference ) node ) . setKind ( CompletionOnQualifiedTypeReference . K_INTERFACE ) ; } } protected void consumeAnnotationName ( ) { int index ; if ( ( index = this . indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . consumeAnnotationName ( ) ; this . pushOnElementStack ( K_BETWEEN_ANNOTATION_NAME_AND_RPAREN , LPAREN_NOT_CONSUMED ) ; return ; } MarkerAnnotation markerAnnotation = null ; int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; TypeReference typeReference ; char [ ] [ ] subset = identifierSubSet ( index ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; if ( index == <NUM_LIT:0> ) { typeReference = createSingleAssistTypeReference ( assistIdentifier ( ) , positions [ <NUM_LIT:0> ] ) ; } else { typeReference = createQualifiedAssistTypeReference ( subset , assistIdentifier ( ) , positions ) ; } markerAnnotation = new CompletionOnMarkerAnnotationName ( typeReference , typeReference . sourceStart ) ; this . intPtr -- ; markerAnnotation . declarationSourceEnd = markerAnnotation . sourceEnd ; pushOnExpressionStack ( markerAnnotation ) ; this . assistNode = markerAnnotation ; this . isOrphanCompletionNode = true ; this . lastCheckPoint = markerAnnotation . sourceEnd + <NUM_LIT:1> ; this . pushOnElementStack ( K_BETWEEN_ANNOTATION_NAME_AND_RPAREN , LPAREN_NOT_CONSUMED | ANNOTATION_NAME_COMPLETION ) ; } protected void consumeAnnotationTypeDeclarationHeaderName ( ) { super . consumeAnnotationTypeDeclarationHeaderName ( ) ; this . hasUnusedModifiers = false ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } } protected void consumeAnnotationTypeDeclarationHeaderNameWithTypeParameters ( ) { super . consumeAnnotationTypeDeclarationHeaderNameWithTypeParameters ( ) ; this . hasUnusedModifiers = false ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . astStack [ this . astPtr ] ; this . pendingAnnotation = null ; } } protected void consumeLabel ( ) { super . consumeLabel ( ) ; pushOnLabelStack ( this . identifierStack [ this . identifierPtr ] ) ; this . pushOnElementStack ( K_LABEL , this . labelPtr ) ; } protected void consumeMarkerAnnotation ( ) { if ( this . topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BETWEEN_ANNOTATION_NAME_AND_RPAREN && ( this . topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) & ANNOTATION_NAME_COMPLETION ) != <NUM_LIT:0> ) { popElement ( K_BETWEEN_ANNOTATION_NAME_AND_RPAREN ) ; this . restartRecovery = true ; } else { popElement ( K_BETWEEN_ANNOTATION_NAME_AND_RPAREN ) ; super . consumeMarkerAnnotation ( ) ; } } protected void consumeMemberValuePair ( ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { super . consumeMemberValuePair ( ) ; MemberValuePair memberValuePair = ( MemberValuePair ) this . astStack [ this . astPtr ] ; if ( this . assistNode != null && memberValuePair . value == this . assistNode ) { this . assistNodeParent = memberValuePair ; } return ; } char [ ] simpleName = this . identifierStack [ this . identifierPtr ] ; long position = this . identifierPositionStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; int end = ( int ) position ; int start = ( int ) ( position > > > <NUM_LIT:32> ) ; this . expressionPtr -- ; this . expressionLengthPtr -- ; CompletionOnMemberValueName memberValueName = new CompletionOnMemberValueName ( simpleName , start , end ) ; pushOnAstStack ( memberValueName ) ; this . assistNode = memberValueName ; this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; this . restartRecovery = true ; } protected void consumeMemberValueAsName ( ) { if ( ( indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . consumeMemberValueAsName ( ) ; } else { super . consumeMemberValueAsName ( ) ; if ( this . topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BETWEEN_ANNOTATION_NAME_AND_RPAREN ) { this . restartRecovery = true ; } } } protected void consumeMethodBody ( ) { popElement ( K_BLOCK_DELIMITER ) ; super . consumeMethodBody ( ) ; } protected void consumeMethodHeader ( ) { super . consumeMethodHeader ( ) ; pushOnElementStack ( K_BLOCK_DELIMITER ) ; } protected void consumeMethodDeclaration ( boolean isNotAbstract ) { if ( ! isNotAbstract ) { popElement ( K_BLOCK_DELIMITER ) ; } super . consumeMethodDeclaration ( isNotAbstract ) ; } protected void consumeModifiers ( ) { super . consumeModifiers ( ) ; this . lastModifiersStart = this . intStack [ this . intPtr ] ; this . lastModifiers = this . intStack [ this . intPtr - <NUM_LIT:1> ] ; } protected void consumeReferenceType ( ) { if ( this . identifierLengthStack [ this . identifierLengthPtr ] > <NUM_LIT:1> ) { this . invocationType = NO_RECEIVER ; this . qualifier = - <NUM_LIT:1> ; } super . consumeReferenceType ( ) ; } protected void consumeRestoreDiet ( ) { super . consumeRestoreDiet ( ) ; if ( isInsideMethod ( ) ) { popElement ( K_LOCAL_INITIALIZER_DELIMITER ) ; } } protected void consumeSingleMemberAnnotation ( ) { if ( this . topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BETWEEN_ANNOTATION_NAME_AND_RPAREN && ( this . topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) & ANNOTATION_NAME_COMPLETION ) != <NUM_LIT:0> ) { popElement ( K_BETWEEN_ANNOTATION_NAME_AND_RPAREN ) ; this . restartRecovery = true ; } else { popElement ( K_BETWEEN_ANNOTATION_NAME_AND_RPAREN ) ; super . consumeSingleMemberAnnotation ( ) ; } } protected void consumeSingleStaticImportDeclarationName ( ) { super . consumeSingleStaticImportDeclarationName ( ) ; this . pendingAnnotation = null ; } protected void consumeSingleTypeImportDeclarationName ( ) { super . consumeSingleTypeImportDeclarationName ( ) ; this . pendingAnnotation = null ; } protected void consumeStatementBreakWithLabel ( ) { super . consumeStatementBreakWithLabel ( ) ; if ( this . record ) { ASTNode breakStatement = this . astStack [ this . astPtr ] ; if ( ! isAlreadyPotentialName ( breakStatement . sourceStart ) ) { addPotentialName ( null , breakStatement . sourceStart , breakStatement . sourceEnd ) ; } } } protected void consumeStatementLabel ( ) { popElement ( K_LABEL ) ; super . consumeStatementLabel ( ) ; } protected void consumeStatementSwitch ( ) { super . consumeStatementSwitch ( ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_SWITCH_LABEL ) { popElement ( K_SWITCH_LABEL ) ; popElement ( K_BLOCK_DELIMITER ) ; } } protected void consumeStatementWhile ( ) { super . consumeStatementWhile ( ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_CONTROL_STATEMENT_DELIMITER ) { popElement ( K_CONTROL_STATEMENT_DELIMITER ) ; } } protected void consumeStaticImportOnDemandDeclarationName ( ) { super . consumeStaticImportOnDemandDeclarationName ( ) ; this . pendingAnnotation = null ; } protected void consumeStaticInitializer ( ) { super . consumeStaticInitializer ( ) ; this . pendingAnnotation = null ; } protected void consumeNestedMethod ( ) { super . consumeNestedMethod ( ) ; if ( ! ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BLOCK_DELIMITER ) ) pushOnElementStack ( K_BLOCK_DELIMITER ) ; } protected void consumeNormalAnnotation ( ) { if ( this . topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BETWEEN_ANNOTATION_NAME_AND_RPAREN && ( this . topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) & ANNOTATION_NAME_COMPLETION ) != <NUM_LIT:0> ) { popElement ( K_BETWEEN_ANNOTATION_NAME_AND_RPAREN ) ; this . restartRecovery = true ; } else { popElement ( K_BETWEEN_ANNOTATION_NAME_AND_RPAREN ) ; super . consumeNormalAnnotation ( ) ; } } protected void consumePackageDeclarationName ( ) { super . consumePackageDeclarationName ( ) ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . compilationUnit . currentPackage ; this . pendingAnnotation = null ; } } protected void consumePackageDeclarationNameWithModifiers ( ) { super . consumePackageDeclarationNameWithModifiers ( ) ; if ( this . pendingAnnotation != null ) { this . pendingAnnotation . potentialAnnotatedNode = this . compilationUnit . currentPackage ; this . pendingAnnotation = null ; } } protected void consumePrimaryNoNewArrayName ( ) { this . invocationType = NO_RECEIVER ; this . qualifier = - <NUM_LIT:1> ; super . consumePrimaryNoNewArrayName ( ) ; } protected void consumePrimaryNoNewArrayNameSuper ( ) { this . invocationType = NO_RECEIVER ; this . qualifier = - <NUM_LIT:1> ; super . consumePrimaryNoNewArrayNameSuper ( ) ; } protected void consumePrimaryNoNewArrayNameThis ( ) { this . invocationType = NO_RECEIVER ; this . qualifier = - <NUM_LIT:1> ; super . consumePrimaryNoNewArrayNameThis ( ) ; } protected void consumePushPosition ( ) { super . consumePushPosition ( ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BINARY_OPERATOR ) { int info = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) ; popElement ( K_BINARY_OPERATOR ) ; pushOnElementStack ( K_UNARY_OPERATOR , info ) ; } } protected void consumeToken ( int token ) { if ( this . isFirst ) { super . consumeToken ( token ) ; return ; } if ( this . canBeExplicitConstructor == NEXTTOKEN ) { this . canBeExplicitConstructor = YES ; } else { this . canBeExplicitConstructor = NO ; } int previous = this . previousToken ; int prevIdentifierPtr = this . previousIdentifierPtr ; if ( isInsideMethod ( ) || isInsideFieldInitialization ( ) || isInsideAnnotation ( ) ) { switch ( token ) { case TokenNameLPAREN : if ( previous == TokenNameIdentifier && topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_PARAMETERIZED_METHOD_INVOCATION ) { popElement ( K_PARAMETERIZED_METHOD_INVOCATION ) ; } else { popElement ( K_BETWEEN_NEW_AND_LEFT_BRACKET ) ; } break ; case TokenNameLBRACE : popElement ( K_BETWEEN_NEW_AND_LEFT_BRACKET ) ; break ; case TokenNameLBRACKET : if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BETWEEN_NEW_AND_LEFT_BRACKET ) { popElement ( K_BETWEEN_NEW_AND_LEFT_BRACKET ) ; pushOnElementStack ( K_ARRAY_CREATION ) ; } break ; case TokenNameRBRACE : int kind = topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ; switch ( kind ) { case K_BLOCK_DELIMITER : popElement ( K_BLOCK_DELIMITER ) ; break ; case K_MEMBER_VALUE_ARRAY_INITIALIZER : popElement ( K_MEMBER_VALUE_ARRAY_INITIALIZER ) ; break ; default : popElement ( K_ARRAY_INITIALIZER ) ; break ; } break ; case TokenNameRBRACKET : if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BETWEEN_LEFT_AND_RIGHT_BRACKET ) { popElement ( K_BETWEEN_LEFT_AND_RIGHT_BRACKET ) ; } break ; } } super . consumeToken ( token ) ; if ( token == TokenNameIdentifier && this . identifierStack [ this . identifierPtr ] == assistIdentifier ( ) && this . currentElement == null && isIndirectlyInsideFieldInitialization ( ) ) { this . scanner . eofPosition = this . cursorLocation < Integer . MAX_VALUE ? this . cursorLocation + <NUM_LIT:1> : this . cursorLocation ; } if ( isInsideMethod ( ) || isInsideFieldInitialization ( ) || isInsideAttributeValue ( ) ) { switch ( token ) { case TokenNameDOT : switch ( previous ) { case TokenNamethis : this . invocationType = EXPLICIT_RECEIVER ; break ; case TokenNamesuper : this . invocationType = SUPER_RECEIVER ; break ; case TokenNameIdentifier : if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) != K_BETWEEN_NEW_AND_LEFT_BRACKET ) { if ( this . identifierPtr != prevIdentifierPtr ) { this . invocationType = EXPLICIT_RECEIVER ; } else { this . invocationType = NAME_RECEIVER ; } } break ; } break ; case TokenNameIdentifier : if ( previous == TokenNameDOT ) { if ( this . invocationType != SUPER_RECEIVER && this . invocationType != NAME_RECEIVER && this . invocationType != ALLOCATION && this . invocationType != QUALIFIED_ALLOCATION ) { this . invocationType = EXPLICIT_RECEIVER ; this . qualifier = this . expressionPtr ; } } if ( previous == TokenNameGREATER ) { if ( this . invocationType != SUPER_RECEIVER && this . invocationType != NAME_RECEIVER && this . invocationType != ALLOCATION && this . invocationType != QUALIFIED_ALLOCATION ) { if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_PARAMETERIZED_METHOD_INVOCATION ) { this . invocationType = EXPLICIT_RECEIVER ; this . qualifier = this . expressionPtr ; } } } break ; case TokenNamenew : pushOnElementStack ( K_BETWEEN_NEW_AND_LEFT_BRACKET ) ; this . qualifier = this . expressionPtr ; if ( previous == TokenNameDOT ) { this . invocationType = QUALIFIED_ALLOCATION ; } else { this . invocationType = ALLOCATION ; } break ; case TokenNamethis : if ( previous == TokenNameDOT ) { this . invocationType = QUALIFIED_ALLOCATION ; this . qualifier = this . expressionPtr ; } break ; case TokenNamesuper : if ( previous == TokenNameDOT ) { this . invocationType = QUALIFIED_ALLOCATION ; this . qualifier = this . expressionPtr ; } break ; case TokenNamecatch : pushOnElementStack ( K_BETWEEN_CATCH_AND_RIGHT_PAREN ) ; break ; case TokenNameLPAREN : if ( this . invocationType == NO_RECEIVER || this . invocationType == NAME_RECEIVER || this . invocationType == SUPER_RECEIVER ) { this . qualifier = this . expressionPtr ; } switch ( previous ) { case TokenNameIdentifier : if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_SELECTOR ) { int info = <NUM_LIT:0> ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) == K_BETWEEN_ANNOTATION_NAME_AND_RPAREN && ( info = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) & LPAREN_NOT_CONSUMED ) != <NUM_LIT:0> ) { popElement ( K_SELECTOR ) ; popElement ( K_BETWEEN_ANNOTATION_NAME_AND_RPAREN ) ; if ( ( info & ANNOTATION_NAME_COMPLETION ) != <NUM_LIT:0> ) { this . pushOnElementStack ( K_BETWEEN_ANNOTATION_NAME_AND_RPAREN , LPAREN_CONSUMED | ANNOTATION_NAME_COMPLETION ) ; } else { this . pushOnElementStack ( K_BETWEEN_ANNOTATION_NAME_AND_RPAREN , LPAREN_CONSUMED ) ; } } else { this . pushOnElementStack ( K_SELECTOR_INVOCATION_TYPE , this . invocationType ) ; this . pushOnElementStack ( K_SELECTOR_QUALIFIER , this . qualifier ) ; } } this . qualifier = - <NUM_LIT:1> ; this . invocationType = NO_RECEIVER ; break ; case TokenNamethis : if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_SELECTOR ) { this . pushOnElementStack ( K_SELECTOR_INVOCATION_TYPE , ( this . invocationType == QUALIFIED_ALLOCATION ) ? QUALIFIED_ALLOCATION : ALLOCATION ) ; this . pushOnElementStack ( K_SELECTOR_QUALIFIER , this . qualifier ) ; } this . qualifier = - <NUM_LIT:1> ; this . invocationType = NO_RECEIVER ; break ; case TokenNamesuper : if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_SELECTOR ) { this . pushOnElementStack ( K_SELECTOR_INVOCATION_TYPE , ( this . invocationType == QUALIFIED_ALLOCATION ) ? QUALIFIED_ALLOCATION : ALLOCATION ) ; this . pushOnElementStack ( K_SELECTOR_QUALIFIER , this . qualifier ) ; } this . qualifier = - <NUM_LIT:1> ; this . invocationType = NO_RECEIVER ; break ; case TokenNameGREATER : case TokenNameRIGHT_SHIFT : case TokenNameUNSIGNED_RIGHT_SHIFT : if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_SELECTOR ) { int info ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) == K_BINARY_OPERATOR && ( ( info = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) ) == GREATER || info == RIGHT_SHIFT || info == UNSIGNED_RIGHT_SHIFT ) ) { popElement ( K_SELECTOR ) ; } else { this . pushOnElementStack ( K_SELECTOR_INVOCATION_TYPE , ( this . invocationType == QUALIFIED_ALLOCATION ) ? QUALIFIED_ALLOCATION : ALLOCATION ) ; this . pushOnElementStack ( K_SELECTOR_QUALIFIER , this . qualifier ) ; } } this . qualifier = - <NUM_LIT:1> ; this . invocationType = NO_RECEIVER ; break ; } break ; case TokenNameLBRACE : int kind = topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ; if ( kind == K_FIELD_INITIALIZER_DELIMITER || kind == K_LOCAL_INITIALIZER_DELIMITER || kind == K_ARRAY_CREATION ) { pushOnElementStack ( K_ARRAY_INITIALIZER , this . endPosition ) ; } else if ( kind == K_BETWEEN_ANNOTATION_NAME_AND_RPAREN ) { pushOnElementStack ( K_MEMBER_VALUE_ARRAY_INITIALIZER , this . endPosition ) ; } else { if ( kind == K_CONTROL_STATEMENT_DELIMITER ) { int info = topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) ; popElement ( K_CONTROL_STATEMENT_DELIMITER ) ; if ( info == IF ) { pushOnElementStack ( K_BLOCK_DELIMITER , IF , this . expressionStack [ this . expressionPtr ] ) ; } else { pushOnElementStack ( K_BLOCK_DELIMITER , info ) ; } } else { switch ( previous ) { case TokenNameRPAREN : switch ( this . previousKind ) { case K_BETWEEN_CATCH_AND_RIGHT_PAREN : pushOnElementStack ( K_BLOCK_DELIMITER , CATCH ) ; break ; case K_BETWEEN_SWITCH_AND_RIGHT_PAREN : pushOnElementStack ( K_BLOCK_DELIMITER , SWITCH ) ; break ; case K_BETWEEN_SYNCHRONIZED_AND_RIGHT_PAREN : pushOnElementStack ( K_BLOCK_DELIMITER , SYNCHRONIZED ) ; break ; default : pushOnElementStack ( K_BLOCK_DELIMITER ) ; break ; } break ; case TokenNametry : pushOnElementStack ( K_BLOCK_DELIMITER , TRY ) ; break ; case TokenNamedo : pushOnElementStack ( K_BLOCK_DELIMITER , DO ) ; break ; default : pushOnElementStack ( K_BLOCK_DELIMITER ) ; break ; } } } break ; case TokenNameLBRACKET : if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) != K_ARRAY_CREATION ) { pushOnElementStack ( K_BETWEEN_LEFT_AND_RIGHT_BRACKET ) ; } else { switch ( previous ) { case TokenNameIdentifier : case TokenNameboolean : case TokenNamebyte : case TokenNamechar : case TokenNamedouble : case TokenNamefloat : case TokenNameint : case TokenNamelong : case TokenNameshort : case TokenNameGREATER : case TokenNameRIGHT_SHIFT : case TokenNameUNSIGNED_RIGHT_SHIFT : this . invocationType = NO_RECEIVER ; this . qualifier = - <NUM_LIT:1> ; break ; } } break ; case TokenNameRPAREN : switch ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ) { case K_BETWEEN_CATCH_AND_RIGHT_PAREN : popElement ( K_BETWEEN_CATCH_AND_RIGHT_PAREN ) ; break ; case K_BETWEEN_INSTANCEOF_AND_RPAREN : popElement ( K_BETWEEN_INSTANCEOF_AND_RPAREN ) ; case K_BETWEEN_IF_AND_RIGHT_PAREN : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == this . bracketDepth ) { popElement ( K_BETWEEN_IF_AND_RIGHT_PAREN ) ; pushOnElementStack ( K_CONTROL_STATEMENT_DELIMITER , IF , this . expressionStack [ this . expressionPtr ] ) ; } break ; case K_BETWEEN_WHILE_AND_RIGHT_PAREN : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == this . bracketDepth ) { popElement ( K_BETWEEN_WHILE_AND_RIGHT_PAREN ) ; pushOnElementStack ( K_CONTROL_STATEMENT_DELIMITER , WHILE ) ; } break ; case K_BETWEEN_FOR_AND_RIGHT_PAREN : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == this . bracketDepth ) { popElement ( K_BETWEEN_FOR_AND_RIGHT_PAREN ) ; pushOnElementStack ( K_CONTROL_STATEMENT_DELIMITER , FOR ) ; } break ; case K_BETWEEN_SWITCH_AND_RIGHT_PAREN : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == this . bracketDepth ) { popElement ( K_BETWEEN_SWITCH_AND_RIGHT_PAREN ) ; } break ; case K_BETWEEN_SYNCHRONIZED_AND_RIGHT_PAREN : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == this . bracketDepth ) { popElement ( K_BETWEEN_SYNCHRONIZED_AND_RIGHT_PAREN ) ; } break ; } break ; case TokenNamethrow : pushOnElementStack ( K_INSIDE_THROW_STATEMENT , this . bracketDepth ) ; break ; case TokenNameSEMICOLON : switch ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ) { case K_INSIDE_THROW_STATEMENT : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == this . bracketDepth ) { popElement ( K_INSIDE_THROW_STATEMENT ) ; } break ; case K_INSIDE_RETURN_STATEMENT : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == this . bracketDepth ) { popElement ( K_INSIDE_RETURN_STATEMENT ) ; } break ; case K_INSIDE_ASSERT_STATEMENT : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == this . bracketDepth ) { popElement ( K_INSIDE_ASSERT_STATEMENT ) ; } break ; case K_INSIDE_ASSERT_EXCEPTION : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == this . bracketDepth ) { popElement ( K_INSIDE_ASSERT_EXCEPTION ) ; popElement ( K_INSIDE_ASSERT_STATEMENT ) ; } break ; case K_INSIDE_BREAK_STATEMENT : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == this . bracketDepth ) { popElement ( K_INSIDE_BREAK_STATEMENT ) ; } break ; case K_INSIDE_CONTINUE_STATEMENT : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == this . bracketDepth ) { popElement ( K_INSIDE_CONTINUE_STATEMENT ) ; } break ; case K_BETWEEN_FOR_AND_RIGHT_PAREN : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == this . bracketDepth - <NUM_LIT:1> ) { popElement ( K_BETWEEN_FOR_AND_RIGHT_PAREN ) ; pushOnElementStack ( K_INSIDE_FOR_CONDITIONAL , this . bracketDepth - <NUM_LIT:1> ) ; } break ; case K_INSIDE_FOR_CONDITIONAL : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == this . bracketDepth - <NUM_LIT:1> ) { popElement ( K_INSIDE_FOR_CONDITIONAL ) ; pushOnElementStack ( K_BETWEEN_FOR_AND_RIGHT_PAREN , this . bracketDepth - <NUM_LIT:1> ) ; } break ; } break ; case TokenNamereturn : pushOnElementStack ( K_INSIDE_RETURN_STATEMENT , this . bracketDepth ) ; break ; case TokenNameMULTIPLY : pushOnElementStack ( K_BINARY_OPERATOR , MULTIPLY ) ; break ; case TokenNameDIVIDE : pushOnElementStack ( K_BINARY_OPERATOR , DIVIDE ) ; break ; case TokenNameREMAINDER : pushOnElementStack ( K_BINARY_OPERATOR , REMAINDER ) ; break ; case TokenNamePLUS : pushOnElementStack ( K_BINARY_OPERATOR , PLUS ) ; break ; case TokenNameMINUS : pushOnElementStack ( K_BINARY_OPERATOR , MINUS ) ; break ; case TokenNameLEFT_SHIFT : pushOnElementStack ( K_BINARY_OPERATOR , LEFT_SHIFT ) ; break ; case TokenNameRIGHT_SHIFT : pushOnElementStack ( K_BINARY_OPERATOR , RIGHT_SHIFT ) ; break ; case TokenNameUNSIGNED_RIGHT_SHIFT : pushOnElementStack ( K_BINARY_OPERATOR , UNSIGNED_RIGHT_SHIFT ) ; break ; case TokenNameLESS : switch ( previous ) { case TokenNameDOT : pushOnElementStack ( K_PARAMETERIZED_METHOD_INVOCATION ) ; break ; case TokenNamenew : pushOnElementStack ( K_PARAMETERIZED_ALLOCATION ) ; break ; } pushOnElementStack ( K_BINARY_OPERATOR , LESS ) ; break ; case TokenNameGREATER : pushOnElementStack ( K_BINARY_OPERATOR , GREATER ) ; break ; case TokenNameLESS_EQUAL : pushOnElementStack ( K_BINARY_OPERATOR , LESS_EQUAL ) ; break ; case TokenNameGREATER_EQUAL : pushOnElementStack ( K_BINARY_OPERATOR , GREATER_EQUAL ) ; break ; case TokenNameAND : pushOnElementStack ( K_BINARY_OPERATOR , AND ) ; break ; case TokenNameXOR : pushOnElementStack ( K_BINARY_OPERATOR , XOR ) ; break ; case TokenNameOR : if ( topKnownElementKind ( COMPLETION_PARSER ) != K_BETWEEN_CATCH_AND_RIGHT_PAREN ) pushOnElementStack ( K_BINARY_OPERATOR , OR ) ; break ; case TokenNameAND_AND : pushOnElementStack ( K_BINARY_OPERATOR , AND_AND ) ; break ; case TokenNameOR_OR : pushOnElementStack ( K_BINARY_OPERATOR , OR_OR ) ; break ; case TokenNamePLUS_PLUS : pushOnElementStack ( K_UNARY_OPERATOR , PLUS_PLUS ) ; break ; case TokenNameMINUS_MINUS : pushOnElementStack ( K_UNARY_OPERATOR , MINUS_MINUS ) ; break ; case TokenNameTWIDDLE : pushOnElementStack ( K_UNARY_OPERATOR , TWIDDLE ) ; break ; case TokenNameNOT : pushOnElementStack ( K_UNARY_OPERATOR , NOT ) ; break ; case TokenNameEQUAL_EQUAL : pushOnElementStack ( K_BINARY_OPERATOR , EQUAL_EQUAL ) ; break ; case TokenNameNOT_EQUAL : pushOnElementStack ( K_BINARY_OPERATOR , NOT_EQUAL ) ; break ; case TokenNameinstanceof : pushOnElementStack ( K_BINARY_OPERATOR , INSTANCEOF ) ; break ; case TokenNameQUESTION : if ( previous != TokenNameLESS && previous != TokenNameCOMMA ) { pushOnElementStack ( K_CONDITIONAL_OPERATOR , QUESTION ) ; } break ; case TokenNameCOLON : switch ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ) { case K_CONDITIONAL_OPERATOR : if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == QUESTION ) { popElement ( K_CONDITIONAL_OPERATOR ) ; pushOnElementStack ( K_CONDITIONAL_OPERATOR , COLON ) ; } break ; case K_BETWEEN_CASE_AND_COLON : popElement ( K_BETWEEN_CASE_AND_COLON ) ; break ; case K_BETWEEN_DEFAULT_AND_COLON : popElement ( K_BETWEEN_DEFAULT_AND_COLON ) ; break ; case K_INSIDE_ASSERT_STATEMENT : pushOnElementStack ( K_INSIDE_ASSERT_EXCEPTION , this . bracketDepth ) ; break ; } break ; case TokenNameif : pushOnElementStack ( K_BETWEEN_IF_AND_RIGHT_PAREN , this . bracketDepth ) ; break ; case TokenNameelse : if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_CONTROL_STATEMENT_DELIMITER ) { popElement ( K_CONTROL_STATEMENT_DELIMITER ) ; } pushOnElementStack ( K_CONTROL_STATEMENT_DELIMITER ) ; break ; case TokenNamewhile : pushOnElementStack ( K_BETWEEN_WHILE_AND_RIGHT_PAREN , this . bracketDepth ) ; break ; case TokenNamefor : pushOnElementStack ( K_BETWEEN_FOR_AND_RIGHT_PAREN , this . bracketDepth ) ; break ; case TokenNameswitch : pushOnElementStack ( K_BETWEEN_SWITCH_AND_RIGHT_PAREN , this . bracketDepth ) ; break ; case TokenNamesynchronized : pushOnElementStack ( K_BETWEEN_SYNCHRONIZED_AND_RIGHT_PAREN , this . bracketDepth ) ; break ; case TokenNameassert : pushOnElementStack ( K_INSIDE_ASSERT_STATEMENT , this . bracketDepth ) ; break ; case TokenNamecase : pushOnElementStack ( K_BETWEEN_CASE_AND_COLON ) ; break ; case TokenNamedefault : pushOnElementStack ( K_BETWEEN_DEFAULT_AND_COLON ) ; break ; case TokenNameextends : pushOnElementStack ( K_EXTENDS_KEYWORD ) ; break ; case TokenNamebreak : pushOnElementStack ( K_INSIDE_BREAK_STATEMENT , this . bracketDepth ) ; break ; case TokenNamecontinue : pushOnElementStack ( K_INSIDE_CONTINUE_STATEMENT , this . bracketDepth ) ; break ; } } else if ( isInsideAnnotation ( ) ) { switch ( token ) { case TokenNameLBRACE : this . bracketDepth ++ ; int kind = topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ; if ( kind == K_BETWEEN_ANNOTATION_NAME_AND_RPAREN ) { pushOnElementStack ( K_MEMBER_VALUE_ARRAY_INITIALIZER , this . endPosition ) ; } break ; } } else { switch ( token ) { case TokenNameextends : pushOnElementStack ( K_EXTENDS_KEYWORD ) ; break ; case TokenNameLESS : pushOnElementStack ( K_BINARY_OPERATOR , LESS ) ; break ; case TokenNameGREATER : pushOnElementStack ( K_BINARY_OPERATOR , GREATER ) ; break ; case TokenNameRIGHT_SHIFT : pushOnElementStack ( K_BINARY_OPERATOR , RIGHT_SHIFT ) ; break ; case TokenNameUNSIGNED_RIGHT_SHIFT : pushOnElementStack ( K_BINARY_OPERATOR , UNSIGNED_RIGHT_SHIFT ) ; break ; } } } protected void consumeOnlySynchronized ( ) { super . consumeOnlySynchronized ( ) ; this . hasUnusedModifiers = false ; } protected void consumeOnlyTypeArguments ( ) { super . consumeOnlyTypeArguments ( ) ; popElement ( K_BINARY_OPERATOR ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_PARAMETERIZED_METHOD_INVOCATION ) { popElement ( K_PARAMETERIZED_METHOD_INVOCATION ) ; pushOnElementStack ( K_PARAMETERIZED_METHOD_INVOCATION , INSIDE_NAME ) ; } else { popElement ( K_PARAMETERIZED_ALLOCATION ) ; } } protected void consumeOnlyTypeArgumentsForCastExpression ( ) { super . consumeOnlyTypeArgumentsForCastExpression ( ) ; pushOnElementStack ( K_PARAMETERIZED_CAST ) ; } protected void consumeOpenFakeBlock ( ) { super . consumeOpenFakeBlock ( ) ; pushOnElementStack ( K_BLOCK_DELIMITER ) ; } protected void consumeRightParen ( ) { super . consumeRightParen ( ) ; } protected void consumeReferenceType1 ( ) { super . consumeReferenceType1 ( ) ; popElement ( K_BINARY_OPERATOR ) ; } protected void consumeReferenceType2 ( ) { super . consumeReferenceType2 ( ) ; popElement ( K_BINARY_OPERATOR ) ; } protected void consumeReferenceType3 ( ) { super . consumeReferenceType3 ( ) ; popElement ( K_BINARY_OPERATOR ) ; } protected void consumeTypeArgumentReferenceType1 ( ) { super . consumeTypeArgumentReferenceType1 ( ) ; popElement ( K_BINARY_OPERATOR ) ; } protected void consumeTypeArgumentReferenceType2 ( ) { super . consumeTypeArgumentReferenceType2 ( ) ; popElement ( K_BINARY_OPERATOR ) ; } protected void consumeTypeArguments ( ) { super . consumeTypeArguments ( ) ; popElement ( K_BINARY_OPERATOR ) ; } protected void consumeTypeHeaderNameWithTypeParameters ( ) { super . consumeTypeHeaderNameWithTypeParameters ( ) ; TypeDeclaration typeDecl = ( TypeDeclaration ) this . astStack [ this . astPtr ] ; classHeaderExtendsOrImplements ( ( typeDecl . modifiers & ClassFileConstants . AccInterface ) != <NUM_LIT:0> ) ; } protected void consumeTypeImportOnDemandDeclarationName ( ) { super . consumeTypeImportOnDemandDeclarationName ( ) ; this . pendingAnnotation = null ; } protected void consumeTypeParameters ( ) { super . consumeTypeParameters ( ) ; popElement ( K_BINARY_OPERATOR ) ; } protected void consumeTypeParameterHeader ( ) { super . consumeTypeParameterHeader ( ) ; TypeParameter typeParameter = ( TypeParameter ) this . genericsStack [ this . genericsPtr ] ; if ( typeParameter . type != null || ( typeParameter . bounds != null && typeParameter . bounds . length > <NUM_LIT:0> ) ) return ; if ( assistIdentifier ( ) == null && this . currentToken == TokenNameIdentifier ) { if ( this . cursorLocation < this . scanner . startPosition && this . scanner . currentPosition == this . scanner . startPosition ) { this . pushIdentifier ( ) ; } else if ( this . cursorLocation + <NUM_LIT:1> >= this . scanner . startPosition && this . cursorLocation < this . scanner . currentPosition ) { this . pushIdentifier ( ) ; } else { return ; } } else { return ; } CompletionOnKeyword1 keyword = new CompletionOnKeyword1 ( this . identifierStack [ this . identifierPtr ] , this . identifierPositionStack [ this . identifierPtr ] , Keywords . EXTENDS ) ; keyword . canCompleteEmptyToken = true ; typeParameter . type = keyword ; this . identifierPtr -- ; this . identifierLengthPtr -- ; this . assistNode = typeParameter . type ; this . lastCheckPoint = typeParameter . type . sourceEnd + <NUM_LIT:1> ; } protected void consumeTypeParameter1 ( ) { super . consumeTypeParameter1 ( ) ; popElement ( K_BINARY_OPERATOR ) ; } protected void consumeTypeParameterWithExtends ( ) { super . consumeTypeParameterWithExtends ( ) ; if ( this . assistNode != null && this . assistNodeParent == null ) { TypeParameter typeParameter = ( TypeParameter ) this . genericsStack [ this . genericsPtr ] ; if ( typeParameter != null && typeParameter . type == this . assistNode ) this . assistNodeParent = typeParameter ; } popElement ( K_EXTENDS_KEYWORD ) ; } protected void consumeTypeParameterWithExtendsAndBounds ( ) { super . consumeTypeParameterWithExtendsAndBounds ( ) ; if ( this . assistNode != null && this . assistNodeParent == null ) { TypeParameter typeParameter = ( TypeParameter ) this . genericsStack [ this . genericsPtr ] ; if ( typeParameter != null && typeParameter . type == this . assistNode ) this . assistNodeParent = typeParameter ; } popElement ( K_EXTENDS_KEYWORD ) ; } protected void consumeTypeParameter1WithExtends ( ) { super . consumeTypeParameter1WithExtends ( ) ; if ( this . assistNode != null && this . assistNodeParent == null ) { TypeParameter typeParameter = ( TypeParameter ) this . genericsStack [ this . genericsPtr ] ; if ( typeParameter != null && typeParameter . type == this . assistNode ) this . assistNodeParent = typeParameter ; } popElement ( K_EXTENDS_KEYWORD ) ; } protected void consumeTypeParameter1WithExtendsAndBounds ( ) { super . consumeTypeParameter1WithExtendsAndBounds ( ) ; if ( this . assistNode != null && this . assistNodeParent == null ) { TypeParameter typeParameter = ( TypeParameter ) this . genericsStack [ this . genericsPtr ] ; if ( typeParameter != null && typeParameter . type == this . assistNode ) this . assistNodeParent = typeParameter ; } popElement ( K_EXTENDS_KEYWORD ) ; } protected void consumeUnionType ( ) { pushOnElementStack ( K_NEXT_TYPEREF_IS_EXCEPTION ) ; super . consumeUnionType ( ) ; popElement ( K_NEXT_TYPEREF_IS_EXCEPTION ) ; } protected void consumeUnionTypeAsClassType ( ) { pushOnElementStack ( K_NEXT_TYPEREF_IS_EXCEPTION ) ; super . consumeUnionTypeAsClassType ( ) ; popElement ( K_NEXT_TYPEREF_IS_EXCEPTION ) ; } protected void consumeWildcard ( ) { super . consumeWildcard ( ) ; if ( assistIdentifier ( ) == null && this . currentToken == TokenNameIdentifier ) { if ( this . cursorLocation < this . scanner . startPosition && this . scanner . currentPosition == this . scanner . startPosition ) { this . pushIdentifier ( ) ; } else if ( this . cursorLocation + <NUM_LIT:1> >= this . scanner . startPosition && this . cursorLocation < this . scanner . currentPosition ) { this . pushIdentifier ( ) ; } else { return ; } } else { return ; } Wildcard wildcard = ( Wildcard ) this . genericsStack [ this . genericsPtr ] ; CompletionOnKeyword1 keyword = new CompletionOnKeyword1 ( this . identifierStack [ this . identifierPtr ] , this . identifierPositionStack [ this . identifierPtr ] , new char [ ] [ ] { Keywords . EXTENDS , Keywords . SUPER } ) ; keyword . canCompleteEmptyToken = true ; wildcard . kind = Wildcard . EXTENDS ; wildcard . bound = keyword ; this . identifierPtr -- ; this . identifierLengthPtr -- ; this . assistNode = wildcard . bound ; this . lastCheckPoint = wildcard . bound . sourceEnd + <NUM_LIT:1> ; } protected void consumeWildcard1 ( ) { super . consumeWildcard1 ( ) ; popElement ( K_BINARY_OPERATOR ) ; } protected void consumeWildcard2 ( ) { super . consumeWildcard2 ( ) ; popElement ( K_BINARY_OPERATOR ) ; } protected void consumeWildcard3 ( ) { super . consumeWildcard3 ( ) ; popElement ( K_BINARY_OPERATOR ) ; } protected void consumeWildcardBoundsExtends ( ) { super . consumeWildcardBoundsExtends ( ) ; if ( this . assistNode != null && this . assistNodeParent == null ) { Wildcard wildcard = ( Wildcard ) this . genericsStack [ this . genericsPtr ] ; if ( wildcard != null && wildcard . bound == this . assistNode ) this . assistNodeParent = wildcard ; } popElement ( K_EXTENDS_KEYWORD ) ; } protected void consumeWildcardBounds1Extends ( ) { super . consumeWildcardBounds1Extends ( ) ; if ( this . assistNode != null && this . assistNodeParent == null ) { Wildcard wildcard = ( Wildcard ) this . genericsStack [ this . genericsPtr ] ; if ( wildcard != null && wildcard . bound == this . assistNode ) this . assistNodeParent = wildcard ; } popElement ( K_EXTENDS_KEYWORD ) ; } protected void consumeWildcardBounds2Extends ( ) { super . consumeWildcardBounds2Extends ( ) ; if ( this . assistNode != null && this . assistNodeParent == null ) { Wildcard wildcard = ( Wildcard ) this . genericsStack [ this . genericsPtr ] ; if ( wildcard != null && wildcard . bound == this . assistNode ) this . assistNodeParent = wildcard ; } popElement ( K_EXTENDS_KEYWORD ) ; } protected void consumeWildcardBounds3Extends ( ) { super . consumeWildcardBounds3Extends ( ) ; if ( this . assistNode != null && this . assistNodeParent == null ) { Wildcard wildcard = ( Wildcard ) this . genericsStack [ this . genericsPtr ] ; if ( wildcard != null && wildcard . bound == this . assistNode ) this . assistNodeParent = wildcard ; } popElement ( K_EXTENDS_KEYWORD ) ; } protected void consumeUnaryExpression ( int op ) { super . consumeUnaryExpression ( op ) ; popElement ( K_UNARY_OPERATOR ) ; if ( this . expressionStack [ this . expressionPtr ] instanceof UnaryExpression ) { UnaryExpression exp = ( UnaryExpression ) this . expressionStack [ this . expressionPtr ] ; if ( this . assistNode != null && exp . expression == this . assistNode ) { this . assistNodeParent = exp ; } } } protected void consumeUnaryExpression ( int op , boolean post ) { super . consumeUnaryExpression ( op , post ) ; popElement ( K_UNARY_OPERATOR ) ; if ( this . expressionStack [ this . expressionPtr ] instanceof UnaryExpression ) { UnaryExpression exp = ( UnaryExpression ) this . expressionStack [ this . expressionPtr ] ; if ( this . assistNode != null && exp . expression == this . assistNode ) { this . assistNodeParent = exp ; } } } public MethodDeclaration convertToMethodDeclaration ( ConstructorDeclaration c , CompilationResult compilationResult ) { MethodDeclaration methodDeclaration = super . convertToMethodDeclaration ( c , compilationResult ) ; if ( this . sourceEnds != null ) { int selectorSourceEnd = this . sourceEnds . removeKey ( c ) ; if ( selectorSourceEnd != - <NUM_LIT:1> ) this . sourceEnds . put ( methodDeclaration , selectorSourceEnd ) ; } return methodDeclaration ; } public ImportReference createAssistImportReference ( char [ ] [ ] tokens , long [ ] positions , int mod ) { return new CompletionOnImportReference ( tokens , positions , mod ) ; } public ImportReference createAssistPackageReference ( char [ ] [ ] tokens , long [ ] positions ) { return new CompletionOnPackageReference ( tokens , positions ) ; } public NameReference createQualifiedAssistNameReference ( char [ ] [ ] previousIdentifiers , char [ ] assistName , long [ ] positions ) { return new CompletionOnQualifiedNameReference ( previousIdentifiers , assistName , positions , isInsideAttributeValue ( ) ) ; } public TypeReference createQualifiedAssistTypeReference ( char [ ] [ ] previousIdentifiers , char [ ] assistName , long [ ] positions ) { switch ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ) { case K_NEXT_TYPEREF_IS_EXCEPTION : if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) == K_BETWEEN_CATCH_AND_RIGHT_PAREN ) this . isOrphanCompletionNode = true ; return new CompletionOnQualifiedTypeReference ( previousIdentifiers , assistName , positions , CompletionOnQualifiedTypeReference . K_EXCEPTION ) ; case K_NEXT_TYPEREF_IS_CLASS : return new CompletionOnQualifiedTypeReference ( previousIdentifiers , assistName , positions , CompletionOnQualifiedTypeReference . K_CLASS ) ; case K_NEXT_TYPEREF_IS_INTERFACE : return new CompletionOnQualifiedTypeReference ( previousIdentifiers , assistName , positions , CompletionOnQualifiedTypeReference . K_INTERFACE ) ; default : return new CompletionOnQualifiedTypeReference ( previousIdentifiers , assistName , positions ) ; } } public TypeReference createParameterizedQualifiedAssistTypeReference ( char [ ] [ ] previousIdentifiers , TypeReference [ ] [ ] typeArguments , char [ ] assistName , TypeReference [ ] assistTypeArguments , long [ ] positions ) { boolean isParameterized = false ; for ( int i = <NUM_LIT:0> ; i < typeArguments . length ; i ++ ) { if ( typeArguments [ i ] != null ) { isParameterized = true ; } } if ( ! isParameterized ) { return createQualifiedAssistTypeReference ( previousIdentifiers , assistName , positions ) ; } else { switch ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ) { case K_NEXT_TYPEREF_IS_EXCEPTION : if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) == K_BETWEEN_CATCH_AND_RIGHT_PAREN ) this . isOrphanCompletionNode = true ; return new CompletionOnParameterizedQualifiedTypeReference ( previousIdentifiers , typeArguments , assistName , positions , CompletionOnParameterizedQualifiedTypeReference . K_EXCEPTION ) ; case K_NEXT_TYPEREF_IS_CLASS : return new CompletionOnParameterizedQualifiedTypeReference ( previousIdentifiers , typeArguments , assistName , positions , CompletionOnParameterizedQualifiedTypeReference . K_CLASS ) ; case K_NEXT_TYPEREF_IS_INTERFACE : return new CompletionOnParameterizedQualifiedTypeReference ( previousIdentifiers , typeArguments , assistName , positions , CompletionOnParameterizedQualifiedTypeReference . K_INTERFACE ) ; default : return new CompletionOnParameterizedQualifiedTypeReference ( previousIdentifiers , typeArguments , assistName , positions ) ; } } } public NameReference createSingleAssistNameReference ( char [ ] assistName , long position ) { int kind = topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ; if ( ! isInsideMethod ( ) ) { if ( isInsideFieldInitialization ( ) ) { return new CompletionOnSingleNameReference ( assistName , position , new char [ ] [ ] { Keywords . FALSE , Keywords . TRUE } , false , isInsideAttributeValue ( ) ) ; } return new CompletionOnSingleNameReference ( assistName , position , isInsideAttributeValue ( ) ) ; } else { boolean canBeExplicitConstructorCall = false ; if ( kind == K_BLOCK_DELIMITER && this . previousKind == K_BLOCK_DELIMITER && this . previousInfo == DO ) { return new CompletionOnKeyword3 ( assistName , position , Keywords . WHILE ) ; } else if ( kind == K_BLOCK_DELIMITER && this . previousKind == K_BLOCK_DELIMITER && this . previousInfo == TRY ) { return new CompletionOnKeyword3 ( assistName , position , new char [ ] [ ] { Keywords . CATCH , Keywords . FINALLY } ) ; } else if ( kind == K_BLOCK_DELIMITER && topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == SWITCH ) { return new CompletionOnKeyword3 ( assistName , position , new char [ ] [ ] { Keywords . CASE , Keywords . DEFAULT } ) ; } else { char [ ] [ ] keywords = new char [ Keywords . COUNT ] [ ] ; int count = <NUM_LIT:0> ; if ( ( this . lastModifiers & ClassFileConstants . AccStatic ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . SUPER ; keywords [ count ++ ] = Keywords . THIS ; } keywords [ count ++ ] = Keywords . NEW ; if ( kind == K_BLOCK_DELIMITER || kind == K_CONTROL_STATEMENT_DELIMITER ) { if ( this . canBeExplicitConstructor == YES ) { canBeExplicitConstructorCall = true ; } if ( this . options . complianceLevel >= ClassFileConstants . JDK1_4 ) { keywords [ count ++ ] = Keywords . ASSERT ; } keywords [ count ++ ] = Keywords . DO ; keywords [ count ++ ] = Keywords . FOR ; keywords [ count ++ ] = Keywords . IF ; keywords [ count ++ ] = Keywords . RETURN ; keywords [ count ++ ] = Keywords . SWITCH ; keywords [ count ++ ] = Keywords . SYNCHRONIZED ; keywords [ count ++ ] = Keywords . THROW ; keywords [ count ++ ] = Keywords . TRY ; keywords [ count ++ ] = Keywords . WHILE ; keywords [ count ++ ] = Keywords . FINAL ; keywords [ count ++ ] = Keywords . CLASS ; if ( this . previousKind == K_BLOCK_DELIMITER ) { switch ( this . previousInfo ) { case IF : keywords [ count ++ ] = Keywords . ELSE ; break ; case CATCH : keywords [ count ++ ] = Keywords . CATCH ; keywords [ count ++ ] = Keywords . FINALLY ; break ; } } else if ( this . previousKind == K_CONTROL_STATEMENT_DELIMITER && this . previousInfo == IF ) { keywords [ count ++ ] = Keywords . ELSE ; } if ( isInsideLoop ( ) ) { keywords [ count ++ ] = Keywords . CONTINUE ; } if ( isInsideBreakable ( ) ) { keywords [ count ++ ] = Keywords . BREAK ; } } else if ( kind != K_BETWEEN_CASE_AND_COLON && kind != K_BETWEEN_DEFAULT_AND_COLON ) { keywords [ count ++ ] = Keywords . TRUE ; keywords [ count ++ ] = Keywords . FALSE ; keywords [ count ++ ] = Keywords . NULL ; if ( kind == K_SWITCH_LABEL ) { if ( topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) != DEFAULT ) { keywords [ count ++ ] = Keywords . DEFAULT ; } keywords [ count ++ ] = Keywords . BREAK ; keywords [ count ++ ] = Keywords . CASE ; if ( this . options . complianceLevel >= ClassFileConstants . JDK1_4 ) { keywords [ count ++ ] = Keywords . ASSERT ; } keywords [ count ++ ] = Keywords . DO ; keywords [ count ++ ] = Keywords . FOR ; keywords [ count ++ ] = Keywords . IF ; keywords [ count ++ ] = Keywords . RETURN ; keywords [ count ++ ] = Keywords . SWITCH ; keywords [ count ++ ] = Keywords . SYNCHRONIZED ; keywords [ count ++ ] = Keywords . THROW ; keywords [ count ++ ] = Keywords . TRY ; keywords [ count ++ ] = Keywords . WHILE ; keywords [ count ++ ] = Keywords . FINAL ; keywords [ count ++ ] = Keywords . CLASS ; if ( isInsideLoop ( ) ) { keywords [ count ++ ] = Keywords . CONTINUE ; } } } System . arraycopy ( keywords , <NUM_LIT:0> , keywords = new char [ count ] [ ] , <NUM_LIT:0> , count ) ; return new CompletionOnSingleNameReference ( assistName , position , keywords , canBeExplicitConstructorCall , isInsideAttributeValue ( ) ) ; } } } public TypeReference createSingleAssistTypeReference ( char [ ] assistName , long position ) { switch ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) ) { case K_NEXT_TYPEREF_IS_EXCEPTION : if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER , <NUM_LIT:1> ) == K_BETWEEN_CATCH_AND_RIGHT_PAREN ) this . isOrphanCompletionNode = true ; return new CompletionOnSingleTypeReference ( assistName , position , CompletionOnSingleTypeReference . K_EXCEPTION ) ; case K_NEXT_TYPEREF_IS_CLASS : return new CompletionOnSingleTypeReference ( assistName , position , CompletionOnSingleTypeReference . K_CLASS ) ; case K_NEXT_TYPEREF_IS_INTERFACE : return new CompletionOnSingleTypeReference ( assistName , position , CompletionOnSingleTypeReference . K_INTERFACE ) ; default : return new CompletionOnSingleTypeReference ( assistName , position ) ; } } public TypeReference createParameterizedSingleAssistTypeReference ( TypeReference [ ] typeArguments , char [ ] assistName , long position ) { return createSingleAssistTypeReference ( assistName , position ) ; } protected StringLiteral createStringLiteral ( char [ ] token , int start , int end , int lineNumber ) { if ( start <= this . cursorLocation && this . cursorLocation <= end ) { char [ ] source = this . scanner . source ; int contentStart = start ; int contentEnd = end ; int pos = contentStart ; if ( source [ pos ] == '<STR_LIT:\">' ) { contentStart = pos + <NUM_LIT:1> ; } else if ( source [ pos ] == '<STR_LIT:\\>' && source [ pos + <NUM_LIT:1> ] == '<CHAR_LIT>' ) { pos += <NUM_LIT:2> ; while ( source [ pos ] == '<CHAR_LIT>' ) { pos ++ ; } if ( source [ pos ] == <NUM_LIT:0> && source [ pos + <NUM_LIT:1> ] == <NUM_LIT:0> && source [ pos + <NUM_LIT:2> ] == <NUM_LIT:2> && source [ pos + <NUM_LIT:3> ] == <NUM_LIT:2> ) { contentStart = pos + <NUM_LIT:4> ; } } pos = contentEnd ; if ( source [ pos ] == '<STR_LIT:\">' ) { contentEnd = pos - <NUM_LIT:1> ; } else if ( source . length > <NUM_LIT:5> && source [ pos - <NUM_LIT:4> ] == '<CHAR_LIT>' ) { if ( source [ pos - <NUM_LIT:3> ] == <NUM_LIT:0> && source [ pos - <NUM_LIT:2> ] == <NUM_LIT:0> && source [ pos - <NUM_LIT:1> ] == <NUM_LIT:2> && source [ pos ] == <NUM_LIT:2> ) { pos -= <NUM_LIT:5> ; while ( pos > - <NUM_LIT:1> && source [ pos ] == '<CHAR_LIT>' ) { pos -- ; } if ( pos > - <NUM_LIT:1> && source [ pos ] == '<STR_LIT:\\>' ) { contentEnd = pos - <NUM_LIT:1> ; } } } if ( contentEnd < start ) { contentEnd = end ; } if ( this . cursorLocation != end || end == contentEnd ) { CompletionOnStringLiteral stringLiteral = new CompletionOnStringLiteral ( token , start , end , contentStart , contentEnd , lineNumber ) ; this . assistNode = stringLiteral ; this . restartRecovery = true ; this . lastCheckPoint = end ; return stringLiteral ; } } return super . createStringLiteral ( token , start , end , lineNumber ) ; } protected TypeReference copyDims ( TypeReference typeRef , int dim ) { if ( this . assistNode == typeRef ) { return typeRef ; } TypeReference result = super . copyDims ( typeRef , dim ) ; if ( this . assistNodeParent == typeRef ) { this . assistNodeParent = result ; } return result ; } public CompilationUnitDeclaration dietParse ( ICompilationUnit sourceUnit , CompilationResult compilationResult , int cursorLoc ) { this . cursorLocation = cursorLoc ; CompletionScanner completionScanner = ( CompletionScanner ) this . scanner ; completionScanner . completionIdentifier = null ; completionScanner . cursorLocation = cursorLoc ; return this . dietParse ( sourceUnit , compilationResult ) ; } public void flushAssistState ( ) { super . flushAssistState ( ) ; this . isOrphanCompletionNode = false ; this . isAlreadyAttached = false ; this . assistNodeParent = null ; CompletionScanner completionScanner = ( CompletionScanner ) this . scanner ; completionScanner . completedIdentifierStart = <NUM_LIT:0> ; completionScanner . completedIdentifierEnd = - <NUM_LIT:1> ; } protected TypeReference getTypeReferenceForGenericType ( int dim , int identifierLength , int numberOfIdentifiers ) { TypeReference ref = super . getTypeReferenceForGenericType ( dim , identifierLength , numberOfIdentifiers ) ; checkForDiamond ( ref ) ; if ( this . assistNode != null ) { if ( identifierLength == <NUM_LIT:1> && numberOfIdentifiers == <NUM_LIT:1> ) { ParameterizedSingleTypeReference singleRef = ( ParameterizedSingleTypeReference ) ref ; TypeReference [ ] typeArguments = singleRef . typeArguments ; for ( int i = <NUM_LIT:0> ; i < typeArguments . length ; i ++ ) { if ( typeArguments [ i ] == this . assistNode ) { this . assistNodeParent = ref ; return ref ; } } } else { ParameterizedQualifiedTypeReference qualifiedRef = ( ParameterizedQualifiedTypeReference ) ref ; TypeReference [ ] [ ] typeArguments = qualifiedRef . typeArguments ; for ( int i = <NUM_LIT:0> ; i < typeArguments . length ; i ++ ) { if ( typeArguments [ i ] != null ) { for ( int j = <NUM_LIT:0> ; j < typeArguments [ i ] . length ; j ++ ) { if ( typeArguments [ i ] [ j ] == this . assistNode ) { this . assistNodeParent = ref ; return ref ; } } } } } } return ref ; } protected NameReference getUnspecifiedReference ( ) { NameReference nameReference = super . getUnspecifiedReference ( ) ; if ( this . record ) { recordReference ( nameReference ) ; } return nameReference ; } protected NameReference getUnspecifiedReferenceOptimized ( ) { if ( this . identifierLengthStack [ this . identifierLengthPtr ] > <NUM_LIT:1> ) { this . invocationType = NO_RECEIVER ; this . qualifier = - <NUM_LIT:1> ; } NameReference nameReference = super . getUnspecifiedReferenceOptimized ( ) ; if ( this . record ) { recordReference ( nameReference ) ; } return nameReference ; } private boolean isAlreadyPotentialName ( int identifierStart ) { if ( this . potentialVariableNamesPtr < <NUM_LIT:0> ) return false ; return identifierStart <= this . potentialVariableNameEnds [ this . potentialVariableNamesPtr ] ; } protected int indexOfAssistIdentifier ( boolean useGenericsStack ) { if ( this . record ) return - <NUM_LIT:1> ; return super . indexOfAssistIdentifier ( useGenericsStack ) ; } public void initialize ( ) { super . initialize ( ) ; this . labelPtr = - <NUM_LIT:1> ; initializeForBlockStatements ( ) ; } public void initialize ( boolean initializeNLS ) { super . initialize ( initializeNLS ) ; this . labelPtr = - <NUM_LIT:1> ; initializeForBlockStatements ( ) ; } private void initializeForBlockStatements ( ) { this . previousToken = - <NUM_LIT:1> ; this . previousIdentifierPtr = - <NUM_LIT:1> ; this . invocationType = NO_RECEIVER ; this . qualifier = - <NUM_LIT:1> ; popUntilElement ( K_SWITCH_LABEL ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) != K_SWITCH_LABEL ) { if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_ARRAY_INITIALIZER ) { popUntilElement ( K_ARRAY_INITIALIZER ) ; } else { popUntilElement ( K_BLOCK_DELIMITER ) ; } } } public void initializeScanner ( ) { this . scanner = new CompletionScanner ( this . options . sourceLevel ) ; } private boolean isAfterArrayType ( ) { if ( ( this . intPtr > - <NUM_LIT:1> ) && ( this . intStack [ this . intPtr ] < <NUM_LIT:11> ) ) { return true ; } return false ; } private boolean isEmptyNameCompletion ( ) { return this . assistNode != null && this . assistNode instanceof CompletionOnSingleNameReference && ( ( ( CompletionOnSingleNameReference ) this . assistNode ) . token . length == <NUM_LIT:0> ) ; } protected boolean isInsideAnnotation ( ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { if ( this . elementKindStack [ i ] == K_BETWEEN_ANNOTATION_NAME_AND_RPAREN ) return true ; i -- ; } return false ; } protected boolean isIndirectlyInsideBlock ( ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { if ( this . elementKindStack [ i ] == K_BLOCK_DELIMITER ) return true ; i -- ; } return false ; } protected boolean isInsideBlock ( ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { switch ( this . elementKindStack [ i ] ) { case K_TYPE_DELIMITER : return false ; case K_METHOD_DELIMITER : return false ; case K_FIELD_INITIALIZER_DELIMITER : return false ; case K_BLOCK_DELIMITER : return true ; } i -- ; } return false ; } protected boolean isInsideBreakable ( ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { switch ( this . elementKindStack [ i ] ) { case K_TYPE_DELIMITER : return false ; case K_METHOD_DELIMITER : return false ; case K_FIELD_INITIALIZER_DELIMITER : return false ; case K_SWITCH_LABEL : return true ; case K_BLOCK_DELIMITER : case K_CONTROL_STATEMENT_DELIMITER : switch ( this . elementInfoStack [ i ] ) { case FOR : case DO : case WHILE : return true ; } } i -- ; } return false ; } protected boolean isInsideLoop ( ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { switch ( this . elementKindStack [ i ] ) { case K_TYPE_DELIMITER : return false ; case K_METHOD_DELIMITER : return false ; case K_FIELD_INITIALIZER_DELIMITER : return false ; case K_BLOCK_DELIMITER : case K_CONTROL_STATEMENT_DELIMITER : switch ( this . elementInfoStack [ i ] ) { case FOR : case DO : case WHILE : return true ; } } i -- ; } return false ; } protected boolean isInsideReturn ( ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { switch ( this . elementKindStack [ i ] ) { case K_TYPE_DELIMITER : return false ; case K_METHOD_DELIMITER : return false ; case K_FIELD_INITIALIZER_DELIMITER : return false ; case K_BLOCK_DELIMITER : return false ; case K_CONTROL_STATEMENT_DELIMITER : return false ; case K_INSIDE_RETURN_STATEMENT : return true ; } i -- ; } return false ; } public CompilationUnitDeclaration parse ( ICompilationUnit sourceUnit , CompilationResult compilationResult , int cursorLoc ) { this . cursorLocation = cursorLoc ; CompletionScanner completionScanner = ( CompletionScanner ) this . scanner ; completionScanner . completionIdentifier = null ; completionScanner . cursorLocation = cursorLoc ; return this . parse ( sourceUnit , compilationResult ) ; } public void parseBlockStatements ( ConstructorDeclaration cd , CompilationUnitDeclaration unit ) { this . canBeExplicitConstructor = <NUM_LIT:1> ; super . parseBlockStatements ( cd , unit ) ; } public MethodDeclaration parseSomeStatements ( int start , int end , int fakeBlocksCount , CompilationUnitDeclaration unit ) { this . methodRecoveryActivated = true ; initialize ( ) ; goForBlockStatementsopt ( ) ; MethodDeclaration fakeMethod = new MethodDeclaration ( unit . compilationResult ( ) ) ; fakeMethod . selector = FAKE_METHOD_NAME ; fakeMethod . bodyStart = start ; fakeMethod . bodyEnd = end ; fakeMethod . declarationSourceStart = start ; fakeMethod . declarationSourceEnd = end ; fakeMethod . sourceStart = start ; fakeMethod . sourceEnd = start ; this . referenceContext = fakeMethod ; this . compilationUnit = unit ; this . diet = false ; this . restartRecovery = true ; this . scanner . resetTo ( start , end ) ; consumeNestedMethod ( ) ; for ( int i = <NUM_LIT:0> ; i < fakeBlocksCount ; i ++ ) { consumeOpenFakeBlock ( ) ; } try { parse ( ) ; } catch ( AbortCompilation ex ) { this . lastAct = ERROR_ACTION ; } finally { this . nestedMethod [ this . nestedType ] -- ; } if ( ! this . hasError ) { int length ; if ( this . astLengthPtr > - <NUM_LIT:1> && ( length = this . astLengthStack [ this . astLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . astStack , ( this . astPtr -= length ) + <NUM_LIT:1> , fakeMethod . statements = new Statement [ length ] , <NUM_LIT:0> , length ) ; } } return fakeMethod ; } protected void popUntilCompletedAnnotationIfNecessary ( ) { if ( this . elementPtr < <NUM_LIT:0> ) return ; int i = this . elementPtr ; while ( i > - <NUM_LIT:1> && ( this . elementKindStack [ i ] != K_BETWEEN_ANNOTATION_NAME_AND_RPAREN || ( this . elementInfoStack [ i ] & ANNOTATION_NAME_COMPLETION ) == <NUM_LIT:0> ) ) { i -- ; } if ( i >= <NUM_LIT:0> ) { this . previousKind = this . elementKindStack [ i ] ; this . previousInfo = this . elementInfoStack [ i ] ; this . previousObjectInfo = this . elementObjectInfoStack [ i ] ; for ( int j = i ; j <= this . elementPtr ; j ++ ) { this . elementObjectInfoStack [ j ] = null ; } this . elementPtr = i - <NUM_LIT:1> ; } } protected void prepareForBlockStatements ( ) { this . nestedMethod [ this . nestedType = <NUM_LIT:0> ] = <NUM_LIT:1> ; this . variablesCounter [ this . nestedType ] = <NUM_LIT:0> ; this . realBlockStack [ this . realBlockPtr = <NUM_LIT:1> ] = <NUM_LIT:0> ; initializeForBlockStatements ( ) ; } protected void pushOnLabelStack ( char [ ] label ) { if ( this . labelPtr < - <NUM_LIT:1> ) return ; int stackLength = this . labelStack . length ; if ( ++ this . labelPtr >= stackLength ) { System . arraycopy ( this . labelStack , <NUM_LIT:0> , this . labelStack = new char [ stackLength + LabelStackIncrement ] [ ] , <NUM_LIT:0> , stackLength ) ; } this . labelStack [ this . labelPtr ] = label ; } private void pushCompletionOnMemberAccessOnExpressionStack ( boolean isSuperAccess ) { char [ ] source = this . identifierStack [ this . identifierPtr ] ; long pos = this . identifierPositionStack [ this . identifierPtr -- ] ; CompletionOnMemberAccess fr = new CompletionOnMemberAccess ( source , pos , isInsideAnnotation ( ) ) ; this . assistNode = fr ; this . lastCheckPoint = fr . sourceEnd + <NUM_LIT:1> ; this . identifierLengthPtr -- ; if ( isSuperAccess ) { fr . sourceStart = this . intStack [ this . intPtr -- ] ; fr . receiver = new SuperReference ( fr . sourceStart , this . endPosition ) ; pushOnExpressionStack ( fr ) ; } else { if ( ( fr . receiver = this . expressionStack [ this . expressionPtr ] ) . isThis ( ) ) { fr . sourceStart = fr . receiver . sourceStart ; } this . expressionStack [ this . expressionPtr ] = fr ; } } private void recordReference ( NameReference nameReference ) { if ( ! this . skipRecord && this . recordFrom <= nameReference . sourceStart && nameReference . sourceEnd <= this . recordTo && ! isAlreadyPotentialName ( nameReference . sourceStart ) ) { char [ ] token ; if ( nameReference instanceof SingleNameReference ) { token = ( ( SingleNameReference ) nameReference ) . token ; } else { token = ( ( QualifiedNameReference ) nameReference ) . tokens [ <NUM_LIT:0> ] ; } if ( Character . isUpperCase ( token [ <NUM_LIT:0> ] ) ) return ; addPotentialName ( token , nameReference . sourceStart , nameReference . sourceEnd ) ; } } public void recoveryExitFromVariable ( ) { if ( this . currentElement != null && this . currentElement instanceof RecoveredLocalVariable ) { RecoveredElement oldElement = this . currentElement ; super . recoveryExitFromVariable ( ) ; if ( oldElement != this . currentElement ) { popElement ( K_LOCAL_INITIALIZER_DELIMITER ) ; } } else if ( this . currentElement != null && this . currentElement instanceof RecoveredField ) { RecoveredElement oldElement = this . currentElement ; super . recoveryExitFromVariable ( ) ; if ( oldElement != this . currentElement ) { if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_ARRAY_INITIALIZER ) { popElement ( K_ARRAY_INITIALIZER ) ; popElement ( K_FIELD_INITIALIZER_DELIMITER ) ; } } } else { super . recoveryExitFromVariable ( ) ; } } public void recoveryTokenCheck ( ) { RecoveredElement oldElement = this . currentElement ; switch ( this . currentToken ) { case TokenNameLBRACE : if ( ! this . ignoreNextOpeningBrace ) { this . pendingAnnotation = null ; } super . recoveryTokenCheck ( ) ; break ; case TokenNameRBRACE : super . recoveryTokenCheck ( ) ; if ( this . currentElement != oldElement && oldElement instanceof RecoveredBlock ) { if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_ARRAY_INITIALIZER ) { popElement ( K_ARRAY_INITIALIZER ) ; } else { popElement ( K_BLOCK_DELIMITER ) ; } } break ; case TokenNamecase : super . recoveryTokenCheck ( ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BLOCK_DELIMITER && topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == SWITCH ) { pushOnElementStack ( K_SWITCH_LABEL ) ; } break ; case TokenNamedefault : super . recoveryTokenCheck ( ) ; if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_BLOCK_DELIMITER && topKnownElementInfo ( COMPLETION_OR_ASSIST_PARSER ) == SWITCH ) { pushOnElementStack ( K_SWITCH_LABEL , DEFAULT ) ; } else if ( topKnownElementKind ( COMPLETION_OR_ASSIST_PARSER ) == K_SWITCH_LABEL ) { popElement ( K_SWITCH_LABEL ) ; pushOnElementStack ( K_SWITCH_LABEL , DEFAULT ) ; } break ; default : super . recoveryTokenCheck ( ) ; break ; } } public void reset ( ) { super . reset ( ) ; this . cursorLocation = <NUM_LIT:0> ; if ( this . storeSourceEnds ) { this . sourceEnds = new HashtableOfObjectToInt ( ) ; } } public void resetAfterCompletion ( ) { this . cursorLocation = <NUM_LIT:0> ; flushAssistState ( ) ; } public void restoreAssistParser ( Object parserState ) { int [ ] state = ( int [ ] ) parserState ; CompletionScanner completionScanner = ( CompletionScanner ) this . scanner ; this . cursorLocation = state [ <NUM_LIT:0> ] ; completionScanner . cursorLocation = state [ <NUM_LIT:1> ] ; } protected boolean resumeAfterRecovery ( ) { this . hasUnusedModifiers = false ; if ( this . assistNode != null ) { if ( ( this . scanner . eofPosition == this . cursorLocation + <NUM_LIT:1> ) && ( ! ( this . referenceContext instanceof CompilationUnitDeclaration ) || isIndirectlyInsideFieldInitialization ( ) || this . assistNodeParent instanceof FieldDeclaration && ! ( this . assistNodeParent instanceof Initializer ) ) ) { if ( this . currentElement instanceof RecoveredType || this . currentElement . enclosingType ( ) != null ) { this . pendingAnnotation = null ; if ( this . lastCheckPoint <= this . assistNode . sourceEnd ) { this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; } int end = this . currentElement . topElement ( ) . sourceEnd ( ) ; this . scanner . eofPosition = end < Integer . MAX_VALUE ? end + <NUM_LIT:1> : end ; } else { resetStacks ( ) ; return false ; } } } return super . resumeAfterRecovery ( ) ; } public void setAssistIdentifier ( char [ ] assistIdent ) { ( ( CompletionScanner ) this . scanner ) . completionIdentifier = assistIdent ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i <= this . elementPtr ; i ++ ) { buffer . append ( String . valueOf ( this . elementKindStack [ i ] ) ) . append ( '<CHAR_LIT:U+002C>' ) ; } buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i <= this . elementPtr ; i ++ ) { buffer . append ( String . valueOf ( this . elementInfoStack [ i ] ) ) . append ( '<CHAR_LIT:U+002C>' ) ; } buffer . append ( "<STR_LIT>" ) ; buffer . append ( super . toString ( ) ) ; return String . valueOf ( buffer ) ; } protected void updateRecoveryState ( ) { this . currentElement . updateFromParserState ( ) ; completionIdentifierCheck ( ) ; attachOrphanCompletionNode ( ) ; if ( this . assistNode != null && this . currentElement != null ) { this . currentElement . preserveEnclosingBlocks ( ) ; } recoveryTokenCheck ( ) ; recoveryExitFromVariable ( ) ; } protected LocalDeclaration createLocalDeclaration ( char [ ] assistName , int sourceStart , int sourceEnd ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { return super . createLocalDeclaration ( assistName , sourceStart , sourceEnd ) ; } else { CompletionOnLocalName local = new CompletionOnLocalName ( assistName , sourceStart , sourceEnd ) ; this . assistNode = local ; this . lastCheckPoint = sourceEnd + <NUM_LIT:1> ; return local ; } } protected JavadocParser createJavadocParser ( ) { return new CompletionJavadocParser ( this ) ; } protected FieldDeclaration createFieldDeclaration ( char [ ] assistName , int sourceStart , int sourceEnd ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> || ( this . currentElement instanceof RecoveredUnit && ( ( RecoveredUnit ) this . currentElement ) . typeCount == <NUM_LIT:0> ) ) { return super . createFieldDeclaration ( assistName , sourceStart , sourceEnd ) ; } else { CompletionOnFieldName field = new CompletionOnFieldName ( assistName , sourceStart , sourceEnd ) ; this . assistNode = field ; this . lastCheckPoint = sourceEnd + <NUM_LIT:1> ; return field ; } } private boolean stackHasInstanceOfExpression ( Object [ ] stackToSearch , int startIndex ) { int indexInstanceOf = startIndex ; while ( indexInstanceOf >= <NUM_LIT:0> ) { if ( stackToSearch [ indexInstanceOf ] instanceof InstanceOfExpression ) { return true ; } indexInstanceOf -- ; } return false ; } protected boolean isInsideArrayInitializer ( ) { int i = this . elementPtr ; if ( i > - <NUM_LIT:1> && this . elementKindStack [ i ] == K_ARRAY_INITIALIZER ) { return true ; } return false ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . JavadocQualifiedTypeReference ; public class CompletionOnJavadocQualifiedTypeReference extends JavadocQualifiedTypeReference implements CompletionOnJavadoc { public int completionFlags = JAVADOC ; public char [ ] completionIdentifier ; public CompletionOnJavadocQualifiedTypeReference ( char [ ] [ ] sources , char [ ] identifier , long [ ] pos , int tagStart , int tagEnd ) { super ( sources , pos , tagStart , tagEnd ) ; this . completionIdentifier = identifier ; } public CompletionOnJavadocQualifiedTypeReference ( JavadocQualifiedTypeReference typeRef ) { super ( typeRef . tokens , typeRef . sourcePositions , typeRef . tagSourceStart , typeRef . tagSourceStart ) ; this . completionIdentifier = CharOperation . NO_CHAR ; } public void addCompletionFlags ( int flags ) { this . completionFlags |= flags ; } public boolean completeAnException ( ) { return ( this . completionFlags & EXCEPTION ) != <NUM_LIT:0> ; } public boolean completeInText ( ) { return ( this . completionFlags & TEXT ) != <NUM_LIT:0> ; } public boolean completeBaseTypes ( ) { return ( this . completionFlags & BASE_TYPES ) != <NUM_LIT:0> ; } public boolean completeFormalReference ( ) { return ( this . completionFlags & FORMAL_REFERENCE ) != <NUM_LIT:0> ; } public int getCompletionFlags ( ) { return this . completionFlags ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; super . printExpression ( indent , output ) ; indent ++ ; if ( this . completionFlags > <NUM_LIT:0> ) { output . append ( '<STR_LIT:\n>' ) ; for ( int i = <NUM_LIT:0> ; i < indent ; i ++ ) output . append ( '<STR_LIT:\t>' ) ; output . append ( "<STR_LIT>" ) ; char separator = <NUM_LIT:0> ; if ( completeAnException ( ) ) { output . append ( "<STR_LIT>" ) ; separator = '<CHAR_LIT:U+002C>' ; } if ( completeInText ( ) ) { if ( separator != <NUM_LIT:0> ) output . append ( separator ) ; output . append ( "<STR_LIT:text>" ) ; separator = '<CHAR_LIT:U+002C>' ; } if ( completeBaseTypes ( ) ) { if ( separator != <NUM_LIT:0> ) output . append ( separator ) ; output . append ( "<STR_LIT>" ) ; separator = '<CHAR_LIT:U+002C>' ; } if ( completeFormalReference ( ) ) { if ( separator != <NUM_LIT:0> ) output . append ( separator ) ; output . append ( "<STR_LIT>" ) ; separator = '<CHAR_LIT:U+002C>' ; } output . append ( '<STR_LIT:\n>' ) ; } indent -- ; for ( int i = <NUM_LIT:0> ; i < indent ; i ++ ) output . append ( '<STR_LIT:\t>' ) ; return output . append ( '<CHAR_LIT:>>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; public class CompletionOnQualifiedAllocationExpression extends QualifiedAllocationExpression { public TypeBinding resolveType ( BlockScope scope ) { TypeBinding [ ] argumentTypes = Binding . NO_PARAMETERS ; if ( this . arguments != null ) { int argsLength = this . arguments . length ; int length = this . arguments . length ; argumentTypes = new TypeBinding [ length ] ; for ( int a = argsLength ; -- a >= <NUM_LIT:0> ; ) { argumentTypes [ a ] = this . arguments [ a ] . resolveType ( scope ) ; } } final boolean isDiamond = this . type != null && ( this . type . bits & ASTNode . IsDiamond ) != <NUM_LIT:0> ; if ( this . enclosingInstance != null ) { TypeBinding enclosingType = this . enclosingInstance . resolveType ( scope ) ; if ( enclosingType == null ) { if ( this . enclosingInstance instanceof AllocationExpression ) { TypeReference enclosingInstanceType = ( ( AllocationExpression ) this . enclosingInstance ) . type ; if ( enclosingInstanceType != null ) { enclosingType = enclosingInstanceType . resolvedType ; } } } if ( enclosingType == null || ! ( enclosingType instanceof ReferenceBinding ) ) { throw new CompletionNodeFound ( ) ; } this . resolvedType = ( ( SingleTypeReference ) this . type ) . resolveTypeEnclosing ( scope , ( ReferenceBinding ) enclosingType ) ; if ( isDiamond && ( this . resolvedType instanceof ParameterizedTypeBinding ) ) { TypeBinding [ ] inferredTypes = inferElidedTypes ( ( ( ParameterizedTypeBinding ) this . resolvedType ) . genericType ( ) , null , argumentTypes , scope ) ; if ( inferredTypes != null ) { this . resolvedType = this . type . resolvedType = scope . environment ( ) . createParameterizedType ( ( ( ParameterizedTypeBinding ) this . resolvedType ) . genericType ( ) , inferredTypes , ( ( ParameterizedTypeBinding ) this . resolvedType ) . enclosingType ( ) ) ; } else { this . bits |= ASTNode . IsDiamond ; } } if ( ! ( this . resolvedType instanceof ReferenceBinding ) ) throw new CompletionNodeFound ( ) ; if ( this . resolvedType . isInterface ( ) ) this . resolvedType = scope . getJavaLangObject ( ) ; } else { this . resolvedType = this . type . resolveType ( scope , true ) ; if ( isDiamond && ( this . resolvedType instanceof ParameterizedTypeBinding ) ) { TypeBinding [ ] inferredTypes = inferElidedTypes ( ( ( ParameterizedTypeBinding ) this . resolvedType ) . genericType ( ) , null , argumentTypes , scope ) ; if ( inferredTypes != null ) { this . resolvedType = this . type . resolvedType = scope . environment ( ) . createParameterizedType ( ( ( ParameterizedTypeBinding ) this . resolvedType ) . genericType ( ) , inferredTypes , ( ( ParameterizedTypeBinding ) this . resolvedType ) . enclosingType ( ) ) ; } else { this . bits |= ASTNode . IsDiamond ; } } if ( ! ( this . resolvedType instanceof ReferenceBinding ) ) throw new CompletionNodeFound ( ) ; } throw new CompletionNodeFound ( this , this . resolvedType , scope ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { if ( this . enclosingInstance == null ) output . append ( "<STR_LIT>" ) ; else output . append ( "<STR_LIT>" ) ; return super . printExpression ( indent , output ) . append ( '<CHAR_LIT:>>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; public class CompletionJavadoc extends Javadoc { Expression completionNode ; public CompletionJavadoc ( int sourceStart , int sourceEnd ) { super ( sourceStart , sourceEnd ) ; } public Expression getCompletionNode ( ) { return this . completionNode ; } private void internalResolve ( Scope scope ) { if ( this . completionNode != null ) { if ( this . completionNode instanceof CompletionOnJavadocTag ) { ( ( CompletionOnJavadocTag ) this . completionNode ) . filterPossibleTags ( scope ) ; } else { boolean resolve = true ; if ( this . completionNode instanceof CompletionOnJavadocParamNameReference ) { resolve = ( ( CompletionOnJavadocParamNameReference ) this . completionNode ) . token != null ; } else if ( this . completionNode instanceof CompletionOnJavadocTypeParamReference ) { resolve = ( ( CompletionOnJavadocTypeParamReference ) this . completionNode ) . token != null ; } if ( resolve ) { switch ( scope . kind ) { case Scope . CLASS_SCOPE : this . completionNode . resolveType ( ( ClassScope ) scope ) ; break ; case Scope . METHOD_SCOPE : this . completionNode . resolveType ( ( MethodScope ) scope ) ; break ; } } if ( this . completionNode instanceof CompletionOnJavadocParamNameReference ) { CompletionOnJavadocParamNameReference paramNameReference = ( CompletionOnJavadocParamNameReference ) this . completionNode ; if ( scope . kind == Scope . METHOD_SCOPE ) { paramNameReference . missingParams = missingParamTags ( paramNameReference . binding , ( MethodScope ) scope ) ; } if ( paramNameReference . token == null || paramNameReference . token . length == <NUM_LIT:0> ) { paramNameReference . missingTypeParams = missingTypeParameterTags ( paramNameReference . binding , scope ) ; } } else if ( this . completionNode instanceof CompletionOnJavadocTypeParamReference ) { CompletionOnJavadocTypeParamReference typeParamReference = ( CompletionOnJavadocTypeParamReference ) this . completionNode ; typeParamReference . missingParams = missingTypeParameterTags ( typeParamReference . resolvedType , scope ) ; } } Binding qualifiedBinding = null ; if ( this . completionNode instanceof CompletionOnJavadocQualifiedTypeReference ) { CompletionOnJavadocQualifiedTypeReference typeRef = ( CompletionOnJavadocQualifiedTypeReference ) this . completionNode ; if ( typeRef . packageBinding == null ) { qualifiedBinding = typeRef . resolvedType ; } else { qualifiedBinding = typeRef . packageBinding ; } } else if ( this . completionNode instanceof CompletionOnJavadocMessageSend ) { CompletionOnJavadocMessageSend msg = ( CompletionOnJavadocMessageSend ) this . completionNode ; if ( ! msg . receiver . isThis ( ) ) qualifiedBinding = msg . receiver . resolvedType ; } else if ( this . completionNode instanceof CompletionOnJavadocAllocationExpression ) { CompletionOnJavadocAllocationExpression alloc = ( CompletionOnJavadocAllocationExpression ) this . completionNode ; qualifiedBinding = alloc . type . resolvedType ; } throw new CompletionNodeFound ( this . completionNode , qualifiedBinding , scope ) ; } } public StringBuffer print ( int indent , StringBuffer output ) { printIndent ( indent , output ) . append ( "<STR_LIT>" ) ; boolean nodePrinted = false ; if ( this . paramReferences != null ) { for ( int i = <NUM_LIT:0> , length = this . paramReferences . length ; i < length ; i ++ ) { printIndent ( indent , output ) . append ( "<STR_LIT>" ) ; this . paramReferences [ i ] . print ( indent , output ) . append ( '<STR_LIT:\n>' ) ; if ( ! nodePrinted && this . completionNode != null ) { nodePrinted = this . completionNode == this . paramReferences [ i ] ; } } } if ( this . paramTypeParameters != null ) { for ( int i = <NUM_LIT:0> , length = this . paramTypeParameters . length ; i < length ; i ++ ) { printIndent ( indent , output ) . append ( "<STR_LIT>" ) ; this . paramTypeParameters [ i ] . print ( indent , output ) . append ( "<STR_LIT>" ) ; if ( ! nodePrinted && this . completionNode != null ) { nodePrinted = this . completionNode == this . paramTypeParameters [ i ] ; } } } if ( this . returnStatement != null ) { printIndent ( indent , output ) . append ( "<STR_LIT>" ) ; this . returnStatement . print ( indent , output ) . append ( '<STR_LIT:\n>' ) ; } if ( this . exceptionReferences != null ) { for ( int i = <NUM_LIT:0> , length = this . exceptionReferences . length ; i < length ; i ++ ) { printIndent ( indent , output ) . append ( "<STR_LIT>" ) ; this . exceptionReferences [ i ] . print ( indent , output ) . append ( '<STR_LIT:\n>' ) ; if ( ! nodePrinted && this . completionNode != null ) { nodePrinted = this . completionNode == this . exceptionReferences [ i ] ; } } } if ( this . seeReferences != null ) { for ( int i = <NUM_LIT:0> , length = this . seeReferences . length ; i < length ; i ++ ) { printIndent ( indent , output ) . append ( "<STR_LIT>" ) ; this . seeReferences [ i ] . print ( indent , output ) . append ( '<STR_LIT:\n>' ) ; if ( ! nodePrinted && this . completionNode != null ) { nodePrinted = this . completionNode == this . seeReferences [ i ] ; } } } if ( ! nodePrinted && this . completionNode != null ) { printIndent ( indent , output ) . append ( "<STR_LIT>" ) ; this . completionNode . print ( indent , output ) . append ( '<STR_LIT:\n>' ) ; } printIndent ( indent , output ) . append ( "<STR_LIT>" ) ; return output ; } public void resolve ( ClassScope scope ) { super . resolve ( scope ) ; internalResolve ( scope ) ; } public void resolve ( CompilationUnitScope scope ) { internalResolve ( scope ) ; } public void resolve ( MethodScope scope ) { super . resolve ( scope ) ; internalResolve ( scope ) ; } private char [ ] [ ] missingParamTags ( Binding paramNameRefBinding , MethodScope methScope ) { AbstractMethodDeclaration md = methScope . referenceMethod ( ) ; int paramTagsSize = this . paramReferences == null ? <NUM_LIT:0> : this . paramReferences . length ; if ( md == null ) return null ; int argumentsSize = md . arguments == null ? <NUM_LIT:0> : md . arguments . length ; if ( argumentsSize == <NUM_LIT:0> ) return null ; if ( paramTagsSize == <NUM_LIT:0> ) { char [ ] [ ] missingParams = new char [ argumentsSize ] [ ] ; for ( int i = <NUM_LIT:0> ; i < argumentsSize ; i ++ ) { missingParams [ i ] = md . arguments [ i ] . name ; } return missingParams ; } char [ ] [ ] missingParams = new char [ argumentsSize ] [ ] ; int size = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < argumentsSize ; i ++ ) { Argument arg = md . arguments [ i ] ; boolean found = false ; int paramNameRefCount = <NUM_LIT:0> ; for ( int j = <NUM_LIT:0> ; j < paramTagsSize && ! found ; j ++ ) { JavadocSingleNameReference param = this . paramReferences [ j ] ; if ( arg . binding == param . binding ) { if ( param . binding == paramNameRefBinding ) { paramNameRefCount ++ ; found = paramNameRefCount > <NUM_LIT:1> ; } else { found = true ; } } } if ( ! found ) { missingParams [ size ++ ] = arg . name ; } } if ( size > <NUM_LIT:0> ) { if ( size != argumentsSize ) { System . arraycopy ( missingParams , <NUM_LIT:0> , missingParams = new char [ size ] [ ] , <NUM_LIT:0> , size ) ; } return missingParams ; } return null ; } private char [ ] [ ] missingTypeParameterTags ( Binding paramNameRefBinding , Scope scope ) { int paramTypeParamLength = this . paramTypeParameters == null ? <NUM_LIT:0> : this . paramTypeParameters . length ; TypeParameter [ ] parameters = null ; TypeVariableBinding [ ] typeVariables = null ; switch ( scope . kind ) { case Scope . METHOD_SCOPE : AbstractMethodDeclaration methodDeclaration = ( ( MethodScope ) scope ) . referenceMethod ( ) ; if ( methodDeclaration == null ) return null ; parameters = methodDeclaration . typeParameters ( ) ; typeVariables = methodDeclaration . binding . typeVariables ; break ; case Scope . CLASS_SCOPE : TypeDeclaration typeDeclaration = ( ( ClassScope ) scope ) . referenceContext ; parameters = typeDeclaration . typeParameters ; typeVariables = typeDeclaration . binding . typeVariables ; break ; } if ( typeVariables == null || typeVariables . length == <NUM_LIT:0> ) return null ; if ( parameters != null ) { int typeParametersLength = parameters . length ; if ( paramTypeParamLength == <NUM_LIT:0> ) { char [ ] [ ] missingParams = new char [ typeParametersLength ] [ ] ; for ( int i = <NUM_LIT:0> ; i < typeParametersLength ; i ++ ) { missingParams [ i ] = parameters [ i ] . name ; } return missingParams ; } char [ ] [ ] missingParams = new char [ typeParametersLength ] [ ] ; int size = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < typeParametersLength ; i ++ ) { TypeParameter parameter = parameters [ i ] ; boolean found = false ; int paramNameRefCount = <NUM_LIT:0> ; for ( int j = <NUM_LIT:0> ; j < paramTypeParamLength && ! found ; j ++ ) { if ( parameter . binding == this . paramTypeParameters [ j ] . resolvedType ) { if ( parameter . binding == paramNameRefBinding ) { paramNameRefCount ++ ; found = paramNameRefCount > <NUM_LIT:1> ; } else { found = true ; } } } if ( ! found ) { missingParams [ size ++ ] = parameter . name ; } } if ( size > <NUM_LIT:0> ) { if ( size != typeParametersLength ) { System . arraycopy ( missingParams , <NUM_LIT:0> , missingParams = new char [ size ] [ ] , <NUM_LIT:0> , size ) ; } return missingParams ; } } return null ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; import org . eclipse . jdt . internal . compiler . ast . MemberValuePair ; public class CompletionOnMemberValueName extends MemberValuePair { public CompletionOnMemberValueName ( char [ ] token , int sourceStart , int sourceEnd ) { super ( token , sourceStart , sourceEnd , null ) ; } public StringBuffer print ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; output . append ( this . name ) ; output . append ( '<CHAR_LIT:>>' ) ; return output ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . complete ; public interface CompletionOnJavadoc { int JAVADOC = <NUM_LIT> ; int EXCEPTION = <NUM_LIT> ; int TEXT = <NUM_LIT> ; int BASE_TYPES = <NUM_LIT> ; int ONLY_INLINE_TAG = <NUM_LIT> ; int REPLACE_TAG = <NUM_LIT> ; int FORMAL_REFERENCE = <NUM_LIT> ; int ALL_POSSIBLE_TAGS = <NUM_LIT> ; public int getCompletionFlags ( ) ; public void addCompletionFlags ( int flags ) ; } </s>
|
<s> package org . eclipse . jdt . internal . codeassist ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . CompletionContext ; import org . eclipse . jdt . core . CompletionFlags ; import org . eclipse . jdt . core . CompletionProposal ; import org . eclipse . jdt . core . CompletionRequestor ; import org . eclipse . jdt . core . Flags ; import org . eclipse . jdt . core . IAccessRule ; import org . eclipse . jdt . core . ICodeAssist ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . IPackageFragmentRoot ; 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 . env . IBinaryType ; import org . eclipse . jdt . internal . core . BinaryType ; import org . eclipse . jdt . internal . core . JavaElement ; import org . eclipse . jdt . internal . core . JavaModelManager ; import org . eclipse . jdt . internal . core . NameLookup ; import org . eclipse . jdt . internal . core . SourceMapper ; public class InternalCompletionProposal extends CompletionProposal { private static Object NO_ATTACHED_SOURCE = new Object ( ) ; protected CompletionEngine completionEngine ; protected NameLookup nameLookup ; protected char [ ] declarationPackageName ; protected char [ ] declarationTypeName ; protected char [ ] packageName ; protected char [ ] typeName ; protected char [ ] [ ] parameterPackageNames ; protected char [ ] [ ] parameterTypeNames ; protected char [ ] originalSignature ; private boolean hasNoParameterNamesFromIndex = false ; private boolean updateCompletion = false ; protected int accessibility = IAccessRule . K_ACCESSIBLE ; protected boolean isConstructor = false ; private int completionKind ; private int completionLocation ; private int tokenStart = <NUM_LIT:0> ; private int tokenEnd = <NUM_LIT:0> ; private char [ ] completion = CharOperation . NO_CHAR ; private int replaceStart = <NUM_LIT:0> ; private int replaceEnd = <NUM_LIT:0> ; private int relevance = <NUM_LIT:1> ; private char [ ] declarationSignature = null ; private char [ ] declarationKey = null ; private char [ ] name = null ; private char [ ] signature = null ; private char [ ] key = null ; private CompletionProposal [ ] requiredProposals ; private int flags = Flags . AccDefault ; private int additionalFlags = CompletionFlags . Default ; private char [ ] [ ] parameterNames = null ; private boolean parameterNamesComputed = false ; protected char [ ] [ ] findConstructorParameterNames ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] selector , char [ ] [ ] paramTypeNames ) { if ( paramTypeNames == null || declaringTypeName == null ) return null ; char [ ] [ ] parameters = null ; int length = paramTypeNames . length ; char [ ] tName = CharOperation . concat ( declaringTypePackageName , declaringTypeName , '<CHAR_LIT:.>' ) ; Object cachedType = this . completionEngine . typeCache . get ( tName ) ; IType type = null ; if ( cachedType != null ) { if ( cachedType != NO_ATTACHED_SOURCE && cachedType instanceof BinaryType ) { type = ( BinaryType ) cachedType ; } } else { NameLookup . Answer answer = this . nameLookup . findType ( new String ( declaringTypeName ) , new String ( declaringTypePackageName ) , false , NameLookup . ACCEPT_CLASSES & NameLookup . ACCEPT_INTERFACES , true , false , false , null ) ; type = answer == null ? null : answer . type ; if ( type instanceof BinaryType ) { this . completionEngine . typeCache . put ( tName , type ) ; } else { type = null ; } } if ( type != null ) { try { IMethod method = findMethod ( type , selector , paramTypeNames ) ; if ( this . hasNoParameterNamesFromIndex ) { IPackageFragmentRoot packageFragmentRoot = ( IPackageFragmentRoot ) type . getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; if ( packageFragmentRoot . isArchive ( ) || this . completionEngine . openedBinaryTypes < getOpenedBinaryTypesThreshold ( ) ) { SourceMapper mapper = ( ( JavaElement ) method ) . getSourceMapper ( ) ; if ( mapper != null ) { char [ ] [ ] paramNames = mapper . getMethodParameterNames ( method ) ; if ( paramNames == null ) { if ( ! packageFragmentRoot . isArchive ( ) ) this . completionEngine . openedBinaryTypes ++ ; IBinaryType info = ( IBinaryType ) ( ( BinaryType ) type ) . getElementInfo ( ) ; char [ ] source = mapper . findSource ( type , info ) ; if ( source != null ) { mapper . mapSource ( type , source , info ) ; } paramNames = mapper . getMethodParameterNames ( method ) ; } if ( paramNames != null ) { parameters = paramNames ; } } } } else { IBinaryMethod info = ( IBinaryMethod ) ( ( JavaElement ) method ) . getElementInfo ( ) ; char [ ] [ ] argumentNames = info . getArgumentNames ( ) ; if ( argumentNames != null && argumentNames . length == length ) { parameters = argumentNames ; return parameters ; } parameters = new char [ length ] [ ] ; String [ ] params = method . getParameterNames ( ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { parameters [ i ] = params [ i ] . toCharArray ( ) ; } } } catch ( JavaModelException e ) { parameters = null ; } } if ( parameters == null ) { parameters = CompletionEngine . createDefaultParameterNames ( length ) ; } return parameters ; } protected char [ ] [ ] findMethodParameterNames ( char [ ] declaringTypePackageName , char [ ] declaringTypeName , char [ ] selector , char [ ] [ ] paramTypeNames ) { if ( paramTypeNames == null || declaringTypeName == null ) return null ; char [ ] [ ] parameters = null ; int length = paramTypeNames . length ; char [ ] tName = CharOperation . concat ( declaringTypePackageName , declaringTypeName , '<CHAR_LIT:.>' ) ; Object cachedType = this . completionEngine . typeCache . get ( tName ) ; IType type = null ; if ( cachedType != null ) { if ( cachedType != NO_ATTACHED_SOURCE && cachedType instanceof BinaryType ) { type = ( BinaryType ) cachedType ; } } else { NameLookup . Answer answer = this . nameLookup . findType ( new String ( declaringTypeName ) , new String ( declaringTypePackageName ) , false , NameLookup . ACCEPT_CLASSES & NameLookup . ACCEPT_INTERFACES , true , false , false , null ) ; type = answer == null ? null : answer . type ; if ( type instanceof BinaryType ) { this . completionEngine . typeCache . put ( tName , type ) ; } else { type = null ; } } if ( type != null ) { try { IMethod method = findMethod ( type , selector , paramTypeNames ) ; parameters = new char [ length ] [ ] ; String [ ] params = method . getParameterNames ( ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { parameters [ i ] = params [ i ] . toCharArray ( ) ; } } catch ( JavaModelException e ) { parameters = null ; } } if ( parameters == null ) { parameters = CompletionEngine . createDefaultParameterNames ( length ) ; } return parameters ; } private IMethod findMethod ( IType type , char [ ] selector , char [ ] [ ] paramTypeNames ) throws JavaModelException { IMethod method = null ; int startingIndex = <NUM_LIT:0> ; String [ ] args ; IType enclosingType = type . getDeclaringType ( ) ; if ( enclosingType != null && CharOperation . equals ( type . getElementName ( ) . toCharArray ( ) , selector ) && ! Flags . isStatic ( type . getFlags ( ) ) ) { args = new String [ paramTypeNames . length + <NUM_LIT:1> ] ; startingIndex = <NUM_LIT:1> ; args [ <NUM_LIT:0> ] = Signature . createTypeSignature ( enclosingType . getFullyQualifiedName ( ) , true ) ; } else { args = new String [ paramTypeNames . length ] ; } int length = args . length ; for ( int i = startingIndex ; i < length ; i ++ ) { args [ i ] = new String ( paramTypeNames [ 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 ; } protected char [ ] getDeclarationPackageName ( ) { return this . declarationPackageName ; } protected char [ ] getDeclarationTypeName ( ) { return this . declarationTypeName ; } private int getOpenedBinaryTypesThreshold ( ) { return JavaModelManager . getJavaModelManager ( ) . getOpenableCacheSize ( ) / <NUM_LIT:10> ; } protected char [ ] getPackageName ( ) { return this . packageName ; } protected char [ ] getTypeName ( ) { return this . typeName ; } protected char [ ] [ ] getParameterPackageNames ( ) { return this . parameterPackageNames ; } protected char [ ] [ ] getParameterTypeNames ( ) { return this . parameterTypeNames ; } protected void setDeclarationPackageName ( char [ ] declarationPackageName ) { this . declarationPackageName = declarationPackageName ; } protected void setDeclarationTypeName ( char [ ] declarationTypeName ) { this . declarationTypeName = declarationTypeName ; } protected void setPackageName ( char [ ] packageName ) { this . packageName = packageName ; } protected void setTypeName ( char [ ] typeName ) { this . typeName = typeName ; } protected void setParameterPackageNames ( char [ ] [ ] parameterPackageNames ) { this . parameterPackageNames = parameterPackageNames ; } protected void setParameterTypeNames ( char [ ] [ ] parameterTypeNames ) { this . parameterTypeNames = parameterTypeNames ; } protected void setAccessibility ( int kind ) { this . accessibility = kind ; } protected void setIsContructor ( boolean isConstructor ) { this . isConstructor = isConstructor ; } public void setOriginalSignature ( char [ ] originalSignature ) { this . originalSignature = originalSignature ; } public InternalCompletionProposal ( int kind , int completionLocation ) { if ( ( kind < FIRST_KIND ) || ( kind > LAST_KIND ) ) { throw new IllegalArgumentException ( ) ; } if ( this . completion == null || completionLocation < <NUM_LIT:0> ) { if ( this . completion == null || completionLocation != - <NUM_LIT:1> ) { throw new IllegalArgumentException ( ) ; } completionLocation = <NUM_LIT:0> ; } this . completionKind = kind ; this . completionLocation = completionLocation ; } public int getAdditionalFlags ( ) { return this . additionalFlags ; } public void setAdditionalFlags ( int additionalFlags ) { this . additionalFlags = additionalFlags ; } public int getKind ( ) { return this . completionKind ; } public int getCompletionLocation ( ) { return this . completionLocation ; } public int getTokenStart ( ) { return this . tokenStart ; } public int getTokenEnd ( ) { return this . tokenEnd ; } public void setTokenRange ( int startIndex , int endIndex ) { if ( startIndex < <NUM_LIT:0> || endIndex < startIndex ) { throw new IllegalArgumentException ( ) ; } this . tokenStart = startIndex ; this . tokenEnd = endIndex ; } public char [ ] getCompletion ( ) { if ( this . completionKind == METHOD_DECLARATION ) { findParameterNames ( null ) ; if ( this . updateCompletion ) { this . updateCompletion = false ; if ( this . parameterNames != null ) { int length = this . parameterNames . length ; StringBuffer completionBuffer = new StringBuffer ( this . completion . length ) ; int start = <NUM_LIT:0> ; int end = CharOperation . indexOf ( '<CHAR_LIT>' , this . completion ) ; completionBuffer . append ( this . completion , start , end - start ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { completionBuffer . append ( this . parameterNames [ i ] ) ; start = end + <NUM_LIT:1> ; end = CharOperation . indexOf ( '<CHAR_LIT>' , this . completion , start ) ; if ( end > - <NUM_LIT:1> ) { completionBuffer . append ( this . completion , start , end - start ) ; } else { completionBuffer . append ( this . completion , start , this . completion . length - start ) ; } } int nameLength = completionBuffer . length ( ) ; this . completion = new char [ nameLength ] ; completionBuffer . getChars ( <NUM_LIT:0> , nameLength , this . completion , <NUM_LIT:0> ) ; } } } return this . completion ; } public void setCompletion ( char [ ] completion ) { this . completion = completion ; } public int getReplaceStart ( ) { return this . replaceStart ; } public int getReplaceEnd ( ) { return this . replaceEnd ; } public void setReplaceRange ( int startIndex , int endIndex ) { if ( startIndex < <NUM_LIT:0> || endIndex < startIndex ) { throw new IllegalArgumentException ( ) ; } this . replaceStart = startIndex ; this . replaceEnd = endIndex ; } public int getRelevance ( ) { return this . relevance ; } public void setRelevance ( int rating ) { if ( rating <= <NUM_LIT:0> ) { throw new IllegalArgumentException ( ) ; } this . relevance = rating ; } public char [ ] getDeclarationSignature ( ) { return this . declarationSignature ; } public char [ ] getDeclarationKey ( ) { return this . declarationKey ; } public void setDeclarationSignature ( char [ ] signature ) { this . declarationSignature = signature ; } public void setDeclarationKey ( char [ ] key ) { this . declarationKey = key ; } public char [ ] getName ( ) { return this . name ; } public void setName ( char [ ] name ) { this . name = name ; } public char [ ] getSignature ( ) { return this . signature ; } public char [ ] getKey ( ) { return this . key ; } public void setSignature ( char [ ] signature ) { this . signature = signature ; } public void setKey ( char [ ] key ) { this . key = key ; } public int getFlags ( ) { return this . flags ; } public void setFlags ( int flags ) { this . flags = flags ; } public void setHasNoParameterNamesFromIndex ( boolean hasNoParameterNamesFromIndex ) { this . hasNoParameterNamesFromIndex = hasNoParameterNamesFromIndex ; } public CompletionProposal [ ] getRequiredProposals ( ) { return this . requiredProposals ; } public void setRequiredProposals ( CompletionProposal [ ] proposals ) { this . requiredProposals = proposals ; } public char [ ] [ ] findParameterNames ( IProgressMonitor monitor ) { if ( ! this . parameterNamesComputed ) { this . parameterNamesComputed = true ; switch ( this . completionKind ) { case ANONYMOUS_CLASS_DECLARATION : try { this . parameterNames = findMethodParameterNames ( this . declarationPackageName , this . declarationTypeName , CharOperation . lastSegment ( this . declarationTypeName , '<CHAR_LIT:.>' ) , Signature . getParameterTypes ( this . originalSignature == null ? this . signature : this . originalSignature ) ) ; } catch ( IllegalArgumentException e ) { if ( this . parameterTypeNames != null ) { this . parameterNames = CompletionEngine . createDefaultParameterNames ( this . parameterTypeNames . length ) ; } else { this . parameterNames = null ; } } break ; case ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION : try { this . parameterNames = findConstructorParameterNames ( this . declarationPackageName , this . declarationTypeName , CharOperation . lastSegment ( this . declarationTypeName , '<CHAR_LIT:.>' ) , Signature . getParameterTypes ( this . originalSignature == null ? this . signature : this . originalSignature ) ) ; } catch ( IllegalArgumentException e ) { if ( this . parameterTypeNames != null ) { this . parameterNames = CompletionEngine . createDefaultParameterNames ( this . parameterTypeNames . length ) ; } else { this . parameterNames = null ; } } break ; case METHOD_REF : case METHOD_REF_WITH_CASTED_RECEIVER : try { this . parameterNames = findMethodParameterNames ( this . declarationPackageName , this . declarationTypeName , this . name , Signature . getParameterTypes ( this . originalSignature == null ? this . signature : this . originalSignature ) ) ; } catch ( IllegalArgumentException e ) { if ( this . parameterTypeNames != null ) { this . parameterNames = CompletionEngine . createDefaultParameterNames ( this . parameterTypeNames . length ) ; } else { this . parameterNames = null ; } } break ; case CONSTRUCTOR_INVOCATION : try { this . parameterNames = findConstructorParameterNames ( this . declarationPackageName , this . declarationTypeName , this . name , Signature . getParameterTypes ( this . originalSignature == null ? this . signature : this . originalSignature ) ) ; } catch ( IllegalArgumentException e ) { if ( this . parameterTypeNames != null ) { this . parameterNames = CompletionEngine . createDefaultParameterNames ( this . parameterTypeNames . length ) ; } else { this . parameterNames = null ; } } break ; case METHOD_DECLARATION : try { this . parameterNames = findMethodParameterNames ( this . declarationPackageName , this . declarationTypeName , this . name , Signature . getParameterTypes ( this . originalSignature == null ? this . signature : this . originalSignature ) ) ; } catch ( IllegalArgumentException e ) { if ( this . parameterTypeNames != null ) { this . parameterNames = CompletionEngine . createDefaultParameterNames ( this . parameterTypeNames . length ) ; } else { this . parameterNames = null ; } } if ( this . parameterNames != null ) { this . updateCompletion = true ; } break ; } } return this . parameterNames ; } public void setParameterNames ( char [ ] [ ] parameterNames ) { this . parameterNames = parameterNames ; this . parameterNamesComputed = true ; } public int getAccessibility ( ) { return this . accessibility ; } public boolean isConstructor ( ) { return this . isConstructor ; } private int receiverStart ; private int receiverEnd ; private char [ ] receiverSignature ; public char [ ] getReceiverSignature ( ) { return this . receiverSignature ; } public int getReceiverStart ( ) { return this . receiverStart ; } public int getReceiverEnd ( ) { return this . receiverEnd ; } public void setReceiverSignature ( char [ ] signature ) { this . receiverSignature = signature ; } public void setReceiverRange ( int startIndex , int endIndex ) { this . receiverStart = startIndex ; this . receiverEnd = endIndex ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( '<CHAR_LIT:[>' ) ; switch ( this . completionKind ) { case CompletionProposal . ANONYMOUS_CLASS_DECLARATION : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . FIELD_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . KEYWORD : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . LABEL_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . LOCAL_VARIABLE_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . METHOD_DECLARATION : buffer . append ( "<STR_LIT>" ) ; if ( this . isConstructor ) { buffer . append ( "<STR_LIT>" ) ; } break ; case CompletionProposal . METHOD_REF : buffer . append ( "<STR_LIT>" ) ; if ( this . isConstructor ) { buffer . append ( "<STR_LIT>" ) ; } break ; case CompletionProposal . PACKAGE_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . TYPE_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . VARIABLE_DECLARATION : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . POTENTIAL_METHOD_DECLARATION : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . METHOD_NAME_REFERENCE : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . ANNOTATION_ATTRIBUTE_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . JAVADOC_BLOCK_TAG : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . JAVADOC_INLINE_TAG : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . JAVADOC_FIELD_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . JAVADOC_METHOD_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . JAVADOC_TYPE_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . JAVADOC_PARAM_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . JAVADOC_VALUE_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . FIELD_IMPORT : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . METHOD_IMPORT : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . TYPE_IMPORT : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . METHOD_REF_WITH_CASTED_RECEIVER : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . FIELD_REF_WITH_CASTED_RECEIVER : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . CONSTRUCTOR_INVOCATION : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION : buffer . append ( "<STR_LIT>" ) ; break ; default : buffer . append ( "<STR_LIT>" ) ; break ; } buffer . append ( "<STR_LIT>" ) ; if ( this . completion != null ) buffer . append ( this . completion ) ; buffer . append ( "<STR_LIT>" ) ; if ( this . declarationSignature != null ) buffer . append ( this . declarationSignature ) ; buffer . append ( "<STR_LIT>" ) ; if ( this . signature != null ) buffer . append ( this . signature ) ; buffer . append ( "<STR_LIT>" ) ; if ( this . declarationKey != null ) buffer . append ( this . declarationKey ) ; buffer . append ( "<STR_LIT>" ) ; if ( this . key != null ) buffer . append ( this . key ) ; buffer . append ( "<STR_LIT>" ) ; if ( this . name != null ) buffer . append ( this . name ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . replaceStart ) ; buffer . append ( '<CHAR_LIT:U+002C>' ) ; buffer . append ( this . replaceEnd ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . tokenStart ) ; buffer . append ( '<CHAR_LIT:U+002C>' ) ; buffer . append ( this . tokenEnd ) ; buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . relevance ) ; buffer . append ( '<CHAR_LIT:}>' ) ; return buffer . toString ( ) ; } public boolean canUseDiamond ( CompletionContext coreContext ) { if ( this . getKind ( ) != CONSTRUCTOR_INVOCATION ) return false ; if ( coreContext instanceof InternalCompletionContext ) { InternalCompletionContext internalCompletionContext = ( InternalCompletionContext ) coreContext ; if ( internalCompletionContext . extendedContext == null ) return false ; char [ ] name1 = this . declarationPackageName ; char [ ] name2 = this . declarationTypeName ; char [ ] declarationType = CharOperation . concat ( name1 , name2 , '<CHAR_LIT:.>' ) ; char [ ] sign = ( this . originalSignature != null ) ? this . originalSignature : getSignature ( ) ; if ( ! ( sign == null || sign . length < <NUM_LIT:2> ) ) { sign = Signature . removeCapture ( sign ) ; } char [ ] [ ] types = Signature . getParameterTypes ( sign ) ; String [ ] paramTypeNames = new String [ types . length ] ; for ( int i = <NUM_LIT:0> ; i < types . length ; i ++ ) { paramTypeNames [ i ] = new String ( Signature . toCharArray ( types [ i ] ) ) ; } return internalCompletionContext . extendedContext . canUseDiamond ( paramTypeNames , declarationType ) ; } else { return false ; } } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist ; import org . eclipse . jdt . core . CompletionProposal ; import org . eclipse . jdt . core . CompletionRequestor ; import org . eclipse . jdt . core . Flags ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . IProblem ; public class CompletionRequestorWrapper extends CompletionRequestor { private static boolean DECODE_SIGNATURE = false ; private org . eclipse . jdt . core . ICompletionRequestor requestor ; public CompletionRequestorWrapper ( org . eclipse . jdt . core . ICompletionRequestor requestor ) { this . requestor = requestor ; } public void accept ( CompletionProposal proposal ) { InternalCompletionProposal internalCompletionProposal = ( InternalCompletionProposal ) proposal ; switch ( internalCompletionProposal . getKind ( ) ) { case CompletionProposal . KEYWORD : this . requestor . acceptKeyword ( internalCompletionProposal . getName ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; break ; case CompletionProposal . PACKAGE_REF : if ( DECODE_SIGNATURE ) { this . requestor . acceptPackage ( internalCompletionProposal . getDeclarationSignature ( ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } else { this . requestor . acceptPackage ( internalCompletionProposal . getPackageName ( ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } break ; case CompletionProposal . TYPE_REF : if ( ( internalCompletionProposal . getFlags ( ) & Flags . AccEnum ) != <NUM_LIT:0> ) { } else if ( ( internalCompletionProposal . getFlags ( ) & Flags . AccInterface ) != <NUM_LIT:0> ) { if ( DECODE_SIGNATURE ) { this . requestor . acceptInterface ( internalCompletionProposal . getDeclarationSignature ( ) , Signature . getSignatureSimpleName ( internalCompletionProposal . getSignature ( ) ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getFlags ( ) & ~ Flags . AccInterface , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } else { this . requestor . acceptInterface ( internalCompletionProposal . getPackageName ( ) == null ? CharOperation . NO_CHAR : internalCompletionProposal . getPackageName ( ) , internalCompletionProposal . getTypeName ( ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getFlags ( ) & ~ Flags . AccInterface , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } } else { if ( DECODE_SIGNATURE ) { this . requestor . acceptClass ( internalCompletionProposal . getDeclarationSignature ( ) , Signature . getSignatureSimpleName ( internalCompletionProposal . getSignature ( ) ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } else { this . requestor . acceptClass ( internalCompletionProposal . getPackageName ( ) == null ? CharOperation . NO_CHAR : internalCompletionProposal . getPackageName ( ) , internalCompletionProposal . getTypeName ( ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } } break ; case CompletionProposal . FIELD_REF : if ( DECODE_SIGNATURE ) { this . requestor . acceptField ( Signature . getSignatureQualifier ( internalCompletionProposal . getDeclarationSignature ( ) ) , Signature . getSignatureSimpleName ( internalCompletionProposal . getDeclarationSignature ( ) ) , internalCompletionProposal . getName ( ) , Signature . getSignatureQualifier ( internalCompletionProposal . getSignature ( ) ) , Signature . getSignatureSimpleName ( internalCompletionProposal . getSignature ( ) ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } else { this . requestor . acceptField ( internalCompletionProposal . getDeclarationPackageName ( ) == null ? CharOperation . NO_CHAR : internalCompletionProposal . getDeclarationPackageName ( ) , internalCompletionProposal . getDeclarationTypeName ( ) == null ? CharOperation . NO_CHAR : internalCompletionProposal . getDeclarationTypeName ( ) , internalCompletionProposal . getName ( ) , internalCompletionProposal . getPackageName ( ) == null ? CharOperation . NO_CHAR : internalCompletionProposal . getPackageName ( ) , internalCompletionProposal . getTypeName ( ) == null ? CharOperation . NO_CHAR : internalCompletionProposal . getTypeName ( ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } break ; case CompletionProposal . METHOD_REF : if ( DECODE_SIGNATURE ) { this . requestor . acceptMethod ( Signature . getSignatureQualifier ( internalCompletionProposal . getDeclarationSignature ( ) ) , Signature . getSignatureSimpleName ( internalCompletionProposal . getDeclarationSignature ( ) ) , internalCompletionProposal . getName ( ) , getParameterPackages ( internalCompletionProposal . getSignature ( ) ) , getParameterTypes ( internalCompletionProposal . getSignature ( ) ) , internalCompletionProposal . findParameterNames ( null ) == null ? CharOperation . NO_CHAR_CHAR : internalCompletionProposal . findParameterNames ( null ) , Signature . getSignatureQualifier ( Signature . getReturnType ( internalCompletionProposal . getSignature ( ) ) ) , Signature . getSignatureSimpleName ( Signature . getReturnType ( internalCompletionProposal . getSignature ( ) ) ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } else { this . requestor . acceptMethod ( internalCompletionProposal . getDeclarationPackageName ( ) == null ? CharOperation . NO_CHAR : internalCompletionProposal . getDeclarationPackageName ( ) , internalCompletionProposal . getDeclarationTypeName ( ) == null ? CharOperation . NO_CHAR : internalCompletionProposal . getDeclarationTypeName ( ) , internalCompletionProposal . getName ( ) , internalCompletionProposal . getParameterPackageNames ( ) == null ? CharOperation . NO_CHAR_CHAR : internalCompletionProposal . getParameterPackageNames ( ) , internalCompletionProposal . getParameterTypeNames ( ) == null ? CharOperation . NO_CHAR_CHAR : internalCompletionProposal . getParameterTypeNames ( ) , internalCompletionProposal . findParameterNames ( null ) == null ? CharOperation . NO_CHAR_CHAR : internalCompletionProposal . findParameterNames ( null ) , internalCompletionProposal . getPackageName ( ) == null ? CharOperation . NO_CHAR : internalCompletionProposal . getPackageName ( ) , internalCompletionProposal . getTypeName ( ) == null ? CharOperation . NO_CHAR : internalCompletionProposal . getTypeName ( ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } break ; case CompletionProposal . METHOD_DECLARATION : if ( DECODE_SIGNATURE ) { this . requestor . acceptMethodDeclaration ( Signature . getSignatureQualifier ( internalCompletionProposal . getDeclarationSignature ( ) ) , Signature . getSignatureSimpleName ( internalCompletionProposal . getDeclarationSignature ( ) ) , internalCompletionProposal . getName ( ) , getParameterPackages ( internalCompletionProposal . getSignature ( ) ) , getParameterTypes ( internalCompletionProposal . getSignature ( ) ) , internalCompletionProposal . findParameterNames ( null ) == null ? CharOperation . NO_CHAR_CHAR : internalCompletionProposal . findParameterNames ( null ) , Signature . getSignatureQualifier ( Signature . getReturnType ( internalCompletionProposal . getSignature ( ) ) ) , Signature . getSignatureSimpleName ( Signature . getReturnType ( internalCompletionProposal . getSignature ( ) ) ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } else { this . requestor . acceptMethodDeclaration ( internalCompletionProposal . getDeclarationPackageName ( ) , internalCompletionProposal . getDeclarationTypeName ( ) , internalCompletionProposal . getName ( ) , internalCompletionProposal . getParameterPackageNames ( ) == null ? CharOperation . NO_CHAR_CHAR : internalCompletionProposal . getParameterPackageNames ( ) , internalCompletionProposal . getParameterTypeNames ( ) == null ? CharOperation . NO_CHAR_CHAR : internalCompletionProposal . getParameterTypeNames ( ) , internalCompletionProposal . findParameterNames ( null ) == null ? CharOperation . NO_CHAR_CHAR : internalCompletionProposal . findParameterNames ( null ) , internalCompletionProposal . getPackageName ( ) , internalCompletionProposal . getTypeName ( ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } break ; case CompletionProposal . ANONYMOUS_CLASS_DECLARATION : if ( DECODE_SIGNATURE ) { this . requestor . acceptAnonymousType ( Signature . getSignatureQualifier ( internalCompletionProposal . getDeclarationSignature ( ) ) , Signature . getSignatureSimpleName ( internalCompletionProposal . getDeclarationSignature ( ) ) , getParameterPackages ( internalCompletionProposal . getSignature ( ) ) , getParameterTypes ( internalCompletionProposal . getSignature ( ) ) , internalCompletionProposal . findParameterNames ( null ) == null ? CharOperation . NO_CHAR_CHAR : internalCompletionProposal . findParameterNames ( null ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } else { this . requestor . acceptAnonymousType ( internalCompletionProposal . getDeclarationPackageName ( ) , internalCompletionProposal . getDeclarationTypeName ( ) , internalCompletionProposal . getParameterPackageNames ( ) == null ? CharOperation . NO_CHAR_CHAR : internalCompletionProposal . getParameterPackageNames ( ) , internalCompletionProposal . getParameterTypeNames ( ) == null ? CharOperation . NO_CHAR_CHAR : internalCompletionProposal . getParameterTypeNames ( ) , internalCompletionProposal . findParameterNames ( null ) == null ? CharOperation . NO_CHAR_CHAR : internalCompletionProposal . findParameterNames ( null ) , internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } break ; case CompletionProposal . LABEL_REF : this . requestor . acceptLabel ( internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; break ; case CompletionProposal . LOCAL_VARIABLE_REF : if ( DECODE_SIGNATURE ) { this . requestor . acceptLocalVariable ( internalCompletionProposal . getCompletion ( ) , Signature . getSignatureQualifier ( internalCompletionProposal . getSignature ( ) ) , Signature . getSignatureSimpleName ( internalCompletionProposal . getSignature ( ) ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } else { this . requestor . acceptLocalVariable ( internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getPackageName ( ) == null ? CharOperation . NO_CHAR : internalCompletionProposal . getPackageName ( ) , internalCompletionProposal . getTypeName ( ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } break ; case CompletionProposal . VARIABLE_DECLARATION : if ( DECODE_SIGNATURE ) { this . requestor . acceptLocalVariable ( internalCompletionProposal . getCompletion ( ) , Signature . getSignatureQualifier ( internalCompletionProposal . getSignature ( ) ) , Signature . getSignatureSimpleName ( internalCompletionProposal . getSignature ( ) ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } else { this . requestor . acceptLocalVariable ( internalCompletionProposal . getCompletion ( ) , internalCompletionProposal . getPackageName ( ) , internalCompletionProposal . getTypeName ( ) , internalCompletionProposal . getFlags ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } break ; case CompletionProposal . POTENTIAL_METHOD_DECLARATION : if ( this . requestor instanceof IExtendedCompletionRequestor ) { IExtendedCompletionRequestor r = ( IExtendedCompletionRequestor ) this . requestor ; if ( DECODE_SIGNATURE ) { r . acceptPotentialMethodDeclaration ( Signature . getSignatureQualifier ( internalCompletionProposal . getDeclarationSignature ( ) ) , Signature . getSignatureSimpleName ( internalCompletionProposal . getDeclarationSignature ( ) ) , internalCompletionProposal . getName ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } else { r . acceptPotentialMethodDeclaration ( internalCompletionProposal . getDeclarationPackageName ( ) , internalCompletionProposal . getDeclarationTypeName ( ) , internalCompletionProposal . getName ( ) , internalCompletionProposal . getReplaceStart ( ) , internalCompletionProposal . getReplaceEnd ( ) , internalCompletionProposal . getRelevance ( ) ) ; } } break ; } } public void completionFailure ( IProblem problem ) { this . requestor . acceptError ( problem ) ; } private char [ ] [ ] getParameterPackages ( char [ ] methodSignature ) { char [ ] [ ] parameterQualifiedTypes = Signature . getParameterTypes ( methodSignature ) ; int length = parameterQualifiedTypes == null ? <NUM_LIT:0> : parameterQualifiedTypes . length ; char [ ] [ ] parameterPackages = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { parameterPackages [ i ] = Signature . getSignatureQualifier ( parameterQualifiedTypes [ i ] ) ; } return parameterPackages ; } private char [ ] [ ] getParameterTypes ( char [ ] methodSignature ) { char [ ] [ ] parameterQualifiedTypes = Signature . getParameterTypes ( methodSignature ) ; int length = parameterQualifiedTypes == null ? <NUM_LIT:0> : parameterQualifiedTypes . length ; char [ ] [ ] parameterPackages = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { parameterPackages [ i ] = Signature . getSignatureSimpleName ( parameterQualifiedTypes [ i ] ) ; } return parameterPackages ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist ; import java . util . ArrayList ; import java . util . Locale ; import java . util . Map ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . jdt . core . CompletionContext ; import org . eclipse . jdt . core . CompletionFlags ; import org . eclipse . jdt . core . CompletionProposal ; import org . eclipse . jdt . core . CompletionRequestor ; import org . eclipse . jdt . core . Flags ; import org . eclipse . jdt . core . IAccessRule ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . ITypeRoot ; 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 . core . compiler . IProblem ; import org . eclipse . jdt . core . search . IJavaSearchConstants ; import org . eclipse . jdt . internal . codeassist . complete . * ; import org . eclipse . jdt . internal . codeassist . impl . AssistParser ; import org . eclipse . jdt . internal . codeassist . impl . Engine ; import org . eclipse . jdt . internal . codeassist . impl . Keywords ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . DefaultErrorHandlingPolicies ; import org . eclipse . jdt . internal . compiler . ExtraFlags ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . env . * ; import org . eclipse . jdt . internal . compiler . impl . ReferenceContext ; import org . eclipse . jdt . internal . compiler . lookup . * ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . parser . SourceTypeConverter ; import org . eclipse . jdt . internal . compiler . parser . JavadocTagConstants ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . compiler . problem . DefaultProblemFactory ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . compiler . problem . ProblemSeverities ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObject ; import org . eclipse . jdt . internal . compiler . util . ObjectVector ; import org . eclipse . jdt . internal . core . BasicCompilationUnit ; import org . eclipse . jdt . internal . core . INamingRequestor ; import org . eclipse . jdt . internal . core . InternalNamingConventions ; import org . eclipse . jdt . internal . core . JavaModelManager ; import org . eclipse . jdt . internal . core . SourceMethod ; import org . eclipse . jdt . internal . core . SourceMethodElementInfo ; import org . eclipse . jdt . internal . core . SourceType ; import org . eclipse . jdt . internal . core . BinaryTypeConverter ; import org . eclipse . jdt . internal . core . SearchableEnvironment ; import org . eclipse . jdt . internal . core . SourceTypeElementInfo ; import org . eclipse . jdt . internal . core . search . matching . JavaSearchNameEnvironment ; import org . eclipse . jdt . internal . core . util . Messages ; public final class CompletionEngine extends Engine implements ISearchRequestor , TypeConstants , TerminalTokens , RelevanceConstants , SuffixConstants { private static class AcceptedConstructor { public int modifiers ; public char [ ] simpleTypeName ; public int parameterCount ; public char [ ] signature ; public char [ ] [ ] parameterTypes ; public char [ ] [ ] parameterNames ; public int typeModifiers ; public char [ ] packageName ; public int extraFlags ; public int accessibility ; public boolean proposeType = false ; public boolean proposeConstructor = false ; public char [ ] fullyQualifiedName = null ; public boolean mustBeQualified = false ; public AcceptedConstructor ( int modifiers , char [ ] simpleTypeName , int parameterCount , char [ ] signature , char [ ] [ ] parameterTypes , char [ ] [ ] parameterNames , int typeModifiers , char [ ] packageName , int extraFlags , int accessibility ) { this . modifiers = modifiers ; this . simpleTypeName = simpleTypeName ; this . parameterCount = parameterCount ; this . signature = signature ; this . parameterTypes = parameterTypes ; this . parameterNames = parameterNames ; this . typeModifiers = typeModifiers ; this . packageName = packageName ; this . extraFlags = extraFlags ; this . accessibility = accessibility ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( '<CHAR_LIT>' ) ; buffer . append ( this . packageName ) ; buffer . append ( '<CHAR_LIT:U+002C>' ) ; buffer . append ( this . simpleTypeName ) ; buffer . append ( '<CHAR_LIT:}>' ) ; return buffer . toString ( ) ; } } private static class AcceptedType { public char [ ] packageName ; public char [ ] simpleTypeName ; public char [ ] [ ] enclosingTypeNames ; public int modifiers ; public int accessibility ; public boolean mustBeQualified = false ; public char [ ] fullyQualifiedName = null ; public char [ ] qualifiedTypeName = null ; public AcceptedType ( char [ ] packageName , char [ ] simpleTypeName , char [ ] [ ] enclosingTypeNames , int modifiers , int accessibility ) { this . packageName = packageName ; this . simpleTypeName = simpleTypeName ; this . enclosingTypeNames = enclosingTypeNames ; this . modifiers = modifiers ; this . accessibility = accessibility ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( '<CHAR_LIT>' ) ; buffer . append ( this . packageName ) ; buffer . append ( '<CHAR_LIT:U+002C>' ) ; buffer . append ( this . simpleTypeName ) ; buffer . append ( '<CHAR_LIT:U+002C>' ) ; buffer . append ( CharOperation . concatWith ( this . enclosingTypeNames , '<CHAR_LIT:.>' ) ) ; buffer . append ( '<CHAR_LIT:}>' ) ; return buffer . toString ( ) ; } } public class CompletionProblemFactory extends DefaultProblemFactory { private int lastErrorStart ; private boolean checkProblems = false ; public boolean hasForbiddenProblems = false ; public boolean hasAllowedProblems = false ; public CompletionProblemFactory ( Locale loc ) { super ( loc ) ; } private CategorizedProblem checkProblem ( CategorizedProblem pb , char [ ] originatingFileName , int severity , int start ) { int id = pb . getID ( ) ; if ( CompletionEngine . this . actualCompletionPosition > start && this . lastErrorStart < start && pb . isError ( ) && ( id & IProblem . Syntax ) == <NUM_LIT:0> && ( CompletionEngine . this . fileName == null || CharOperation . equals ( CompletionEngine . this . fileName , originatingFileName ) ) ) { CompletionEngine . this . problem = pb ; this . lastErrorStart = start ; } if ( this . checkProblems && ! this . hasForbiddenProblems ) { switch ( id ) { case IProblem . UsingDeprecatedType : this . hasForbiddenProblems = CompletionEngine . this . options . checkDeprecation ; break ; case IProblem . NotVisibleType : this . hasForbiddenProblems = CompletionEngine . this . options . checkVisibility ; break ; case IProblem . ForbiddenReference : this . hasForbiddenProblems = CompletionEngine . this . options . checkForbiddenReference ; break ; case IProblem . DiscouragedReference : this . hasForbiddenProblems = CompletionEngine . this . options . checkDiscouragedReference ; break ; default : if ( ( severity & ProblemSeverities . Optional ) != <NUM_LIT:0> ) { this . hasAllowedProblems = true ; } else { this . hasForbiddenProblems = true ; } break ; } } return pb ; } public CategorizedProblem createProblem ( char [ ] originatingFileName , int problemId , String [ ] problemArguments , int elaborationId , String [ ] messageArguments , int severity , int start , int end , int lineNumber , int columnNumber ) { return checkProblem ( super . createProblem ( originatingFileName , problemId , problemArguments , elaborationId , messageArguments , severity , start , end , lineNumber , columnNumber ) , originatingFileName , severity , start ) ; } public CategorizedProblem createProblem ( char [ ] originatingFileName , int problemId , String [ ] problemArguments , String [ ] messageArguments , int severity , int start , int end , int lineNumber , int columnNumber ) { return checkProblem ( super . createProblem ( originatingFileName , problemId , problemArguments , messageArguments , severity , start , end , lineNumber , columnNumber ) , originatingFileName , severity , start ) ; } public void startCheckingProblems ( ) { this . checkProblems = true ; this . hasForbiddenProblems = false ; this . hasAllowedProblems = false ; } public void stopCheckingProblems ( ) { this . checkProblems = false ; } } public static char [ ] createBindingKey ( char [ ] packageName , char [ ] typeName ) { char [ ] signature = createTypeSignature ( packageName , typeName ) ; CharOperation . replace ( signature , '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) ; return signature ; } public static char [ ] [ ] createDefaultParameterNames ( int length ) { char [ ] [ ] parameters ; switch ( length ) { case <NUM_LIT:0> : parameters = new char [ length ] [ ] ; break ; case <NUM_LIT:1> : parameters = ARGS1 ; break ; case <NUM_LIT:2> : parameters = ARGS2 ; break ; case <NUM_LIT:3> : parameters = ARGS3 ; break ; case <NUM_LIT:4> : parameters = ARGS4 ; break ; default : parameters = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { parameters [ i ] = CharOperation . concat ( ARG , String . valueOf ( i ) . toCharArray ( ) ) ; } break ; } return parameters ; } public static char [ ] createMethodSignature ( char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] returnTypeSignature ) { char [ ] [ ] parameterTypeSignature = new char [ parameterTypeNames . length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < parameterTypeSignature . length ; i ++ ) { parameterTypeSignature [ i ] = Signature . createCharArrayTypeSignature ( CharOperation . concat ( parameterPackageNames [ i ] , CharOperation . replaceOnCopy ( parameterTypeNames [ i ] , '<CHAR_LIT:.>' , '<CHAR_LIT>' ) , '<CHAR_LIT:.>' ) , true ) ; } return Signature . createMethodSignature ( parameterTypeSignature , returnTypeSignature ) ; } public static char [ ] createMethodSignature ( char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] returnPackagename , char [ ] returnTypeName ) { char [ ] returnTypeSignature = returnTypeName == null || returnTypeName . length == <NUM_LIT:0> ? Signature . createCharArrayTypeSignature ( VOID , true ) : Signature . createCharArrayTypeSignature ( CharOperation . concat ( returnPackagename , CharOperation . replaceOnCopy ( returnTypeName , '<CHAR_LIT:.>' , '<CHAR_LIT>' ) , '<CHAR_LIT:.>' ) , true ) ; return createMethodSignature ( parameterPackageNames , parameterTypeNames , returnTypeSignature ) ; } public static char [ ] createNonGenericTypeSignature ( char [ ] qualifiedPackageName , char [ ] qualifiedTypeName ) { return Signature . createCharArrayTypeSignature ( CharOperation . concat ( qualifiedPackageName , CharOperation . replaceOnCopy ( qualifiedTypeName , '<CHAR_LIT:.>' , '<CHAR_LIT>' ) , '<CHAR_LIT:.>' ) , true ) ; } public static char [ ] createTypeSignature ( char [ ] qualifiedPackageName , char [ ] qualifiedTypeName ) { char [ ] name = new char [ qualifiedTypeName . length ] ; System . arraycopy ( qualifiedTypeName , <NUM_LIT:0> , name , <NUM_LIT:0> , qualifiedTypeName . length ) ; int depth = <NUM_LIT:0> ; int length = name . length ; for ( int i = length - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { switch ( name [ i ] ) { case '<CHAR_LIT:.>' : if ( depth == <NUM_LIT:0> && name [ i - <NUM_LIT:1> ] != '<CHAR_LIT:>>' ) { name [ i ] = '<CHAR_LIT>' ; } break ; case '<CHAR_LIT>' : depth -- ; break ; case '<CHAR_LIT:>>' : depth ++ ; break ; } } return Signature . createCharArrayTypeSignature ( CharOperation . concat ( qualifiedPackageName , name , '<CHAR_LIT:.>' ) , true ) ; } private static char [ ] getRequiredTypeSignature ( TypeBinding typeBinding ) { char [ ] result = null ; StringBuffer sig = new StringBuffer ( <NUM_LIT:10> ) ; sig . append ( typeBinding . signature ( ) ) ; int sigLength = sig . length ( ) ; result = new char [ sigLength ] ; sig . getChars ( <NUM_LIT:0> , sigLength , result , <NUM_LIT:0> ) ; result = CharOperation . replaceOnCopy ( result , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; return result ; } private static char [ ] getTypeName ( TypeReference typeReference ) { char [ ] typeName = CharOperation . concatWith ( typeReference . getTypeName ( ) , '<CHAR_LIT:.>' ) ; int dims = typeReference . dimensions ( ) ; if ( dims > <NUM_LIT:0> ) { int length = typeName . length ; int newLength = length + ( dims * <NUM_LIT:2> ) ; System . arraycopy ( typeName , <NUM_LIT:0> , typeName = new char [ newLength ] , <NUM_LIT:0> , length ) ; for ( int k = length ; k < newLength ; k += <NUM_LIT:2> ) { typeName [ k ] = '<CHAR_LIT:[>' ; typeName [ k + <NUM_LIT:1> ] = '<CHAR_LIT:]>' ; } } return typeName ; } private static boolean hasStaticMemberTypes ( ReferenceBinding typeBinding , SourceTypeBinding invocationType , CompilationUnitScope unitScope ) { ReferenceBinding [ ] memberTypes = typeBinding . memberTypes ( ) ; int length = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; next : for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ReferenceBinding memberType = memberTypes [ i ] ; if ( invocationType != null && ! memberType . canBeSeenBy ( typeBinding , invocationType ) ) { continue next ; } else if ( invocationType == null && ! memberType . canBeSeenBy ( unitScope . fPackage ) ) { continue next ; } if ( ( memberType . modifiers & ClassFileConstants . AccStatic ) != <NUM_LIT:0> ) { return true ; } } return false ; } private static boolean hasMemberTypesInEnclosingScope ( SourceTypeBinding typeBinding , Scope scope ) { ReferenceBinding [ ] memberTypes = typeBinding . memberTypes ( ) ; int length = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; if ( length > <NUM_LIT:0> ) { MethodScope methodScope = scope . methodScope ( ) ; if ( methodScope != null && ! methodScope . isStatic ) { ClassScope classScope = typeBinding . scope ; Scope currentScope = scope ; while ( currentScope != null ) { if ( currentScope == classScope ) { return true ; } currentScope = currentScope . parent ; } } } return false ; } public HashtableOfObject typeCache ; public int openedBinaryTypes ; public static boolean DEBUG = false ; public static boolean PERF = false ; private static final char [ ] KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS = new char [ ] { } ; private static final char [ ] KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS = new char [ ] { } ; private static final char [ ] ARG = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] ARG0 = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] ARG1 = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] ARG2 = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] ARG3 = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] [ ] ARGS1 = new char [ ] [ ] { ARG0 } ; private static final char [ ] [ ] ARGS2 = new char [ ] [ ] { ARG0 , ARG1 } ; private static final char [ ] [ ] ARGS3 = new char [ ] [ ] { ARG0 , ARG1 , ARG2 } ; private static final char [ ] [ ] ARGS4 = new char [ ] [ ] { ARG0 , ARG1 , ARG2 , ARG3 } ; private final static int CHECK_CANCEL_FREQUENCY = <NUM_LIT> ; public final static boolean NO_TYPE_COMPLETION_ON_EMPTY_TOKEN = false ; private final static char [ ] ERROR_PATTERN = "<STR_LIT>" . toCharArray ( ) ; private final static char [ ] EXCEPTION_PATTERN = "<STR_LIT>" . toCharArray ( ) ; private final static char [ ] SEMICOLON = new char [ ] { '<CHAR_LIT:;>' } ; private final static char [ ] CLASS = "<STR_LIT>" . toCharArray ( ) ; private final static char [ ] VOID = "<STR_LIT>" . toCharArray ( ) ; private final static char [ ] INT = "<STR_LIT:int>" . toCharArray ( ) ; private final static char [ ] INT_SIGNATURE = new char [ ] { Signature . C_INT } ; private final static char [ ] VALUE = "<STR_LIT:value>" . toCharArray ( ) ; private final static char [ ] EXTENDS = "<STR_LIT>" . toCharArray ( ) ; private final static char [ ] SUPER = "<STR_LIT>" . toCharArray ( ) ; private final static char [ ] DEFAULT_CONSTRUCTOR_SIGNATURE = "<STR_LIT>" . toCharArray ( ) ; private final static char [ ] DOT = "<STR_LIT:.>" . toCharArray ( ) ; private final static char [ ] VARARGS = "<STR_LIT:...>" . toCharArray ( ) ; private final static char [ ] IMPORT = "<STR_LIT>" . toCharArray ( ) ; private final static char [ ] STATIC = "<STR_LIT>" . toCharArray ( ) ; private final static char [ ] ON_DEMAND = "<STR_LIT>" . toCharArray ( ) ; private final static char [ ] IMPORT_END = "<STR_LIT>" . toCharArray ( ) ; private final static char [ ] JAVA_LANG_OBJECT_SIGNATURE = createTypeSignature ( CharOperation . concatWith ( JAVA_LANG , '<CHAR_LIT:.>' ) , OBJECT ) ; private final static char [ ] JAVA_LANG_NAME = CharOperation . concatWith ( JAVA_LANG , '<CHAR_LIT:.>' ) ; private final static int NONE = <NUM_LIT:0> ; private final static int SUPERTYPE = <NUM_LIT:1> ; private final static int SUBTYPE = <NUM_LIT:2> ; private final static char [ ] DOT_ENUM = "<STR_LIT>" . toCharArray ( ) ; int expectedTypesPtr = - <NUM_LIT:1> ; TypeBinding [ ] expectedTypes = new TypeBinding [ <NUM_LIT:1> ] ; int expectedTypesFilter ; boolean hasJavaLangObjectAsExpectedType = false ; boolean hasExpectedArrayTypes = false ; boolean hasComputedExpectedArrayTypes = false ; int uninterestingBindingsPtr = - <NUM_LIT:1> ; Binding [ ] uninterestingBindings = new Binding [ <NUM_LIT:1> ] ; int forbbidenBindingsPtr = - <NUM_LIT:1> ; Binding [ ] forbbidenBindings = new Binding [ <NUM_LIT:1> ] ; int uninterestingBindingsFilter ; ImportBinding [ ] favoriteReferenceBindings ; boolean assistNodeIsClass ; boolean assistNodeIsEnum ; boolean assistNodeIsException ; boolean assistNodeIsInterface ; boolean assistNodeIsAnnotation ; boolean assistNodeIsConstructor ; boolean assistNodeIsSuperType ; boolean assistNodeIsExtendedType ; boolean assistNodeIsInterfaceExcludingAnnotation ; int assistNodeInJavadoc = <NUM_LIT:0> ; boolean assistNodeCanBeSingleMemberAnnotation = false ; boolean assistNodeIsInsideCase = false ; boolean assistNodeIsString = false ; long targetedElement ; WorkingCopyOwner owner ; IProgressMonitor monitor ; IJavaProject javaProject ; ITypeRoot typeRoot ; CompletionParser parser ; CompletionRequestor requestor ; CompletionProblemFactory problemFactory ; ProblemReporter problemReporter ; private JavaSearchNameEnvironment noCacheNameEnvironment ; char [ ] source ; char [ ] completionToken ; char [ ] qualifiedCompletionToken ; boolean resolvingImports = false ; boolean resolvingStaticImports = false ; boolean insideQualifiedReference = false ; boolean noProposal = true ; CategorizedProblem problem = null ; char [ ] fileName = null ; int startPosition , actualCompletionPosition , endPosition , offset ; int tokenStart , tokenEnd ; int javadocTagPosition ; HashtableOfObject knownPkgs = new HashtableOfObject ( <NUM_LIT:10> ) ; HashtableOfObject knownTypes = new HashtableOfObject ( <NUM_LIT:10> ) ; static final BaseTypeBinding [ ] BASE_TYPES = { TypeBinding . BOOLEAN , TypeBinding . BYTE , TypeBinding . CHAR , TypeBinding . DOUBLE , TypeBinding . FLOAT , TypeBinding . INT , TypeBinding . LONG , TypeBinding . SHORT , TypeBinding . VOID } ; static final int BASE_TYPES_LENGTH = BASE_TYPES . length ; static final char [ ] [ ] BASE_TYPE_NAMES = new char [ BASE_TYPES_LENGTH ] [ ] ; static final int BASE_TYPES_WITHOUT_VOID_LENGTH = BASE_TYPES . length - <NUM_LIT:1> ; static final char [ ] [ ] BASE_TYPE_NAMES_WITHOUT_VOID = new char [ BASE_TYPES_WITHOUT_VOID_LENGTH ] [ ] ; static { for ( int i = <NUM_LIT:0> ; i < BASE_TYPES_LENGTH ; i ++ ) { BASE_TYPE_NAMES [ i ] = BASE_TYPES [ i ] . simpleName ; } for ( int i = <NUM_LIT:0> ; i < BASE_TYPES_WITHOUT_VOID_LENGTH ; i ++ ) { BASE_TYPE_NAMES_WITHOUT_VOID [ i ] = BASE_TYPES [ i ] . simpleName ; } } static final char [ ] classField = "<STR_LIT:class>" . toCharArray ( ) ; static final char [ ] lengthField = "<STR_LIT>" . toCharArray ( ) ; static final char [ ] cloneMethod = "<STR_LIT>" . toCharArray ( ) ; static final char [ ] THIS = "<STR_LIT>" . toCharArray ( ) ; static final char [ ] THROWS = "<STR_LIT>" . toCharArray ( ) ; static InvocationSite FakeInvocationSite = new InvocationSite ( ) { public TypeBinding [ ] genericTypeArguments ( ) { return null ; } public boolean isSuperAccess ( ) { return false ; } public boolean isTypeAccess ( ) { return false ; } public void setActualReceiverType ( ReferenceBinding receiverType ) { } public void setDepth ( int depth ) { } public void setFieldIndex ( int depth ) { } public int sourceEnd ( ) { return <NUM_LIT:0> ; } public int sourceStart ( ) { return <NUM_LIT:0> ; } public TypeBinding expectedType ( ) { return null ; } } ; private int foundTypesCount ; private ObjectVector acceptedTypes ; private int foundConstructorsCount ; private ObjectVector acceptedConstructors ; public CompletionEngine ( SearchableEnvironment nameEnvironment , CompletionRequestor requestor , Map settings , IJavaProject javaProject , WorkingCopyOwner owner , IProgressMonitor monitor ) { super ( settings ) ; this . javaProject = javaProject ; this . requestor = requestor ; this . nameEnvironment = nameEnvironment ; this . typeCache = new HashtableOfObject ( <NUM_LIT:5> ) ; this . openedBinaryTypes = <NUM_LIT:0> ; this . problemFactory = new CompletionProblemFactory ( Locale . getDefault ( ) ) ; this . problemReporter = new ProblemReporter ( DefaultErrorHandlingPolicies . proceedWithAllProblems ( ) , this . compilerOptions , this . problemFactory ) ; this . lookupEnvironment = new LookupEnvironment ( this , this . compilerOptions , this . problemReporter , nameEnvironment ) ; this . parser = new CompletionParser ( this . problemReporter , this . requestor . isExtendedContextRequired ( ) ) ; this . owner = owner ; this . monitor = monitor ; } public void accept ( ICompilationUnit sourceUnit , AccessRestriction accessRestriction ) { if ( ! CharOperation . equals ( sourceUnit . getMainTypeName ( ) , TypeConstants . PACKAGE_INFO_NAME ) ) { super . accept ( sourceUnit , accessRestriction ) ; } } public void acceptConstructor ( int modifiers , char [ ] simpleTypeName , int parameterCount , char [ ] signature , char [ ] [ ] parameterTypes , char [ ] [ ] parameterNames , int typeModifiers , char [ ] packageName , int extraFlags , String path , AccessRestriction accessRestriction ) { if ( ( this . foundConstructorsCount % ( CHECK_CANCEL_FREQUENCY ) ) == <NUM_LIT:0> ) checkCancel ( ) ; this . foundConstructorsCount ++ ; if ( ( typeModifiers & ClassFileConstants . AccEnum ) != <NUM_LIT:0> ) return ; if ( this . options . checkDeprecation && ( typeModifiers & ClassFileConstants . AccDeprecated ) != <NUM_LIT:0> ) return ; if ( this . options . checkVisibility ) { if ( ( typeModifiers & ClassFileConstants . AccPublic ) == <NUM_LIT:0> ) { if ( ( typeModifiers & ClassFileConstants . AccPrivate ) != <NUM_LIT:0> ) return ; if ( this . currentPackageName == null ) { initializePackageCache ( ) ; } if ( ! CharOperation . equals ( packageName , this . currentPackageName ) ) return ; } } int accessibility = IAccessRule . K_ACCESSIBLE ; if ( accessRestriction != null ) { switch ( accessRestriction . getProblemId ( ) ) { case IProblem . ForbiddenReference : if ( this . options . checkForbiddenReference ) { return ; } accessibility = IAccessRule . K_NON_ACCESSIBLE ; break ; case IProblem . DiscouragedReference : if ( this . options . checkDiscouragedReference ) { return ; } accessibility = IAccessRule . K_DISCOURAGED ; break ; } } if ( this . acceptedConstructors == null ) { this . acceptedConstructors = new ObjectVector ( ) ; } this . acceptedConstructors . add ( new AcceptedConstructor ( modifiers , simpleTypeName , parameterCount , signature , parameterTypes , parameterNames , typeModifiers , packageName , extraFlags , accessibility ) ) ; } private void acceptConstructors ( Scope scope ) { final boolean DEFER_QUALIFIED_PROPOSALS = false ; this . checkCancel ( ) ; if ( this . acceptedConstructors == null ) return ; int length = this . acceptedConstructors . size ( ) ; if ( length == <NUM_LIT:0> ) return ; HashtableOfObject onDemandFound = new HashtableOfObject ( ) ; ArrayList deferredProposals = null ; if ( DEFER_QUALIFIED_PROPOSALS ) { deferredProposals = new ArrayList ( ) ; } try { next : for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( ( i % CHECK_CANCEL_FREQUENCY ) == <NUM_LIT:0> ) checkCancel ( ) ; AcceptedConstructor acceptedConstructor = ( AcceptedConstructor ) this . acceptedConstructors . elementAt ( i ) ; final int typeModifiers = acceptedConstructor . typeModifiers ; final char [ ] packageName = acceptedConstructor . packageName ; final char [ ] simpleTypeName = acceptedConstructor . simpleTypeName ; final int modifiers = acceptedConstructor . modifiers ; final int parameterCount = acceptedConstructor . parameterCount ; final char [ ] signature = acceptedConstructor . signature ; final char [ ] [ ] parameterTypes = acceptedConstructor . parameterTypes ; final char [ ] [ ] parameterNames = acceptedConstructor . parameterNames ; final int extraFlags = acceptedConstructor . extraFlags ; final int accessibility = acceptedConstructor . accessibility ; boolean proposeType = hasArrayTypeAsExpectedSuperTypes ( ) || ( extraFlags & ExtraFlags . HasNonPrivateStaticMemberTypes ) != <NUM_LIT:0> ; char [ ] fullyQualifiedName = CharOperation . concat ( packageName , simpleTypeName , '<CHAR_LIT:.>' ) ; Object knownTypeKind = this . knownTypes . get ( fullyQualifiedName ) ; if ( knownTypeKind != null ) { if ( knownTypeKind == KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS ) { continue next ; } proposeType = false ; } else { this . knownTypes . put ( fullyQualifiedName , KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS ) ; } boolean proposeConstructor = true ; if ( this . options . checkVisibility ) { if ( ( modifiers & ClassFileConstants . AccPublic ) == <NUM_LIT:0> ) { if ( ( modifiers & ClassFileConstants . AccPrivate ) != <NUM_LIT:0> ) { if ( ! proposeType ) continue next ; proposeConstructor = false ; } else { if ( this . currentPackageName == null ) { initializePackageCache ( ) ; } if ( ! CharOperation . equals ( packageName , this . currentPackageName ) ) { if ( ( typeModifiers & ClassFileConstants . AccAbstract ) == <NUM_LIT:0> || ( modifiers & ClassFileConstants . AccProtected ) == <NUM_LIT:0> ) { if ( ! proposeType ) continue next ; proposeConstructor = false ; } } } } } acceptedConstructor . fullyQualifiedName = fullyQualifiedName ; acceptedConstructor . proposeType = proposeType ; acceptedConstructor . proposeConstructor = proposeConstructor ; if ( ! this . importCachesInitialized ) { initializeImportCaches ( ) ; } for ( int j = <NUM_LIT:0> ; j < this . importCacheCount ; j ++ ) { char [ ] [ ] importName = this . importsCache [ j ] ; if ( CharOperation . equals ( simpleTypeName , importName [ <NUM_LIT:0> ] ) ) { if ( proposeType ) { proposeType ( packageName , simpleTypeName , typeModifiers , accessibility , simpleTypeName , fullyQualifiedName , ! CharOperation . equals ( fullyQualifiedName , importName [ <NUM_LIT:1> ] ) , scope ) ; } if ( proposeConstructor && ! Flags . isEnum ( typeModifiers ) ) { boolean isQualified = ! CharOperation . equals ( fullyQualifiedName , importName [ <NUM_LIT:1> ] ) ; if ( ! isQualified ) { proposeConstructor ( simpleTypeName , parameterCount , signature , parameterTypes , parameterNames , modifiers , packageName , typeModifiers , accessibility , simpleTypeName , fullyQualifiedName , isQualified , scope , extraFlags ) ; } else { acceptedConstructor . mustBeQualified = true ; if ( DEFER_QUALIFIED_PROPOSALS ) { deferredProposals . add ( acceptedConstructor ) ; } else { proposeConstructor ( acceptedConstructor , scope ) ; } } } continue next ; } } if ( CharOperation . equals ( this . currentPackageName , packageName ) ) { if ( proposeType ) { proposeType ( packageName , simpleTypeName , typeModifiers , accessibility , simpleTypeName , fullyQualifiedName , false , scope ) ; } if ( proposeConstructor && ! Flags . isEnum ( typeModifiers ) ) { proposeConstructor ( simpleTypeName , parameterCount , signature , parameterTypes , parameterNames , modifiers , packageName , typeModifiers , accessibility , simpleTypeName , fullyQualifiedName , false , scope , extraFlags ) ; } continue next ; } else { char [ ] fullyQualifiedEnclosingTypeOrPackageName = null ; AcceptedConstructor foundConstructor = null ; if ( ( foundConstructor = ( AcceptedConstructor ) onDemandFound . get ( simpleTypeName ) ) == null ) { for ( int j = <NUM_LIT:0> ; j < this . onDemandImportCacheCount ; j ++ ) { ImportBinding importBinding = this . onDemandImportsCache [ j ] ; char [ ] [ ] importName = importBinding . compoundName ; char [ ] importFlatName = CharOperation . concatWith ( importName , '<CHAR_LIT:.>' ) ; if ( fullyQualifiedEnclosingTypeOrPackageName == null ) { fullyQualifiedEnclosingTypeOrPackageName = packageName ; } if ( CharOperation . equals ( fullyQualifiedEnclosingTypeOrPackageName , importFlatName ) ) { if ( importBinding . isStatic ( ) ) { if ( ( typeModifiers & ClassFileConstants . AccStatic ) != <NUM_LIT:0> ) { onDemandFound . put ( simpleTypeName , acceptedConstructor ) ; continue next ; } } else { onDemandFound . put ( simpleTypeName , acceptedConstructor ) ; continue next ; } } } } else if ( ! foundConstructor . mustBeQualified ) { done : for ( int j = <NUM_LIT:0> ; j < this . onDemandImportCacheCount ; j ++ ) { ImportBinding importBinding = this . onDemandImportsCache [ j ] ; char [ ] [ ] importName = importBinding . compoundName ; char [ ] importFlatName = CharOperation . concatWith ( importName , '<CHAR_LIT:.>' ) ; if ( fullyQualifiedEnclosingTypeOrPackageName == null ) { fullyQualifiedEnclosingTypeOrPackageName = packageName ; } if ( CharOperation . equals ( fullyQualifiedEnclosingTypeOrPackageName , importFlatName ) ) { if ( importBinding . isStatic ( ) ) { if ( ( typeModifiers & ClassFileConstants . AccStatic ) != <NUM_LIT:0> ) { foundConstructor . mustBeQualified = true ; break done ; } } else { foundConstructor . mustBeQualified = true ; break done ; } } } } if ( proposeType ) { proposeType ( packageName , simpleTypeName , typeModifiers , accessibility , simpleTypeName , fullyQualifiedName , true , scope ) ; } if ( proposeConstructor && ! Flags . isEnum ( typeModifiers ) ) { acceptedConstructor . mustBeQualified = true ; if ( DEFER_QUALIFIED_PROPOSALS ) { deferredProposals . add ( acceptedConstructor ) ; } else { proposeConstructor ( acceptedConstructor , scope ) ; } } } } char [ ] [ ] keys = onDemandFound . keyTable ; Object [ ] values = onDemandFound . valueTable ; int max = keys . length ; for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) { if ( ( i % CHECK_CANCEL_FREQUENCY ) == <NUM_LIT:0> ) checkCancel ( ) ; if ( keys [ i ] != null ) { AcceptedConstructor value = ( AcceptedConstructor ) values [ i ] ; if ( value != null ) { char [ ] fullyQualifiedEnclosingTypeOrPackageName = null ; done : for ( int j = <NUM_LIT:0> ; j < this . onDemandImportCacheCount ; j ++ ) { ImportBinding importBinding = this . onDemandImportsCache [ j ] ; char [ ] [ ] importName = importBinding . compoundName ; char [ ] importFlatName = CharOperation . concatWith ( importName , '<CHAR_LIT:.>' ) ; if ( fullyQualifiedEnclosingTypeOrPackageName == null ) { fullyQualifiedEnclosingTypeOrPackageName = value . packageName ; } if ( CharOperation . equals ( fullyQualifiedEnclosingTypeOrPackageName , importFlatName ) ) { if ( importBinding . isStatic ( ) ) { if ( ( value . modifiers & ClassFileConstants . AccStatic ) != <NUM_LIT:0> ) { value . mustBeQualified = true ; break done ; } } else { value . mustBeQualified = true ; break done ; } } } if ( value . proposeType ) { proposeType ( value . packageName , value . simpleTypeName , value . typeModifiers , value . accessibility , value . simpleTypeName , value . fullyQualifiedName , value . mustBeQualified , scope ) ; } if ( value . proposeConstructor && ! Flags . isEnum ( value . modifiers ) ) { if ( ! value . mustBeQualified ) { proposeConstructor ( value . simpleTypeName , value . parameterCount , value . signature , value . parameterTypes , value . parameterNames , value . modifiers , value . packageName , value . typeModifiers , value . accessibility , value . simpleTypeName , value . fullyQualifiedName , value . mustBeQualified , scope , value . extraFlags ) ; } else { if ( DEFER_QUALIFIED_PROPOSALS ) { deferredProposals . add ( value ) ; } else { proposeConstructor ( value , scope ) ; } } } } } } if ( DEFER_QUALIFIED_PROPOSALS ) { int size = deferredProposals . size ( ) ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { if ( ( i % CHECK_CANCEL_FREQUENCY ) == <NUM_LIT:0> ) checkCancel ( ) ; AcceptedConstructor deferredProposal = ( AcceptedConstructor ) deferredProposals . get ( i ) ; if ( deferredProposal . proposeConstructor ) { proposeConstructor ( deferredProposal . simpleTypeName , deferredProposal . parameterCount , deferredProposal . signature , deferredProposal . parameterTypes , deferredProposal . parameterNames , deferredProposal . modifiers , deferredProposal . packageName , deferredProposal . typeModifiers , deferredProposal . accessibility , deferredProposal . simpleTypeName , deferredProposal . fullyQualifiedName , deferredProposal . mustBeQualified , scope , deferredProposal . extraFlags ) ; } } } } finally { this . acceptedTypes = null ; } } public void acceptPackage ( char [ ] packageName ) { if ( this . knownPkgs . containsKey ( packageName ) ) return ; this . knownPkgs . put ( packageName , this ) ; char [ ] completion ; if ( this . resolvingImports ) { if ( this . resolvingStaticImports ) { completion = CharOperation . concat ( packageName , new char [ ] { '<CHAR_LIT:.>' } ) ; } else { completion = CharOperation . concat ( packageName , new char [ ] { '<CHAR_LIT:.>' , '<CHAR_LIT>' , '<CHAR_LIT:;>' } ) ; } } else { completion = packageName ; } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( this . qualifiedCompletionToken == null ? this . completionToken : this . qualifiedCompletionToken , packageName ) ; if ( ! this . resolvingImports ) { relevance += computeRelevanceForQualification ( true ) ; } relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . PACKAGE_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . PACKAGE_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( packageName ) ; proposal . setPackageName ( packageName ) ; proposal . setCompletion ( completion ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } public void acceptType ( char [ ] packageName , char [ ] simpleTypeName , char [ ] [ ] enclosingTypeNames , int modifiers , AccessRestriction accessRestriction ) { if ( ( this . foundTypesCount % CHECK_CANCEL_FREQUENCY ) == <NUM_LIT:0> ) checkCancel ( ) ; this . foundTypesCount ++ ; if ( this . options . checkDeprecation && ( modifiers & ClassFileConstants . AccDeprecated ) != <NUM_LIT:0> ) return ; if ( this . assistNodeIsExtendedType && ( modifiers & ClassFileConstants . AccFinal ) != <NUM_LIT:0> ) return ; if ( this . options . checkVisibility ) { if ( ( modifiers & ClassFileConstants . AccPublic ) == <NUM_LIT:0> ) { if ( ( modifiers & ClassFileConstants . AccPrivate ) != <NUM_LIT:0> ) return ; char [ ] currentPackage = CharOperation . concatWith ( this . unitScope . fPackage . compoundName , '<CHAR_LIT:.>' ) ; if ( ! CharOperation . equals ( packageName , currentPackage ) ) return ; } } int accessibility = IAccessRule . K_ACCESSIBLE ; if ( accessRestriction != null ) { switch ( accessRestriction . getProblemId ( ) ) { case IProblem . ForbiddenReference : if ( this . options . checkForbiddenReference ) { return ; } accessibility = IAccessRule . K_NON_ACCESSIBLE ; break ; case IProblem . DiscouragedReference : if ( this . options . checkDiscouragedReference ) { return ; } accessibility = IAccessRule . K_DISCOURAGED ; break ; } } if ( isForbiddenType ( packageName , simpleTypeName , enclosingTypeNames ) ) { return ; } if ( this . acceptedTypes == null ) { this . acceptedTypes = new ObjectVector ( ) ; } this . acceptedTypes . add ( new AcceptedType ( packageName , simpleTypeName , enclosingTypeNames , modifiers , accessibility ) ) ; } private void acceptTypes ( Scope scope ) { this . checkCancel ( ) ; if ( this . acceptedTypes == null ) return ; int length = this . acceptedTypes . size ( ) ; if ( length == <NUM_LIT:0> ) return ; HashtableOfObject onDemandFound = new HashtableOfObject ( ) ; try { next : for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( ( i % CHECK_CANCEL_FREQUENCY ) == <NUM_LIT:0> ) checkCancel ( ) ; AcceptedType acceptedType = ( AcceptedType ) this . acceptedTypes . elementAt ( i ) ; char [ ] packageName = acceptedType . packageName ; char [ ] simpleTypeName = acceptedType . simpleTypeName ; char [ ] [ ] enclosingTypeNames = acceptedType . enclosingTypeNames ; int modifiers = acceptedType . modifiers ; int accessibility = acceptedType . accessibility ; char [ ] typeName ; char [ ] flatEnclosingTypeNames ; if ( enclosingTypeNames == null || enclosingTypeNames . length == <NUM_LIT:0> ) { flatEnclosingTypeNames = null ; typeName = simpleTypeName ; } else { flatEnclosingTypeNames = CharOperation . concatWith ( acceptedType . enclosingTypeNames , '<CHAR_LIT:.>' ) ; typeName = CharOperation . concat ( flatEnclosingTypeNames , simpleTypeName , '<CHAR_LIT:.>' ) ; } char [ ] fullyQualifiedName = CharOperation . concat ( packageName , typeName , '<CHAR_LIT:.>' ) ; if ( this . knownTypes . containsKey ( fullyQualifiedName ) ) continue next ; this . knownTypes . put ( fullyQualifiedName , KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS ) ; if ( this . resolvingImports ) { if ( this . compilerOptions . complianceLevel >= ClassFileConstants . JDK1_4 && packageName . length == <NUM_LIT:0> ) { continue next ; } char [ ] completionName = this . insideQualifiedReference ? simpleTypeName : fullyQualifiedName ; if ( this . resolvingStaticImports ) { if ( enclosingTypeNames == null || enclosingTypeNames . length == <NUM_LIT:0> ) { completionName = CharOperation . concat ( completionName , new char [ ] { '<CHAR_LIT:.>' } ) ; } else if ( ( modifiers & ClassFileConstants . AccStatic ) == <NUM_LIT:0> ) { continue next ; } else { completionName = CharOperation . concat ( completionName , new char [ ] { '<CHAR_LIT:;>' } ) ; } } else { completionName = CharOperation . concat ( completionName , new char [ ] { '<CHAR_LIT:;>' } ) ; } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( packageName , fullyQualifiedName ) ; relevance += computeRelevanceForRestrictions ( accessibility ) ; relevance += computeRelevanceForCaseMatching ( this . completionToken , simpleTypeName ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { createTypeProposal ( packageName , typeName , modifiers , accessibility , completionName , relevance ) ; } } else { if ( ! this . importCachesInitialized ) { initializeImportCaches ( ) ; } for ( int j = <NUM_LIT:0> ; j < this . importCacheCount ; j ++ ) { char [ ] [ ] importName = this . importsCache [ j ] ; if ( CharOperation . equals ( typeName , importName [ <NUM_LIT:0> ] ) ) { proposeType ( packageName , simpleTypeName , modifiers , accessibility , typeName , fullyQualifiedName , ! CharOperation . equals ( fullyQualifiedName , importName [ <NUM_LIT:1> ] ) , scope ) ; continue next ; } } if ( ( enclosingTypeNames == null || enclosingTypeNames . length == <NUM_LIT:0> ) && CharOperation . equals ( this . currentPackageName , packageName ) ) { proposeType ( packageName , simpleTypeName , modifiers , accessibility , typeName , fullyQualifiedName , false , scope ) ; continue next ; } else { char [ ] fullyQualifiedEnclosingTypeOrPackageName = null ; AcceptedType foundType = null ; if ( ( foundType = ( AcceptedType ) onDemandFound . get ( simpleTypeName ) ) == null ) { for ( int j = <NUM_LIT:0> ; j < this . onDemandImportCacheCount ; j ++ ) { ImportBinding importBinding = this . onDemandImportsCache [ j ] ; char [ ] [ ] importName = importBinding . compoundName ; char [ ] importFlatName = CharOperation . concatWith ( importName , '<CHAR_LIT:.>' ) ; if ( fullyQualifiedEnclosingTypeOrPackageName == null ) { if ( enclosingTypeNames != null && enclosingTypeNames . length != <NUM_LIT:0> ) { fullyQualifiedEnclosingTypeOrPackageName = CharOperation . concat ( packageName , flatEnclosingTypeNames , '<CHAR_LIT:.>' ) ; } else { fullyQualifiedEnclosingTypeOrPackageName = packageName ; } } if ( CharOperation . equals ( fullyQualifiedEnclosingTypeOrPackageName , importFlatName ) ) { if ( importBinding . isStatic ( ) ) { if ( ( modifiers & ClassFileConstants . AccStatic ) != <NUM_LIT:0> ) { acceptedType . qualifiedTypeName = typeName ; acceptedType . fullyQualifiedName = fullyQualifiedName ; onDemandFound . put ( simpleTypeName , acceptedType ) ; continue next ; } } else { acceptedType . qualifiedTypeName = typeName ; acceptedType . fullyQualifiedName = fullyQualifiedName ; onDemandFound . put ( simpleTypeName , acceptedType ) ; continue next ; } } } } else if ( ! foundType . mustBeQualified ) { done : for ( int j = <NUM_LIT:0> ; j < this . onDemandImportCacheCount ; j ++ ) { ImportBinding importBinding = this . onDemandImportsCache [ j ] ; char [ ] [ ] importName = importBinding . compoundName ; char [ ] importFlatName = CharOperation . concatWith ( importName , '<CHAR_LIT:.>' ) ; if ( fullyQualifiedEnclosingTypeOrPackageName == null ) { if ( enclosingTypeNames != null && enclosingTypeNames . length != <NUM_LIT:0> ) { fullyQualifiedEnclosingTypeOrPackageName = CharOperation . concat ( packageName , flatEnclosingTypeNames , '<CHAR_LIT:.>' ) ; } else { fullyQualifiedEnclosingTypeOrPackageName = packageName ; } } if ( CharOperation . equals ( fullyQualifiedEnclosingTypeOrPackageName , importFlatName ) ) { if ( importBinding . isStatic ( ) ) { if ( ( modifiers & ClassFileConstants . AccStatic ) != <NUM_LIT:0> ) { foundType . mustBeQualified = true ; break done ; } } else { foundType . mustBeQualified = true ; break done ; } } } } proposeType ( packageName , simpleTypeName , modifiers , accessibility , typeName , fullyQualifiedName , true , scope ) ; } } } char [ ] [ ] keys = onDemandFound . keyTable ; Object [ ] values = onDemandFound . valueTable ; int max = keys . length ; for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) { if ( ( i % CHECK_CANCEL_FREQUENCY ) == <NUM_LIT:0> ) checkCancel ( ) ; if ( keys [ i ] != null ) { AcceptedType value = ( AcceptedType ) values [ i ] ; if ( value != null ) { proposeType ( value . packageName , value . simpleTypeName , value . modifiers , value . accessibility , value . qualifiedTypeName , value . fullyQualifiedName , value . mustBeQualified , scope ) ; } } } } finally { this . acceptedTypes = null ; } } public void acceptUnresolvedName ( char [ ] name ) { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( false ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( this . completionToken , name ) ; relevance += computeRelevanceForQualification ( false ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; CompletionEngine . this . noProposal = false ; if ( ! CompletionEngine . this . requestor . isIgnored ( CompletionProposal . LOCAL_VARIABLE_REF ) ) { InternalCompletionProposal proposal = CompletionEngine . this . createProposal ( CompletionProposal . LOCAL_VARIABLE_REF , CompletionEngine . this . actualCompletionPosition ) ; proposal . setSignature ( JAVA_LANG_OBJECT_SIGNATURE ) ; proposal . setPackageName ( JAVA_LANG_NAME ) ; proposal . setTypeName ( OBJECT ) ; proposal . setName ( name ) ; proposal . setCompletion ( name ) ; proposal . setFlags ( Flags . AccDefault ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; CompletionEngine . this . requestor . accept ( proposal ) ; if ( DEBUG ) { CompletionEngine . this . printDebug ( proposal ) ; } } } private void addExpectedType ( TypeBinding type , Scope scope ) { if ( type == null || ! type . isValidBinding ( ) || type == TypeBinding . NULL ) return ; for ( int i = <NUM_LIT:0> ; i <= this . expectedTypesPtr ; i ++ ) { if ( this . expectedTypes [ i ] == type ) return ; } int length = this . expectedTypes . length ; if ( ++ this . expectedTypesPtr >= length ) System . arraycopy ( this . expectedTypes , <NUM_LIT:0> , this . expectedTypes = new TypeBinding [ length * <NUM_LIT:2> ] , <NUM_LIT:0> , length ) ; this . expectedTypes [ this . expectedTypesPtr ] = type ; if ( type == scope . getJavaLangObject ( ) ) { this . hasJavaLangObjectAsExpectedType = true ; } } private void addForbiddenBindings ( Binding binding ) { if ( binding == null ) return ; int length = this . forbbidenBindings . length ; if ( ++ this . forbbidenBindingsPtr >= length ) System . arraycopy ( this . forbbidenBindings , <NUM_LIT:0> , this . forbbidenBindings = new Binding [ length * <NUM_LIT:2> ] , <NUM_LIT:0> , length ) ; this . forbbidenBindings [ this . forbbidenBindingsPtr ] = binding ; } private void addUninterestingBindings ( Binding binding ) { if ( binding == null ) return ; int length = this . uninterestingBindings . length ; if ( ++ this . uninterestingBindingsPtr >= length ) System . arraycopy ( this . uninterestingBindings , <NUM_LIT:0> , this . uninterestingBindings = new Binding [ length * <NUM_LIT:2> ] , <NUM_LIT:0> , length ) ; this . uninterestingBindings [ this . uninterestingBindingsPtr ] = binding ; } private final boolean areParametersCompatibleWith ( TypeBinding [ ] parameters , TypeBinding [ ] arguments , boolean isVarargs ) { int paramLength = parameters . length ; int argLength = arguments . length ; int lastIndex = argLength ; if ( isVarargs ) { lastIndex = paramLength - <NUM_LIT:1> ; if ( paramLength == argLength ) { TypeBinding varArgType = parameters [ lastIndex ] ; TypeBinding lastArgument = arguments [ lastIndex ] ; if ( varArgType != lastArgument && ! lastArgument . isCompatibleWith ( varArgType ) ) return false ; } else if ( paramLength < argLength ) { TypeBinding varArgType = ( ( ArrayBinding ) parameters [ lastIndex ] ) . elementsType ( ) ; for ( int i = lastIndex ; i < argLength ; i ++ ) if ( varArgType != arguments [ i ] && ! arguments [ i ] . isCompatibleWith ( varArgType ) ) return false ; } else if ( lastIndex != argLength ) { return false ; } } else { if ( paramLength != argLength ) return false ; } for ( int i = <NUM_LIT:0> ; i < lastIndex ; i ++ ) if ( parameters [ i ] != arguments [ i ] && ! arguments [ i ] . isCompatibleWith ( parameters [ i ] ) ) return false ; return true ; } private void buildContext ( ASTNode astNode , ASTNode astNodeParent , CompilationUnitDeclaration compilationUnitDeclaration , Binding qualifiedBinding , Scope scope ) { InternalCompletionContext context = new InternalCompletionContext ( ) ; if ( this . requestor . isExtendedContextRequired ( ) ) { context . setExtendedData ( this . typeRoot , compilationUnitDeclaration , this . lookupEnvironment , scope , astNode , astNodeParent , this . owner , this . parser ) ; } if ( this . expectedTypesPtr > - <NUM_LIT:1> ) { int length = this . expectedTypesPtr + <NUM_LIT:1> ; char [ ] [ ] expTypes = new char [ length ] [ ] ; char [ ] [ ] expKeys = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { expTypes [ i ] = getSignature ( this . expectedTypes [ i ] ) ; expKeys [ i ] = this . expectedTypes [ i ] . computeUniqueKey ( ) ; } context . setExpectedTypesSignatures ( expTypes ) ; context . setExpectedTypesKeys ( expKeys ) ; } context . setOffset ( this . actualCompletionPosition + <NUM_LIT:1> - this . offset ) ; if ( astNode instanceof CompletionOnJavadoc ) { this . assistNodeInJavadoc = ( ( CompletionOnJavadoc ) astNode ) . getCompletionFlags ( ) ; context . setJavadoc ( this . assistNodeInJavadoc ) ; } if ( ! ( astNode instanceof CompletionOnJavadoc ) ) { CompletionScanner scanner = ( CompletionScanner ) this . parser . scanner ; context . setToken ( scanner . completionIdentifier ) ; context . setTokenRange ( scanner . completedIdentifierStart - this . offset , scanner . completedIdentifierEnd - this . offset , scanner . endOfEmptyToken - this . offset ) ; } else if ( astNode instanceof CompletionOnJavadocTag ) { CompletionOnJavadocTag javadocTag = ( CompletionOnJavadocTag ) astNode ; context . setToken ( CharOperation . concat ( new char [ ] { '<CHAR_LIT>' } , javadocTag . token ) ) ; context . setTokenRange ( javadocTag . tagSourceStart - this . offset , javadocTag . tagSourceEnd - this . offset , ( ( CompletionScanner ) this . parser . javadocParser . scanner ) . endOfEmptyToken - this . offset ) ; } else { CompletionScanner scanner = ( CompletionScanner ) this . parser . javadocParser . scanner ; context . setToken ( scanner . completionIdentifier ) ; context . setTokenRange ( scanner . completedIdentifierStart - this . offset , scanner . completedIdentifierEnd - this . offset , scanner . endOfEmptyToken - this . offset ) ; } if ( astNode instanceof CompletionOnStringLiteral ) { context . setTokenKind ( CompletionContext . TOKEN_KIND_STRING_LITERAL ) ; } else { context . setTokenKind ( CompletionContext . TOKEN_KIND_NAME ) ; } buildTokenLocationContext ( context , scope , astNode , astNodeParent ) ; if ( DEBUG ) { System . out . println ( context . toString ( ) ) ; } this . requestor . acceptContext ( context ) ; } private void buildTokenLocationContext ( InternalCompletionContext context , Scope scope , ASTNode astNode , ASTNode astNodeParent ) { if ( scope == null || context . isInJavadoc ( ) ) return ; if ( astNode instanceof CompletionOnFieldType ) { CompletionOnFieldType field = ( CompletionOnFieldType ) astNode ; if ( ! field . isLocalVariable && field . modifiers == ClassFileConstants . AccDefault && ( field . annotations == null || field . annotations . length == <NUM_LIT:0> ) ) { context . setTokenLocation ( CompletionContext . TL_MEMBER_START ) ; } } else if ( astNode instanceof CompletionOnMethodReturnType ) { CompletionOnMethodReturnType method = ( CompletionOnMethodReturnType ) astNode ; if ( method . modifiers == ClassFileConstants . AccDefault && ( method . annotations == null || method . annotations . length == <NUM_LIT:0> ) ) { context . setTokenLocation ( CompletionContext . TL_MEMBER_START ) ; } } else { ReferenceContext referenceContext = scope . referenceContext ( ) ; if ( referenceContext instanceof AbstractMethodDeclaration ) { AbstractMethodDeclaration methodDeclaration = ( AbstractMethodDeclaration ) referenceContext ; if ( methodDeclaration . bodyStart <= astNode . sourceStart && astNode . sourceEnd <= methodDeclaration . bodyEnd ) { if ( astNodeParent == null && astNode instanceof CompletionOnSingleNameReference && ! ( ( CompletionOnSingleNameReference ) astNode ) . isPrecededByModifiers ) { context . setTokenLocation ( CompletionContext . TL_STATEMENT_START ) ; } } } else if ( referenceContext instanceof TypeDeclaration ) { TypeDeclaration typeDeclaration = ( TypeDeclaration ) referenceContext ; FieldDeclaration [ ] fields = typeDeclaration . fields ; if ( fields != null ) { done : for ( int i = <NUM_LIT:0> ; i < fields . length ; i ++ ) { if ( fields [ i ] instanceof Initializer ) { Initializer initializer = ( Initializer ) fields [ i ] ; if ( initializer . block . sourceStart <= astNode . sourceStart && astNode . sourceStart < initializer . bodyEnd ) { if ( astNodeParent == null && astNode instanceof CompletionOnSingleNameReference && ! ( ( CompletionOnSingleNameReference ) astNode ) . isPrecededByModifiers ) { context . setTokenLocation ( CompletionContext . TL_STATEMENT_START ) ; } break done ; } } } } } } } void checkCancel ( ) { if ( this . monitor != null && this . monitor . isCanceled ( ) ) { throw new OperationCanceledException ( ) ; } } private boolean complete ( ASTNode astNode , ASTNode astNodeParent , ASTNode enclosingNode , CompilationUnitDeclaration compilationUnitDeclaration , Binding qualifiedBinding , Scope scope , boolean insideTypeAnnotation ) { setSourceAndTokenRange ( astNode . sourceStart , astNode . sourceEnd ) ; scope = computeForbiddenBindings ( astNode , astNodeParent , scope ) ; computeUninterestingBindings ( astNode , astNodeParent , scope ) ; if ( astNodeParent != null ) { if ( ! isValidParent ( astNodeParent , astNode , scope ) ) return false ; computeExpectedTypes ( astNodeParent , astNode , scope ) ; } buildContext ( astNode , astNodeParent , compilationUnitDeclaration , qualifiedBinding , scope ) ; if ( astNode instanceof CompletionOnFieldType ) { completionOnFieldType ( astNode , scope ) ; } else if ( astNode instanceof CompletionOnMethodReturnType ) { completionOnMethodReturnType ( astNode , scope ) ; } else if ( astNode instanceof CompletionOnSingleNameReference ) { completionOnSingleNameReference ( astNode , astNodeParent , scope , insideTypeAnnotation ) ; } else if ( astNode instanceof CompletionOnSingleTypeReference ) { completionOnSingleTypeReference ( astNode , astNodeParent , qualifiedBinding , scope ) ; } else if ( astNode instanceof CompletionOnQualifiedNameReference ) { completionOnQualifiedNameReference ( astNode , enclosingNode , qualifiedBinding , scope , insideTypeAnnotation ) ; } else if ( astNode instanceof CompletionOnQualifiedTypeReference ) { completionOnQualifiedTypeReference ( astNode , astNodeParent , qualifiedBinding , scope ) ; } else if ( astNode instanceof CompletionOnMemberAccess ) { completionOnMemberAccess ( astNode , enclosingNode , qualifiedBinding , scope , insideTypeAnnotation ) ; } else if ( astNode instanceof CompletionOnMessageSend ) { completionOnMessageSend ( astNode , qualifiedBinding , scope ) ; } else if ( astNode instanceof CompletionOnExplicitConstructorCall ) { completionOnExplicitConstructorCall ( astNode , qualifiedBinding , scope ) ; } else if ( astNode instanceof CompletionOnQualifiedAllocationExpression ) { completionOnQualifiedAllocationExpression ( astNode , qualifiedBinding , scope ) ; } else if ( astNode instanceof CompletionOnClassLiteralAccess ) { completionOnClassLiteralAccess ( astNode , qualifiedBinding , scope ) ; } else if ( astNode instanceof CompletionOnMethodName ) { completionOnMethodName ( astNode , scope ) ; } else if ( astNode instanceof CompletionOnFieldName ) { completionOnFieldName ( astNode , scope ) ; } else if ( astNode instanceof CompletionOnLocalName ) { completionOnLocalOrArgumentName ( astNode , scope ) ; } else if ( astNode instanceof CompletionOnArgumentName ) { completionOnLocalOrArgumentName ( astNode , scope ) ; } else if ( astNode instanceof CompletionOnKeyword ) { completionOnKeyword ( astNode ) ; } else if ( astNode instanceof CompletionOnParameterizedQualifiedTypeReference ) { completionOnParameterizedQualifiedTypeReference ( astNode , astNodeParent , qualifiedBinding , scope ) ; } else if ( astNode instanceof CompletionOnMarkerAnnotationName ) { completionOnMarkerAnnotationName ( astNode , qualifiedBinding , scope ) ; } else if ( astNode instanceof CompletionOnMemberValueName ) { completionOnMemberValueName ( astNode , astNodeParent , scope , insideTypeAnnotation ) ; } else if ( astNode instanceof CompletionOnBranchStatementLabel ) { completionOnBranchStatementLabel ( astNode ) ; } else if ( astNode instanceof CompletionOnMessageSendName ) { completionOnMessageSendName ( astNode , qualifiedBinding , scope ) ; } else if ( ( astNode . bits & ASTNode . InsideJavadoc ) != <NUM_LIT:0> ) { if ( astNode instanceof CompletionOnJavadocSingleTypeReference ) { completionOnJavadocSingleTypeReference ( astNode , scope ) ; } else if ( astNode instanceof CompletionOnJavadocQualifiedTypeReference ) { completionOnJavadocQualifiedTypeReference ( astNode , qualifiedBinding , scope ) ; } else if ( astNode instanceof CompletionOnJavadocFieldReference ) { completionOnJavadocFieldReference ( astNode , scope ) ; } else if ( astNode instanceof CompletionOnJavadocMessageSend ) { completionOnJavadocMessageSend ( astNode , qualifiedBinding , scope ) ; } else if ( astNode instanceof CompletionOnJavadocAllocationExpression ) { completionOnJavadocAllocationExpression ( astNode , qualifiedBinding , scope ) ; } else if ( astNode instanceof CompletionOnJavadocParamNameReference ) { completionOnJavadocParamNameReference ( astNode ) ; } else if ( astNode instanceof CompletionOnJavadocTypeParamReference ) { completionOnJavadocTypeParamReference ( astNode ) ; } else if ( astNode instanceof CompletionOnJavadocTag ) { completionOnJavadocTag ( astNode ) ; } } return true ; } public void complete ( ICompilationUnit sourceUnit , int completionPosition , int pos , ITypeRoot root ) { if ( DEBUG ) { System . out . print ( "<STR_LIT>" ) ; System . out . print ( sourceUnit . getFileName ( ) ) ; System . out . print ( "<STR_LIT>" ) ; System . out . println ( completionPosition ) ; System . out . println ( "<STR_LIT>" ) ; System . out . println ( sourceUnit . getContents ( ) ) ; } if ( this . monitor != null ) this . monitor . beginTask ( Messages . engine_completing , IProgressMonitor . UNKNOWN ) ; this . requestor . beginReporting ( ) ; boolean contextAccepted = false ; try { this . fileName = sourceUnit . getFileName ( ) ; this . actualCompletionPosition = completionPosition - <NUM_LIT:1> ; this . offset = pos ; this . typeRoot = root ; this . checkCancel ( ) ; CompilationResult result = new CompilationResult ( sourceUnit , <NUM_LIT:1> , <NUM_LIT:1> , this . compilerOptions . maxProblemsPerUnit ) ; CompilationUnitDeclaration parsedUnit = this . parser . dietParse ( sourceUnit , result , this . actualCompletionPosition ) ; if ( parsedUnit != null ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; System . out . println ( parsedUnit . toString ( ) ) ; } if ( parsedUnit . currentPackage instanceof CompletionOnPackageReference ) { contextAccepted = true ; buildContext ( parsedUnit . currentPackage , null , parsedUnit , null , null ) ; if ( ! this . requestor . isIgnored ( CompletionProposal . PACKAGE_REF ) ) { findPackages ( ( CompletionOnPackageReference ) parsedUnit . currentPackage ) ; } if ( this . noProposal && this . problem != null ) { this . requestor . completionFailure ( this . problem ) ; if ( DEBUG ) { this . printDebug ( this . problem ) ; } } return ; } ImportReference [ ] imports = parsedUnit . imports ; if ( imports != null ) { for ( int i = <NUM_LIT:0> , length = imports . length ; i < length ; i ++ ) { ImportReference importReference = imports [ i ] ; if ( importReference instanceof CompletionOnImportReference ) { this . lookupEnvironment . buildTypeBindings ( parsedUnit , null ) ; if ( ( this . unitScope = parsedUnit . scope ) != null ) { contextAccepted = true ; buildContext ( importReference , null , parsedUnit , null , null ) ; long positions = importReference . sourcePositions [ importReference . tokens . length - <NUM_LIT:1> ] ; setSourceAndTokenRange ( ( int ) ( positions > > > <NUM_LIT:32> ) , ( int ) positions ) ; char [ ] [ ] oldTokens = importReference . tokens ; int tokenCount = oldTokens . length ; if ( tokenCount == <NUM_LIT:1> ) { findImports ( ( CompletionOnImportReference ) importReference , true ) ; } else if ( tokenCount > <NUM_LIT:1> ) { this . insideQualifiedReference = true ; char [ ] lastToken = oldTokens [ tokenCount - <NUM_LIT:1> ] ; char [ ] [ ] qualifierTokens = CharOperation . subarray ( oldTokens , <NUM_LIT:0> , tokenCount - <NUM_LIT:1> ) ; Binding binding = this . unitScope . getTypeOrPackage ( qualifierTokens ) ; if ( binding != null ) { if ( binding instanceof PackageBinding ) { findImports ( ( CompletionOnImportReference ) importReference , false ) ; } else { ReferenceBinding ref = ( ReferenceBinding ) binding ; if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { findImportsOfMemberTypes ( lastToken , ref , importReference . isStatic ( ) ) ; } if ( importReference . isStatic ( ) ) { if ( ! this . requestor . isIgnored ( CompletionProposal . FIELD_REF ) ) { findImportsOfStaticFields ( lastToken , ref ) ; } if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_NAME_REFERENCE ) ) { findImportsOfStaticMethods ( lastToken , ref ) ; } } } } } if ( this . noProposal && this . problem != null ) { this . requestor . completionFailure ( this . problem ) ; if ( DEBUG ) { this . printDebug ( this . problem ) ; } } } return ; } else if ( importReference instanceof CompletionOnKeyword ) { contextAccepted = true ; buildContext ( importReference , null , parsedUnit , null , null ) ; if ( ! this . requestor . isIgnored ( CompletionProposal . KEYWORD ) ) { setSourceAndTokenRange ( importReference . sourceStart , importReference . sourceEnd ) ; CompletionOnKeyword keyword = ( CompletionOnKeyword ) importReference ; findKeywords ( keyword . getToken ( ) , keyword . getPossibleKeywords ( ) , true , false , parsedUnit . currentPackage != null ) ; } if ( this . noProposal && this . problem != null ) { this . requestor . completionFailure ( this . problem ) ; if ( DEBUG ) { this . printDebug ( this . problem ) ; } } return ; } } } if ( parsedUnit . types != null ) { try { this . lookupEnvironment . buildTypeBindings ( parsedUnit , null ) ; if ( ( this . unitScope = parsedUnit . scope ) != null ) { this . source = sourceUnit . getContents ( ) ; this . lookupEnvironment . completeTypeBindings ( parsedUnit , true ) ; parsedUnit . scope . faultInTypes ( ) ; parseBlockStatements ( parsedUnit , this . actualCompletionPosition ) ; if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; System . out . println ( parsedUnit . toString ( ) ) ; } parsedUnit . resolve ( ) ; } } catch ( CompletionNodeFound e ) { if ( e . astNode != null ) { if ( DEBUG ) { System . out . print ( "<STR_LIT>" ) ; System . out . println ( e . astNode . toString ( ) ) ; if ( this . parser . assistNodeParent != null ) { System . out . print ( "<STR_LIT>" ) ; System . out . println ( this . parser . assistNodeParent ) ; } } this . lookupEnvironment . unitBeingCompleted = parsedUnit ; contextAccepted = complete ( e . astNode , this . parser . assistNodeParent , this . parser . enclosingNode , parsedUnit , e . qualifiedBinding , e . scope , e . insideTypeAnnotation ) ; } } } } if ( this . noProposal && this . problem != null ) { if ( ! contextAccepted ) { contextAccepted = true ; InternalCompletionContext context = new InternalCompletionContext ( ) ; context . setOffset ( completionPosition - this . offset ) ; context . setTokenKind ( CompletionContext . TOKEN_KIND_UNKNOWN ) ; if ( this . requestor . isExtendedContextRequired ( ) ) context . setExtended ( ) ; this . requestor . acceptContext ( context ) ; } this . requestor . completionFailure ( this . problem ) ; if ( DEBUG ) { this . printDebug ( this . problem ) ; } } } catch ( IndexOutOfBoundsException e ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; e . printStackTrace ( System . out ) ; } } catch ( InvalidCursorLocation e ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; e . printStackTrace ( System . out ) ; } } catch ( AbortCompilation e ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; e . printStackTrace ( System . out ) ; } } catch ( CompletionNodeFound e ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; e . printStackTrace ( System . out ) ; } } finally { if ( ! contextAccepted ) { contextAccepted = true ; InternalCompletionContext context = new InternalCompletionContext ( ) ; context . setTokenKind ( CompletionContext . TOKEN_KIND_UNKNOWN ) ; context . setOffset ( completionPosition - this . offset ) ; if ( this . requestor . isExtendedContextRequired ( ) ) context . setExtended ( ) ; this . requestor . acceptContext ( context ) ; } this . requestor . endReporting ( ) ; if ( this . monitor != null ) this . monitor . done ( ) ; reset ( ) ; } } public void complete ( IType type , char [ ] snippet , int position , char [ ] [ ] localVariableTypeNames , char [ ] [ ] localVariableNames , int [ ] localVariableModifiers , boolean isStatic ) { if ( this . requestor != null ) { this . requestor . beginReporting ( ) ; } boolean contextAccepted = false ; IType topLevelType = type ; while ( topLevelType . getDeclaringType ( ) != null ) { topLevelType = topLevelType . getDeclaringType ( ) ; } this . fileName = topLevelType . getParent ( ) . getElementName ( ) . toCharArray ( ) ; CompilationResult compilationResult = new CompilationResult ( this . fileName , <NUM_LIT:1> , <NUM_LIT:1> , this . compilerOptions . maxProblemsPerUnit ) ; CompilationUnitDeclaration compilationUnit = null ; try { TypeDeclaration typeDeclaration = null ; if ( type instanceof SourceType ) { SourceType sourceType = ( SourceType ) type ; ISourceType info = ( ISourceType ) sourceType . getElementInfo ( ) ; compilationUnit = SourceTypeConverter . buildCompilationUnit ( new ISourceType [ ] { info } , SourceTypeConverter . FIELD_AND_METHOD | SourceTypeConverter . MEMBER_TYPE , this . problemReporter , compilationResult ) ; if ( compilationUnit . types != null ) typeDeclaration = compilationUnit . types [ <NUM_LIT:0> ] ; } else { compilationUnit = new CompilationUnitDeclaration ( this . problemReporter , compilationResult , <NUM_LIT:0> ) ; typeDeclaration = new BinaryTypeConverter ( this . parser . problemReporter ( ) , compilationResult , null ) . buildTypeDeclaration ( type , compilationUnit ) ; } if ( typeDeclaration != null ) { Initializer fakeInitializer = parseSnippeInitializer ( snippet , position , localVariableTypeNames , localVariableNames , localVariableModifiers , isStatic ) ; FieldDeclaration [ ] oldFields = typeDeclaration . fields ; FieldDeclaration [ ] newFields = null ; if ( oldFields != null ) { newFields = new FieldDeclaration [ oldFields . length + <NUM_LIT:1> ] ; System . arraycopy ( oldFields , <NUM_LIT:0> , newFields , <NUM_LIT:0> , oldFields . length ) ; newFields [ oldFields . length ] = fakeInitializer ; } else { newFields = new FieldDeclaration [ ] { fakeInitializer } ; } typeDeclaration . fields = newFields ; if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; System . out . println ( compilationUnit . toString ( ) ) ; } if ( compilationUnit . types != null ) { try { this . lookupEnvironment . buildTypeBindings ( compilationUnit , null ) ; if ( ( this . unitScope = compilationUnit . scope ) != null ) { this . lookupEnvironment . completeTypeBindings ( compilationUnit , true ) ; compilationUnit . scope . faultInTypes ( ) ; compilationUnit . resolve ( ) ; } } catch ( CompletionNodeFound e ) { if ( e . astNode != null ) { contextAccepted = complete ( e . astNode , this . parser . assistNodeParent , this . parser . enclosingNode , compilationUnit , e . qualifiedBinding , e . scope , e . insideTypeAnnotation ) ; } } } if ( this . noProposal && this . problem != null ) { if ( ! contextAccepted ) { contextAccepted = true ; InternalCompletionContext context = new InternalCompletionContext ( ) ; if ( this . requestor . isExtendedContextRequired ( ) ) context . setExtended ( ) ; this . requestor . acceptContext ( context ) ; } this . requestor . completionFailure ( this . problem ) ; if ( DEBUG ) { this . printDebug ( this . problem ) ; } } } } catch ( IndexOutOfBoundsException e ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; e . printStackTrace ( System . out ) ; } } catch ( InvalidCursorLocation e ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; e . printStackTrace ( System . out ) ; } } catch ( AbortCompilation e ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; e . printStackTrace ( System . out ) ; } } catch ( CompletionNodeFound e ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; e . printStackTrace ( System . out ) ; } } catch ( JavaModelException e ) { } if ( ! contextAccepted ) { contextAccepted = true ; InternalCompletionContext context = new InternalCompletionContext ( ) ; if ( this . requestor . isExtendedContextRequired ( ) ) context . setExtended ( ) ; this . requestor . acceptContext ( context ) ; } if ( this . requestor != null ) { this . requestor . endReporting ( ) ; } } private void completionOnBranchStatementLabel ( ASTNode astNode ) { if ( ! this . requestor . isIgnored ( CompletionProposal . LABEL_REF ) ) { CompletionOnBranchStatementLabel label = ( CompletionOnBranchStatementLabel ) astNode ; this . completionToken = label . label ; findLabels ( this . completionToken , label . possibleLabels ) ; } } private void completionOnClassLiteralAccess ( ASTNode astNode , Binding qualifiedBinding , Scope scope ) { if ( ! this . requestor . isIgnored ( CompletionProposal . FIELD_REF ) ) { CompletionOnClassLiteralAccess access = ( CompletionOnClassLiteralAccess ) astNode ; setSourceAndTokenRange ( access . classStart , access . sourceEnd ) ; this . completionToken = access . completionIdentifier ; findClassField ( this . completionToken , ( TypeBinding ) qualifiedBinding , scope , null , null , null , false ) ; } } private void completionOnExplicitConstructorCall ( ASTNode astNode , Binding qualifiedBinding , Scope scope ) { if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) ) { setSourceAndTokenRange ( astNode . sourceStart , astNode . sourceEnd , false ) ; CompletionOnExplicitConstructorCall constructorCall = ( CompletionOnExplicitConstructorCall ) astNode ; TypeBinding [ ] argTypes = computeTypes ( constructorCall . arguments ) ; findConstructors ( ( ReferenceBinding ) qualifiedBinding , argTypes , scope , constructorCall , false , null , null , null , false ) ; } } private void completionOnFieldName ( ASTNode astNode , Scope scope ) { if ( ! this . requestor . isIgnored ( CompletionProposal . VARIABLE_DECLARATION ) ) { CompletionOnFieldName field = ( CompletionOnFieldName ) astNode ; FieldBinding [ ] fields = scope . enclosingSourceType ( ) . fields ( ) ; char [ ] [ ] excludeNames = new char [ fields . length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < fields . length ; i ++ ) { excludeNames [ i ] = fields [ i ] . name ; } this . completionToken = field . realName ; int kind = ( field . modifiers & ClassFileConstants . AccStatic ) == <NUM_LIT:0> ? InternalNamingConventions . VK_INSTANCE_FIELD : ( field . modifiers & ClassFileConstants . AccFinal ) == <NUM_LIT:0> ? InternalNamingConventions . VK_STATIC_FIELD : InternalNamingConventions . VK_STATIC_FINAL_FIELD ; findVariableNames ( field . realName , field . type , excludeNames , null , kind ) ; } } private void completionOnFieldType ( ASTNode astNode , Scope scope ) { CompletionOnFieldType field = ( CompletionOnFieldType ) astNode ; CompletionOnSingleTypeReference type = ( CompletionOnSingleTypeReference ) field . type ; this . completionToken = type . token ; setSourceAndTokenRange ( type . sourceStart , type . sourceEnd ) ; findTypesAndPackages ( this . completionToken , scope , true , true , new ObjectVector ( ) ) ; if ( ! this . requestor . isIgnored ( CompletionProposal . KEYWORD ) ) { findKeywordsForMember ( this . completionToken , field . modifiers ) ; } if ( ! field . isLocalVariable && field . modifiers == ClassFileConstants . AccDefault ) { SourceTypeBinding enclosingType = scope . enclosingSourceType ( ) ; if ( ! enclosingType . isAnnotationType ( ) ) { if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_DECLARATION ) ) { findMethodDeclarations ( this . completionToken , enclosingType , scope , new ObjectVector ( ) , null , null , null , false ) ; } if ( ! this . requestor . isIgnored ( CompletionProposal . POTENTIAL_METHOD_DECLARATION ) ) { proposeNewMethod ( this . completionToken , enclosingType ) ; } } } } private void completionOnJavadocAllocationExpression ( ASTNode astNode , Binding qualifiedBinding , Scope scope ) { CompletionOnJavadocAllocationExpression allocExpression = ( CompletionOnJavadocAllocationExpression ) astNode ; this . javadocTagPosition = allocExpression . tagSourceStart ; int rangeStart = astNode . sourceStart ; if ( allocExpression . type . isThis ( ) ) { if ( allocExpression . completeInText ( ) ) { rangeStart = allocExpression . separatorPosition ; } } else if ( allocExpression . completeInText ( ) ) { rangeStart = allocExpression . type . sourceStart ; } setSourceAndTokenRange ( rangeStart , astNode . sourceEnd , false ) ; TypeBinding [ ] argTypes = computeTypes ( allocExpression . arguments ) ; ReferenceBinding ref = ( ReferenceBinding ) qualifiedBinding ; if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) && ref . isClass ( ) ) { findConstructors ( ref , argTypes , scope , allocExpression , false , null , null , null , false ) ; } } private void completionOnJavadocFieldReference ( ASTNode astNode , Scope scope ) { this . insideQualifiedReference = true ; CompletionOnJavadocFieldReference fieldRef = ( CompletionOnJavadocFieldReference ) astNode ; this . completionToken = fieldRef . token ; long completionPosition = fieldRef . nameSourcePosition ; this . javadocTagPosition = fieldRef . tagSourceStart ; if ( fieldRef . actualReceiverType != null && fieldRef . actualReceiverType . isValidBinding ( ) ) { ReferenceBinding receiverType = ( ReferenceBinding ) fieldRef . actualReceiverType ; int rangeStart = ( int ) ( completionPosition > > > <NUM_LIT:32> ) ; if ( fieldRef . receiver . isThis ( ) ) { if ( fieldRef . completeInText ( ) ) { rangeStart = fieldRef . separatorPosition ; } } else if ( fieldRef . completeInText ( ) ) { rangeStart = fieldRef . receiver . sourceStart ; } setSourceAndTokenRange ( rangeStart , ( int ) completionPosition ) ; if ( ! this . requestor . isIgnored ( CompletionProposal . FIELD_REF ) || ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_FIELD_REF ) ) { findFields ( this . completionToken , receiverType , scope , new ObjectVector ( ) , new ObjectVector ( ) , false , fieldRef , scope , false , true , null , null , null , false , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; } if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) || ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_METHOD_REF ) ) { findMethods ( this . completionToken , null , null , receiverType , scope , new ObjectVector ( ) , false , false , fieldRef , scope , false , false , true , null , null , null , false , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; if ( fieldRef . actualReceiverType instanceof ReferenceBinding ) { ReferenceBinding refBinding = ( ReferenceBinding ) fieldRef . actualReceiverType ; if ( this . completionToken == null || CharOperation . prefixEquals ( this . completionToken , refBinding . sourceName ) || ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( this . completionToken , refBinding . sourceName ) ) ) { findConstructors ( refBinding , null , scope , fieldRef , false , null , null , null , false ) ; } } } } } private void completionOnJavadocMessageSend ( ASTNode astNode , Binding qualifiedBinding , Scope scope ) { CompletionOnJavadocMessageSend messageSend = ( CompletionOnJavadocMessageSend ) astNode ; TypeBinding [ ] argTypes = null ; this . completionToken = messageSend . selector ; this . javadocTagPosition = messageSend . tagSourceStart ; int rangeStart = astNode . sourceStart ; if ( messageSend . receiver . isThis ( ) ) { if ( messageSend . completeInText ( ) ) { rangeStart = messageSend . separatorPosition ; } } else if ( messageSend . completeInText ( ) ) { rangeStart = messageSend . receiver . sourceStart ; } setSourceAndTokenRange ( rangeStart , astNode . sourceEnd , false ) ; if ( qualifiedBinding == null ) { if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) ) { findImplicitMessageSends ( this . completionToken , argTypes , scope , messageSend , scope , new ObjectVector ( ) ) ; } } else if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) ) { findMethods ( this . completionToken , null , argTypes , ( ReferenceBinding ) ( ( ReferenceBinding ) qualifiedBinding ) . capture ( scope , messageSend . receiver . sourceEnd ) , scope , new ObjectVector ( ) , false , false , messageSend , scope , false , messageSend . receiver instanceof SuperReference , true , null , null , null , false , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; } } private void completionOnJavadocParamNameReference ( ASTNode astNode ) { if ( ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_PARAM_REF ) ) { CompletionOnJavadocParamNameReference paramRef = ( CompletionOnJavadocParamNameReference ) astNode ; setSourceAndTokenRange ( paramRef . tagSourceStart , paramRef . tagSourceEnd ) ; findJavadocParamNames ( paramRef . token , paramRef . missingParams , false ) ; findJavadocParamNames ( paramRef . token , paramRef . missingTypeParams , true ) ; } } private void completionOnJavadocQualifiedTypeReference ( ASTNode astNode , Binding qualifiedBinding , Scope scope ) { this . insideQualifiedReference = true ; CompletionOnJavadocQualifiedTypeReference typeRef = ( CompletionOnJavadocQualifiedTypeReference ) astNode ; this . completionToken = typeRef . completionIdentifier ; long completionPosition = typeRef . sourcePositions [ typeRef . tokens . length ] ; this . javadocTagPosition = typeRef . tagSourceStart ; if ( qualifiedBinding instanceof ReferenceBinding && ! ( qualifiedBinding instanceof TypeVariableBinding ) ) { if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) || ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> && ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_TYPE_REF ) ) ) { int rangeStart = typeRef . completeInText ( ) ? typeRef . sourceStart : ( int ) ( completionPosition > > > <NUM_LIT:32> ) ; setSourceAndTokenRange ( rangeStart , ( int ) completionPosition ) ; findMemberTypes ( this . completionToken , ( ReferenceBinding ) qualifiedBinding , scope , scope . enclosingSourceType ( ) , false , false , new ObjectVector ( ) , null , null , null , false ) ; } } else if ( qualifiedBinding instanceof PackageBinding ) { setSourceRange ( astNode . sourceStart , ( int ) completionPosition ) ; int rangeStart = typeRef . completeInText ( ) ? typeRef . sourceStart : ( int ) ( completionPosition > > > <NUM_LIT:32> ) ; setTokenRange ( rangeStart , ( int ) completionPosition ) ; findTypesAndSubpackages ( this . completionToken , ( PackageBinding ) qualifiedBinding , scope ) ; } } private void completionOnJavadocSingleTypeReference ( ASTNode astNode , Scope scope ) { CompletionOnJavadocSingleTypeReference typeRef = ( CompletionOnJavadocSingleTypeReference ) astNode ; this . completionToken = typeRef . token ; this . javadocTagPosition = typeRef . tagSourceStart ; setSourceAndTokenRange ( typeRef . sourceStart , typeRef . sourceEnd ) ; findTypesAndPackages ( this . completionToken , scope , ( this . assistNodeInJavadoc & CompletionOnJavadoc . BASE_TYPES ) != <NUM_LIT:0> , false , new ObjectVector ( ) ) ; } private void completionOnJavadocTag ( ASTNode astNode ) { CompletionOnJavadocTag javadocTag = ( CompletionOnJavadocTag ) astNode ; setSourceAndTokenRange ( javadocTag . tagSourceStart , javadocTag . sourceEnd ) ; findJavadocBlockTags ( javadocTag ) ; findJavadocInlineTags ( javadocTag ) ; } private void completionOnJavadocTypeParamReference ( ASTNode astNode ) { if ( ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_PARAM_REF ) ) { CompletionOnJavadocTypeParamReference paramRef = ( CompletionOnJavadocTypeParamReference ) astNode ; setSourceAndTokenRange ( paramRef . tagSourceStart , paramRef . tagSourceEnd ) ; findJavadocParamNames ( paramRef . token , paramRef . missingParams , true ) ; } } private void completionOnKeyword ( ASTNode astNode ) { if ( ! this . requestor . isIgnored ( CompletionProposal . KEYWORD ) ) { CompletionOnKeyword keyword = ( CompletionOnKeyword ) astNode ; findKeywords ( keyword . getToken ( ) , keyword . getPossibleKeywords ( ) , keyword . canCompleteEmptyToken ( ) , false , false ) ; } } private void completionOnLocalOrArgumentName ( ASTNode astNode , Scope scope ) { if ( ! this . requestor . isIgnored ( CompletionProposal . VARIABLE_DECLARATION ) ) { LocalDeclaration variable = ( LocalDeclaration ) astNode ; int kind ; if ( variable instanceof CompletionOnLocalName ) { this . completionToken = ( ( CompletionOnLocalName ) variable ) . realName ; kind = InternalNamingConventions . VK_LOCAL ; } else { CompletionOnArgumentName arg = ( CompletionOnArgumentName ) variable ; this . completionToken = arg . realName ; kind = arg . isCatchArgument ? InternalNamingConventions . VK_LOCAL : InternalNamingConventions . VK_PARAMETER ; } char [ ] [ ] alreadyDefinedName = computeAlreadyDefinedName ( ( BlockScope ) scope , variable ) ; char [ ] [ ] forbiddenNames = findVariableFromUnresolvedReference ( variable , ( BlockScope ) scope , alreadyDefinedName ) ; LocalVariableBinding [ ] locals = ( ( BlockScope ) scope ) . locals ; char [ ] [ ] discouragedNames = new char [ locals . length ] [ ] ; int localCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < locals . length ; i ++ ) { if ( locals [ i ] != null ) { discouragedNames [ localCount ++ ] = locals [ i ] . name ; } } System . arraycopy ( discouragedNames , <NUM_LIT:0> , discouragedNames = new char [ localCount ] [ ] , <NUM_LIT:0> , localCount ) ; findVariableNames ( this . completionToken , variable . type , discouragedNames , forbiddenNames , kind ) ; } } private void completionOnMarkerAnnotationName ( ASTNode astNode , Binding qualifiedBinding , Scope scope ) { CompletionOnMarkerAnnotationName annot = ( CompletionOnMarkerAnnotationName ) astNode ; CompletionOnAnnotationOfType fakeType = ( CompletionOnAnnotationOfType ) scope . parent . referenceContext ( ) ; if ( fakeType . annotations [ <NUM_LIT:0> ] == annot ) { if ( scope . parent . parent == null || ! ( scope . parent . parent instanceof MethodScope ) ) { this . targetedElement = computeTargetedElement ( fakeType ) ; } } this . assistNodeIsAnnotation = true ; if ( annot . type instanceof CompletionOnSingleTypeReference ) { CompletionOnSingleTypeReference type = ( CompletionOnSingleTypeReference ) annot . type ; this . completionToken = type . token ; setSourceAndTokenRange ( type . sourceStart , type . sourceEnd ) ; if ( scope . parent . parent != null && ! ( scope . parent . parent instanceof MethodScope ) && ! fakeType . isParameter ) { if ( this . completionToken . length <= Keywords . INTERFACE . length && CharOperation . prefixEquals ( this . completionToken , Keywords . INTERFACE , false ) ) { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( this . completionToken , Keywords . INTERFACE ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; relevance += R_ANNOTATION ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . KEYWORD ) ) { CompletionProposal proposal = createProposal ( CompletionProposal . KEYWORD , this . actualCompletionPosition ) ; proposal . setName ( Keywords . INTERFACE ) ; proposal . setCompletion ( Keywords . INTERFACE ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } findTypesAndPackages ( this . completionToken , scope , false , false , new ObjectVector ( ) ) ; } else if ( annot . type instanceof CompletionOnQualifiedTypeReference ) { this . insideQualifiedReference = true ; CompletionOnQualifiedTypeReference type = ( CompletionOnQualifiedTypeReference ) annot . type ; this . completionToken = type . completionIdentifier ; long completionPosition = type . sourcePositions [ type . tokens . length ] ; if ( qualifiedBinding instanceof PackageBinding ) { setSourceRange ( astNode . sourceStart , ( int ) completionPosition ) ; setTokenRange ( ( int ) ( completionPosition > > > <NUM_LIT:32> ) , ( int ) completionPosition ) ; findTypesAndSubpackages ( this . completionToken , ( PackageBinding ) qualifiedBinding , scope ) ; } else { setSourceAndTokenRange ( ( int ) ( completionPosition > > > <NUM_LIT:32> ) , ( int ) completionPosition ) ; findMemberTypes ( this . completionToken , ( ReferenceBinding ) qualifiedBinding , scope , scope . enclosingSourceType ( ) , false , false , new ObjectVector ( ) , null , null , null , false ) ; } } } private void completionOnMemberAccess ( ASTNode astNode , ASTNode enclosingNode , Binding qualifiedBinding , Scope scope , boolean insideTypeAnnotation ) { this . insideQualifiedReference = true ; CompletionOnMemberAccess access = ( CompletionOnMemberAccess ) astNode ; long completionPosition = access . nameSourcePosition ; setSourceAndTokenRange ( ( int ) ( completionPosition > > > <NUM_LIT:32> ) , ( int ) completionPosition ) ; this . completionToken = access . token ; if ( qualifiedBinding . problemId ( ) == ProblemReasons . NotFound ) { if ( this . assistNodeInJavadoc == <NUM_LIT:0> && ( this . requestor . isAllowingRequiredProposals ( CompletionProposal . FIELD_REF , CompletionProposal . TYPE_REF ) || this . requestor . isAllowingRequiredProposals ( CompletionProposal . METHOD_REF , CompletionProposal . TYPE_REF ) ) ) { ProblemMethodBinding problemMethodBinding = ( ProblemMethodBinding ) qualifiedBinding ; findFieldsAndMethodsFromMissingReturnType ( problemMethodBinding . selector , problemMethodBinding . parameters , scope , access , insideTypeAnnotation ) ; } } else { if ( ! access . isInsideAnnotation ) { if ( ! this . requestor . isIgnored ( CompletionProposal . KEYWORD ) ) { findKeywords ( this . completionToken , new char [ ] [ ] { Keywords . NEW } , false , false , false ) ; } ObjectVector fieldsFound = new ObjectVector ( ) ; ObjectVector methodsFound = new ObjectVector ( ) ; boolean superCall = access . receiver instanceof SuperReference ; findFieldsAndMethods ( this . completionToken , ( ( TypeBinding ) qualifiedBinding ) . capture ( scope , access . receiver . sourceEnd ) , scope , fieldsFound , methodsFound , access , scope , false , superCall , null , null , null , false , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; if ( ! superCall ) { checkCancel ( ) ; findFieldsAndMethodsFromCastedReceiver ( enclosingNode , qualifiedBinding , scope , fieldsFound , methodsFound , access , scope , access . receiver ) ; } } } } private void completionOnMemberValueName ( ASTNode astNode , ASTNode astNodeParent , Scope scope , boolean insideTypeAnnotation ) { CompletionOnMemberValueName memberValuePair = ( CompletionOnMemberValueName ) astNode ; Annotation annotation = ( Annotation ) astNodeParent ; this . completionToken = memberValuePair . name ; ReferenceBinding annotationType = ( ReferenceBinding ) annotation . resolvedType ; if ( annotationType != null && annotationType . isAnnotationType ( ) ) { if ( ! this . requestor . isIgnored ( CompletionProposal . ANNOTATION_ATTRIBUTE_REF ) ) { findAnnotationAttributes ( this . completionToken , annotation . memberValuePairs ( ) , annotationType ) ; } if ( this . assistNodeCanBeSingleMemberAnnotation ) { if ( this . expectedTypesPtr > - <NUM_LIT:1> && this . expectedTypes [ <NUM_LIT:0> ] . isAnnotationType ( ) ) { findTypesAndPackages ( this . completionToken , scope , false , false , new ObjectVector ( ) ) ; } else { if ( this . expectedTypesPtr > - <NUM_LIT:1> ) { this . assistNodeIsEnum = true ; done : for ( int i = <NUM_LIT:0> ; i <= this . expectedTypesPtr ; i ++ ) { if ( ! this . expectedTypes [ i ] . isEnum ( ) ) { this . assistNodeIsEnum = false ; break done ; } } } if ( scope instanceof BlockScope && ! this . requestor . isIgnored ( CompletionProposal . LOCAL_VARIABLE_REF ) ) { char [ ] [ ] alreadyDefinedName = computeAlreadyDefinedName ( ( BlockScope ) scope , FakeInvocationSite ) ; findUnresolvedReference ( memberValuePair . sourceStart , memberValuePair . sourceEnd , ( BlockScope ) scope , alreadyDefinedName ) ; } findVariablesAndMethods ( this . completionToken , scope , FakeInvocationSite , scope , insideTypeAnnotation , true ) ; findTypesAndPackages ( this . completionToken , scope , false , false , new ObjectVector ( ) ) ; } } } } private void completionOnMessageSend ( ASTNode astNode , Binding qualifiedBinding , Scope scope ) { setSourceAndTokenRange ( astNode . sourceStart , astNode . sourceEnd , false ) ; CompletionOnMessageSend messageSend = ( CompletionOnMessageSend ) astNode ; TypeBinding [ ] argTypes = computeTypes ( messageSend . arguments ) ; this . completionToken = messageSend . selector ; if ( qualifiedBinding == null ) { if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) ) { ObjectVector methodsFound = new ObjectVector ( ) ; findImplicitMessageSends ( this . completionToken , argTypes , scope , messageSend , scope , methodsFound ) ; checkCancel ( ) ; findLocalMethodsFromStaticImports ( this . completionToken , scope , messageSend , scope , true , methodsFound , true ) ; } } else if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) ) { findMethods ( this . completionToken , null , argTypes , ( ReferenceBinding ) ( ( ReferenceBinding ) qualifiedBinding ) . capture ( scope , messageSend . receiver . sourceEnd ) , scope , new ObjectVector ( ) , false , true , messageSend , scope , false , messageSend . receiver instanceof SuperReference , false , null , null , null , false , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; } } private void completionOnMessageSendName ( ASTNode astNode , Binding qualifiedBinding , Scope scope ) { if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) ) { CompletionOnMessageSendName messageSend = ( CompletionOnMessageSendName ) astNode ; this . insideQualifiedReference = true ; this . completionToken = messageSend . selector ; boolean onlyStatic = false ; if ( messageSend . receiver instanceof NameReference ) { onlyStatic = ( ( NameReference ) messageSend . receiver ) . isTypeReference ( ) ; } else if ( ! ( messageSend . receiver instanceof MessageSend ) && ! ( messageSend . receiver instanceof FieldReference ) && ! ( messageSend . receiver . isThis ( ) ) ) { onlyStatic = true ; } TypeBinding receiverType = ( TypeBinding ) qualifiedBinding ; if ( receiverType != null && receiverType instanceof ReferenceBinding ) { TypeBinding [ ] typeArgTypes = computeTypesIfCorrect ( messageSend . typeArguments ) ; if ( typeArgTypes != null ) { findMethods ( this . completionToken , typeArgTypes , null , ( ReferenceBinding ) receiverType . capture ( scope , messageSend . receiver . sourceEnd ) , scope , new ObjectVector ( ) , onlyStatic , false , messageSend , scope , false , false , false , null , null , null , false , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; } } } } private void completionOnMethodName ( ASTNode astNode , Scope scope ) { if ( ! this . requestor . isIgnored ( CompletionProposal . VARIABLE_DECLARATION ) ) { CompletionOnMethodName method = ( CompletionOnMethodName ) astNode ; setSourceAndTokenRange ( method . sourceStart , method . selectorEnd ) ; FieldBinding [ ] fields = scope . enclosingSourceType ( ) . fields ( ) ; char [ ] [ ] excludeNames = new char [ fields . length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < fields . length ; i ++ ) { excludeNames [ i ] = fields [ i ] . name ; } this . completionToken = method . selector ; int kind = ( method . modifiers & ClassFileConstants . AccStatic ) == <NUM_LIT:0> ? InternalNamingConventions . VK_INSTANCE_FIELD : ( method . modifiers & ClassFileConstants . AccFinal ) == <NUM_LIT:0> ? InternalNamingConventions . VK_STATIC_FIELD : InternalNamingConventions . VK_STATIC_FINAL_FIELD ; findVariableNames ( this . completionToken , method . returnType , excludeNames , null , kind ) ; } } private void completionOnMethodReturnType ( ASTNode astNode , Scope scope ) { CompletionOnMethodReturnType method = ( CompletionOnMethodReturnType ) astNode ; SingleTypeReference type = ( CompletionOnSingleTypeReference ) method . returnType ; this . completionToken = type . token ; setSourceAndTokenRange ( type . sourceStart , type . sourceEnd ) ; findTypesAndPackages ( this . completionToken , scope . parent , true , true , new ObjectVector ( ) ) ; if ( ! this . requestor . isIgnored ( CompletionProposal . KEYWORD ) ) { findKeywordsForMember ( this . completionToken , method . modifiers ) ; } if ( method . modifiers == ClassFileConstants . AccDefault ) { SourceTypeBinding enclosingType = scope . enclosingSourceType ( ) ; if ( ! enclosingType . isAnnotationType ( ) ) { if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_DECLARATION ) ) { findMethodDeclarations ( this . completionToken , scope . enclosingSourceType ( ) , scope , new ObjectVector ( ) , null , null , null , false ) ; } if ( ! this . requestor . isIgnored ( CompletionProposal . POTENTIAL_METHOD_DECLARATION ) ) { proposeNewMethod ( this . completionToken , scope . enclosingSourceType ( ) ) ; } } } } private void completionOnParameterizedQualifiedTypeReference ( ASTNode astNode , ASTNode astNodeParent , Binding qualifiedBinding , Scope scope ) { if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { CompletionOnParameterizedQualifiedTypeReference ref = ( CompletionOnParameterizedQualifiedTypeReference ) astNode ; this . insideQualifiedReference = true ; this . assistNodeIsClass = ref . isClass ( ) ; this . assistNodeIsException = ref . isException ( ) ; this . assistNodeIsInterface = ref . isInterface ( ) ; this . assistNodeIsSuperType = ref . isSuperType ( ) ; this . assistNodeIsExtendedType = assistNodeIsExtendedType ( astNode , astNodeParent ) ; this . assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation ( astNode , astNodeParent ) ; this . completionToken = ref . completionIdentifier ; long completionPosition = ref . sourcePositions [ ref . tokens . length ] ; setSourceAndTokenRange ( ( int ) ( completionPosition > > > <NUM_LIT:32> ) , ( int ) completionPosition ) ; if ( qualifiedBinding . problemId ( ) == ProblemReasons . NotFound || ( ( ( ReferenceBinding ) qualifiedBinding ) . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ) { if ( this . assistNodeInJavadoc == <NUM_LIT:0> && ( this . requestor . isAllowingRequiredProposals ( CompletionProposal . TYPE_REF , CompletionProposal . TYPE_REF ) ) ) { if ( ref . tokens . length == <NUM_LIT:1> ) { findMemberTypesFromMissingType ( ref , ref . sourcePositions [ <NUM_LIT:0> ] , scope ) ; } } } else { ObjectVector typesFound = new ObjectVector ( ) ; if ( this . assistNodeIsException && astNodeParent instanceof TryStatement ) { findExceptionFromTryStatement ( this . completionToken , ( ReferenceBinding ) qualifiedBinding , scope . enclosingSourceType ( ) , ( BlockScope ) scope , typesFound ) ; } checkCancel ( ) ; findMemberTypes ( this . completionToken , ( ReferenceBinding ) qualifiedBinding , scope , scope . enclosingSourceType ( ) , false , false , typesFound , null , null , null , false ) ; } } } private boolean assistNodeIsExtendedType ( ASTNode astNode , ASTNode astNodeParent ) { if ( astNodeParent == null ) return false ; if ( astNodeParent instanceof TypeDeclaration ) { TypeDeclaration typeDeclaration = ( TypeDeclaration ) astNodeParent ; return ( typeDeclaration . superclass == astNode ) ; } else if ( astNodeParent instanceof TypeParameter ) { TypeParameter typeParameter = ( TypeParameter ) astNodeParent ; return ( typeParameter . type == astNode ) ; } else if ( astNodeParent instanceof Wildcard ) { Wildcard wildcard = ( Wildcard ) astNodeParent ; return ( wildcard . bound == astNode && wildcard . kind == Wildcard . EXTENDS ) ; } return false ; } private boolean assistNodeIsInterfaceExcludingAnnotation ( ASTNode astNode , ASTNode astNodeParent ) { if ( astNodeParent == null ) return false ; if ( astNodeParent instanceof TypeDeclaration ) { TypeDeclaration typeDeclaration = ( TypeDeclaration ) astNodeParent ; TypeReference [ ] superInterfaces = typeDeclaration . superInterfaces ; int length = superInterfaces == null ? <NUM_LIT:0> : superInterfaces . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( superInterfaces [ i ] == astNode ) return true ; } } return false ; } private boolean assistNodeIsInsideCase ( ASTNode astNode , ASTNode astNodeParent ) { if ( astNodeParent instanceof SwitchStatement ) { CaseStatement [ ] cases = ( ( SwitchStatement ) astNodeParent ) . cases ; for ( int i = <NUM_LIT:0> , caseCount = ( ( SwitchStatement ) astNodeParent ) . caseCount ; i < caseCount ; i ++ ) { CompletionNodeDetector detector = new CompletionNodeDetector ( astNode , cases [ i ] ) ; if ( detector . containsCompletionNode ( ) ) { return true ; } } } return false ; } private void completionOnQualifiedAllocationExpression ( ASTNode astNode , Binding qualifiedBinding , Scope scope ) { setSourceAndTokenRange ( astNode . sourceStart , astNode . sourceEnd , false ) ; CompletionOnQualifiedAllocationExpression allocExpression = ( CompletionOnQualifiedAllocationExpression ) astNode ; TypeBinding [ ] argTypes = computeTypes ( allocExpression . arguments ) ; ReferenceBinding ref = ( ReferenceBinding ) qualifiedBinding ; if ( ref . problemId ( ) == ProblemReasons . NotFound ) { findConstructorsFromMissingType ( allocExpression . type , argTypes , scope , allocExpression ) ; } else { if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) && ref . isClass ( ) && ! ref . isAbstract ( ) ) { findConstructors ( ref , argTypes , scope , allocExpression , false , null , null , null , false ) ; } checkCancel ( ) ; if ( ! this . requestor . isIgnored ( CompletionProposal . ANONYMOUS_CLASS_DECLARATION ) && ! ref . isFinal ( ) && ! ref . isEnum ( ) ) { findAnonymousType ( ref , argTypes , scope , allocExpression , null , null , null , false ) ; } } } private void completionOnQualifiedNameReference ( ASTNode astNode , ASTNode enclosingNode , Binding qualifiedBinding , Scope scope , boolean insideTypeAnnotation ) { this . insideQualifiedReference = true ; CompletionOnQualifiedNameReference ref = ( CompletionOnQualifiedNameReference ) astNode ; this . completionToken = ref . completionIdentifier ; long completionPosition = ref . sourcePositions [ ref . sourcePositions . length - <NUM_LIT:1> ] ; if ( qualifiedBinding . problemId ( ) == ProblemReasons . NotFound ) { setSourceAndTokenRange ( ( int ) ( completionPosition > > > <NUM_LIT:32> ) , ( int ) completionPosition ) ; if ( this . assistNodeInJavadoc == <NUM_LIT:0> && ( this . requestor . isAllowingRequiredProposals ( CompletionProposal . FIELD_REF , CompletionProposal . TYPE_REF ) || this . requestor . isAllowingRequiredProposals ( CompletionProposal . METHOD_REF , CompletionProposal . TYPE_REF ) || this . requestor . isAllowingRequiredProposals ( CompletionProposal . TYPE_REF , CompletionProposal . TYPE_REF ) ) ) { if ( ref . tokens . length == <NUM_LIT:1> ) { boolean foundSomeFields = findFieldsAndMethodsFromMissingFieldType ( ref . tokens [ <NUM_LIT:0> ] , scope , ref , insideTypeAnnotation ) ; if ( ! foundSomeFields ) { checkCancel ( ) ; findMembersFromMissingType ( ref . tokens [ <NUM_LIT:0> ] , ref . sourcePositions [ <NUM_LIT:0> ] , null , scope , ref , ref . isInsideAnnotationAttribute ) ; } } } } else if ( qualifiedBinding instanceof VariableBinding ) { setSourceAndTokenRange ( ( int ) ( completionPosition > > > <NUM_LIT:32> ) , ( int ) completionPosition ) ; TypeBinding receiverType = ( ( VariableBinding ) qualifiedBinding ) . type ; if ( receiverType != null && ( receiverType . tagBits & TagBits . HasMissingType ) == <NUM_LIT:0> ) { ObjectVector fieldsFound = new ObjectVector ( ) ; ObjectVector methodsFound = new ObjectVector ( ) ; findFieldsAndMethods ( this . completionToken , receiverType . capture ( scope , ref . sourceEnd ) , scope , fieldsFound , methodsFound , ref , scope , false , false , null , null , null , false , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; checkCancel ( ) ; findFieldsAndMethodsFromCastedReceiver ( enclosingNode , qualifiedBinding , scope , fieldsFound , methodsFound , ref , scope , ref ) ; } else if ( this . assistNodeInJavadoc == <NUM_LIT:0> && ( this . requestor . isAllowingRequiredProposals ( CompletionProposal . FIELD_REF , CompletionProposal . TYPE_REF ) || this . requestor . isAllowingRequiredProposals ( CompletionProposal . METHOD_REF , CompletionProposal . TYPE_REF ) ) ) { boolean proposeField = ! this . requestor . isIgnored ( CompletionProposal . FIELD_REF ) ; boolean proposeMethod = ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) ; if ( proposeField || proposeMethod ) { if ( ref . tokens . length == <NUM_LIT:1> ) { if ( qualifiedBinding instanceof LocalVariableBinding ) { LocalVariableBinding localVariableBinding = ( LocalVariableBinding ) qualifiedBinding ; findFieldsAndMethodsFromMissingType ( localVariableBinding . declaration . type , localVariableBinding . declaringScope , ref , scope ) ; } else { findFieldsAndMethodsFromMissingFieldType ( ref . tokens [ <NUM_LIT:0> ] , scope , ref , insideTypeAnnotation ) ; } } } } } else if ( qualifiedBinding instanceof ReferenceBinding && ! ( qualifiedBinding instanceof TypeVariableBinding ) ) { boolean isInsideAnnotationAttribute = ref . isInsideAnnotationAttribute ; ReferenceBinding receiverType = ( ReferenceBinding ) qualifiedBinding ; setSourceAndTokenRange ( ( int ) ( completionPosition > > > <NUM_LIT:32> ) , ( int ) completionPosition ) ; findMembers ( this . completionToken , receiverType , scope , ref , isInsideAnnotationAttribute , null , null , null , false ) ; } else if ( qualifiedBinding instanceof PackageBinding ) { setSourceRange ( astNode . sourceStart , ( int ) completionPosition ) ; setTokenRange ( ( int ) ( completionPosition > > > <NUM_LIT:32> ) , ( int ) completionPosition ) ; findTypesAndSubpackages ( this . completionToken , ( PackageBinding ) qualifiedBinding , scope ) ; } } private void completionOnQualifiedTypeReference ( ASTNode astNode , ASTNode astNodeParent , Binding qualifiedBinding , Scope scope ) { this . insideQualifiedReference = true ; CompletionOnQualifiedTypeReference ref = ( CompletionOnQualifiedTypeReference ) astNode ; this . assistNodeIsClass = ref . isClass ( ) ; this . assistNodeIsException = ref . isException ( ) ; this . assistNodeIsInterface = ref . isInterface ( ) ; this . assistNodeIsConstructor = ref . isConstructorType ; this . assistNodeIsSuperType = ref . isSuperType ( ) ; this . assistNodeIsExtendedType = assistNodeIsExtendedType ( astNode , astNodeParent ) ; this . assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation ( astNode , astNodeParent ) ; this . completionToken = ref . completionIdentifier ; long completionPosition = ref . sourcePositions [ ref . tokens . length ] ; if ( qualifiedBinding . problemId ( ) == ProblemReasons . NotFound ) { setSourceAndTokenRange ( ( int ) ( completionPosition > > > <NUM_LIT:32> ) , ( int ) completionPosition ) ; if ( this . assistNodeInJavadoc == <NUM_LIT:0> && ( this . requestor . isAllowingRequiredProposals ( CompletionProposal . TYPE_REF , CompletionProposal . TYPE_REF ) ) ) { if ( ref . tokens . length == <NUM_LIT:1> ) { findMemberTypesFromMissingType ( ref . tokens [ <NUM_LIT:0> ] , ref . sourcePositions [ <NUM_LIT:0> ] , scope ) ; } } } else if ( qualifiedBinding instanceof ReferenceBinding && ! ( qualifiedBinding instanceof TypeVariableBinding ) ) { if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { setSourceAndTokenRange ( ( int ) ( completionPosition > > > <NUM_LIT:32> ) , ( int ) completionPosition ) ; ObjectVector typesFound = new ObjectVector ( ) ; if ( this . assistNodeIsException && astNodeParent instanceof TryStatement ) { findExceptionFromTryStatement ( this . completionToken , ( ReferenceBinding ) qualifiedBinding , scope . enclosingSourceType ( ) , ( BlockScope ) scope , typesFound ) ; } checkCancel ( ) ; findMemberTypes ( this . completionToken , ( ReferenceBinding ) qualifiedBinding , scope , scope . enclosingSourceType ( ) , false , false , typesFound , null , null , null , false ) ; } } else if ( qualifiedBinding instanceof PackageBinding ) { setSourceRange ( astNode . sourceStart , ( int ) completionPosition ) ; setTokenRange ( ( int ) ( completionPosition > > > <NUM_LIT:32> ) , ( int ) completionPosition ) ; findTypesAndSubpackages ( this . completionToken , ( PackageBinding ) qualifiedBinding , scope ) ; } } private void completionOnSingleNameReference ( ASTNode astNode , ASTNode astNodeParent , Scope scope , boolean insideTypeAnnotation ) { CompletionOnSingleNameReference singleNameReference = ( CompletionOnSingleNameReference ) astNode ; this . completionToken = singleNameReference . token ; SwitchStatement switchStatement = astNodeParent instanceof SwitchStatement ? ( SwitchStatement ) astNodeParent : null ; if ( switchStatement != null && switchStatement . expression . resolvedType != null && switchStatement . expression . resolvedType . isEnum ( ) ) { if ( ! this . requestor . isIgnored ( CompletionProposal . FIELD_REF ) ) { this . assistNodeIsEnum = true ; findEnumConstantsFromSwithStatement ( this . completionToken , ( SwitchStatement ) astNodeParent ) ; } } else if ( this . expectedTypesPtr > - <NUM_LIT:1> && this . expectedTypes [ <NUM_LIT:0> ] . isAnnotationType ( ) ) { findTypesAndPackages ( this . completionToken , scope , false , false , new ObjectVector ( ) ) ; } else { if ( this . expectedTypesPtr > - <NUM_LIT:1> ) { this . assistNodeIsEnum = true ; done : for ( int i = <NUM_LIT:0> ; i <= this . expectedTypesPtr ; i ++ ) { if ( ! this . expectedTypes [ i ] . isEnum ( ) ) { this . assistNodeIsEnum = false ; break done ; } } } if ( scope instanceof BlockScope && ! this . requestor . isIgnored ( CompletionProposal . LOCAL_VARIABLE_REF ) ) { char [ ] [ ] alreadyDefinedName = computeAlreadyDefinedName ( ( BlockScope ) scope , singleNameReference ) ; findUnresolvedReference ( singleNameReference . sourceStart , singleNameReference . sourceEnd , ( BlockScope ) scope , alreadyDefinedName ) ; } checkCancel ( ) ; findVariablesAndMethods ( this . completionToken , scope , singleNameReference , scope , insideTypeAnnotation , singleNameReference . isInsideAnnotationAttribute ) ; checkCancel ( ) ; findTypesAndPackages ( this . completionToken , scope , true , false , new ObjectVector ( ) ) ; if ( ! this . requestor . isIgnored ( CompletionProposal . KEYWORD ) ) { if ( this . completionToken != null && this . completionToken . length != <NUM_LIT:0> ) { findKeywords ( this . completionToken , singleNameReference . possibleKeywords , false , false , false ) ; } else { findTrueOrFalseKeywords ( singleNameReference . possibleKeywords ) ; } } if ( singleNameReference . canBeExplicitConstructor && ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) ) { if ( CharOperation . prefixEquals ( this . completionToken , Keywords . THIS , false ) ) { ReferenceBinding ref = scope . enclosingSourceType ( ) ; findExplicitConstructors ( Keywords . THIS , ref , ( MethodScope ) scope , singleNameReference ) ; } else if ( CharOperation . prefixEquals ( this . completionToken , Keywords . SUPER , false ) ) { ReferenceBinding ref = scope . enclosingSourceType ( ) ; findExplicitConstructors ( Keywords . SUPER , ref . superclass ( ) , ( MethodScope ) scope , singleNameReference ) ; } } } } private void completionOnSingleTypeReference ( ASTNode astNode , ASTNode astNodeParent , Binding qualifiedBinding , Scope scope ) { CompletionOnSingleTypeReference singleRef = ( CompletionOnSingleTypeReference ) astNode ; this . completionToken = singleRef . token ; this . assistNodeIsClass = singleRef . isClass ( ) ; this . assistNodeIsException = singleRef . isException ( ) ; this . assistNodeIsInterface = singleRef . isInterface ( ) ; this . assistNodeIsConstructor = singleRef . isConstructorType ; this . assistNodeIsSuperType = singleRef . isSuperType ( ) ; this . assistNodeIsExtendedType = assistNodeIsExtendedType ( astNode , astNodeParent ) ; this . assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation ( astNode , astNodeParent ) ; if ( qualifiedBinding == null ) { if ( this . completionToken . length == <NUM_LIT:0> && ( astNodeParent instanceof ParameterizedSingleTypeReference || astNodeParent instanceof ParameterizedQualifiedTypeReference ) ) { this . setSourceAndTokenRange ( astNode . sourceStart , astNode . sourceStart - <NUM_LIT:1> , false ) ; findParameterizedType ( ( TypeReference ) astNodeParent , scope ) ; } else { ObjectVector typesFound = new ObjectVector ( ) ; if ( this . assistNodeIsException && astNodeParent instanceof TryStatement ) { findExceptionFromTryStatement ( this . completionToken , null , scope . enclosingSourceType ( ) , ( BlockScope ) scope , typesFound ) ; } checkCancel ( ) ; findTypesAndPackages ( this . completionToken , scope , this . assistNodeIsConstructor , false , typesFound ) ; } } else if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { findMemberTypes ( this . completionToken , ( ReferenceBinding ) qualifiedBinding , scope , scope . enclosingSourceType ( ) , false , false , false , false , ! this . assistNodeIsConstructor , null , new ObjectVector ( ) , null , null , null , false ) ; } } private char [ ] [ ] computeAlreadyDefinedName ( BlockScope scope , InvocationSite invocationSite ) { ArrayList result = new ArrayList ( ) ; boolean staticsOnly = false ; Scope currentScope = scope ; done1 : while ( true ) { switch ( currentScope . kind ) { case Scope . METHOD_SCOPE : MethodScope methodScope = ( MethodScope ) currentScope ; staticsOnly |= methodScope . isStatic | methodScope . isConstructorCall ; case Scope . BLOCK_SCOPE : BlockScope blockScope = ( BlockScope ) currentScope ; next : for ( int i = <NUM_LIT:0> , length = blockScope . locals . length ; i < length ; i ++ ) { LocalVariableBinding local = blockScope . locals [ i ] ; if ( local == null ) break next ; if ( local . isSecret ( ) ) continue next ; result . add ( local . name ) ; } break ; case Scope . CLASS_SCOPE : ClassScope classScope = ( ClassScope ) currentScope ; SourceTypeBinding enclosingType = classScope . referenceContext . binding ; computeAlreadyDefinedName ( enclosingType , classScope , staticsOnly , invocationSite , result ) ; staticsOnly |= enclosingType . isStatic ( ) ; break ; case Scope . COMPILATION_UNIT_SCOPE : break done1 ; } currentScope = currentScope . parent ; } if ( result . size ( ) == <NUM_LIT:0> ) return CharOperation . NO_CHAR_CHAR ; return ( char [ ] [ ] ) result . toArray ( new char [ result . size ( ) ] [ ] ) ; } private void computeAlreadyDefinedName ( FieldBinding [ ] fields , Scope scope , boolean onlyStaticFields , ReferenceBinding receiverType , InvocationSite invocationSite , ArrayList result ) { next : for ( int f = fields . length ; -- f >= <NUM_LIT:0> ; ) { FieldBinding field = fields [ f ] ; if ( field . isSynthetic ( ) ) continue next ; if ( onlyStaticFields && ! field . isStatic ( ) ) continue next ; if ( ! field . canBeSeenBy ( receiverType , invocationSite , scope ) ) continue next ; result . add ( field . name ) ; } } private void computeAlreadyDefinedName ( SourceTypeBinding receiverType , ClassScope scope , boolean onlyStaticFields , InvocationSite invocationSite , ArrayList result ) { ReferenceBinding currentType = receiverType ; ReferenceBinding [ ] interfacesToVisit = null ; int nextPosition = <NUM_LIT:0> ; do { ReferenceBinding [ ] itsInterfaces = currentType . superInterfaces ( ) ; if ( itsInterfaces != Binding . NO_SUPERINTERFACES ) { if ( interfacesToVisit == null ) { interfacesToVisit = itsInterfaces ; nextPosition = interfacesToVisit . length ; } else { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + <NUM_LIT:5> ] , <NUM_LIT:0> , nextPosition ) ; nextInterface : for ( int a = <NUM_LIT:0> ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = <NUM_LIT:0> ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } FieldBinding [ ] fields = currentType . availableFields ( ) ; if ( fields != null && fields . length > <NUM_LIT:0> ) { computeAlreadyDefinedName ( fields , scope , onlyStaticFields , receiverType , invocationSite , result ) ; } currentType = currentType . superclass ( ) ; } while ( currentType != null ) ; if ( interfacesToVisit != null ) { for ( int i = <NUM_LIT:0> ; i < nextPosition ; i ++ ) { ReferenceBinding anInterface = interfacesToVisit [ i ] ; FieldBinding [ ] fields = anInterface . availableFields ( ) ; if ( fields != null ) { computeAlreadyDefinedName ( fields , scope , onlyStaticFields , receiverType , invocationSite , result ) ; } ReferenceBinding [ ] itsInterfaces = anInterface . superInterfaces ( ) ; if ( itsInterfaces != Binding . NO_SUPERINTERFACES ) { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + <NUM_LIT:5> ] , <NUM_LIT:0> , nextPosition ) ; nextInterface : for ( int a = <NUM_LIT:0> ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = <NUM_LIT:0> ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } } } int computeBaseRelevance ( ) { return R_DEFAULT ; } private void computeExpectedTypes ( ASTNode parent , ASTNode node , Scope scope ) { this . expectedTypesFilter = SUBTYPE ; this . hasJavaLangObjectAsExpectedType = false ; if ( parent instanceof AbstractVariableDeclaration && ! ( parent instanceof TypeParameter ) ) { AbstractVariableDeclaration variable = ( AbstractVariableDeclaration ) parent ; TypeBinding binding = variable . type . resolvedType ; if ( binding != null ) { if ( ! ( variable . initialization instanceof ArrayInitializer ) ) { addExpectedType ( binding , scope ) ; } else { binding = binding . leafComponentType ( ) ; addExpectedType ( binding , scope ) ; } } } else if ( parent instanceof Assignment ) { TypeBinding binding = ( ( Assignment ) parent ) . lhs . resolvedType ; if ( binding != null ) { addExpectedType ( binding , scope ) ; } } else if ( parent instanceof ReturnStatement ) { if ( scope . methodScope ( ) . referenceContext instanceof AbstractMethodDeclaration ) { MethodBinding methodBinding = ( ( AbstractMethodDeclaration ) scope . methodScope ( ) . referenceContext ) . binding ; TypeBinding binding = methodBinding == null ? null : methodBinding . returnType ; if ( binding != null ) { addExpectedType ( binding , scope ) ; } } } else if ( parent instanceof CastExpression ) { TypeReference e = ( ( CastExpression ) parent ) . type ; TypeBinding binding = e . resolvedType ; if ( binding != null ) { addExpectedType ( binding , scope ) ; this . expectedTypesFilter = SUBTYPE | SUPERTYPE ; } } else if ( parent instanceof MessageSend ) { MessageSend messageSend = ( MessageSend ) parent ; if ( messageSend . actualReceiverType instanceof ReferenceBinding ) { ReferenceBinding binding = ( ReferenceBinding ) messageSend . actualReceiverType ; boolean isStatic = messageSend . receiver . isTypeReference ( ) ; while ( binding != null ) { computeExpectedTypesForMessageSend ( binding , messageSend . selector , messageSend . arguments , ( ReferenceBinding ) messageSend . actualReceiverType , scope , messageSend , isStatic ) ; computeExpectedTypesForMessageSendForInterface ( binding , messageSend . selector , messageSend . arguments , ( ReferenceBinding ) messageSend . actualReceiverType , scope , messageSend , isStatic ) ; binding = binding . superclass ( ) ; } } } else if ( parent instanceof AllocationExpression ) { AllocationExpression allocationExpression = ( AllocationExpression ) parent ; ReferenceBinding binding = ( ReferenceBinding ) allocationExpression . type . resolvedType ; if ( binding != null ) { computeExpectedTypesForAllocationExpression ( binding , allocationExpression . arguments , scope , allocationExpression ) ; } } else if ( parent instanceof OperatorExpression ) { int operator = ( parent . bits & ASTNode . OperatorMASK ) > > ASTNode . OperatorSHIFT ; if ( parent instanceof ConditionalExpression ) { } else if ( parent instanceof InstanceOfExpression ) { InstanceOfExpression e = ( InstanceOfExpression ) parent ; TypeBinding binding = e . expression . resolvedType ; if ( binding != null ) { addExpectedType ( binding , scope ) ; this . expectedTypesFilter = SUBTYPE | SUPERTYPE ; } } else if ( parent instanceof BinaryExpression ) { BinaryExpression binaryExpression = ( BinaryExpression ) parent ; switch ( operator ) { case OperatorIds . EQUAL_EQUAL : TypeBinding binding = binaryExpression . left . resolvedType ; if ( binding != null ) { addExpectedType ( binding , scope ) ; this . expectedTypesFilter = SUBTYPE | SUPERTYPE ; } break ; case OperatorIds . PLUS : addExpectedType ( TypeBinding . SHORT , scope ) ; addExpectedType ( TypeBinding . INT , scope ) ; addExpectedType ( TypeBinding . LONG , scope ) ; addExpectedType ( TypeBinding . FLOAT , scope ) ; addExpectedType ( TypeBinding . DOUBLE , scope ) ; addExpectedType ( TypeBinding . CHAR , scope ) ; addExpectedType ( TypeBinding . BYTE , scope ) ; addExpectedType ( scope . getJavaLangString ( ) , scope ) ; break ; case OperatorIds . AND_AND : case OperatorIds . OR_OR : case OperatorIds . XOR : addExpectedType ( TypeBinding . BOOLEAN , scope ) ; break ; default : addExpectedType ( TypeBinding . SHORT , scope ) ; addExpectedType ( TypeBinding . INT , scope ) ; addExpectedType ( TypeBinding . LONG , scope ) ; addExpectedType ( TypeBinding . FLOAT , scope ) ; addExpectedType ( TypeBinding . DOUBLE , scope ) ; addExpectedType ( TypeBinding . CHAR , scope ) ; addExpectedType ( TypeBinding . BYTE , scope ) ; break ; } if ( operator == OperatorIds . LESS ) { if ( binaryExpression . left instanceof SingleNameReference ) { SingleNameReference name = ( SingleNameReference ) binaryExpression . left ; Binding b = scope . getBinding ( name . token , Binding . VARIABLE | Binding . TYPE , name , false ) ; if ( b instanceof ReferenceBinding ) { TypeVariableBinding [ ] typeVariableBindings = ( ( ReferenceBinding ) b ) . typeVariables ( ) ; if ( typeVariableBindings != null && typeVariableBindings . length > <NUM_LIT:0> ) { addExpectedType ( typeVariableBindings [ <NUM_LIT:0> ] . firstBound , scope ) ; } } } } } else if ( parent instanceof UnaryExpression ) { switch ( operator ) { case OperatorIds . NOT : addExpectedType ( TypeBinding . BOOLEAN , scope ) ; break ; case OperatorIds . TWIDDLE : addExpectedType ( TypeBinding . SHORT , scope ) ; addExpectedType ( TypeBinding . INT , scope ) ; addExpectedType ( TypeBinding . LONG , scope ) ; addExpectedType ( TypeBinding . CHAR , scope ) ; addExpectedType ( TypeBinding . BYTE , scope ) ; break ; case OperatorIds . PLUS : case OperatorIds . MINUS : case OperatorIds . PLUS_PLUS : case OperatorIds . MINUS_MINUS : addExpectedType ( TypeBinding . SHORT , scope ) ; addExpectedType ( TypeBinding . INT , scope ) ; addExpectedType ( TypeBinding . LONG , scope ) ; addExpectedType ( TypeBinding . FLOAT , scope ) ; addExpectedType ( TypeBinding . DOUBLE , scope ) ; addExpectedType ( TypeBinding . CHAR , scope ) ; addExpectedType ( TypeBinding . BYTE , scope ) ; break ; } } } else if ( parent instanceof ArrayReference ) { addExpectedType ( TypeBinding . SHORT , scope ) ; addExpectedType ( TypeBinding . INT , scope ) ; addExpectedType ( TypeBinding . LONG , scope ) ; } else if ( parent instanceof ParameterizedSingleTypeReference ) { ParameterizedSingleTypeReference ref = ( ParameterizedSingleTypeReference ) parent ; TypeBinding expected = null ; if ( this . parser . enclosingNode instanceof AbstractVariableDeclaration || this . parser . enclosingNode instanceof ReturnStatement ) { if ( this . parser . enclosingNode instanceof AbstractVariableDeclaration ) { AbstractVariableDeclaration abstractVariableDeclaration = ( AbstractVariableDeclaration ) this . parser . enclosingNode ; expected = abstractVariableDeclaration . initialization != null ? abstractVariableDeclaration . initialization . expectedType ( ) : null ; } else { ReturnStatement returnStatement = ( ReturnStatement ) this . parser . enclosingNode ; if ( returnStatement . expression != null ) { expected = returnStatement . expression . expectedType ( ) ; } } addExpectedType ( expected , scope ) ; } else { TypeVariableBinding [ ] typeVariables = ( ( ReferenceBinding ) ref . resolvedType ) . typeVariables ( ) ; int length = ref . typeArguments == null ? <NUM_LIT:0> : ref . typeArguments . length ; if ( typeVariables != null && typeVariables . length >= length ) { int index = length - <NUM_LIT:1> ; while ( index > - <NUM_LIT:1> && ref . typeArguments [ index ] != node ) index -- ; TypeBinding bound = typeVariables [ index ] . firstBound ; addExpectedType ( bound == null ? scope . getJavaLangObject ( ) : bound , scope ) ; } } } else if ( parent instanceof ParameterizedQualifiedTypeReference ) { ParameterizedQualifiedTypeReference ref = ( ParameterizedQualifiedTypeReference ) parent ; TypeReference [ ] [ ] arguments = ref . typeArguments ; TypeBinding expected = null ; if ( this . parser . enclosingNode instanceof AbstractVariableDeclaration || this . parser . enclosingNode instanceof ReturnStatement ) { if ( this . parser . enclosingNode instanceof AbstractVariableDeclaration ) { AbstractVariableDeclaration abstractVariableDeclaration = ( AbstractVariableDeclaration ) this . parser . enclosingNode ; expected = abstractVariableDeclaration . initialization != null ? abstractVariableDeclaration . initialization . expectedType ( ) : null ; } else { ReturnStatement returnStatement = ( ReturnStatement ) this . parser . enclosingNode ; if ( returnStatement . expression != null ) { expected = returnStatement . expression . expectedType ( ) ; } } addExpectedType ( expected , scope ) ; } else { TypeVariableBinding [ ] typeVariables = ( ( ReferenceBinding ) ref . resolvedType ) . typeVariables ( ) ; if ( typeVariables != null ) { int iLength = arguments == null ? <NUM_LIT:0> : arguments . length ; done : for ( int i = <NUM_LIT:0> ; i < iLength ; i ++ ) { int jLength = arguments [ i ] == null ? <NUM_LIT:0> : arguments [ i ] . length ; for ( int j = <NUM_LIT:0> ; j < jLength ; j ++ ) { if ( arguments [ i ] [ j ] == node && typeVariables . length > j ) { TypeBinding bound = typeVariables [ j ] . firstBound ; addExpectedType ( bound == null ? scope . getJavaLangObject ( ) : bound , scope ) ; break done ; } } } } } } else if ( parent instanceof MemberValuePair ) { MemberValuePair memberValuePair = ( MemberValuePair ) parent ; if ( memberValuePair . binding != null ) { addExpectedType ( memberValuePair . binding . returnType , scope ) ; } } else if ( parent instanceof NormalAnnotation ) { NormalAnnotation annotation = ( NormalAnnotation ) parent ; MemberValuePair [ ] memberValuePairs = annotation . memberValuePairs ( ) ; if ( memberValuePairs == null || memberValuePairs . length == <NUM_LIT:0> ) { if ( annotation . resolvedType instanceof ReferenceBinding ) { MethodBinding [ ] methodBindings = ( ( ReferenceBinding ) annotation . resolvedType ) . availableMethods ( ) ; if ( methodBindings != null && methodBindings . length > <NUM_LIT:0> && CharOperation . equals ( methodBindings [ <NUM_LIT:0> ] . selector , VALUE ) ) { boolean canBeSingleMemberAnnotation = true ; done : for ( int i = <NUM_LIT:1> ; i < methodBindings . length ; i ++ ) { if ( ( methodBindings [ i ] . modifiers & ClassFileConstants . AccAnnotationDefault ) == <NUM_LIT:0> ) { canBeSingleMemberAnnotation = false ; break done ; } } if ( canBeSingleMemberAnnotation ) { this . assistNodeCanBeSingleMemberAnnotation = canBeSingleMemberAnnotation ; addExpectedType ( methodBindings [ <NUM_LIT:0> ] . returnType , scope ) ; } } } } } else if ( parent instanceof TryStatement ) { boolean isException = false ; if ( node instanceof CompletionOnSingleTypeReference ) { isException = ( ( CompletionOnSingleTypeReference ) node ) . isException ( ) ; } else if ( node instanceof CompletionOnQualifiedTypeReference ) { isException = ( ( CompletionOnQualifiedTypeReference ) node ) . isException ( ) ; } else if ( node instanceof CompletionOnParameterizedQualifiedTypeReference ) { isException = ( ( CompletionOnParameterizedQualifiedTypeReference ) node ) . isException ( ) ; } if ( isException ) { ThrownExceptionFinder thrownExceptionFinder = new ThrownExceptionFinder ( ) ; thrownExceptionFinder . processThrownExceptions ( ( TryStatement ) parent , ( BlockScope ) scope ) ; ReferenceBinding [ ] bindings = thrownExceptionFinder . getThrownUncaughtExceptions ( ) ; ReferenceBinding [ ] alreadyCaughtExceptions = thrownExceptionFinder . getAlreadyCaughtExceptions ( ) ; ReferenceBinding [ ] discouragedExceptions = thrownExceptionFinder . getDiscouragedExceptions ( ) ; if ( bindings != null && bindings . length > <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < bindings . length ; i ++ ) { addExpectedType ( bindings [ i ] , scope ) ; } this . expectedTypesFilter = SUPERTYPE ; } if ( alreadyCaughtExceptions != null && alreadyCaughtExceptions . length > <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < alreadyCaughtExceptions . length ; i ++ ) { addForbiddenBindings ( alreadyCaughtExceptions [ i ] ) ; this . knownTypes . put ( CharOperation . concat ( alreadyCaughtExceptions [ i ] . qualifiedPackageName ( ) , alreadyCaughtExceptions [ i ] . qualifiedSourceName ( ) , '<CHAR_LIT:.>' ) , KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS ) ; } } if ( discouragedExceptions != null && discouragedExceptions . length > <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < discouragedExceptions . length ; i ++ ) { addUninterestingBindings ( discouragedExceptions [ i ] ) ; } } } } else if ( parent instanceof SwitchStatement ) { SwitchStatement switchStatement = ( SwitchStatement ) parent ; this . assistNodeIsInsideCase = assistNodeIsInsideCase ( node , parent ) ; if ( switchStatement . expression != null && switchStatement . expression . resolvedType != null ) { if ( this . assistNodeIsInsideCase && switchStatement . expression . resolvedType . id == TypeIds . T_JavaLangString && this . compilerOptions . complianceLevel >= ClassFileConstants . JDK1_7 ) { this . assistNodeIsString = true ; } addExpectedType ( switchStatement . expression . resolvedType , scope ) ; } } else if ( parent instanceof WhileStatement ) { addExpectedType ( TypeBinding . BOOLEAN , scope ) ; } else if ( parent instanceof IfStatement ) { addExpectedType ( TypeBinding . BOOLEAN , scope ) ; } else if ( parent instanceof AssertStatement ) { AssertStatement assertStatement = ( AssertStatement ) parent ; if ( assertStatement . assertExpression == node ) { addExpectedType ( TypeBinding . BOOLEAN , scope ) ; } } else if ( parent instanceof ForStatement ) { addExpectedType ( TypeBinding . BOOLEAN , scope ) ; } else if ( parent instanceof Javadoc ) { if ( scope . kind == Scope . METHOD_SCOPE ) { MethodScope methodScope = ( MethodScope ) scope ; AbstractMethodDeclaration methodDecl = methodScope . referenceMethod ( ) ; if ( methodDecl != null && methodDecl . binding != null ) { ReferenceBinding [ ] exceptions = methodDecl . binding . thrownExceptions ; if ( exceptions != null ) { for ( int i = <NUM_LIT:0> ; i < exceptions . length ; i ++ ) { addExpectedType ( exceptions [ i ] , scope ) ; } } } } } if ( this . expectedTypesPtr + <NUM_LIT:1> != this . expectedTypes . length ) { System . arraycopy ( this . expectedTypes , <NUM_LIT:0> , this . expectedTypes = new TypeBinding [ this . expectedTypesPtr + <NUM_LIT:1> ] , <NUM_LIT:0> , this . expectedTypesPtr + <NUM_LIT:1> ) ; } } private void computeExpectedTypesForAllocationExpression ( ReferenceBinding binding , Expression [ ] arguments , Scope scope , InvocationSite invocationSite ) { MethodBinding [ ] methods = binding . availableMethods ( ) ; nextMethod : for ( int i = <NUM_LIT:0> ; i < methods . length ; i ++ ) { MethodBinding method = methods [ i ] ; if ( ! method . isConstructor ( ) ) continue nextMethod ; if ( method . isSynthetic ( ) ) continue nextMethod ; if ( this . options . checkVisibility && ! method . canBeSeenBy ( invocationSite , scope ) ) continue nextMethod ; TypeBinding [ ] parameters = method . parameters ; if ( parameters . length < arguments . length ) continue nextMethod ; int length = arguments . length - <NUM_LIT:1> ; for ( int j = <NUM_LIT:0> ; j < length ; j ++ ) { Expression argument = arguments [ j ] ; TypeBinding argType = argument . resolvedType ; if ( argType != null && ! argType . isCompatibleWith ( parameters [ j ] ) ) continue nextMethod ; } TypeBinding expectedType = method . parameters [ arguments . length - <NUM_LIT:1> ] ; if ( expectedType != null ) { addExpectedType ( expectedType , scope ) ; } } } private void computeExpectedTypesForMessageSend ( ReferenceBinding binding , char [ ] selector , Expression [ ] arguments , ReferenceBinding receiverType , Scope scope , InvocationSite invocationSite , boolean isStatic ) { MethodBinding [ ] methods = binding . availableMethods ( ) ; nextMethod : for ( int i = <NUM_LIT:0> ; i < methods . length ; i ++ ) { MethodBinding method = methods [ i ] ; if ( method . isSynthetic ( ) ) continue nextMethod ; if ( method . isDefaultAbstract ( ) ) continue nextMethod ; if ( method . isConstructor ( ) ) continue nextMethod ; if ( isStatic && ! method . isStatic ( ) ) continue nextMethod ; if ( this . options . checkVisibility && ! method . canBeSeenBy ( receiverType , invocationSite , scope ) ) continue nextMethod ; if ( ! CharOperation . equals ( method . selector , selector ) ) continue nextMethod ; TypeBinding [ ] parameters = method . parameters ; if ( parameters . length < arguments . length ) continue nextMethod ; int length = arguments . length - <NUM_LIT:1> ; for ( int j = <NUM_LIT:0> ; j < length ; j ++ ) { Expression argument = arguments [ j ] ; TypeBinding argType = argument . resolvedType ; if ( argType != null && ! argType . isCompatibleWith ( parameters [ j ] ) ) continue nextMethod ; } TypeBinding expectedType = method . parameters [ arguments . length - <NUM_LIT:1> ] ; if ( expectedType != null ) { addExpectedType ( expectedType , scope ) ; } } } private void computeExpectedTypesForMessageSendForInterface ( ReferenceBinding binding , char [ ] selector , Expression [ ] arguments , ReferenceBinding receiverType , Scope scope , InvocationSite invocationSite , boolean isStatic ) { ReferenceBinding [ ] itsInterfaces = binding . superInterfaces ( ) ; if ( itsInterfaces != Binding . NO_SUPERINTERFACES ) { ReferenceBinding [ ] interfacesToVisit = itsInterfaces ; int nextPosition = interfacesToVisit . length ; for ( int i = <NUM_LIT:0> ; i < nextPosition ; i ++ ) { ReferenceBinding currentType = interfacesToVisit [ i ] ; computeExpectedTypesForMessageSend ( currentType , selector , arguments , receiverType , scope , invocationSite , isStatic ) ; if ( ( itsInterfaces = currentType . superInterfaces ( ) ) != Binding . NO_SUPERINTERFACES ) { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + <NUM_LIT:5> ] , <NUM_LIT:0> , nextPosition ) ; nextInterface : for ( int a = <NUM_LIT:0> ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = <NUM_LIT:0> ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } } } private Scope computeForbiddenBindings ( ASTNode astNode , ASTNode astNodeParent , Scope scope ) { if ( scope instanceof ClassScope ) { TypeDeclaration typeDeclaration = ( ( ClassScope ) scope ) . referenceContext ; if ( typeDeclaration . superclass == astNode ) { addForbiddenBindings ( typeDeclaration . binding ) ; addForbiddenBindingsForMemberTypes ( typeDeclaration ) ; return scope . parent ; } TypeReference [ ] superInterfaces = typeDeclaration . superInterfaces ; int length = superInterfaces == null ? <NUM_LIT:0> : superInterfaces . length ; int astNodeIndex = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( superInterfaces [ i ] == astNode ) { addForbiddenBindings ( typeDeclaration . binding ) ; addForbiddenBindingsForMemberTypes ( typeDeclaration ) ; astNodeIndex = i ; break ; } } if ( astNodeIndex >= <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < astNodeIndex ; i ++ ) { addForbiddenBindings ( superInterfaces [ i ] . resolvedType ) ; } return scope . parent ; } } return scope ; } private void addForbiddenBindingsForMemberTypes ( TypeDeclaration typeDeclaration ) { TypeDeclaration [ ] memberTypes = typeDeclaration . memberTypes ; int memberTypesLen = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; for ( int i = <NUM_LIT:0> ; i < memberTypesLen ; i ++ ) { addForbiddenBindings ( memberTypes [ i ] . binding ) ; addForbiddenBindingsForMemberTypes ( memberTypes [ i ] ) ; } } private char [ ] computePrefix ( SourceTypeBinding declarationType , SourceTypeBinding invocationType , boolean isStatic ) { StringBuffer completion = new StringBuffer ( <NUM_LIT:10> ) ; if ( isStatic ) { completion . append ( declarationType . sourceName ( ) ) ; } else if ( declarationType == invocationType ) { completion . append ( THIS ) ; } else { if ( ! declarationType . isNestedType ( ) ) { completion . append ( declarationType . sourceName ( ) ) ; completion . append ( '<CHAR_LIT:.>' ) ; completion . append ( THIS ) ; } else if ( ! declarationType . isAnonymousType ( ) ) { completion . append ( declarationType . sourceName ( ) ) ; completion . append ( '<CHAR_LIT:.>' ) ; completion . append ( THIS ) ; } } return completion . toString ( ) . toCharArray ( ) ; } private int computeRelevanceForAnnotation ( ) { if ( this . assistNodeIsAnnotation ) { return R_ANNOTATION ; } return <NUM_LIT:0> ; } private int computeRelevanceForAnnotationTarget ( TypeBinding typeBinding ) { if ( this . assistNodeIsAnnotation && ( this . targetedElement & TagBits . AnnotationTargetMASK ) != <NUM_LIT:0> ) { long target = typeBinding . getAnnotationTagBits ( ) & TagBits . AnnotationTargetMASK ; if ( target == <NUM_LIT:0> || ( target & this . targetedElement ) != <NUM_LIT:0> ) { return R_TARGET ; } } return <NUM_LIT:0> ; } int computeRelevanceForCaseMatching ( char [ ] token , char [ ] proposalName ) { if ( this . options . camelCaseMatch ) { if ( CharOperation . equals ( token , proposalName , true ) ) { return R_CASE + R_EXACT_NAME ; } else if ( CharOperation . prefixEquals ( token , proposalName , true ) ) { return R_CASE ; } else if ( CharOperation . camelCaseMatch ( token , proposalName ) ) { return R_CAMEL_CASE ; } else if ( CharOperation . equals ( token , proposalName , false ) ) { return R_EXACT_NAME ; } } else if ( CharOperation . prefixEquals ( token , proposalName , true ) ) { if ( CharOperation . equals ( token , proposalName , true ) ) { return R_CASE + R_EXACT_NAME ; } else { return R_CASE ; } } else if ( CharOperation . equals ( token , proposalName , false ) ) { return R_EXACT_NAME ; } return <NUM_LIT:0> ; } private int computeRelevanceForClass ( ) { if ( this . assistNodeIsClass ) { return R_CLASS ; } return <NUM_LIT:0> ; } private int computeRelevanceForConstructor ( ) { if ( this . assistNodeIsConstructor ) { return R_CONSTRUCTOR ; } return <NUM_LIT:0> ; } private int computeRelevanceForEnum ( ) { if ( this . assistNodeIsEnum ) { return R_ENUM ; } return <NUM_LIT:0> ; } private int computeRelevanceForEnumConstant ( TypeBinding proposalType ) { if ( this . assistNodeIsEnum && proposalType != null && this . expectedTypes != null ) { for ( int i = <NUM_LIT:0> ; i <= this . expectedTypesPtr ; i ++ ) { if ( proposalType . isEnum ( ) && proposalType == this . expectedTypes [ i ] ) { return R_ENUM + R_ENUM_CONSTANT ; } } } return <NUM_LIT:0> ; } private int computeRelevanceForException ( ) { if ( this . assistNodeIsException ) { return R_EXCEPTION ; } return <NUM_LIT:0> ; } private int computeRelevanceForException ( char [ ] proposalName ) { if ( ( this . assistNodeIsException || ( this . assistNodeInJavadoc & CompletionOnJavadoc . EXCEPTION ) != <NUM_LIT:0> ) && ( CharOperation . match ( EXCEPTION_PATTERN , proposalName , false ) || CharOperation . match ( ERROR_PATTERN , proposalName , false ) ) ) { return R_EXCEPTION ; } return <NUM_LIT:0> ; } private int computeRelevanceForExpectingType ( char [ ] packageName , char [ ] typeName ) { if ( this . expectedTypes != null ) { for ( int i = <NUM_LIT:0> ; i <= this . expectedTypesPtr ; i ++ ) { if ( CharOperation . equals ( this . expectedTypes [ i ] . qualifiedPackageName ( ) , packageName ) && CharOperation . equals ( this . expectedTypes [ i ] . qualifiedSourceName ( ) , typeName ) ) { return R_EXACT_EXPECTED_TYPE ; } } if ( this . hasJavaLangObjectAsExpectedType ) { return R_EXPECTED_TYPE ; } } return <NUM_LIT:0> ; } private int computeRelevanceForExpectingType ( TypeBinding proposalType ) { if ( this . expectedTypes != null && proposalType != null ) { int relevance = <NUM_LIT:0> ; if ( proposalType == TypeBinding . VOID && this . expectedTypesPtr >= <NUM_LIT:0> ) { return R_VOID ; } for ( int i = <NUM_LIT:0> ; i <= this . expectedTypesPtr ; i ++ ) { if ( ( this . expectedTypesFilter & SUBTYPE ) != <NUM_LIT:0> && proposalType . isCompatibleWith ( this . expectedTypes [ i ] ) ) { if ( CharOperation . equals ( this . expectedTypes [ i ] . qualifiedPackageName ( ) , proposalType . qualifiedPackageName ( ) ) && CharOperation . equals ( this . expectedTypes [ i ] . qualifiedSourceName ( ) , proposalType . qualifiedSourceName ( ) ) ) { return R_EXACT_EXPECTED_TYPE ; } relevance = R_EXPECTED_TYPE ; } if ( ( this . expectedTypesFilter & SUPERTYPE ) != <NUM_LIT:0> && this . expectedTypes [ i ] . isCompatibleWith ( proposalType ) ) { if ( CharOperation . equals ( this . expectedTypes [ i ] . qualifiedPackageName ( ) , proposalType . qualifiedPackageName ( ) ) && CharOperation . equals ( this . expectedTypes [ i ] . qualifiedSourceName ( ) , proposalType . qualifiedSourceName ( ) ) ) { return R_EXACT_EXPECTED_TYPE ; } relevance = R_EXPECTED_TYPE ; } if ( this . unitScope != null && this . unitScope . isBoxingCompatibleWith ( proposalType , this . expectedTypes [ i ] ) ) { relevance = R_EXPECTED_TYPE ; } } return relevance ; } return <NUM_LIT:0> ; } private int computeRelevanceForInheritance ( ReferenceBinding receiverType , ReferenceBinding declaringClass ) { if ( receiverType == declaringClass ) return R_NON_INHERITED ; return <NUM_LIT:0> ; } int computeRelevanceForInterestingProposal ( ) { return computeRelevanceForInterestingProposal ( null ) ; } private int computeRelevanceForInterestingProposal ( Binding binding ) { if ( this . uninterestingBindings != null ) { for ( int i = <NUM_LIT:0> ; i <= this . uninterestingBindingsPtr ; i ++ ) { if ( this . uninterestingBindings [ i ] == binding ) { return <NUM_LIT:0> ; } if ( ( this . uninterestingBindingsFilter & SUBTYPE ) != <NUM_LIT:0> ) { if ( binding instanceof TypeBinding && this . uninterestingBindings [ i ] instanceof TypeBinding && ( ( TypeBinding ) binding ) . isCompatibleWith ( ( TypeBinding ) this . uninterestingBindings [ i ] ) ) { return <NUM_LIT:0> ; } } if ( ( this . uninterestingBindingsFilter & SUPERTYPE ) != <NUM_LIT:0> ) { if ( binding instanceof TypeBinding && this . uninterestingBindings [ i ] instanceof TypeBinding && ( ( TypeBinding ) this . uninterestingBindings [ i ] ) . isCompatibleWith ( ( TypeBinding ) binding ) ) { return <NUM_LIT:0> ; } } } } return R_INTERESTING ; } private int computeRelevanceForInterestingProposal ( char [ ] givenPkgName , char [ ] fullTypeName ) { for ( int i = <NUM_LIT:0> ; i <= this . uninterestingBindingsPtr ; i ++ ) { if ( this . uninterestingBindings [ i ] instanceof TypeBinding ) { TypeBinding typeBinding = ( TypeBinding ) this . uninterestingBindings [ i ] ; char [ ] currPkgName = typeBinding . qualifiedPackageName ( ) ; if ( CharOperation . equals ( givenPkgName , currPkgName ) ) { char [ ] currTypeName = typeBinding . qualifiedSourceName ( ) ; if ( CharOperation . equals ( fullTypeName , currTypeName ) ) { return <NUM_LIT:0> ; } } } } return R_INTERESTING ; } private int computeRelevanceForInterface ( ) { if ( this . assistNodeIsInterface ) { return R_INTERFACE ; } return <NUM_LIT:0> ; } private int computeRelevanceForMissingElements ( boolean hasProblems ) { if ( ! hasProblems ) { return R_NO_PROBLEMS ; } return <NUM_LIT:0> ; } int computeRelevanceForQualification ( boolean prefixRequired ) { if ( ! prefixRequired && ! this . insideQualifiedReference ) { return R_UNQUALIFIED ; } if ( prefixRequired && this . insideQualifiedReference ) { return R_QUALIFIED ; } return <NUM_LIT:0> ; } int computeRelevanceForResolution ( ) { return computeRelevanceForResolution ( true ) ; } int computeRelevanceForResolution ( boolean isResolved ) { if ( isResolved ) { return R_RESOLVED ; } return <NUM_LIT:0> ; } int computeRelevanceForRestrictions ( int accessRuleKind ) { if ( accessRuleKind == IAccessRule . K_ACCESSIBLE ) { return R_NON_RESTRICTED ; } return <NUM_LIT:0> ; } private int computeRelevanceForStatic ( boolean onlyStatic , boolean isStatic ) { if ( this . insideQualifiedReference && ! onlyStatic && ! isStatic ) { return R_NON_STATIC ; } return <NUM_LIT:0> ; } private int computeRelevanceForFinal ( boolean onlyFinal , boolean isFinal ) { if ( onlyFinal && isFinal ) { return R_FINAL ; } return <NUM_LIT:0> ; } private long computeTargetedElement ( CompletionOnAnnotationOfType fakeNode ) { ASTNode annotatedElement = fakeNode . potentialAnnotatedNode ; if ( annotatedElement instanceof TypeDeclaration ) { TypeDeclaration annotatedTypeDeclaration = ( TypeDeclaration ) annotatedElement ; if ( TypeDeclaration . kind ( annotatedTypeDeclaration . modifiers ) == TypeDeclaration . ANNOTATION_TYPE_DECL ) { return TagBits . AnnotationForAnnotationType | TagBits . AnnotationForType ; } return TagBits . AnnotationForType ; } else if ( annotatedElement instanceof FieldDeclaration ) { if ( fakeNode . isParameter ) { return TagBits . AnnotationForParameter ; } return TagBits . AnnotationForField ; } else if ( annotatedElement instanceof MethodDeclaration ) { return TagBits . AnnotationForMethod ; } else if ( annotatedElement instanceof Argument ) { return TagBits . AnnotationForParameter ; } else if ( annotatedElement instanceof ConstructorDeclaration ) { return TagBits . AnnotationForConstructor ; } else if ( annotatedElement instanceof LocalDeclaration ) { return TagBits . AnnotationForLocalVariable ; } else if ( annotatedElement instanceof ImportReference ) { return TagBits . AnnotationForPackage ; } return <NUM_LIT:0> ; } private TypeBinding [ ] computeTypes ( Expression [ ] arguments ) { if ( arguments == null ) return null ; int argsLength = arguments . length ; TypeBinding [ ] argTypes = new TypeBinding [ argsLength ] ; for ( int a = argsLength ; -- a >= <NUM_LIT:0> ; ) { argTypes [ a ] = arguments [ a ] . resolvedType ; } return argTypes ; } private TypeBinding [ ] computeTypesIfCorrect ( Expression [ ] arguments ) { if ( arguments == null ) return null ; int argsLength = arguments . length ; TypeBinding [ ] argTypes = new TypeBinding [ argsLength ] ; for ( int a = argsLength ; -- a >= <NUM_LIT:0> ; ) { TypeBinding typeBinding = arguments [ a ] . resolvedType ; if ( typeBinding == null || ! typeBinding . isValidBinding ( ) ) return null ; argTypes [ a ] = typeBinding ; } return argTypes ; } private void computeUninterestingBindings ( ASTNode astNode , ASTNode parent , Scope scope ) { this . uninterestingBindingsFilter = NONE ; if ( parent instanceof LocalDeclaration ) { addUninterestingBindings ( ( ( LocalDeclaration ) parent ) . binding ) ; } else if ( parent instanceof FieldDeclaration ) { addUninterestingBindings ( ( ( FieldDeclaration ) parent ) . binding ) ; } else if ( parent instanceof TryStatement ) { boolean isException = false ; if ( astNode instanceof CompletionOnSingleTypeReference ) { isException = ( ( CompletionOnSingleTypeReference ) astNode ) . isException ( ) ; } else if ( astNode instanceof CompletionOnQualifiedTypeReference ) { isException = ( ( CompletionOnQualifiedTypeReference ) astNode ) . isException ( ) ; } else if ( astNode instanceof CompletionOnParameterizedQualifiedTypeReference ) { isException = ( ( CompletionOnParameterizedQualifiedTypeReference ) astNode ) . isException ( ) ; } if ( isException ) { this . uninterestingBindingsFilter |= SUBTYPE ; Argument [ ] args = ( ( TryStatement ) parent ) . catchArguments ; for ( int i = <NUM_LIT:0> ; i < args . length ; i ++ ) { if ( args [ i ] . type instanceof UnionTypeReference ) { CompletionNodeDetector detector = new CompletionNodeDetector ( astNode , args [ i ] ) ; if ( detector . containsCompletionNode ( ) ) { this . uninterestingBindingsFilter |= SUPERTYPE ; break ; } } } } } } private char [ ] createImportCharArray ( char [ ] importedElement , boolean isStatic , boolean onDemand ) { char [ ] result = IMPORT ; if ( isStatic ) { result = CharOperation . concat ( result , STATIC , '<CHAR_LIT:U+0020>' ) ; } result = CharOperation . concat ( result , importedElement , '<CHAR_LIT:U+0020>' ) ; if ( onDemand ) { result = CharOperation . concat ( result , ON_DEMAND ) ; } return CharOperation . concat ( result , IMPORT_END ) ; } private void createMethod ( MethodBinding method , char [ ] [ ] parameterPackageNames , char [ ] [ ] parameterTypeNames , char [ ] [ ] parameterNames , Scope scope , StringBuffer completion ) { int insertedModifiers = method . modifiers & ~ ( ClassFileConstants . AccNative | ClassFileConstants . AccAbstract ) ; if ( insertedModifiers != ClassFileConstants . AccDefault ) { ASTNode . printModifiers ( insertedModifiers , completion ) ; } TypeVariableBinding [ ] typeVariableBindings = method . typeVariables ; if ( typeVariableBindings != null && typeVariableBindings . length != <NUM_LIT:0> ) { completion . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < typeVariableBindings . length ; i ++ ) { if ( i != <NUM_LIT:0> ) { completion . append ( '<CHAR_LIT:U+002C>' ) ; completion . append ( '<CHAR_LIT:U+0020>' ) ; } createTypeVariable ( typeVariableBindings [ i ] , scope , completion ) ; } completion . append ( '<CHAR_LIT:>>' ) ; completion . append ( '<CHAR_LIT:U+0020>' ) ; } createType ( method . returnType , scope , completion ) ; completion . append ( '<CHAR_LIT:U+0020>' ) ; completion . append ( method . selector ) ; completion . append ( '<CHAR_LIT:(>' ) ; TypeBinding [ ] parameterTypes = method . parameters ; int length = parameterTypes . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( i != <NUM_LIT:0> ) { completion . append ( '<CHAR_LIT:U+002C>' ) ; completion . append ( '<CHAR_LIT:U+0020>' ) ; } createType ( parameterTypes [ i ] , scope , completion ) ; completion . append ( '<CHAR_LIT:U+0020>' ) ; if ( parameterNames != null ) { completion . append ( parameterNames [ i ] ) ; } else { completion . append ( '<CHAR_LIT>' ) ; } } completion . append ( '<CHAR_LIT:)>' ) ; ReferenceBinding [ ] exceptions = method . thrownExceptions ; if ( exceptions != null && exceptions . length > <NUM_LIT:0> ) { completion . append ( '<CHAR_LIT:U+0020>' ) ; completion . append ( THROWS ) ; completion . append ( '<CHAR_LIT:U+0020>' ) ; for ( int i = <NUM_LIT:0> ; i < exceptions . length ; i ++ ) { if ( i != <NUM_LIT:0> ) { completion . append ( '<CHAR_LIT:U+0020>' ) ; completion . append ( '<CHAR_LIT:U+002C>' ) ; } createType ( exceptions [ i ] , scope , completion ) ; } } } protected InternalCompletionProposal createProposal ( int kind , int completionOffset ) { InternalCompletionProposal proposal = ( InternalCompletionProposal ) CompletionProposal . create ( kind , completionOffset - this . offset ) ; proposal . nameLookup = this . nameEnvironment . nameLookup ; proposal . completionEngine = this ; return proposal ; } private CompletionProposal createRequiredTypeProposal ( Binding binding , int start , int end , int relevance ) { InternalCompletionProposal proposal = null ; if ( binding instanceof ReferenceBinding ) { ReferenceBinding typeBinding = ( ReferenceBinding ) binding ; char [ ] packageName = typeBinding . qualifiedPackageName ( ) ; char [ ] typeName = typeBinding . qualifiedSourceName ( ) ; char [ ] fullyQualifiedName = CharOperation . concat ( packageName , typeName , '<CHAR_LIT:.>' ) ; proposal = createProposal ( CompletionProposal . TYPE_REF , this . actualCompletionPosition ) ; proposal . nameLookup = this . nameEnvironment . nameLookup ; proposal . completionEngine = this ; proposal . setDeclarationSignature ( packageName ) ; proposal . setSignature ( getRequiredTypeSignature ( typeBinding ) ) ; proposal . setPackageName ( packageName ) ; proposal . setTypeName ( typeName ) ; proposal . setCompletion ( fullyQualifiedName ) ; proposal . setFlags ( typeBinding . modifiers ) ; proposal . setReplaceRange ( start - this . offset , end - this . offset ) ; proposal . setTokenRange ( start - this . offset , end - this . offset ) ; proposal . setRelevance ( relevance ) ; } else if ( binding instanceof PackageBinding ) { PackageBinding packageBinding = ( PackageBinding ) binding ; char [ ] packageName = CharOperation . concatWith ( packageBinding . compoundName , '<CHAR_LIT:.>' ) ; proposal = createProposal ( CompletionProposal . PACKAGE_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( packageName ) ; proposal . setPackageName ( packageName ) ; proposal . setCompletion ( packageName ) ; proposal . setReplaceRange ( start - this . offset , end - this . offset ) ; proposal . setTokenRange ( start - this . offset , end - this . offset ) ; proposal . setRelevance ( relevance ) ; } return proposal ; } private void createType ( TypeBinding type , Scope scope , StringBuffer completion ) { switch ( type . kind ( ) ) { case Binding . BASE_TYPE : completion . append ( type . sourceName ( ) ) ; break ; case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : WildcardBinding wildcardBinding = ( WildcardBinding ) type ; completion . append ( '<CHAR_LIT>' ) ; switch ( wildcardBinding . boundKind ) { case Wildcard . EXTENDS : completion . append ( '<CHAR_LIT:U+0020>' ) ; completion . append ( EXTENDS ) ; completion . append ( '<CHAR_LIT:U+0020>' ) ; createType ( wildcardBinding . bound , scope , completion ) ; if ( wildcardBinding . otherBounds != null ) { int length = wildcardBinding . otherBounds . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { completion . append ( '<CHAR_LIT:U+0020>' ) ; completion . append ( '<CHAR_LIT>' ) ; completion . append ( '<CHAR_LIT:U+0020>' ) ; createType ( wildcardBinding . otherBounds [ i ] , scope , completion ) ; } } break ; case Wildcard . SUPER : completion . append ( '<CHAR_LIT:U+0020>' ) ; completion . append ( SUPER ) ; completion . append ( '<CHAR_LIT:U+0020>' ) ; createType ( wildcardBinding . bound , scope , completion ) ; break ; } break ; case Binding . ARRAY_TYPE : createType ( type . leafComponentType ( ) , scope , completion ) ; int dim = type . dimensions ( ) ; for ( int i = <NUM_LIT:0> ; i < dim ; i ++ ) { completion . append ( '<CHAR_LIT:[>' ) ; completion . append ( '<CHAR_LIT:]>' ) ; } break ; case Binding . PARAMETERIZED_TYPE : ParameterizedTypeBinding parameterizedType = ( ParameterizedTypeBinding ) type ; if ( type . isMemberType ( ) ) { createType ( parameterizedType . enclosingType ( ) , scope , completion ) ; completion . append ( '<CHAR_LIT:.>' ) ; completion . append ( parameterizedType . sourceName ) ; } else { completion . append ( CharOperation . concatWith ( parameterizedType . genericType ( ) . compoundName , '<CHAR_LIT:.>' ) ) ; } if ( parameterizedType . arguments != null ) { completion . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> , length = parameterizedType . arguments . length ; i < length ; i ++ ) { if ( i != <NUM_LIT:0> ) completion . append ( '<CHAR_LIT:U+002C>' ) ; createType ( parameterizedType . arguments [ i ] , scope , completion ) ; } completion . append ( '<CHAR_LIT:>>' ) ; } break ; default : char [ ] packageName = type . qualifiedPackageName ( ) ; char [ ] typeName = type . qualifiedSourceName ( ) ; if ( mustQualifyType ( ( ReferenceBinding ) type , packageName , scope ) ) { completion . append ( CharOperation . concat ( packageName , typeName , '<CHAR_LIT:.>' ) ) ; } else { completion . append ( type . sourceName ( ) ) ; } break ; } } private void createTypeParameterProposal ( TypeParameter typeParameter , int relevance ) { char [ ] completionName = typeParameter . name ; if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { InternalCompletionProposal proposal = ( InternalCompletionProposal ) CompletionProposal . create ( CompletionProposal . TYPE_REF , this . actualCompletionPosition - this . offset ) ; proposal . nameLookup = this . nameEnvironment . nameLookup ; proposal . completionEngine = this ; proposal . setSignature ( getSignature ( typeParameter . binding ) ) ; proposal . setTypeName ( completionName ) ; proposal . setCompletion ( completionName ) ; proposal . setFlags ( typeParameter . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } if ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> && ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_TYPE_REF ) ) { char [ ] javadocCompletion = inlineTagCompletion ( completionName , JavadocTagConstants . TAG_LINK ) ; InternalCompletionProposal proposal = ( InternalCompletionProposal ) CompletionProposal . create ( CompletionProposal . JAVADOC_TYPE_REF , this . actualCompletionPosition - this . offset ) ; proposal . nameLookup = this . nameEnvironment . nameLookup ; proposal . completionEngine = this ; proposal . setSignature ( getSignature ( typeParameter . binding ) ) ; proposal . setTypeName ( javadocCompletion ) ; proposal . setCompletion ( javadocCompletion ) ; proposal . setFlags ( typeParameter . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance + R_INLINE_TAG ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } private void createTypeProposal ( char [ ] packageName , char [ ] typeName , int modifiers , int accessibility , char [ ] completionName , int relevance ) { if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) && ( this . assistNodeInJavadoc & CompletionOnJavadoc . ONLY_INLINE_TAG ) == <NUM_LIT:0> ) { InternalCompletionProposal proposal = ( InternalCompletionProposal ) CompletionProposal . create ( CompletionProposal . TYPE_REF , this . actualCompletionPosition - this . offset ) ; proposal . nameLookup = this . nameEnvironment . nameLookup ; proposal . completionEngine = this ; proposal . setDeclarationSignature ( packageName ) ; proposal . setSignature ( createNonGenericTypeSignature ( packageName , typeName ) ) ; proposal . setPackageName ( packageName ) ; proposal . setTypeName ( typeName ) ; proposal . setCompletion ( completionName ) ; proposal . setFlags ( modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; proposal . setAccessibility ( accessibility ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } if ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> && ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_TYPE_REF ) ) { char [ ] javadocCompletion = inlineTagCompletion ( completionName , JavadocTagConstants . TAG_LINK ) ; InternalCompletionProposal proposal = ( InternalCompletionProposal ) CompletionProposal . create ( CompletionProposal . JAVADOC_TYPE_REF , this . actualCompletionPosition - this . offset ) ; proposal . nameLookup = this . nameEnvironment . nameLookup ; proposal . completionEngine = this ; proposal . setDeclarationSignature ( packageName ) ; proposal . setSignature ( createNonGenericTypeSignature ( packageName , typeName ) ) ; proposal . setPackageName ( packageName ) ; proposal . setTypeName ( typeName ) ; proposal . setCompletion ( javadocCompletion ) ; proposal . setFlags ( modifiers ) ; int start = ( this . assistNodeInJavadoc & CompletionOnJavadoc . REPLACE_TAG ) != <NUM_LIT:0> ? this . javadocTagPosition : this . startPosition ; proposal . setReplaceRange ( start - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance + R_INLINE_TAG ) ; proposal . setAccessibility ( accessibility ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } private void createTypeProposal ( ReferenceBinding refBinding , char [ ] typeName , int accessibility , char [ ] completionName , int relevance , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems ) { if ( ! this . isIgnored ( CompletionProposal . TYPE_REF , missingElements != null ) && ( this . assistNodeInJavadoc & CompletionOnJavadoc . ONLY_INLINE_TAG ) == <NUM_LIT:0> ) { InternalCompletionProposal proposal = ( InternalCompletionProposal ) CompletionProposal . create ( CompletionProposal . TYPE_REF , this . actualCompletionPosition - this . offset ) ; proposal . nameLookup = this . nameEnvironment . nameLookup ; proposal . completionEngine = this ; proposal . setDeclarationSignature ( refBinding . qualifiedPackageName ( ) ) ; proposal . setSignature ( getCompletedTypeSignature ( refBinding ) ) ; proposal . setPackageName ( refBinding . qualifiedPackageName ( ) ) ; proposal . setTypeName ( typeName ) ; if ( missingElements != null ) { CompletionProposal [ ] subProposals = new CompletionProposal [ missingElements . length ] ; for ( int i = <NUM_LIT:0> ; i < missingElements . length ; i ++ ) { subProposals [ i ] = createRequiredTypeProposal ( missingElements [ i ] , missingElementsStarts [ i ] , missingElementsEnds [ i ] , relevance ) ; } proposal . setRequiredProposals ( subProposals ) ; } proposal . setCompletion ( completionName ) ; proposal . setFlags ( refBinding . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } if ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> && ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_TYPE_REF ) ) { char [ ] javadocCompletion = inlineTagCompletion ( completionName , JavadocTagConstants . TAG_LINK ) ; InternalCompletionProposal proposal = ( InternalCompletionProposal ) CompletionProposal . create ( CompletionProposal . JAVADOC_TYPE_REF , this . actualCompletionPosition - this . offset ) ; proposal . nameLookup = this . nameEnvironment . nameLookup ; proposal . completionEngine = this ; proposal . setDeclarationSignature ( refBinding . qualifiedPackageName ( ) ) ; proposal . setSignature ( getCompletedTypeSignature ( refBinding ) ) ; proposal . setPackageName ( refBinding . qualifiedPackageName ( ) ) ; proposal . setTypeName ( typeName ) ; proposal . setCompletion ( javadocCompletion ) ; proposal . setFlags ( refBinding . modifiers ) ; int start = ( this . assistNodeInJavadoc & CompletionOnJavadoc . REPLACE_TAG ) != <NUM_LIT:0> ? this . javadocTagPosition : this . startPosition ; proposal . setReplaceRange ( start - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance + R_INLINE_TAG ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } private void createTypeVariable ( TypeVariableBinding typeVariable , Scope scope , StringBuffer completion ) { completion . append ( typeVariable . sourceName ) ; if ( typeVariable . superclass != null && typeVariable . firstBound == typeVariable . superclass ) { completion . append ( '<CHAR_LIT:U+0020>' ) ; completion . append ( EXTENDS ) ; completion . append ( '<CHAR_LIT:U+0020>' ) ; createType ( typeVariable . superclass , scope , completion ) ; } if ( typeVariable . superInterfaces != null && typeVariable . superInterfaces != Binding . NO_SUPERINTERFACES ) { if ( typeVariable . firstBound != typeVariable . superclass ) { completion . append ( '<CHAR_LIT:U+0020>' ) ; completion . append ( EXTENDS ) ; completion . append ( '<CHAR_LIT:U+0020>' ) ; } for ( int i = <NUM_LIT:0> , length = typeVariable . superInterfaces . length ; i < length ; i ++ ) { if ( i > <NUM_LIT:0> || typeVariable . firstBound == typeVariable . superclass ) { completion . append ( '<CHAR_LIT:U+0020>' ) ; completion . append ( EXTENDS ) ; completion . append ( '<CHAR_LIT:U+0020>' ) ; } createType ( typeVariable . superInterfaces [ i ] , scope , completion ) ; } } } private void createVargsType ( TypeBinding type , Scope scope , StringBuffer completion ) { if ( type . isArrayType ( ) ) { createType ( type . leafComponentType ( ) , scope , completion ) ; int dim = type . dimensions ( ) - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < dim ; i ++ ) { completion . append ( '<CHAR_LIT:[>' ) ; completion . append ( '<CHAR_LIT:]>' ) ; } completion . append ( VARARGS ) ; } else { createType ( type , scope , completion ) ; } } private void findAnnotationAttributes ( char [ ] token , MemberValuePair [ ] attributesFound , ReferenceBinding annotation ) { MethodBinding [ ] methods = annotation . availableMethods ( ) ; nextAttribute : for ( int i = <NUM_LIT:0> ; i < methods . length ; i ++ ) { MethodBinding method = methods [ i ] ; if ( ! CharOperation . prefixEquals ( token , method . selector , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( token , method . selector ) ) ) continue nextAttribute ; int length = attributesFound == null ? <NUM_LIT:0> : attributesFound . length ; for ( int j = <NUM_LIT:0> ; j < length ; j ++ ) { if ( CharOperation . equals ( method . selector , attributesFound [ j ] . name , false ) ) continue nextAttribute ; } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( method ) ; relevance += computeRelevanceForCaseMatching ( token , method . selector ) ; relevance += computeRelevanceForQualification ( false ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . ANNOTATION_ATTRIBUTE_REF ) ) { CompletionProposal proposal = createProposal ( CompletionProposal . ANNOTATION_ATTRIBUTE_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( method . declaringClass ) ) ; proposal . setSignature ( getSignature ( method . returnType ) ) ; proposal . setName ( method . selector ) ; proposal . setCompletion ( method . selector ) ; proposal . setFlags ( method . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } void findAnonymousType ( ReferenceBinding currentType , TypeBinding [ ] argTypes , Scope scope , InvocationSite invocationSite , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems ) { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( currentType ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; if ( missingElements != null ) { relevance += computeRelevanceForMissingElements ( missingElementsHaveProblems ) ; } findAnonymousType ( currentType , argTypes , scope , invocationSite , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems , true , false , relevance ) ; } private void findAnonymousType ( ReferenceBinding currentType , TypeBinding [ ] argTypes , Scope scope , InvocationSite invocationSite , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems , boolean exactMatch , boolean isQualified , int relevance ) { if ( currentType . isInterface ( ) ) { char [ ] completion = CharOperation . NO_CHAR ; char [ ] typeCompletion = null ; if ( ! exactMatch ) { typeCompletion = isQualified ? CharOperation . concat ( currentType . qualifiedPackageName ( ) , currentType . qualifiedSourceName ( ) , '<CHAR_LIT:.>' ) : currentType . sourceName ( ) ; if ( this . source != null && this . source . length > this . endPosition && this . source [ this . endPosition ] == '<CHAR_LIT:(>' ) { completion = CharOperation . NO_CHAR ; } else { completion = new char [ ] { '<CHAR_LIT:(>' , '<CHAR_LIT:)>' } ; } } this . noProposal = false ; if ( ! exactMatch ) { if ( ! isIgnored ( CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) ) { char [ ] packageName = currentType . isLocalType ( ) ? null : currentType . qualifiedPackageName ( ) ; char [ ] typeName = currentType . qualifiedSourceName ( ) ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( currentType ) ) ; proposal . setDeclarationKey ( currentType . computeUniqueKey ( ) ) ; proposal . setSignature ( createMethodSignature ( CharOperation . NO_CHAR_CHAR , CharOperation . NO_CHAR_CHAR , CharOperation . NO_CHAR , CharOperation . NO_CHAR ) ) ; proposal . setDeclarationPackageName ( packageName ) ; proposal . setDeclarationTypeName ( typeName ) ; proposal . setName ( currentType . sourceName ( ) ) ; InternalCompletionProposal typeProposal = createProposal ( CompletionProposal . TYPE_REF , this . actualCompletionPosition ) ; typeProposal . nameLookup = this . nameEnvironment . nameLookup ; typeProposal . completionEngine = this ; typeProposal . setDeclarationSignature ( packageName ) ; typeProposal . setSignature ( getRequiredTypeSignature ( currentType ) ) ; typeProposal . setPackageName ( packageName ) ; typeProposal . setTypeName ( typeName ) ; typeProposal . setCompletion ( typeCompletion ) ; typeProposal . setFlags ( currentType . modifiers ) ; typeProposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; typeProposal . setTokenRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; typeProposal . setRelevance ( relevance ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { typeProposal } ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( Flags . AccPublic ) ; proposal . setReplaceRange ( this . endPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } else { if ( ! isIgnored ( CompletionProposal . ANONYMOUS_CLASS_DECLARATION , missingElements != null ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . ANONYMOUS_CLASS_DECLARATION , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( currentType ) ) ; proposal . setDeclarationKey ( currentType . computeUniqueKey ( ) ) ; proposal . setSignature ( createMethodSignature ( CharOperation . NO_CHAR_CHAR , CharOperation . NO_CHAR_CHAR , CharOperation . NO_CHAR , CharOperation . NO_CHAR ) ) ; proposal . setDeclarationPackageName ( currentType . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( currentType . qualifiedSourceName ( ) ) ; if ( missingElements != null ) { CompletionProposal [ ] subProposals = new CompletionProposal [ missingElements . length ] ; for ( int i = <NUM_LIT:0> ; i < missingElements . length ; i ++ ) { subProposals [ i ] = createRequiredTypeProposal ( missingElements [ i ] , missingElementsStarts [ i ] , missingElementsEnds [ i ] , relevance ) ; } proposal . setRequiredProposals ( subProposals ) ; } proposal . setCompletion ( completion ) ; proposal . setFlags ( Flags . AccPublic ) ; proposal . setReplaceRange ( this . endPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenEnd - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } else { findConstructors ( currentType , argTypes , scope , invocationSite , true , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems , exactMatch , isQualified , relevance ) ; } } private void findClassField ( char [ ] token , TypeBinding receiverType , Scope scope , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems ) { if ( token == null ) return ; if ( token . length <= classField . length && CharOperation . prefixEquals ( token , classField , false ) ) { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( token , classField ) ; relevance += computeRelevanceForExpectingType ( scope . getJavaLangClass ( ) ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; relevance += R_NON_INHERITED ; if ( missingElements != null ) { relevance += computeRelevanceForMissingElements ( missingElementsHaveProblems ) ; } this . noProposal = false ; if ( ! isIgnored ( CompletionProposal . FIELD_REF , missingElements != null ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . FIELD_REF , this . actualCompletionPosition ) ; char [ ] signature = createNonGenericTypeSignature ( CharOperation . concatWith ( JAVA_LANG , '<CHAR_LIT:.>' ) , CLASS ) ; if ( this . compilerOptions . sourceLevel > ClassFileConstants . JDK1_4 ) { char [ ] typeArgument = getTypeSignature ( receiverType ) ; int oldLength = signature . length ; int argumentLength = typeArgument . length ; int newLength = oldLength + argumentLength + <NUM_LIT:2> ; System . arraycopy ( signature , <NUM_LIT:0> , signature = new char [ newLength ] , <NUM_LIT:0> , oldLength - <NUM_LIT:1> ) ; signature [ oldLength - <NUM_LIT:1> ] = '<CHAR_LIT>' ; System . arraycopy ( typeArgument , <NUM_LIT:0> , signature , oldLength , argumentLength ) ; signature [ newLength - <NUM_LIT:2> ] = '<CHAR_LIT:>>' ; signature [ newLength - <NUM_LIT:1> ] = '<CHAR_LIT:;>' ; } proposal . setSignature ( signature ) ; proposal . setPackageName ( CharOperation . concatWith ( JAVA_LANG , '<CHAR_LIT:.>' ) ) ; proposal . setTypeName ( CLASS ) ; proposal . setName ( classField ) ; if ( missingElements != null ) { CompletionProposal [ ] subProposals = new CompletionProposal [ missingElements . length ] ; for ( int i = <NUM_LIT:0> ; i < missingElements . length ; i ++ ) { subProposals [ i ] = createRequiredTypeProposal ( missingElements [ i ] , missingElementsStarts [ i ] , missingElementsEnds [ i ] , relevance ) ; } proposal . setRequiredProposals ( subProposals ) ; } proposal . setCompletion ( classField ) ; proposal . setFlags ( Flags . AccStatic | Flags . AccPublic ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } void findConstructors ( ReferenceBinding currentType , TypeBinding [ ] argTypes , Scope scope , InvocationSite invocationSite , boolean forAnonymousType , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems ) { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; if ( missingElements != null ) { relevance += computeRelevanceForMissingElements ( missingElementsHaveProblems ) ; } findConstructors ( currentType , argTypes , scope , invocationSite , forAnonymousType , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems , true , false , relevance ) ; } private void findConstructorsFromMissingType ( TypeReference typeRef , final TypeBinding [ ] argTypes , final Scope scope , final InvocationSite invocationSite ) { MissingTypesGuesser missingTypesConverter = new MissingTypesGuesser ( this ) ; MissingTypesGuesser . GuessedTypeRequestor substitutionRequestor = new MissingTypesGuesser . GuessedTypeRequestor ( ) { public void accept ( TypeBinding guessedType , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean hasProblems ) { if ( guessedType instanceof ReferenceBinding ) { ReferenceBinding ref = ( ReferenceBinding ) guessedType ; if ( ! isIgnored ( CompletionProposal . METHOD_REF , missingElements != null ) && ref . isClass ( ) && ! ref . isAbstract ( ) ) { findConstructors ( ref , argTypes , scope , invocationSite , false , missingElements , missingElementsStarts , missingElementsEnds , hasProblems ) ; } checkCancel ( ) ; if ( ! isIgnored ( CompletionProposal . ANONYMOUS_CLASS_DECLARATION , missingElements != null ) && ! ref . isFinal ( ) && ! ref . isEnum ( ) ) { findAnonymousType ( ref , argTypes , scope , invocationSite , missingElements , missingElementsStarts , missingElementsEnds , hasProblems ) ; } } } } ; missingTypesConverter . guess ( typeRef , scope , substitutionRequestor ) ; } private void findConstructors ( ReferenceBinding currentType , TypeBinding [ ] argTypes , Scope scope , InvocationSite invocationSite , boolean forAnonymousType , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems , boolean exactMatch , boolean isQualified , int relevance ) { MethodBinding [ ] methods = null ; if ( currentType instanceof ParameterizedTypeBinding && invocationSite instanceof CompletionOnQualifiedAllocationExpression ) { CompletionOnQualifiedAllocationExpression alloc = ( CompletionOnQualifiedAllocationExpression ) invocationSite ; if ( ( alloc . bits & ASTNode . IsDiamond ) != <NUM_LIT:0> ) { ParameterizedTypeBinding binding = ( ParameterizedTypeBinding ) currentType ; ReferenceBinding originalGenericType = binding . genericType ( ) ; if ( originalGenericType != null ) methods = originalGenericType . methods ( ) ; } else { methods = currentType . availableMethods ( ) ; } } else { methods = currentType . availableMethods ( ) ; } if ( methods != null ) { int minArgLength = argTypes == null ? <NUM_LIT:0> : argTypes . length ; next : for ( int f = methods . length ; -- f >= <NUM_LIT:0> ; ) { MethodBinding constructor = methods [ f ] ; if ( constructor . isConstructor ( ) ) { if ( constructor . isSynthetic ( ) ) continue next ; if ( this . options . checkDeprecation && constructor . isViewedAsDeprecated ( ) && ! scope . isDefinedInSameUnit ( constructor . declaringClass ) ) continue next ; if ( this . options . checkVisibility && ! constructor . canBeSeenBy ( invocationSite , scope ) ) { if ( ! forAnonymousType || ! constructor . isProtected ( ) ) continue next ; } TypeBinding [ ] parameters = constructor . parameters ; int paramLength = parameters . length ; if ( minArgLength > paramLength ) continue next ; for ( int a = minArgLength ; -- a >= <NUM_LIT:0> ; ) if ( argTypes [ a ] != null ) { if ( ! argTypes [ a ] . isCompatibleWith ( constructor . parameters [ a ] ) ) continue next ; } char [ ] [ ] parameterPackageNames = new char [ paramLength ] [ ] ; char [ ] [ ] parameterTypeNames = new char [ paramLength ] [ ] ; for ( int i = <NUM_LIT:0> ; i < paramLength ; i ++ ) { TypeBinding type = parameters [ i ] ; parameterPackageNames [ i ] = type . qualifiedPackageName ( ) ; parameterTypeNames [ i ] = type . qualifiedSourceName ( ) ; } char [ ] [ ] parameterNames = findMethodParameterNames ( constructor , parameterTypeNames ) ; char [ ] completion = CharOperation . NO_CHAR ; if ( forAnonymousType ) { char [ ] typeCompletion = null ; if ( ! exactMatch ) { typeCompletion = isQualified ? CharOperation . concat ( currentType . qualifiedPackageName ( ) , currentType . qualifiedSourceName ( ) , '<CHAR_LIT:.>' ) : currentType . sourceName ( ) ; if ( this . source != null && this . source . length > this . endPosition && this . source [ this . endPosition ] == '<CHAR_LIT:(>' ) { completion = CharOperation . NO_CHAR ; } else { completion = new char [ ] { '<CHAR_LIT:(>' , '<CHAR_LIT:)>' } ; } } this . noProposal = false ; if ( ! exactMatch ) { if ( ! isIgnored ( CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) ) { char [ ] packageName = currentType . isLocalType ( ) ? null : currentType . qualifiedPackageName ( ) ; char [ ] typeName = currentType . qualifiedSourceName ( ) ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( currentType ) ) ; proposal . setDeclarationKey ( currentType . computeUniqueKey ( ) ) ; proposal . setSignature ( getSignature ( constructor ) ) ; MethodBinding original = constructor . original ( ) ; if ( original != constructor ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setKey ( constructor . computeUniqueKey ( ) ) ; proposal . setDeclarationPackageName ( packageName ) ; proposal . setDeclarationTypeName ( typeName ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; proposal . setName ( currentType . sourceName ( ) ) ; InternalCompletionProposal typeProposal = createProposal ( CompletionProposal . TYPE_REF , this . actualCompletionPosition ) ; typeProposal . nameLookup = this . nameEnvironment . nameLookup ; typeProposal . completionEngine = this ; typeProposal . setDeclarationSignature ( packageName ) ; typeProposal . setSignature ( getRequiredTypeSignature ( currentType ) ) ; typeProposal . setPackageName ( packageName ) ; typeProposal . setTypeName ( typeName ) ; typeProposal . setCompletion ( typeCompletion ) ; typeProposal . setFlags ( currentType . modifiers ) ; typeProposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; typeProposal . setTokenRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; typeProposal . setRelevance ( relevance ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { typeProposal } ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( constructor . modifiers ) ; proposal . setReplaceRange ( this . endPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } else { if ( ! isIgnored ( CompletionProposal . ANONYMOUS_CLASS_DECLARATION , missingElements != null ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . ANONYMOUS_CLASS_DECLARATION , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( currentType ) ) ; proposal . setDeclarationKey ( currentType . computeUniqueKey ( ) ) ; proposal . setSignature ( getSignature ( constructor ) ) ; MethodBinding original = constructor . original ( ) ; if ( original != constructor ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setKey ( constructor . computeUniqueKey ( ) ) ; proposal . setDeclarationPackageName ( currentType . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( currentType . qualifiedSourceName ( ) ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; if ( missingElements != null ) { CompletionProposal [ ] subProposals = new CompletionProposal [ missingElements . length ] ; for ( int i = <NUM_LIT:0> ; i < missingElements . length ; i ++ ) { subProposals [ i ] = createRequiredTypeProposal ( missingElements [ i ] , missingElementsStarts [ i ] , missingElementsEnds [ i ] , relevance ) ; } proposal . setRequiredProposals ( subProposals ) ; } proposal . setCompletion ( completion ) ; proposal . setFlags ( constructor . modifiers ) ; proposal . setReplaceRange ( this . endPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenEnd - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } else { char [ ] typeCompletion = null ; if ( this . assistNodeInJavadoc > <NUM_LIT:0> ) { Expression receiver = null ; char [ ] selector = null ; if ( invocationSite instanceof CompletionOnJavadocAllocationExpression ) { CompletionOnJavadocAllocationExpression alloc = ( CompletionOnJavadocAllocationExpression ) invocationSite ; receiver = alloc . type ; } else if ( invocationSite instanceof CompletionOnJavadocFieldReference ) { CompletionOnJavadocFieldReference fieldRef = ( CompletionOnJavadocFieldReference ) invocationSite ; receiver = fieldRef . receiver ; } if ( receiver != null ) { StringBuffer javadocCompletion = new StringBuffer ( ) ; if ( receiver . isThis ( ) ) { selector = ( ( ( JavadocImplicitTypeReference ) receiver ) . token ) ; if ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> ) { javadocCompletion . append ( '<CHAR_LIT>' ) ; } } else if ( receiver instanceof JavadocSingleTypeReference ) { JavadocSingleTypeReference typeRef = ( JavadocSingleTypeReference ) receiver ; selector = typeRef . token ; if ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> ) { javadocCompletion . append ( typeRef . token ) ; javadocCompletion . append ( '<CHAR_LIT>' ) ; } } else if ( receiver instanceof JavadocQualifiedTypeReference ) { JavadocQualifiedTypeReference typeRef = ( JavadocQualifiedTypeReference ) receiver ; selector = typeRef . tokens [ typeRef . tokens . length - <NUM_LIT:1> ] ; if ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> ) { javadocCompletion . append ( CharOperation . concatWith ( typeRef . tokens , '<CHAR_LIT:.>' ) ) ; javadocCompletion . append ( '<CHAR_LIT>' ) ; } } javadocCompletion . append ( selector ) ; javadocCompletion . append ( '<CHAR_LIT:(>' ) ; if ( constructor . parameters != null ) { boolean isVarargs = constructor . isVarargs ( ) ; for ( int p = <NUM_LIT:0> , ln = constructor . parameters . length ; p < ln ; p ++ ) { if ( p > <NUM_LIT:0> ) javadocCompletion . append ( "<STR_LIT:U+002CU+0020>" ) ; TypeBinding argTypeBinding = constructor . parameters [ p ] ; if ( isVarargs && p == ln - <NUM_LIT:1> ) { createVargsType ( argTypeBinding . erasure ( ) , scope , javadocCompletion ) ; } else { createType ( argTypeBinding . erasure ( ) , scope , javadocCompletion ) ; } } } javadocCompletion . append ( '<CHAR_LIT:)>' ) ; completion = javadocCompletion . toString ( ) . toCharArray ( ) ; } } else { if ( ! exactMatch ) { typeCompletion = isQualified ? CharOperation . concat ( currentType . qualifiedPackageName ( ) , currentType . qualifiedSourceName ( ) , '<CHAR_LIT:.>' ) : currentType . sourceName ( ) ; if ( this . source != null && this . source . length > this . endPosition && this . source [ this . endPosition ] == '<CHAR_LIT:(>' ) { completion = CharOperation . NO_CHAR ; } else { completion = new char [ ] { '<CHAR_LIT:(>' , '<CHAR_LIT:)>' } ; } } } this . noProposal = false ; if ( ! exactMatch ) { if ( ! isIgnored ( CompletionProposal . CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) ) { char [ ] packageName = currentType . isLocalType ( ) ? null : currentType . qualifiedPackageName ( ) ; char [ ] typeName = currentType . qualifiedSourceName ( ) ; int constructorRelevance = relevance + computeRelevanceForConstructor ( ) ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . CONSTRUCTOR_INVOCATION , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( currentType ) ) ; proposal . setSignature ( getSignature ( constructor ) ) ; MethodBinding original = constructor . original ( ) ; if ( original != constructor ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setDeclarationPackageName ( packageName ) ; proposal . setDeclarationTypeName ( typeName ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; proposal . setName ( currentType . sourceName ( ) ) ; InternalCompletionProposal typeProposal = createProposal ( CompletionProposal . TYPE_REF , this . actualCompletionPosition ) ; typeProposal . nameLookup = this . nameEnvironment . nameLookup ; typeProposal . completionEngine = this ; typeProposal . setDeclarationSignature ( packageName ) ; typeProposal . setSignature ( getRequiredTypeSignature ( currentType ) ) ; typeProposal . setPackageName ( packageName ) ; typeProposal . setTypeName ( typeName ) ; typeProposal . setCompletion ( typeCompletion ) ; typeProposal . setFlags ( currentType . modifiers ) ; typeProposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; typeProposal . setTokenRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; typeProposal . setRelevance ( constructorRelevance ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { typeProposal } ) ; proposal . setIsContructor ( true ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( constructor . modifiers ) ; proposal . setReplaceRange ( this . endPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( constructorRelevance ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } else { if ( ! isIgnored ( CompletionProposal . METHOD_REF , missingElements != null ) && ( this . assistNodeInJavadoc & CompletionOnJavadoc . ONLY_INLINE_TAG ) == <NUM_LIT:0> ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . METHOD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( currentType ) ) ; proposal . setSignature ( getSignature ( constructor ) ) ; MethodBinding original = constructor . original ( ) ; if ( original != constructor ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setDeclarationPackageName ( currentType . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( currentType . qualifiedSourceName ( ) ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; proposal . setName ( currentType . sourceName ( ) ) ; if ( missingElements != null ) { CompletionProposal [ ] subProposals = new CompletionProposal [ missingElements . length ] ; for ( int i = <NUM_LIT:0> ; i < missingElements . length ; i ++ ) { subProposals [ i ] = createRequiredTypeProposal ( missingElements [ i ] , missingElementsStarts [ i ] , missingElementsEnds [ i ] , relevance ) ; } proposal . setRequiredProposals ( subProposals ) ; } proposal . setIsContructor ( true ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( constructor . modifiers ) ; int start = ( this . assistNodeInJavadoc > <NUM_LIT:0> ) ? this . startPosition : this . endPosition ; proposal . setReplaceRange ( start - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } if ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> && ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_METHOD_REF ) ) { char [ ] javadocCompletion = inlineTagCompletion ( completion , JavadocTagConstants . TAG_LINK ) ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . JAVADOC_METHOD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( currentType ) ) ; proposal . setSignature ( getSignature ( constructor ) ) ; MethodBinding original = constructor . original ( ) ; if ( original != constructor ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setDeclarationPackageName ( currentType . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( currentType . qualifiedSourceName ( ) ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; proposal . setName ( currentType . sourceName ( ) ) ; proposal . setIsContructor ( true ) ; proposal . setCompletion ( javadocCompletion ) ; proposal . setFlags ( constructor . modifiers ) ; int start = ( this . assistNodeInJavadoc & CompletionOnJavadoc . REPLACE_TAG ) != <NUM_LIT:0> ? this . javadocTagPosition : this . startPosition ; proposal . setReplaceRange ( start - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance + R_INLINE_TAG ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } } } } } private char [ ] getResolvedSignature ( char [ ] [ ] parameterTypes , char [ ] fullyQualifiedTypeName , int parameterCount , Scope scope ) { char [ ] [ ] cn = CharOperation . splitOn ( '<CHAR_LIT:.>' , fullyQualifiedTypeName ) ; TypeReference ref ; if ( cn . length == <NUM_LIT:1> ) { ref = new SingleTypeReference ( cn [ <NUM_LIT:0> ] , <NUM_LIT:0> ) ; } else { ref = new QualifiedTypeReference ( cn , new long [ cn . length ] ) ; } TypeBinding guessedType = null ; INameEnvironment oldNameEnvironment = this . lookupEnvironment . nameEnvironment ; this . lookupEnvironment . nameEnvironment = getNoCacheNameEnvironment ( ) ; try { switch ( scope . kind ) { case Scope . METHOD_SCOPE : case Scope . BLOCK_SCOPE : guessedType = ref . resolveType ( ( BlockScope ) scope ) ; break ; case Scope . CLASS_SCOPE : guessedType = ref . resolveType ( ( ClassScope ) scope ) ; break ; } if ( guessedType != null && guessedType . isValidBinding ( ) ) { guessedType = guessedType . erasure ( ) ; if ( guessedType instanceof SourceTypeBinding ) { SourceTypeBinding refBinding = ( SourceTypeBinding ) guessedType ; if ( refBinding . scope == null || refBinding . scope . referenceContext == null ) return null ; TypeDeclaration typeDeclaration = refBinding . scope . referenceContext ; AbstractMethodDeclaration [ ] methods = typeDeclaration . methods ; next : for ( int i = <NUM_LIT:0> ; i < methods . length ; i ++ ) { AbstractMethodDeclaration method = methods [ i ] ; if ( ! method . isConstructor ( ) ) continue next ; Argument [ ] arguments = method . arguments ; int argumentsLength = arguments == null ? <NUM_LIT:0> : arguments . length ; if ( parameterCount != argumentsLength ) continue next ; for ( int j = <NUM_LIT:0> ; j < argumentsLength ; j ++ ) { char [ ] argumentTypeName = getTypeName ( arguments [ j ] . type ) ; if ( ! CharOperation . equals ( argumentTypeName , parameterTypes [ j ] ) ) { continue next ; } } refBinding . resolveTypesFor ( method . binding ) ; if ( method . binding == null ) continue next ; return getSignature ( method . binding ) ; } } } } finally { this . lookupEnvironment . nameEnvironment = oldNameEnvironment ; } return null ; } private void findConstructorsOrAnonymousTypes ( ReferenceBinding currentType , Scope scope , InvocationSite invocationSite , boolean isQualified , int relevance ) { if ( ! isIgnored ( CompletionProposal . CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) && currentType . isClass ( ) && ! currentType . isAbstract ( ) ) { findConstructors ( currentType , null , scope , invocationSite , false , null , null , null , false , false , isQualified , relevance ) ; } if ( ! isIgnored ( CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) && ! currentType . isFinal ( ) && ( currentType . isInterface ( ) || ( currentType . isClass ( ) && currentType . isAbstract ( ) ) ) ) { findAnonymousType ( currentType , null , scope , invocationSite , null , null , null , false , false , isQualified , relevance ) ; } } private char [ ] [ ] findEnclosingTypeNames ( Scope scope ) { char [ ] [ ] excludedNames = new char [ <NUM_LIT:10> ] [ ] ; int excludedNameCount = <NUM_LIT:0> ; Scope currentScope = scope ; while ( currentScope != null ) { switch ( currentScope . kind ) { case Scope . CLASS_SCOPE : ClassScope classScope = ( ClassScope ) currentScope ; TypeDeclaration typeDeclaration = classScope . referenceContext ; if ( excludedNameCount == excludedNames . length ) { System . arraycopy ( excludedNames , <NUM_LIT:0> , excludedNames = new char [ excludedNameCount * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , excludedNameCount ) ; } excludedNames [ excludedNameCount ++ ] = typeDeclaration . name ; TypeParameter [ ] classTypeParameters = typeDeclaration . typeParameters ; if ( classTypeParameters != null ) { for ( int i = <NUM_LIT:0> ; i < classTypeParameters . length ; i ++ ) { TypeParameter typeParameter = classTypeParameters [ i ] ; if ( excludedNameCount == excludedNames . length ) { System . arraycopy ( excludedNames , <NUM_LIT:0> , excludedNames = new char [ excludedNameCount * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , excludedNameCount ) ; } excludedNames [ excludedNameCount ++ ] = typeParameter . name ; } } break ; case Scope . METHOD_SCOPE : MethodScope methodScope = ( MethodScope ) currentScope ; if ( methodScope . referenceContext instanceof AbstractMethodDeclaration ) { TypeParameter [ ] methodTypeParameters = ( ( AbstractMethodDeclaration ) methodScope . referenceContext ) . typeParameters ( ) ; if ( methodTypeParameters != null ) { for ( int i = <NUM_LIT:0> ; i < methodTypeParameters . length ; i ++ ) { TypeParameter typeParameter = methodTypeParameters [ i ] ; if ( excludedNameCount == excludedNames . length ) { System . arraycopy ( excludedNames , <NUM_LIT:0> , excludedNames = new char [ excludedNameCount * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , excludedNameCount ) ; } excludedNames [ excludedNameCount ++ ] = typeParameter . name ; } } } break ; } currentScope = currentScope . parent ; } if ( excludedNameCount == <NUM_LIT:0> ) { return CharOperation . NO_CHAR_CHAR ; } System . arraycopy ( excludedNames , <NUM_LIT:0> , excludedNames = new char [ excludedNameCount ] [ ] , <NUM_LIT:0> , excludedNameCount ) ; return excludedNames ; } private void findEnumConstants ( char [ ] enumConstantName , ReferenceBinding enumType , Scope invocationScope , ObjectVector fieldsFound , char [ ] [ ] alreadyUsedConstants , int alreadyUsedConstantCount , boolean needQualification ) { FieldBinding [ ] fields = enumType . fields ( ) ; int enumConstantLength = enumConstantName . length ; next : for ( int f = fields . length ; -- f >= <NUM_LIT:0> ; ) { FieldBinding field = fields [ f ] ; if ( field . isSynthetic ( ) ) continue next ; if ( ( field . modifiers & Flags . AccEnum ) == <NUM_LIT:0> ) continue next ; if ( enumConstantLength > field . name . length ) continue next ; if ( ! CharOperation . prefixEquals ( enumConstantName , field . name , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( enumConstantName , field . name ) ) ) continue next ; char [ ] fieldName = field . name ; for ( int i = <NUM_LIT:0> ; i < alreadyUsedConstantCount ; i ++ ) { if ( CharOperation . equals ( alreadyUsedConstants [ i ] , fieldName ) ) continue next ; } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( field ) ; relevance += computeRelevanceForCaseMatching ( enumConstantName , field . name ) ; relevance += computeRelevanceForExpectingType ( field . type ) ; relevance += computeRelevanceForEnumConstant ( field . type ) ; relevance += computeRelevanceForQualification ( needQualification ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; this . noProposal = false ; if ( ! needQualification ) { char [ ] completion = fieldName ; if ( ! this . requestor . isIgnored ( CompletionProposal . FIELD_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . FIELD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( field . declaringClass ) ) ; proposal . setSignature ( getSignature ( field . type ) ) ; proposal . setDeclarationPackageName ( field . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( field . declaringClass . qualifiedSourceName ( ) ) ; proposal . setPackageName ( field . type . qualifiedPackageName ( ) ) ; proposal . setTypeName ( field . type . qualifiedSourceName ( ) ) ; proposal . setName ( field . name ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( field . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } else { TypeBinding visibleType = invocationScope . getType ( field . type . sourceName ( ) ) ; boolean needImport = visibleType == null || ! visibleType . isValidBinding ( ) ; char [ ] completion = CharOperation . concat ( field . type . sourceName ( ) , field . name , '<CHAR_LIT:.>' ) ; if ( ! needImport ) { if ( ! this . requestor . isIgnored ( CompletionProposal . FIELD_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . FIELD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( field . declaringClass ) ) ; proposal . setSignature ( getSignature ( field . type ) ) ; proposal . setDeclarationPackageName ( field . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( field . declaringClass . qualifiedSourceName ( ) ) ; proposal . setPackageName ( field . type . qualifiedPackageName ( ) ) ; proposal . setTypeName ( field . type . qualifiedSourceName ( ) ) ; proposal . setName ( field . name ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( field . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } else { if ( ! this . isIgnored ( CompletionProposal . FIELD_REF , CompletionProposal . TYPE_IMPORT ) ) { CompilationUnitDeclaration cu = this . unitScope . referenceContext ; int importStart = cu . types [ <NUM_LIT:0> ] . declarationSourceStart ; int importEnd = importStart ; ReferenceBinding fieldType = ( ReferenceBinding ) field . type ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . FIELD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( field . declaringClass ) ) ; proposal . setSignature ( getSignature ( field . type ) ) ; proposal . setDeclarationPackageName ( field . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( field . declaringClass . qualifiedSourceName ( ) ) ; proposal . setPackageName ( field . type . qualifiedPackageName ( ) ) ; proposal . setTypeName ( field . type . qualifiedSourceName ( ) ) ; proposal . setName ( field . name ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( field . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; char [ ] typeImportCompletion = createImportCharArray ( CharOperation . concatWith ( fieldType . compoundName , '<CHAR_LIT:.>' ) , false , false ) ; InternalCompletionProposal typeImportProposal = createProposal ( CompletionProposal . TYPE_IMPORT , this . actualCompletionPosition ) ; typeImportProposal . nameLookup = this . nameEnvironment . nameLookup ; typeImportProposal . completionEngine = this ; char [ ] packageName = fieldType . qualifiedPackageName ( ) ; typeImportProposal . setDeclarationSignature ( packageName ) ; typeImportProposal . setSignature ( getSignature ( fieldType ) ) ; typeImportProposal . setPackageName ( packageName ) ; typeImportProposal . setTypeName ( fieldType . qualifiedSourceName ( ) ) ; typeImportProposal . setCompletion ( typeImportCompletion ) ; typeImportProposal . setFlags ( fieldType . modifiers ) ; typeImportProposal . setAdditionalFlags ( CompletionFlags . Default ) ; typeImportProposal . setReplaceRange ( importStart - this . offset , importEnd - this . offset ) ; typeImportProposal . setTokenRange ( importStart - this . offset , importEnd - this . offset ) ; typeImportProposal . setRelevance ( relevance ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { typeImportProposal } ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } } } private void findEnumConstantsFromExpectedTypes ( char [ ] token , Scope invocationScope , ObjectVector fieldsFound ) { int length = this . expectedTypesPtr + <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( this . expectedTypes [ i ] . isEnum ( ) ) { findEnumConstants ( token , ( ReferenceBinding ) this . expectedTypes [ i ] , invocationScope , fieldsFound , CharOperation . NO_CHAR_CHAR , <NUM_LIT:0> , true ) ; } } } private void findEnumConstantsFromSwithStatement ( char [ ] enumConstantName , SwitchStatement switchStatement ) { TypeBinding expressionType = switchStatement . expression . resolvedType ; if ( expressionType != null && expressionType . isEnum ( ) ) { ReferenceBinding enumType = ( ReferenceBinding ) expressionType ; CaseStatement [ ] cases = switchStatement . cases ; char [ ] [ ] alreadyUsedConstants = new char [ switchStatement . caseCount ] [ ] ; int alreadyUsedConstantCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < switchStatement . caseCount ; i ++ ) { Expression caseExpression = cases [ i ] . constantExpression ; if ( ( caseExpression instanceof SingleNameReference ) && ( caseExpression . resolvedType != null && caseExpression . resolvedType . isEnum ( ) ) ) { alreadyUsedConstants [ alreadyUsedConstantCount ++ ] = ( ( SingleNameReference ) cases [ i ] . constantExpression ) . token ; } } findEnumConstants ( enumConstantName , enumType , null , new ObjectVector ( ) , alreadyUsedConstants , alreadyUsedConstantCount , false ) ; } } private void findExceptionFromTryStatement ( char [ ] typeName , ReferenceBinding exceptionType , ReferenceBinding receiverType , SourceTypeBinding invocationType , BlockScope scope , ObjectVector typesFound , boolean searchSuperClasses ) { if ( searchSuperClasses ) { ReferenceBinding javaLangThrowable = scope . getJavaLangThrowable ( ) ; if ( exceptionType != javaLangThrowable ) { ReferenceBinding superClass = exceptionType . superclass ( ) ; while ( superClass != null && superClass != javaLangThrowable ) { findExceptionFromTryStatement ( typeName , superClass , receiverType , invocationType , scope , typesFound , false ) ; superClass = superClass . superclass ( ) ; } } } if ( typeName . length > exceptionType . sourceName . length ) return ; if ( ! CharOperation . prefixEquals ( typeName , exceptionType . sourceName , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( typeName , exceptionType . sourceName ) ) ) return ; if ( this . options . checkDeprecation && exceptionType . isViewedAsDeprecated ( ) && ! scope . isDefinedInSameUnit ( exceptionType ) ) return ; if ( this . options . checkVisibility ) { if ( invocationType != null ) { if ( receiverType != null ) { if ( ! exceptionType . canBeSeenBy ( receiverType , invocationType ) ) return ; } else { if ( ! exceptionType . canBeSeenBy ( exceptionType , invocationType ) ) return ; } } else if ( ! exceptionType . canBeSeenBy ( this . unitScope . fPackage ) ) { return ; } } if ( isForbidden ( exceptionType ) ) return ; for ( int j = typesFound . size ; -- j >= <NUM_LIT:0> ; ) { ReferenceBinding otherType = ( ReferenceBinding ) typesFound . elementAt ( j ) ; if ( exceptionType == otherType ) return ; if ( CharOperation . equals ( exceptionType . sourceName , otherType . sourceName , true ) ) { if ( exceptionType . enclosingType ( ) . isSuperclassOf ( otherType . enclosingType ( ) ) ) return ; if ( otherType . enclosingType ( ) . isInterface ( ) ) if ( exceptionType . enclosingType ( ) . implementsInterface ( otherType . enclosingType ( ) , true ) ) return ; if ( exceptionType . enclosingType ( ) . isInterface ( ) ) if ( otherType . enclosingType ( ) . implementsInterface ( exceptionType . enclosingType ( ) , true ) ) return ; } } typesFound . add ( exceptionType ) ; char [ ] completionName = exceptionType . sourceName ( ) ; boolean isQualified = false ; if ( ! this . insideQualifiedReference ) { isQualified = true ; char [ ] memberPackageName = exceptionType . qualifiedPackageName ( ) ; char [ ] memberTypeName = exceptionType . sourceName ( ) ; char [ ] memberEnclosingTypeNames = null ; ReferenceBinding enclosingType = exceptionType . enclosingType ( ) ; if ( enclosingType != null ) { memberEnclosingTypeNames = exceptionType . enclosingType ( ) . qualifiedSourceName ( ) ; } Scope currentScope = scope ; done : while ( currentScope != null ) { switch ( currentScope . kind ) { case Scope . METHOD_SCOPE : case Scope . BLOCK_SCOPE : BlockScope blockScope = ( BlockScope ) currentScope ; for ( int j = <NUM_LIT:0> , length = blockScope . subscopeCount ; j < length ; j ++ ) { if ( blockScope . subscopes [ j ] instanceof ClassScope ) { SourceTypeBinding localType = ( ( ClassScope ) blockScope . subscopes [ j ] ) . referenceContext . binding ; if ( localType == exceptionType ) { isQualified = false ; break done ; } } } break ; case Scope . CLASS_SCOPE : SourceTypeBinding type = ( ( ClassScope ) currentScope ) . referenceContext . binding ; ReferenceBinding [ ] memberTypes = type . memberTypes ( ) ; if ( memberTypes != null ) { for ( int j = <NUM_LIT:0> ; j < memberTypes . length ; j ++ ) { if ( memberTypes [ j ] == exceptionType ) { isQualified = false ; break done ; } } } break ; case Scope . COMPILATION_UNIT_SCOPE : SourceTypeBinding [ ] types = ( ( CompilationUnitScope ) currentScope ) . topLevelTypes ; if ( types != null ) { for ( int j = <NUM_LIT:0> ; j < types . length ; j ++ ) { if ( types [ j ] == exceptionType ) { isQualified = false ; break done ; } } } break done ; } currentScope = currentScope . parent ; } if ( isQualified && mustQualifyType ( memberPackageName , memberTypeName , memberEnclosingTypeNames , exceptionType . modifiers ) ) { if ( memberPackageName == null || memberPackageName . length == <NUM_LIT:0> ) if ( this . unitScope != null && this . unitScope . fPackage . compoundName != CharOperation . NO_CHAR_CHAR ) return ; } else { isQualified = false ; } if ( isQualified ) { completionName = CharOperation . concat ( memberPackageName , CharOperation . concat ( memberEnclosingTypeNames , memberTypeName , '<CHAR_LIT:.>' ) , '<CHAR_LIT:.>' ) ; } } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( exceptionType ) ; relevance += computeRelevanceForCaseMatching ( typeName , exceptionType . sourceName ) ; relevance += computeRelevanceForExpectingType ( exceptionType ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; if ( ! this . insideQualifiedReference ) { relevance += computeRelevanceForQualification ( isQualified ) ; } relevance += computeRelevanceForClass ( ) ; relevance += computeRelevanceForException ( ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { createTypeProposal ( exceptionType , exceptionType . qualifiedSourceName ( ) , IAccessRule . K_ACCESSIBLE , completionName , relevance , null , null , null , false ) ; } } private void findExceptionFromTryStatement ( char [ ] typeName , ReferenceBinding receiverType , SourceTypeBinding invocationType , BlockScope scope , ObjectVector typesFound ) { for ( int i = <NUM_LIT:0> ; i <= this . expectedTypesPtr ; i ++ ) { ReferenceBinding exceptionType = ( ReferenceBinding ) this . expectedTypes [ i ] ; findExceptionFromTryStatement ( typeName , exceptionType , receiverType , invocationType , scope , typesFound , true ) ; } } private void findExplicitConstructors ( char [ ] name , ReferenceBinding currentType , MethodScope scope , InvocationSite invocationSite ) { ConstructorDeclaration constructorDeclaration = ( ConstructorDeclaration ) scope . referenceContext ; MethodBinding enclosingConstructor = constructorDeclaration . binding ; MethodBinding [ ] methods = currentType . availableMethods ( ) ; if ( methods != null ) { next : for ( int f = methods . length ; -- f >= <NUM_LIT:0> ; ) { MethodBinding constructor = methods [ f ] ; if ( constructor != enclosingConstructor && constructor . isConstructor ( ) ) { if ( constructor . isSynthetic ( ) ) continue next ; if ( this . options . checkDeprecation && constructor . isViewedAsDeprecated ( ) && ! scope . isDefinedInSameUnit ( constructor . declaringClass ) ) continue next ; if ( this . options . checkVisibility && ! constructor . canBeSeenBy ( invocationSite , scope ) ) continue next ; TypeBinding [ ] parameters = constructor . parameters ; int paramLength = parameters . length ; char [ ] [ ] parameterPackageNames = new char [ paramLength ] [ ] ; char [ ] [ ] parameterTypeNames = new char [ paramLength ] [ ] ; for ( int i = <NUM_LIT:0> ; i < paramLength ; i ++ ) { TypeBinding type = parameters [ i ] ; parameterPackageNames [ i ] = type . qualifiedPackageName ( ) ; parameterTypeNames [ i ] = type . qualifiedSourceName ( ) ; } char [ ] [ ] parameterNames = findMethodParameterNames ( constructor , parameterTypeNames ) ; char [ ] completion = CharOperation . NO_CHAR ; if ( this . source != null && this . source . length > this . endPosition && this . source [ this . endPosition ] == '<CHAR_LIT:(>' ) completion = name ; else completion = CharOperation . concat ( name , new char [ ] { '<CHAR_LIT:(>' , '<CHAR_LIT:)>' } ) ; int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( this . completionToken , name ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . METHOD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( currentType ) ) ; proposal . setSignature ( getSignature ( constructor ) ) ; MethodBinding original = constructor . original ( ) ; if ( original != constructor ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setDeclarationPackageName ( currentType . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( currentType . qualifiedSourceName ( ) ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; proposal . setName ( name ) ; proposal . setIsContructor ( true ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( constructor . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } } } private void findFields ( char [ ] fieldName , FieldBinding [ ] fields , Scope scope , ObjectVector fieldsFound , ObjectVector localsFound , boolean onlyStaticFields , ReferenceBinding receiverType , InvocationSite invocationSite , Scope invocationScope , boolean implicitCall , boolean canBePrefixed , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems , char [ ] castedReceiver , int receiverStart , int receiverEnd ) { ObjectVector newFieldsFound = new ObjectVector ( ) ; int fieldBeingCompletedId = - <NUM_LIT:1> ; boolean isFieldBeingCompletedStatic = false ; for ( int f = fields . length ; -- f >= <NUM_LIT:0> ; ) { FieldBinding field = fields [ f ] ; FieldDeclaration fieldDeclaration = field . sourceField ( ) ; ASTNode astNode = this . parser . assistNode ; if ( fieldDeclaration != null && fieldDeclaration . initialization != null && astNode != null ) { if ( fieldDeclaration . initialization . sourceEnd > <NUM_LIT:0> ) { if ( fieldDeclaration . initialization . sourceStart <= astNode . sourceStart && astNode . sourceEnd <= fieldDeclaration . initialization . sourceEnd ) { fieldBeingCompletedId = field . id ; isFieldBeingCompletedStatic = field . isStatic ( ) ; break ; } } else { CompletionNodeDetector detector = new CompletionNodeDetector ( astNode , fieldDeclaration . initialization ) ; if ( detector . containsCompletionNode ( ) ) { fieldBeingCompletedId = field . id ; isFieldBeingCompletedStatic = field . isStatic ( ) ; break ; } } } } int fieldLength = fieldName . length ; next : for ( int f = fields . length ; -- f >= <NUM_LIT:0> ; ) { FieldBinding field = fields [ f ] ; if ( fieldBeingCompletedId >= <NUM_LIT:0> && field . id >= fieldBeingCompletedId ) { if ( ! field . isStatic ( ) ) { continue next ; } else if ( isFieldBeingCompletedStatic ) { continue next ; } } if ( field . isSynthetic ( ) ) continue next ; if ( onlyStaticFields && ! field . isStatic ( ) ) continue next ; if ( fieldLength > field . name . length ) continue next ; if ( ! CharOperation . prefixEquals ( fieldName , field . name , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( fieldName , field . name ) ) ) continue next ; if ( this . options . checkDeprecation && field . isViewedAsDeprecated ( ) && ! scope . isDefinedInSameUnit ( field . declaringClass ) ) continue next ; if ( this . options . checkVisibility && ! field . canBeSeenBy ( receiverType , invocationSite , scope ) ) continue next ; if ( this . assistNodeIsInsideCase ) { if ( field . isFinal ( ) && field . isStatic ( ) ) { if ( this . assistNodeIsString ) { if ( field . type == null || field . type . id != TypeIds . T_JavaLangString ) continue next ; } else if ( ! ( field . type instanceof BaseTypeBinding ) ) continue next ; } else { continue next ; } } boolean prefixRequired = false ; for ( int i = fieldsFound . size ; -- i >= <NUM_LIT:0> ; ) { Object [ ] other = ( Object [ ] ) fieldsFound . elementAt ( i ) ; FieldBinding otherField = ( FieldBinding ) other [ <NUM_LIT:0> ] ; ReferenceBinding otherReceiverType = ( ReferenceBinding ) other [ <NUM_LIT:1> ] ; if ( field == otherField && receiverType == otherReceiverType ) continue next ; if ( CharOperation . equals ( field . name , otherField . name , true ) ) { if ( field . declaringClass . isSuperclassOf ( otherField . declaringClass ) ) continue next ; if ( otherField . declaringClass . isInterface ( ) ) { if ( field . declaringClass == scope . getJavaLangObject ( ) ) continue next ; if ( field . declaringClass . implementsInterface ( otherField . declaringClass , true ) ) continue next ; } if ( field . declaringClass . isInterface ( ) ) if ( otherField . declaringClass . implementsInterface ( field . declaringClass , true ) ) continue next ; if ( canBePrefixed ) { prefixRequired = true ; } else { continue next ; } } } for ( int l = localsFound . size ; -- l >= <NUM_LIT:0> ; ) { LocalVariableBinding local = ( LocalVariableBinding ) localsFound . elementAt ( l ) ; if ( CharOperation . equals ( field . name , local . name , true ) ) { SourceTypeBinding declarationType = scope . enclosingSourceType ( ) ; if ( declarationType . isAnonymousType ( ) && declarationType != invocationScope . enclosingSourceType ( ) ) { continue next ; } if ( canBePrefixed ) { prefixRequired = true ; } else { continue next ; } break ; } } newFieldsFound . add ( new Object [ ] { field , receiverType } ) ; char [ ] completion = field . name ; if ( prefixRequired || this . options . forceImplicitQualification ) { char [ ] prefix = computePrefix ( scope . enclosingSourceType ( ) , invocationScope . enclosingSourceType ( ) , field . isStatic ( ) ) ; completion = CharOperation . concat ( prefix , completion , '<CHAR_LIT:.>' ) ; } if ( castedReceiver != null ) { completion = CharOperation . concat ( castedReceiver , completion ) ; } if ( this . assistNodeInJavadoc > <NUM_LIT:0> ) { if ( invocationSite instanceof CompletionOnJavadocFieldReference ) { CompletionOnJavadocFieldReference fieldRef = ( CompletionOnJavadocFieldReference ) invocationSite ; if ( fieldRef . receiver . isThis ( ) ) { if ( fieldRef . completeInText ( ) ) { completion = CharOperation . concat ( new char [ ] { '<CHAR_LIT>' } , field . name ) ; } } else if ( fieldRef . completeInText ( ) ) { if ( fieldRef . receiver instanceof JavadocSingleTypeReference ) { JavadocSingleTypeReference typeRef = ( JavadocSingleTypeReference ) fieldRef . receiver ; completion = CharOperation . concat ( typeRef . token , field . name , '<CHAR_LIT>' ) ; } else if ( fieldRef . receiver instanceof JavadocQualifiedTypeReference ) { JavadocQualifiedTypeReference typeRef = ( JavadocQualifiedTypeReference ) fieldRef . receiver ; completion = CharOperation . concat ( CharOperation . concatWith ( typeRef . tokens , '<CHAR_LIT:.>' ) , field . name , '<CHAR_LIT>' ) ; } } } } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( field ) ; relevance += computeRelevanceForCaseMatching ( fieldName , field . name ) ; relevance += computeRelevanceForExpectingType ( field . type ) ; relevance += computeRelevanceForEnumConstant ( field . type ) ; relevance += computeRelevanceForStatic ( onlyStaticFields , field . isStatic ( ) ) ; relevance += computeRelevanceForFinal ( this . assistNodeIsInsideCase , field . isFinal ( ) ) ; relevance += computeRelevanceForQualification ( prefixRequired ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; if ( onlyStaticFields && this . insideQualifiedReference ) { relevance += computeRelevanceForInheritance ( receiverType , field . declaringClass ) ; } if ( missingElements != null ) { relevance += computeRelevanceForMissingElements ( missingElementsHaveProblems ) ; } this . noProposal = false ; if ( castedReceiver == null ) { if ( ! this . isIgnored ( CompletionProposal . FIELD_REF , missingElements != null ) && ( this . assistNodeInJavadoc & CompletionOnJavadoc . ONLY_INLINE_TAG ) == <NUM_LIT:0> ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . FIELD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( field . declaringClass ) ) ; proposal . setSignature ( getSignature ( field . type ) ) ; proposal . setDeclarationPackageName ( field . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( field . declaringClass . qualifiedSourceName ( ) ) ; proposal . setPackageName ( field . type . qualifiedPackageName ( ) ) ; proposal . setTypeName ( field . type . qualifiedSourceName ( ) ) ; proposal . setName ( field . name ) ; if ( missingElements != null ) { CompletionProposal [ ] subProposals = new CompletionProposal [ missingElements . length ] ; for ( int i = <NUM_LIT:0> ; i < missingElements . length ; i ++ ) { subProposals [ i ] = createRequiredTypeProposal ( missingElements [ i ] , missingElementsStarts [ i ] , missingElementsEnds [ i ] , relevance ) ; } proposal . setRequiredProposals ( subProposals ) ; } proposal . setCompletion ( completion ) ; proposal . setFlags ( field . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } if ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> && ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_FIELD_REF ) ) { char [ ] javadocCompletion = inlineTagCompletion ( completion , JavadocTagConstants . TAG_LINK ) ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . JAVADOC_FIELD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( field . declaringClass ) ) ; proposal . setSignature ( getSignature ( field . type ) ) ; proposal . setDeclarationPackageName ( field . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( field . declaringClass . qualifiedSourceName ( ) ) ; proposal . setPackageName ( field . type . qualifiedPackageName ( ) ) ; proposal . setTypeName ( field . type . qualifiedSourceName ( ) ) ; proposal . setName ( field . name ) ; proposal . setCompletion ( javadocCompletion ) ; proposal . setFlags ( field . modifiers ) ; int start = ( this . assistNodeInJavadoc & CompletionOnJavadoc . REPLACE_TAG ) != <NUM_LIT:0> ? this . javadocTagPosition : this . startPosition ; proposal . setReplaceRange ( start - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance + R_INLINE_TAG ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } if ( field . isStatic ( ) && ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_VALUE_REF ) ) { javadocCompletion = inlineTagCompletion ( completion , JavadocTagConstants . TAG_VALUE ) ; InternalCompletionProposal valueProposal = createProposal ( CompletionProposal . JAVADOC_VALUE_REF , this . actualCompletionPosition ) ; valueProposal . setDeclarationSignature ( getSignature ( field . declaringClass ) ) ; valueProposal . setSignature ( getSignature ( field . type ) ) ; valueProposal . setDeclarationPackageName ( field . declaringClass . qualifiedPackageName ( ) ) ; valueProposal . setDeclarationTypeName ( field . declaringClass . qualifiedSourceName ( ) ) ; valueProposal . setPackageName ( field . type . qualifiedPackageName ( ) ) ; valueProposal . setTypeName ( field . type . qualifiedSourceName ( ) ) ; valueProposal . setName ( field . name ) ; valueProposal . setCompletion ( javadocCompletion ) ; valueProposal . setFlags ( field . modifiers ) ; valueProposal . setReplaceRange ( start - this . offset , this . endPosition - this . offset ) ; valueProposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; valueProposal . setRelevance ( relevance + R_VALUE_TAG ) ; this . requestor . accept ( valueProposal ) ; if ( DEBUG ) { this . printDebug ( valueProposal ) ; } } } } else { if ( ! this . isIgnored ( CompletionProposal . FIELD_REF_WITH_CASTED_RECEIVER , missingElements != null ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . FIELD_REF_WITH_CASTED_RECEIVER , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( field . declaringClass ) ) ; proposal . setSignature ( getSignature ( field . type ) ) ; proposal . setReceiverSignature ( getSignature ( receiverType ) ) ; proposal . setDeclarationPackageName ( field . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( field . declaringClass . qualifiedSourceName ( ) ) ; proposal . setPackageName ( field . type . qualifiedPackageName ( ) ) ; proposal . setTypeName ( field . type . qualifiedSourceName ( ) ) ; proposal . setName ( field . name ) ; if ( missingElements != null ) { CompletionProposal [ ] subProposals = new CompletionProposal [ missingElements . length ] ; for ( int i = <NUM_LIT:0> ; i < missingElements . length ; i ++ ) { subProposals [ i ] = createRequiredTypeProposal ( missingElements [ i ] , missingElementsStarts [ i ] , missingElementsEnds [ i ] , relevance ) ; } proposal . setRequiredProposals ( subProposals ) ; } proposal . setCompletion ( completion ) ; proposal . setFlags ( field . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setReceiverRange ( receiverStart - this . offset , receiverEnd - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } fieldsFound . addAll ( newFieldsFound ) ; } private void findFields ( char [ ] fieldName , ReferenceBinding receiverType , Scope scope , ObjectVector fieldsFound , ObjectVector localsFound , boolean onlyStaticFields , InvocationSite invocationSite , Scope invocationScope , boolean implicitCall , boolean canBePrefixed , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems , char [ ] castedReceiver , int receiverStart , int receiverEnd ) { boolean notInJavadoc = this . assistNodeInJavadoc == <NUM_LIT:0> ; if ( fieldName == null && notInJavadoc ) return ; ReferenceBinding currentType = receiverType ; ReferenceBinding [ ] interfacesToVisit = null ; int nextPosition = <NUM_LIT:0> ; do { ReferenceBinding [ ] itsInterfaces = currentType . superInterfaces ( ) ; if ( notInJavadoc && itsInterfaces != Binding . NO_SUPERINTERFACES ) { if ( interfacesToVisit == null ) { interfacesToVisit = itsInterfaces ; nextPosition = interfacesToVisit . length ; } else { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + <NUM_LIT:5> ] , <NUM_LIT:0> , nextPosition ) ; nextInterface : for ( int a = <NUM_LIT:0> ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = <NUM_LIT:0> ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } FieldBinding [ ] fields = currentType . availableFields ( ) ; if ( fields != null && fields . length > <NUM_LIT:0> ) { findFields ( fieldName , fields , scope , fieldsFound , localsFound , onlyStaticFields , receiverType , invocationSite , invocationScope , implicitCall , canBePrefixed , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems , castedReceiver , receiverStart , receiverEnd ) ; } currentType = currentType . superclass ( ) ; } while ( notInJavadoc && currentType != null ) ; if ( notInJavadoc && interfacesToVisit != null ) { for ( int i = <NUM_LIT:0> ; i < nextPosition ; i ++ ) { ReferenceBinding anInterface = interfacesToVisit [ i ] ; FieldBinding [ ] fields = anInterface . availableFields ( ) ; if ( fields != null ) { findFields ( fieldName , fields , scope , fieldsFound , localsFound , onlyStaticFields , receiverType , invocationSite , invocationScope , implicitCall , canBePrefixed , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems , castedReceiver , receiverStart , receiverEnd ) ; } ReferenceBinding [ ] itsInterfaces = anInterface . superInterfaces ( ) ; if ( itsInterfaces != Binding . NO_SUPERINTERFACES ) { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + <NUM_LIT:5> ] , <NUM_LIT:0> , nextPosition ) ; nextInterface : for ( int a = <NUM_LIT:0> ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = <NUM_LIT:0> ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } } } protected void findFieldsAndMethods ( char [ ] token , TypeBinding receiverType , Scope scope , ObjectVector fieldsFound , ObjectVector methodsFound , InvocationSite invocationSite , Scope invocationScope , boolean implicitCall , boolean superCall , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems , char [ ] castedReceiver , int receiverStart , int receiverEnd ) { if ( token == null ) return ; if ( receiverType . isBaseType ( ) ) return ; boolean proposeField = castedReceiver == null ? ! this . isIgnored ( CompletionProposal . FIELD_REF , missingElements != null ) : ! this . isIgnored ( CompletionProposal . FIELD_REF_WITH_CASTED_RECEIVER , missingElements != null ) ; boolean proposeMethod = castedReceiver == null ? ! this . isIgnored ( CompletionProposal . METHOD_REF , missingElements != null ) : ! this . isIgnored ( CompletionProposal . METHOD_REF_WITH_CASTED_RECEIVER , missingElements != null ) ; if ( receiverType . isArrayType ( ) ) { if ( proposeField && token . length <= lengthField . length && CharOperation . prefixEquals ( token , lengthField , false ) ) { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( token , lengthField ) ; relevance += computeRelevanceForExpectingType ( TypeBinding . INT ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; if ( missingElements != null ) { relevance += computeRelevanceForMissingElements ( missingElementsHaveProblems ) ; } this . noProposal = false ; if ( castedReceiver == null ) { if ( ! isIgnored ( CompletionProposal . FIELD_REF , missingElements != null ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . FIELD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( receiverType ) ) ; proposal . setSignature ( INT_SIGNATURE ) ; proposal . setTypeName ( INT ) ; proposal . setName ( lengthField ) ; if ( missingElements != null ) { CompletionProposal [ ] subProposals = new CompletionProposal [ missingElements . length ] ; for ( int i = <NUM_LIT:0> ; i < missingElements . length ; i ++ ) { subProposals [ i ] = createRequiredTypeProposal ( missingElements [ i ] , missingElementsStarts [ i ] , missingElementsEnds [ i ] , relevance ) ; } proposal . setRequiredProposals ( subProposals ) ; } proposal . setCompletion ( lengthField ) ; proposal . setFlags ( Flags . AccPublic ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } else { char [ ] completion = CharOperation . concat ( castedReceiver , lengthField ) ; if ( ! this . isIgnored ( CompletionProposal . FIELD_REF_WITH_CASTED_RECEIVER , missingElements != null ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . FIELD_REF_WITH_CASTED_RECEIVER , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( receiverType ) ) ; proposal . setSignature ( INT_SIGNATURE ) ; proposal . setReceiverSignature ( getSignature ( receiverType ) ) ; proposal . setTypeName ( INT ) ; proposal . setName ( lengthField ) ; if ( missingElements != null ) { CompletionProposal [ ] subProposals = new CompletionProposal [ missingElements . length ] ; for ( int i = <NUM_LIT:0> ; i < missingElements . length ; i ++ ) { subProposals [ i ] = createRequiredTypeProposal ( missingElements [ i ] , missingElementsStarts [ i ] , missingElementsEnds [ i ] , relevance ) ; } proposal . setRequiredProposals ( subProposals ) ; } proposal . setCompletion ( completion ) ; proposal . setFlags ( Flags . AccPublic ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setReceiverRange ( receiverStart - this . offset , receiverEnd - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } if ( proposeMethod && token . length <= cloneMethod . length && CharOperation . prefixEquals ( token , cloneMethod , false ) ) { ReferenceBinding objectRef = scope . getJavaLangObject ( ) ; int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( token , cloneMethod ) ; relevance += computeRelevanceForExpectingType ( objectRef ) ; relevance += computeRelevanceForStatic ( false , false ) ; relevance += computeRelevanceForQualification ( false ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; if ( missingElements != null ) { relevance += computeRelevanceForMissingElements ( missingElementsHaveProblems ) ; } char [ ] completion ; if ( this . source != null && this . source . length > this . endPosition && this . source [ this . endPosition ] == '<CHAR_LIT:(>' ) { completion = cloneMethod ; } else { completion = CharOperation . concat ( cloneMethod , new char [ ] { '<CHAR_LIT:(>' , '<CHAR_LIT:)>' } ) ; } if ( castedReceiver != null ) { completion = CharOperation . concat ( castedReceiver , completion ) ; } this . noProposal = false ; if ( castedReceiver == null ) { if ( ! this . isIgnored ( CompletionProposal . METHOD_REF , missingElements != null ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . METHOD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( receiverType ) ) ; proposal . setSignature ( this . compilerOptions . sourceLevel > ClassFileConstants . JDK1_4 && receiverType . isArrayType ( ) ? createMethodSignature ( CharOperation . NO_CHAR_CHAR , CharOperation . NO_CHAR_CHAR , getSignature ( receiverType ) ) : createMethodSignature ( CharOperation . NO_CHAR_CHAR , CharOperation . NO_CHAR_CHAR , CharOperation . concatWith ( JAVA_LANG , '<CHAR_LIT:.>' ) , OBJECT ) ) ; proposal . setPackageName ( CharOperation . concatWith ( JAVA_LANG , '<CHAR_LIT:.>' ) ) ; proposal . setTypeName ( OBJECT ) ; proposal . setName ( cloneMethod ) ; if ( missingElements != null ) { CompletionProposal [ ] subProposals = new CompletionProposal [ missingElements . length ] ; for ( int i = <NUM_LIT:0> ; i < missingElements . length ; i ++ ) { subProposals [ i ] = createRequiredTypeProposal ( missingElements [ i ] , missingElementsStarts [ i ] , missingElementsEnds [ i ] , relevance ) ; } proposal . setRequiredProposals ( subProposals ) ; } proposal . setCompletion ( completion ) ; proposal . setFlags ( Flags . AccPublic ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } methodsFound . add ( new Object [ ] { objectRef . getMethods ( cloneMethod ) [ <NUM_LIT:0> ] , objectRef } ) ; } else { if ( ! this . isIgnored ( CompletionProposal . METHOD_REF_WITH_CASTED_RECEIVER , missingElements != null ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . METHOD_REF_WITH_CASTED_RECEIVER , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( receiverType ) ) ; proposal . setSignature ( this . compilerOptions . sourceLevel > ClassFileConstants . JDK1_4 && receiverType . isArrayType ( ) ? createMethodSignature ( CharOperation . NO_CHAR_CHAR , CharOperation . NO_CHAR_CHAR , getSignature ( receiverType ) ) : createMethodSignature ( CharOperation . NO_CHAR_CHAR , CharOperation . NO_CHAR_CHAR , CharOperation . concatWith ( JAVA_LANG , '<CHAR_LIT:.>' ) , OBJECT ) ) ; proposal . setReceiverSignature ( getSignature ( receiverType ) ) ; proposal . setPackageName ( CharOperation . concatWith ( JAVA_LANG , '<CHAR_LIT:.>' ) ) ; proposal . setTypeName ( OBJECT ) ; proposal . setName ( cloneMethod ) ; if ( missingElements != null ) { CompletionProposal [ ] subProposals = new CompletionProposal [ missingElements . length ] ; for ( int i = <NUM_LIT:0> ; i < missingElements . length ; i ++ ) { subProposals [ i ] = createRequiredTypeProposal ( missingElements [ i ] , missingElementsStarts [ i ] , missingElementsEnds [ i ] , relevance ) ; } proposal . setRequiredProposals ( subProposals ) ; } proposal . setCompletion ( completion ) ; proposal . setFlags ( Flags . AccPublic ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setReceiverRange ( receiverStart - this . offset , receiverEnd - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } receiverType = scope . getJavaLangObject ( ) ; } checkCancel ( ) ; if ( proposeField ) { findFields ( token , ( ReferenceBinding ) receiverType , scope , fieldsFound , new ObjectVector ( ) , false , invocationSite , invocationScope , implicitCall , false , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems , castedReceiver , receiverStart , receiverEnd ) ; } if ( proposeMethod ) { findMethods ( token , null , null , ( ReferenceBinding ) receiverType , scope , methodsFound , false , false , invocationSite , invocationScope , implicitCall , superCall , false , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems , castedReceiver , receiverStart , receiverEnd ) ; } } protected void findFieldsAndMethodsFromAnotherReceiver ( char [ ] token , TypeReference receiverType , Scope scope , ObjectVector fieldsFound , ObjectVector methodsFound , InvocationSite invocationSite , Scope invocationScope , boolean implicitCall , boolean superCall , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems , char [ ] [ ] receiverName , int receiverStart , int receiverEnd ) { if ( receiverType . resolvedType == null ) return ; TypeBinding receiverTypeBinding = receiverType . resolvedType ; char [ ] castedReceiver = null ; char [ ] castedTypeChars = CharOperation . concatWith ( receiverType . getTypeName ( ) , '<CHAR_LIT:.>' ) ; if ( this . source != null ) { int memberRefStart = this . startPosition ; char [ ] receiverChars = CharOperation . subarray ( this . source , receiverStart , receiverEnd ) ; char [ ] dotChars = CharOperation . subarray ( this . source , receiverEnd , memberRefStart ) ; castedReceiver = CharOperation . concat ( CharOperation . concat ( '<CHAR_LIT:(>' , CharOperation . concat ( CharOperation . concat ( '<CHAR_LIT:(>' , castedTypeChars , '<CHAR_LIT:)>' ) , receiverChars ) , '<CHAR_LIT:)>' ) , dotChars ) ; } else { castedReceiver = CharOperation . concat ( CharOperation . concat ( '<CHAR_LIT:(>' , CharOperation . concat ( CharOperation . concat ( '<CHAR_LIT:(>' , castedTypeChars , '<CHAR_LIT:)>' ) , CharOperation . concatWith ( receiverName , '<CHAR_LIT:.>' ) ) , '<CHAR_LIT:)>' ) , DOT ) ; } if ( castedReceiver == null ) return ; int oldStartPosition = this . startPosition ; this . startPosition = receiverStart ; findFieldsAndMethods ( token , receiverTypeBinding , scope , fieldsFound , methodsFound , invocationSite , invocationScope , implicitCall , superCall , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems , castedReceiver , receiverStart , receiverEnd ) ; this . startPosition = oldStartPosition ; } private void findFieldsAndMethodsFromCastedReceiver ( ASTNode enclosingNode , Binding qualifiedBinding , Scope scope , ObjectVector fieldsFound , ObjectVector methodsFound , InvocationSite invocationSite , Scope invocationScope , Expression receiver ) { if ( enclosingNode == null || ! ( enclosingNode instanceof IfStatement ) ) return ; IfStatement ifStatement = ( IfStatement ) enclosingNode ; while ( true ) { if ( ! ( ifStatement . condition instanceof InstanceOfExpression ) ) return ; InstanceOfExpression instanceOfExpression = ( InstanceOfExpression ) ifStatement . condition ; TypeReference instanceOfType = instanceOfExpression . type ; if ( instanceOfType . resolvedType == null ) return ; boolean findFromAnotherReceiver = false ; char [ ] [ ] receiverName = null ; int receiverStart = - <NUM_LIT:1> ; int receiverEnd = - <NUM_LIT:1> ; if ( receiver instanceof QualifiedNameReference ) { QualifiedNameReference qualifiedNameReference = ( QualifiedNameReference ) receiver ; receiverName = qualifiedNameReference . tokens ; if ( receiverName . length != <NUM_LIT:1> ) return ; receiverStart = ( int ) ( qualifiedNameReference . sourcePositions [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; receiverEnd = ( int ) qualifiedNameReference . sourcePositions [ qualifiedNameReference . tokens . length - <NUM_LIT:1> ] + <NUM_LIT:1> ; if ( instanceOfExpression . expression instanceof SingleNameReference && ( ( SingleNameReference ) instanceOfExpression . expression ) . binding == qualifiedBinding && ( qualifiedBinding instanceof LocalVariableBinding || qualifiedBinding instanceof FieldBinding ) ) { findFromAnotherReceiver = true ; } if ( instanceOfExpression . expression instanceof FieldReference ) { FieldReference fieldReference = ( FieldReference ) instanceOfExpression . expression ; if ( fieldReference . receiver instanceof ThisReference && qualifiedBinding instanceof FieldBinding && fieldReference . binding == qualifiedBinding ) { findFromAnotherReceiver = true ; } } } else if ( receiver instanceof FieldReference ) { FieldReference fieldReference1 = ( FieldReference ) receiver ; receiverStart = fieldReference1 . sourceStart ; receiverEnd = fieldReference1 . sourceEnd + <NUM_LIT:1> ; if ( fieldReference1 . receiver instanceof ThisReference ) { receiverName = new char [ ] [ ] { THIS , fieldReference1 . token } ; if ( instanceOfExpression . expression instanceof SingleNameReference && ( ( SingleNameReference ) instanceOfExpression . expression ) . binding == fieldReference1 . binding ) { findFromAnotherReceiver = true ; } if ( instanceOfExpression . expression instanceof FieldReference ) { FieldReference fieldReference2 = ( FieldReference ) instanceOfExpression . expression ; if ( fieldReference2 . receiver instanceof ThisReference && fieldReference2 . binding == fieldReference1 . binding ) { findFromAnotherReceiver = true ; } } } } if ( findFromAnotherReceiver ) { TypeBinding receiverTypeBinding = instanceOfType . resolvedType ; char [ ] castedReceiver = null ; char [ ] castedTypeChars = CharOperation . concatWith ( instanceOfType . getTypeName ( ) , '<CHAR_LIT:.>' ) ; if ( this . source != null ) { int memberRefStart = this . startPosition ; char [ ] receiverChars = CharOperation . subarray ( this . source , receiverStart , receiverEnd ) ; char [ ] dotChars = CharOperation . subarray ( this . source , receiverEnd , memberRefStart ) ; castedReceiver = CharOperation . concat ( CharOperation . concat ( '<CHAR_LIT:(>' , CharOperation . concat ( CharOperation . concat ( '<CHAR_LIT:(>' , castedTypeChars , '<CHAR_LIT:)>' ) , receiverChars ) , '<CHAR_LIT:)>' ) , dotChars ) ; } else { castedReceiver = CharOperation . concat ( CharOperation . concat ( '<CHAR_LIT:(>' , CharOperation . concat ( CharOperation . concat ( '<CHAR_LIT:(>' , castedTypeChars , '<CHAR_LIT:)>' ) , CharOperation . concatWith ( receiverName , '<CHAR_LIT:.>' ) ) , '<CHAR_LIT:)>' ) , DOT ) ; } if ( castedReceiver == null ) return ; int oldStartPosition = this . startPosition ; this . startPosition = receiverStart ; findFieldsAndMethods ( this . completionToken , receiverTypeBinding , scope , fieldsFound , methodsFound , invocationSite , invocationScope , false , false , null , null , null , false , castedReceiver , receiverStart , receiverEnd ) ; this . startPosition = oldStartPosition ; } if ( ifStatement . thenStatement instanceof IfStatement ) { ifStatement = ( IfStatement ) ifStatement . thenStatement ; } else { break ; } } } private void findFieldsAndMethodsFromFavorites ( char [ ] token , Scope scope , InvocationSite invocationSite , Scope invocationScope , ObjectVector localsFound , ObjectVector fieldsFound , ObjectVector methodsFound ) { ObjectVector methodsFoundFromFavorites = new ObjectVector ( ) ; ImportBinding [ ] favoriteBindings = getFavoriteReferenceBindings ( invocationScope ) ; if ( favoriteBindings != null && favoriteBindings . length > <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < favoriteBindings . length ; i ++ ) { ImportBinding favoriteBinding = favoriteBindings [ i ] ; switch ( favoriteBinding . resolvedImport . kind ( ) ) { case Binding . FIELD : FieldBinding fieldBinding = ( FieldBinding ) favoriteBinding . resolvedImport ; findFieldsFromFavorites ( token , new FieldBinding [ ] { fieldBinding } , scope , fieldsFound , localsFound , fieldBinding . declaringClass , invocationSite , invocationScope ) ; break ; case Binding . METHOD : MethodBinding methodBinding = ( MethodBinding ) favoriteBinding . resolvedImport ; MethodBinding [ ] methods = methodBinding . declaringClass . availableMethods ( ) ; long range ; if ( ( range = ReferenceBinding . binarySearch ( methodBinding . selector , methods ) ) >= <NUM_LIT:0> ) { int start = ( int ) range , end = ( int ) ( range > > <NUM_LIT:32> ) ; int length = end - start + <NUM_LIT:1> ; System . arraycopy ( methods , start , methods = new MethodBinding [ length ] , <NUM_LIT:0> , length ) ; } else { methods = Binding . NO_METHODS ; } findLocalMethodsFromFavorites ( token , methods , scope , methodsFound , methodsFoundFromFavorites , methodBinding . declaringClass , invocationSite , invocationScope ) ; break ; case Binding . TYPE : ReferenceBinding referenceBinding = ( ReferenceBinding ) favoriteBinding . resolvedImport ; if ( favoriteBinding . onDemand ) { findFieldsFromFavorites ( token , referenceBinding . availableFields ( ) , scope , fieldsFound , localsFound , referenceBinding , invocationSite , invocationScope ) ; findLocalMethodsFromFavorites ( token , referenceBinding . availableMethods ( ) , scope , methodsFound , methodsFoundFromFavorites , referenceBinding , invocationSite , invocationScope ) ; } break ; } } } methodsFound . addAll ( methodsFoundFromFavorites ) ; } private boolean findFieldsAndMethodsFromMissingFieldType ( char [ ] token , Scope scope , InvocationSite invocationSite , boolean insideTypeAnnotation ) { boolean foundSomeFields = false ; Scope currentScope = scope ; done : while ( true ) { switch ( currentScope . kind ) { case Scope . CLASS_SCOPE : ClassScope classScope = ( ClassScope ) currentScope ; if ( ! insideTypeAnnotation ) { FieldDeclaration [ ] fields = classScope . referenceContext . fields ; int fieldsCount = fields == null ? <NUM_LIT:0> : fields . length ; for ( int i = <NUM_LIT:0> ; i < fieldsCount ; i ++ ) { FieldDeclaration fieldDeclaration = fields [ i ] ; if ( CharOperation . equals ( fieldDeclaration . name , token ) ) { FieldBinding fieldBinding = fieldDeclaration . binding ; if ( fieldBinding == null || fieldBinding . type == null || ( fieldBinding . type . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ) { foundSomeFields = true ; findFieldsAndMethodsFromMissingType ( fieldDeclaration . type , currentScope , invocationSite , scope ) ; } break done ; } } } insideTypeAnnotation = false ; break ; case Scope . COMPILATION_UNIT_SCOPE : break done ; } currentScope = currentScope . parent ; } return foundSomeFields ; } private void findFieldsAndMethodsFromMissingReturnType ( char [ ] token , TypeBinding [ ] arguments , Scope scope , InvocationSite invocationSite , boolean insideTypeAnnotation ) { Scope currentScope = scope ; done : while ( true ) { switch ( currentScope . kind ) { case Scope . CLASS_SCOPE : ClassScope classScope = ( ClassScope ) currentScope ; if ( ! insideTypeAnnotation ) { AbstractMethodDeclaration [ ] methods = classScope . referenceContext . methods ; int methodsCount = methods == null ? <NUM_LIT:0> : methods . length ; for ( int i = <NUM_LIT:0> ; i < methodsCount ; i ++ ) { AbstractMethodDeclaration methodDeclaration = methods [ i ] ; if ( methodDeclaration instanceof MethodDeclaration && CharOperation . equals ( methodDeclaration . selector , token ) ) { MethodDeclaration method = ( MethodDeclaration ) methodDeclaration ; MethodBinding methodBinding = method . binding ; if ( methodBinding == null || methodBinding . returnType == null || ( methodBinding . returnType . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ) { Argument [ ] parameters = method . arguments ; int parametersLength = parameters == null ? <NUM_LIT:0> : parameters . length ; int argumentsLength = arguments == null ? <NUM_LIT:0> : arguments . length ; if ( parametersLength == <NUM_LIT:0> ) { if ( argumentsLength == <NUM_LIT:0> ) { findFieldsAndMethodsFromMissingType ( method . returnType , currentScope , invocationSite , scope ) ; break done ; } } else { TypeBinding [ ] parametersBindings ; if ( methodBinding == null ) { parametersBindings = new TypeBinding [ parametersLength ] ; for ( int j = <NUM_LIT:0> ; j < parametersLength ; j ++ ) { TypeBinding parameterType = parameters [ j ] . type . resolvedType ; if ( ! parameterType . isValidBinding ( ) && parameterType . closestMatch ( ) != null ) { parameterType = parameterType . closestMatch ( ) ; } parametersBindings [ j ] = parameterType ; } } else { parametersBindings = methodBinding . parameters ; } if ( areParametersCompatibleWith ( parametersBindings , arguments , parameters [ parametersLength - <NUM_LIT:1> ] . isVarArgs ( ) ) ) { findFieldsAndMethodsFromMissingType ( method . returnType , currentScope , invocationSite , scope ) ; break done ; } } } } } } insideTypeAnnotation = false ; break ; case Scope . COMPILATION_UNIT_SCOPE : break done ; } currentScope = currentScope . parent ; } } private void findFieldsAndMethodsFromMissingType ( TypeReference typeRef , final Scope scope , final InvocationSite invocationSite , final Scope invocationScope ) { MissingTypesGuesser missingTypesConverter = new MissingTypesGuesser ( this ) ; MissingTypesGuesser . GuessedTypeRequestor substitutionRequestor = new MissingTypesGuesser . GuessedTypeRequestor ( ) { public void accept ( TypeBinding guessedType , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean hasProblems ) { findFieldsAndMethods ( CompletionEngine . this . completionToken , guessedType , scope , new ObjectVector ( ) , new ObjectVector ( ) , invocationSite , invocationScope , false , false , missingElements , missingElementsStarts , missingElementsEnds , hasProblems , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; } } ; missingTypesConverter . guess ( typeRef , scope , substitutionRequestor ) ; } private void findFieldsAndMethodsFromStaticImports ( char [ ] token , Scope scope , InvocationSite invocationSite , Scope invocationScope , boolean exactMatch , boolean insideAnnotationAttribute , ObjectVector localsFound , ObjectVector fieldsFound , ObjectVector methodsFound , boolean proposeField , boolean proposeMethod ) { ImportBinding [ ] importBindings = scope . compilationUnitScope ( ) . imports ; for ( int i = <NUM_LIT:0> ; i < importBindings . length ; i ++ ) { ImportBinding importBinding = importBindings [ i ] ; if ( importBinding . isValidBinding ( ) && importBinding . isStatic ( ) ) { Binding binding = importBinding . resolvedImport ; if ( binding != null && binding . isValidBinding ( ) ) { if ( importBinding . onDemand ) { if ( ( binding . kind ( ) & Binding . TYPE ) != <NUM_LIT:0> ) { if ( proposeField ) { findFields ( token , ( ReferenceBinding ) binding , scope , fieldsFound , localsFound , true , invocationSite , invocationScope , true , false , null , null , null , false , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; } if ( proposeMethod && ! insideAnnotationAttribute ) { findMethods ( token , null , null , ( ReferenceBinding ) binding , scope , methodsFound , true , exactMatch , invocationSite , invocationScope , true , false , false , null , null , null , false , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; } } } else { if ( ( binding . kind ( ) & Binding . FIELD ) != <NUM_LIT:0> ) { if ( proposeField ) { findFields ( token , new FieldBinding [ ] { ( FieldBinding ) binding } , scope , fieldsFound , localsFound , true , ( ( FieldBinding ) binding ) . declaringClass , invocationSite , invocationScope , true , false , null , null , null , false , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; } } else if ( ( binding . kind ( ) & Binding . METHOD ) != <NUM_LIT:0> ) { if ( proposeMethod && ! insideAnnotationAttribute ) { MethodBinding methodBinding = ( MethodBinding ) binding ; if ( ( exactMatch && CharOperation . equals ( token , methodBinding . selector ) ) || ! exactMatch && CharOperation . prefixEquals ( token , methodBinding . selector ) || ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( token , methodBinding . selector ) ) ) { findLocalMethodsFromStaticImports ( token , methodBinding . declaringClass . getMethods ( methodBinding . selector ) , scope , exactMatch , methodsFound , methodBinding . declaringClass , invocationSite ) ; } } } } } } } } private void findFieldsFromFavorites ( char [ ] fieldName , FieldBinding [ ] fields , Scope scope , ObjectVector fieldsFound , ObjectVector localsFound , ReferenceBinding receiverType , InvocationSite invocationSite , Scope invocationScope ) { char [ ] typeName = CharOperation . concatWith ( receiverType . compoundName , '<CHAR_LIT:.>' ) ; int fieldLength = fieldName . length ; next : for ( int f = fields . length ; -- f >= <NUM_LIT:0> ; ) { FieldBinding field = fields [ f ] ; if ( field . isSynthetic ( ) ) continue next ; if ( ! field . isStatic ( ) ) continue next ; if ( fieldLength > field . name . length ) continue next ; if ( ! CharOperation . prefixEquals ( fieldName , field . name , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( fieldName , field . name ) ) ) continue next ; if ( this . options . checkDeprecation && field . isViewedAsDeprecated ( ) && ! scope . isDefinedInSameUnit ( field . declaringClass ) ) continue next ; if ( this . options . checkVisibility && ! field . canBeSeenBy ( receiverType , invocationSite , scope ) ) continue next ; for ( int i = fieldsFound . size ; -- i >= <NUM_LIT:0> ; ) { Object [ ] other = ( Object [ ] ) fieldsFound . elementAt ( i ) ; FieldBinding otherField = ( FieldBinding ) other [ <NUM_LIT:0> ] ; if ( field == otherField ) continue next ; } fieldsFound . add ( new Object [ ] { field , receiverType } ) ; int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( field ) ; relevance += computeRelevanceForCaseMatching ( fieldName , field . name ) ; relevance += computeRelevanceForExpectingType ( field . type ) ; relevance += computeRelevanceForEnumConstant ( field . type ) ; relevance += computeRelevanceForStatic ( true , true ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; CompilationUnitDeclaration cu = this . unitScope . referenceContext ; int importStart = cu . types [ <NUM_LIT:0> ] . declarationSourceStart ; int importEnd = importStart ; this . noProposal = false ; if ( this . compilerOptions . complianceLevel < ClassFileConstants . JDK1_5 || ! this . options . suggestStaticImport ) { if ( ! this . isIgnored ( CompletionProposal . FIELD_REF , CompletionProposal . TYPE_IMPORT ) ) { char [ ] completion = CharOperation . concat ( receiverType . sourceName , field . name , '<CHAR_LIT:.>' ) ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . FIELD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( field . declaringClass ) ) ; proposal . setSignature ( getSignature ( field . type ) ) ; proposal . setDeclarationPackageName ( field . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( field . declaringClass . qualifiedSourceName ( ) ) ; proposal . setPackageName ( field . type . qualifiedPackageName ( ) ) ; proposal . setTypeName ( field . type . qualifiedSourceName ( ) ) ; proposal . setName ( field . name ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( field . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; char [ ] typeImportCompletion = createImportCharArray ( typeName , false , false ) ; InternalCompletionProposal typeImportProposal = createProposal ( CompletionProposal . TYPE_IMPORT , this . actualCompletionPosition ) ; typeImportProposal . nameLookup = this . nameEnvironment . nameLookup ; typeImportProposal . completionEngine = this ; char [ ] packageName = receiverType . qualifiedPackageName ( ) ; typeImportProposal . setDeclarationSignature ( packageName ) ; typeImportProposal . setSignature ( getSignature ( receiverType ) ) ; typeImportProposal . setPackageName ( packageName ) ; typeImportProposal . setTypeName ( receiverType . qualifiedSourceName ( ) ) ; typeImportProposal . setCompletion ( typeImportCompletion ) ; typeImportProposal . setFlags ( receiverType . modifiers ) ; typeImportProposal . setAdditionalFlags ( CompletionFlags . Default ) ; typeImportProposal . setReplaceRange ( importStart - this . offset , importEnd - this . offset ) ; typeImportProposal . setTokenRange ( importStart - this . offset , importEnd - this . offset ) ; typeImportProposal . setRelevance ( relevance ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { typeImportProposal } ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } else { if ( ! this . isIgnored ( CompletionProposal . FIELD_REF , CompletionProposal . FIELD_IMPORT ) ) { char [ ] completion = field . name ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . FIELD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( field . declaringClass ) ) ; proposal . setSignature ( getSignature ( field . type ) ) ; proposal . setDeclarationPackageName ( field . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( field . declaringClass . qualifiedSourceName ( ) ) ; proposal . setPackageName ( field . type . qualifiedPackageName ( ) ) ; proposal . setTypeName ( field . type . qualifiedSourceName ( ) ) ; proposal . setName ( field . name ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( field . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; char [ ] fieldImportCompletion = createImportCharArray ( CharOperation . concat ( typeName , field . name , '<CHAR_LIT:.>' ) , true , false ) ; InternalCompletionProposal fieldImportProposal = createProposal ( CompletionProposal . FIELD_IMPORT , this . actualCompletionPosition ) ; fieldImportProposal . setDeclarationSignature ( getSignature ( field . declaringClass ) ) ; fieldImportProposal . setSignature ( getSignature ( field . type ) ) ; fieldImportProposal . setDeclarationPackageName ( field . declaringClass . qualifiedPackageName ( ) ) ; fieldImportProposal . setDeclarationTypeName ( field . declaringClass . qualifiedSourceName ( ) ) ; fieldImportProposal . setPackageName ( field . type . qualifiedPackageName ( ) ) ; fieldImportProposal . setTypeName ( field . type . qualifiedSourceName ( ) ) ; fieldImportProposal . setName ( field . name ) ; fieldImportProposal . setCompletion ( fieldImportCompletion ) ; fieldImportProposal . setFlags ( field . modifiers ) ; fieldImportProposal . setAdditionalFlags ( CompletionFlags . StaticImport ) ; fieldImportProposal . setReplaceRange ( importStart - this . offset , importEnd - this . offset ) ; fieldImportProposal . setTokenRange ( importStart - this . offset , importEnd - this . offset ) ; fieldImportProposal . setRelevance ( relevance ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { fieldImportProposal } ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } } private void findImplicitMessageSends ( char [ ] token , TypeBinding [ ] argTypes , Scope scope , InvocationSite invocationSite , Scope invocationScope , ObjectVector methodsFound ) { if ( token == null ) return ; boolean staticsOnly = false ; done : while ( true ) { switch ( scope . kind ) { case Scope . METHOD_SCOPE : MethodScope methodScope = ( MethodScope ) scope ; staticsOnly |= methodScope . isStatic | methodScope . isConstructorCall ; break ; case Scope . CLASS_SCOPE : ClassScope classScope = ( ClassScope ) scope ; SourceTypeBinding enclosingType = classScope . referenceContext . binding ; findMethods ( token , null , argTypes , enclosingType , classScope , methodsFound , staticsOnly , true , invocationSite , invocationScope , true , false , true , null , null , null , false , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; staticsOnly |= enclosingType . isStatic ( ) ; break ; case Scope . COMPILATION_UNIT_SCOPE : break done ; } scope = scope . parent ; } } private void findImports ( CompletionOnImportReference importReference , boolean findMembers ) { char [ ] [ ] tokens = importReference . tokens ; char [ ] importName = CharOperation . concatWith ( tokens , '<CHAR_LIT:.>' ) ; if ( importName . length == <NUM_LIT:0> ) return ; char [ ] lastToken = tokens [ tokens . length - <NUM_LIT:1> ] ; if ( lastToken != null && lastToken . length == <NUM_LIT:0> ) importName = CharOperation . concat ( importName , new char [ ] { '<CHAR_LIT:.>' } ) ; this . resolvingImports = true ; this . resolvingStaticImports = importReference . isStatic ( ) ; this . completionToken = lastToken ; this . qualifiedCompletionToken = importName ; if ( ! this . requestor . isIgnored ( CompletionProposal . PACKAGE_REF ) ) { int oldStart = this . startPosition ; int oldEnd = this . endPosition ; setSourceRange ( importReference . sourceStart , importReference . declarationSourceEnd ) ; this . nameEnvironment . findPackages ( importName , this ) ; setSourceRange ( oldStart , oldEnd - <NUM_LIT:1> , false ) ; } if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { this . foundTypesCount = <NUM_LIT:0> ; this . nameEnvironment . findTypes ( importName , findMembers , this . options . camelCaseMatch , IJavaSearchConstants . TYPE , this , this . monitor ) ; acceptTypes ( null ) ; } } private void findImportsOfMemberTypes ( char [ ] typeName , ReferenceBinding ref , boolean onlyStatic ) { ReferenceBinding [ ] memberTypes = ref . memberTypes ( ) ; int typeLength = typeName . length ; next : for ( int m = memberTypes . length ; -- m >= <NUM_LIT:0> ; ) { ReferenceBinding memberType = memberTypes [ m ] ; if ( onlyStatic && ! memberType . isStatic ( ) ) continue next ; if ( typeLength > memberType . sourceName . length ) continue next ; if ( ! CharOperation . prefixEquals ( typeName , memberType . sourceName , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( typeName , memberType . sourceName ) ) ) continue next ; if ( this . options . checkDeprecation && memberType . isViewedAsDeprecated ( ) ) continue next ; if ( this . options . checkVisibility && ! memberType . canBeSeenBy ( this . unitScope . fPackage ) ) continue next ; char [ ] completionName = CharOperation . concat ( memberType . sourceName , SEMICOLON ) ; int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( typeName , memberType . sourceName ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; if ( memberType . isClass ( ) ) { relevance += computeRelevanceForClass ( ) ; } else if ( memberType . isEnum ( ) ) { relevance += computeRelevanceForEnum ( ) ; } else if ( memberType . isInterface ( ) ) { relevance += computeRelevanceForInterface ( ) ; } this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { createTypeProposal ( memberType , memberType . qualifiedSourceName ( ) , IAccessRule . K_ACCESSIBLE , completionName , relevance , null , null , null , false ) ; } } } private void findImportsOfStaticFields ( char [ ] fieldName , ReferenceBinding ref ) { FieldBinding [ ] fields = ref . availableFields ( ) ; int fieldLength = fieldName . length ; next : for ( int m = fields . length ; -- m >= <NUM_LIT:0> ; ) { FieldBinding field = fields [ m ] ; if ( fieldLength > field . name . length ) continue next ; if ( field . isSynthetic ( ) ) continue next ; if ( ! field . isStatic ( ) ) continue next ; if ( ! CharOperation . prefixEquals ( fieldName , field . name , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( fieldName , field . name ) ) ) continue next ; if ( this . options . checkDeprecation && field . isViewedAsDeprecated ( ) ) continue next ; if ( this . options . checkVisibility && ! field . canBeSeenBy ( this . unitScope . fPackage ) ) continue next ; char [ ] completionName = CharOperation . concat ( field . name , SEMICOLON ) ; int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( fieldName , field . name ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . FIELD_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . FIELD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( field . declaringClass ) ) ; proposal . setSignature ( getSignature ( field . type ) ) ; proposal . setDeclarationPackageName ( field . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( field . declaringClass . qualifiedSourceName ( ) ) ; proposal . setPackageName ( field . type . qualifiedPackageName ( ) ) ; proposal . setTypeName ( field . type . qualifiedSourceName ( ) ) ; proposal . setName ( field . name ) ; proposal . setCompletion ( completionName ) ; proposal . setFlags ( field . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } private void findImportsOfStaticMethods ( char [ ] methodName , ReferenceBinding ref ) { MethodBinding [ ] methods = ref . availableMethods ( ) ; int methodLength = methodName . length ; next : for ( int m = methods . length ; -- m >= <NUM_LIT:0> ; ) { MethodBinding method = methods [ m ] ; if ( method . isSynthetic ( ) ) continue next ; if ( method . isDefaultAbstract ( ) ) continue next ; if ( method . isConstructor ( ) ) continue next ; if ( ! method . isStatic ( ) ) continue next ; if ( this . options . checkDeprecation && method . isViewedAsDeprecated ( ) ) continue next ; if ( this . options . checkVisibility && ! method . canBeSeenBy ( this . unitScope . fPackage ) ) continue next ; if ( methodLength > method . selector . length ) continue next ; if ( ! CharOperation . prefixEquals ( methodName , method . selector , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( methodName , method . selector ) ) ) continue next ; int length = method . parameters . length ; char [ ] [ ] parameterPackageNames = new char [ length ] [ ] ; char [ ] [ ] parameterTypeNames = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { TypeBinding type = method . original ( ) . parameters [ i ] ; parameterPackageNames [ i ] = type . qualifiedPackageName ( ) ; parameterTypeNames [ i ] = type . qualifiedSourceName ( ) ; } char [ ] [ ] parameterNames = findMethodParameterNames ( method , parameterTypeNames ) ; char [ ] completionName = CharOperation . concat ( method . selector , SEMICOLON ) ; int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( methodName , method . selector ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_NAME_REFERENCE ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . METHOD_NAME_REFERENCE , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( method . declaringClass ) ) ; proposal . setSignature ( getSignature ( method ) ) ; proposal . setDeclarationPackageName ( method . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( method . declaringClass . qualifiedSourceName ( ) ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; proposal . setPackageName ( method . returnType . qualifiedPackageName ( ) ) ; proposal . setTypeName ( method . returnType . qualifiedSourceName ( ) ) ; proposal . setName ( method . selector ) ; proposal . setCompletion ( completionName ) ; proposal . setFlags ( method . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } private void findInterfacesMethodDeclarations ( char [ ] selector , ReferenceBinding receiverType , ReferenceBinding [ ] itsInterfaces , Scope scope , ObjectVector methodsFound , Binding [ ] missingElements , int [ ] missingElementssStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems ) { if ( selector == null ) return ; if ( itsInterfaces != Binding . NO_SUPERINTERFACES ) { ReferenceBinding [ ] interfacesToVisit = itsInterfaces ; int nextPosition = interfacesToVisit . length ; for ( int i = <NUM_LIT:0> ; i < nextPosition ; i ++ ) { ReferenceBinding currentType = interfacesToVisit [ i ] ; MethodBinding [ ] methods = currentType . availableMethods ( ) ; if ( methods != null ) { findLocalMethodDeclarations ( selector , methods , scope , methodsFound , false , receiverType ) ; } itsInterfaces = currentType . superInterfaces ( ) ; if ( itsInterfaces != null && itsInterfaces != Binding . NO_SUPERINTERFACES ) { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + <NUM_LIT:5> ] , <NUM_LIT:0> , nextPosition ) ; nextInterface : for ( int a = <NUM_LIT:0> ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = <NUM_LIT:0> ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } } } private void findInterfacesMethods ( char [ ] selector , TypeBinding [ ] typeArgTypes , TypeBinding [ ] argTypes , ReferenceBinding receiverType , ReferenceBinding [ ] itsInterfaces , Scope scope , ObjectVector methodsFound , boolean onlyStaticMethods , boolean exactMatch , InvocationSite invocationSite , Scope invocationScope , boolean implicitCall , boolean superCall , boolean canBePrefixed , Binding [ ] missingElements , int [ ] missingElementssStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems , char [ ] castedReceiver , int receiverStart , int receiverEnd ) { if ( selector == null ) return ; if ( itsInterfaces != Binding . NO_SUPERINTERFACES ) { ReferenceBinding [ ] interfacesToVisit = itsInterfaces ; int nextPosition = interfacesToVisit . length ; for ( int i = <NUM_LIT:0> ; i < nextPosition ; i ++ ) { ReferenceBinding currentType = interfacesToVisit [ i ] ; MethodBinding [ ] methods = currentType . availableMethods ( ) ; if ( methods != null ) { findLocalMethods ( selector , typeArgTypes , argTypes , methods , scope , methodsFound , onlyStaticMethods , exactMatch , receiverType , invocationSite , invocationScope , implicitCall , superCall , canBePrefixed , missingElements , missingElementssStarts , missingElementsEnds , missingElementsHaveProblems , castedReceiver , receiverStart , receiverEnd ) ; } itsInterfaces = currentType . superInterfaces ( ) ; if ( itsInterfaces != null && itsInterfaces != Binding . NO_SUPERINTERFACES ) { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + <NUM_LIT:5> ] , <NUM_LIT:0> , nextPosition ) ; nextInterface : for ( int a = <NUM_LIT:0> ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = <NUM_LIT:0> ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } } } private void findJavadocBlockTags ( CompletionOnJavadocTag javadocTag ) { char [ ] [ ] possibleTags = javadocTag . getPossibleBlockTags ( ) ; if ( possibleTags == null ) return ; int length = possibleTags . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_BLOCK_TAG ) ) { char [ ] possibleTag = possibleTags [ i ] ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . JAVADOC_BLOCK_TAG , this . actualCompletionPosition ) ; proposal . setName ( possibleTag ) ; int tagLength = possibleTag . length ; char [ ] completion = new char [ <NUM_LIT:1> + tagLength ] ; completion [ <NUM_LIT:0> ] = '<CHAR_LIT>' ; System . arraycopy ( possibleTag , <NUM_LIT:0> , completion , <NUM_LIT:1> , tagLength ) ; proposal . setCompletion ( completion ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } private void findJavadocInlineTags ( CompletionOnJavadocTag javadocTag ) { char [ ] [ ] possibleTags = javadocTag . getPossibleInlineTags ( ) ; if ( possibleTags == null ) return ; int length = possibleTags . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_INLINE_TAG ) ) { char [ ] possibleTag = possibleTags [ i ] ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . JAVADOC_INLINE_TAG , this . actualCompletionPosition ) ; proposal . setName ( possibleTag ) ; int tagLength = possibleTag . length ; char [ ] completion = new char [ <NUM_LIT:2> + tagLength + <NUM_LIT:1> ] ; completion [ <NUM_LIT:0> ] = '<CHAR_LIT>' ; completion [ <NUM_LIT:1> ] = '<CHAR_LIT>' ; System . arraycopy ( possibleTag , <NUM_LIT:0> , completion , <NUM_LIT:2> , tagLength ) ; completion [ tagLength + <NUM_LIT:2> ] = '<CHAR_LIT:}>' ; proposal . setCompletion ( completion ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } private void findJavadocParamNames ( char [ ] token , char [ ] [ ] missingParams , boolean isTypeParam ) { if ( missingParams == null ) return ; int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; if ( ! isTypeParam ) relevance += R_INTERESTING ; int length = missingParams . length ; relevance += length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char [ ] argName = missingParams [ i ] ; if ( token == null || CharOperation . prefixEquals ( token , argName ) ) { this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_PARAM_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . JAVADOC_PARAM_REF , this . actualCompletionPosition ) ; proposal . setName ( argName ) ; char [ ] completion = isTypeParam ? CharOperation . concat ( '<CHAR_LIT>' , argName , '<CHAR_LIT:>>' ) : argName ; proposal . setCompletion ( completion ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( -- relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } } private void findKeywords ( char [ ] keyword , char [ ] [ ] choices , boolean canCompleteEmptyToken , boolean staticFieldsAndMethodOnly , boolean ignorePackageKeyword ) { if ( choices == null || choices . length == <NUM_LIT:0> ) return ; int length = keyword . length ; if ( canCompleteEmptyToken || length > <NUM_LIT:0> ) for ( int i = <NUM_LIT:0> ; i < choices . length ; i ++ ) if ( length <= choices [ i ] . length && CharOperation . prefixEquals ( keyword , choices [ i ] , false ) ) { if ( ignorePackageKeyword && CharOperation . equals ( choices [ i ] , Keywords . PACKAGE ) ) continue ; int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( keyword , choices [ i ] ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; if ( staticFieldsAndMethodOnly && this . insideQualifiedReference ) relevance += R_NON_INHERITED ; if ( CharOperation . equals ( choices [ i ] , Keywords . TRUE ) || CharOperation . equals ( choices [ i ] , Keywords . FALSE ) ) { relevance += computeRelevanceForExpectingType ( TypeBinding . BOOLEAN ) ; relevance += computeRelevanceForQualification ( false ) ; } this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . KEYWORD ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . KEYWORD , this . actualCompletionPosition ) ; proposal . setName ( choices [ i ] ) ; proposal . setCompletion ( choices [ i ] ) ; proposal . setReplaceRange ( ( canCompleteEmptyToken && ( this . startPosition < <NUM_LIT:0> ) ) ? <NUM_LIT:0> : this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( ( canCompleteEmptyToken && ( this . tokenStart < <NUM_LIT:0> ) ) ? <NUM_LIT:0> : this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } private void findKeywordsForMember ( char [ ] token , int modifiers ) { char [ ] [ ] keywords = new char [ Keywords . COUNT ] [ ] ; int count = <NUM_LIT:0> ; if ( ( modifiers & ClassFileConstants . AccPrivate ) == <NUM_LIT:0> && ( modifiers & ClassFileConstants . AccProtected ) == <NUM_LIT:0> && ( modifiers & ClassFileConstants . AccPublic ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . PROTECTED ; keywords [ count ++ ] = Keywords . PUBLIC ; if ( ( modifiers & ClassFileConstants . AccAbstract ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . PRIVATE ; } } if ( ( modifiers & ClassFileConstants . AccAbstract ) == <NUM_LIT:0> ) { if ( ( modifiers & ~ ( ExtraCompilerModifiers . AccVisibilityMASK | ClassFileConstants . AccStatic ) ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . ABSTRACT ; } if ( ( modifiers & ClassFileConstants . AccFinal ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . FINAL ; } if ( ( modifiers & ClassFileConstants . AccStatic ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . STATIC ; } boolean canBeField = true ; boolean canBeMethod = true ; boolean canBeType = true ; if ( ( modifiers & ClassFileConstants . AccNative ) != <NUM_LIT:0> || ( modifiers & ClassFileConstants . AccStrictfp ) != <NUM_LIT:0> || ( modifiers & ClassFileConstants . AccSynchronized ) != <NUM_LIT:0> ) { canBeField = false ; canBeType = false ; } if ( ( modifiers & ClassFileConstants . AccTransient ) != <NUM_LIT:0> || ( modifiers & ClassFileConstants . AccVolatile ) != <NUM_LIT:0> ) { canBeMethod = false ; canBeType = false ; } if ( canBeField ) { if ( ( modifiers & ClassFileConstants . AccTransient ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . TRANSIENT ; } if ( ( modifiers & ClassFileConstants . AccVolatile ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . VOLATILE ; } } if ( canBeMethod ) { if ( ( modifiers & ClassFileConstants . AccNative ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . NATIVE ; } if ( ( modifiers & ClassFileConstants . AccStrictfp ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . STRICTFP ; } if ( ( modifiers & ClassFileConstants . AccSynchronized ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . SYNCHRONIZED ; } } if ( canBeType ) { keywords [ count ++ ] = Keywords . CLASS ; keywords [ count ++ ] = Keywords . INTERFACE ; if ( ( modifiers & ClassFileConstants . AccFinal ) == <NUM_LIT:0> ) { keywords [ count ++ ] = Keywords . ENUM ; } } } else { keywords [ count ++ ] = Keywords . CLASS ; keywords [ count ++ ] = Keywords . INTERFACE ; } System . arraycopy ( keywords , <NUM_LIT:0> , keywords = new char [ count ] [ ] , <NUM_LIT:0> , count ) ; findKeywords ( token , keywords , false , false , false ) ; } private void findLabels ( char [ ] label , char [ ] [ ] choices ) { if ( choices == null || choices . length == <NUM_LIT:0> ) return ; int length = label . length ; for ( int i = <NUM_LIT:0> ; i < choices . length ; i ++ ) { if ( length <= choices [ i ] . length && CharOperation . prefixEquals ( label , choices [ i ] , false ) ) { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( label , choices [ i ] ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . LABEL_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . LABEL_REF , this . actualCompletionPosition ) ; proposal . setName ( choices [ i ] ) ; proposal . setCompletion ( choices [ i ] ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } } private void findLocalMethodDeclarations ( char [ ] methodName , MethodBinding [ ] methods , Scope scope , ObjectVector methodsFound , boolean exactMatch , ReferenceBinding receiverType ) { ObjectVector newMethodsFound = new ObjectVector ( ) ; int methodLength = methodName . length ; next : for ( int f = methods . length ; -- f >= <NUM_LIT:0> ; ) { MethodBinding method = methods [ f ] ; if ( method . isSynthetic ( ) ) continue next ; if ( method . isDefaultAbstract ( ) ) continue next ; if ( method . isConstructor ( ) ) continue next ; if ( method . isFinal ( ) ) { newMethodsFound . add ( method ) ; continue next ; } if ( this . options . checkDeprecation && method . isViewedAsDeprecated ( ) && ! scope . isDefinedInSameUnit ( method . declaringClass ) ) continue next ; if ( method . isStatic ( ) ) continue next ; if ( ! method . canBeSeenBy ( receiverType , FakeInvocationSite , scope ) ) continue next ; if ( exactMatch ) { if ( ! CharOperation . equals ( methodName , method . selector , false ) ) continue next ; } else { if ( methodLength > method . selector . length ) continue next ; if ( ! CharOperation . prefixEquals ( methodName , method . selector , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( methodName , method . selector ) ) ) continue next ; } for ( int i = methodsFound . size ; -- i >= <NUM_LIT:0> ; ) { MethodBinding otherMethod = ( MethodBinding ) methodsFound . elementAt ( i ) ; if ( method == otherMethod ) continue next ; if ( CharOperation . equals ( method . selector , otherMethod . selector , true ) && this . lookupEnvironment . methodVerifier ( ) . isMethodSubsignature ( otherMethod , method ) ) { continue next ; } } newMethodsFound . add ( method ) ; int length = method . parameters . length ; char [ ] [ ] parameterPackageNames = new char [ length ] [ ] ; char [ ] [ ] parameterFullTypeNames = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { TypeBinding type = method . parameters [ i ] ; parameterPackageNames [ i ] = type . qualifiedPackageName ( ) ; parameterFullTypeNames [ i ] = type . qualifiedSourceName ( ) ; } char [ ] [ ] parameterNames = findMethodParameterNames ( method , parameterFullTypeNames ) ; if ( method . typeVariables != null && method . typeVariables . length > <NUM_LIT:0> ) { char [ ] [ ] excludedNames = findEnclosingTypeNames ( scope ) ; char [ ] [ ] substituedParameterNames = substituteMethodTypeParameterNames ( method . typeVariables , excludedNames ) ; if ( substituedParameterNames != null ) { method = new ParameterizedMethodBinding ( method . declaringClass , method , substituedParameterNames , scope . environment ( ) ) ; } } StringBuffer completion = new StringBuffer ( <NUM_LIT:10> ) ; if ( ! exactMatch ) { createMethod ( method , parameterPackageNames , parameterFullTypeNames , parameterNames , scope , completion ) ; } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( methodName , method . selector ) ; relevance += R_METHOD_OVERIDE ; if ( method . isAbstract ( ) ) relevance += R_ABSTRACT_METHOD ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_DECLARATION ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . METHOD_DECLARATION , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( method . declaringClass ) ) ; proposal . setDeclarationKey ( method . declaringClass . computeUniqueKey ( ) ) ; proposal . setSignature ( getSignature ( method ) ) ; MethodBinding original = method . original ( ) ; if ( original != method ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setKey ( method . computeUniqueKey ( ) ) ; proposal . setDeclarationPackageName ( method . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( method . declaringClass . qualifiedSourceName ( ) ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterFullTypeNames ) ; proposal . setPackageName ( method . returnType . qualifiedPackageName ( ) ) ; proposal . setTypeName ( method . returnType . qualifiedSourceName ( ) ) ; proposal . setCompletion ( completion . toString ( ) . toCharArray ( ) ) ; proposal . setName ( method . selector ) ; proposal . setFlags ( method . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } methodsFound . addAll ( newMethodsFound ) ; } private void findLocalMethods ( char [ ] methodName , TypeBinding [ ] typeArgTypes , TypeBinding [ ] argTypes , MethodBinding [ ] methods , Scope scope , ObjectVector methodsFound , boolean onlyStaticMethods , boolean exactMatch , ReferenceBinding receiverType , InvocationSite invocationSite , Scope invocationScope , boolean implicitCall , boolean superCall , boolean canBePrefixed , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems , char [ ] castedReceiver , int receiverStart , int receiverEnd ) { ObjectVector newMethodsFound = new ObjectVector ( ) ; int methodLength = methodName . length ; int minTypeArgLength = typeArgTypes == null ? <NUM_LIT:0> : typeArgTypes . length ; int minArgLength = argTypes == null ? <NUM_LIT:0> : argTypes . length ; next : for ( int f = methods . length ; -- f >= <NUM_LIT:0> ; ) { MethodBinding method = methods [ f ] ; if ( method . isSynthetic ( ) ) continue next ; if ( method . isDefaultAbstract ( ) ) continue next ; if ( method . isConstructor ( ) ) continue next ; if ( this . options . checkDeprecation && method . isViewedAsDeprecated ( ) && ! scope . isDefinedInSameUnit ( method . declaringClass ) ) continue next ; if ( onlyStaticMethods && ! method . isStatic ( ) ) continue next ; if ( this . options . checkVisibility && ! method . canBeSeenBy ( receiverType , invocationSite , scope ) ) continue next ; if ( superCall && method . isAbstract ( ) ) { methodsFound . add ( new Object [ ] { method , receiverType } ) ; continue next ; } if ( exactMatch ) { if ( ! CharOperation . equals ( methodName , method . selector , false ) ) { continue next ; } } else { if ( methodLength > method . selector . length ) continue next ; if ( ! CharOperation . prefixEquals ( methodName , method . selector , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( methodName , method . selector ) ) ) { continue next ; } } if ( minTypeArgLength != <NUM_LIT:0> && minTypeArgLength != method . typeVariables . length ) continue next ; if ( minTypeArgLength != <NUM_LIT:0> ) { method = scope . environment ( ) . createParameterizedGenericMethod ( method , typeArgTypes ) ; } if ( minArgLength > method . parameters . length ) continue next ; for ( int a = minArgLength ; -- a >= <NUM_LIT:0> ; ) { if ( argTypes [ a ] != null ) { if ( ! argTypes [ a ] . isCompatibleWith ( method . parameters [ a ] ) ) { continue next ; } } } boolean prefixRequired = false ; for ( int i = methodsFound . size ; -- i >= <NUM_LIT:0> ; ) { Object [ ] other = ( Object [ ] ) methodsFound . elementAt ( i ) ; MethodBinding otherMethod = ( MethodBinding ) other [ <NUM_LIT:0> ] ; ReferenceBinding otherReceiverType = ( ReferenceBinding ) other [ <NUM_LIT:1> ] ; if ( method == otherMethod && receiverType == otherReceiverType ) continue next ; if ( CharOperation . equals ( method . selector , otherMethod . selector , true ) ) { if ( receiverType == otherReceiverType ) { if ( this . lookupEnvironment . methodVerifier ( ) . isMethodSubsignature ( otherMethod , method ) ) { if ( ! superCall || ! otherMethod . declaringClass . isInterface ( ) ) { continue next ; } } } else { if ( this . lookupEnvironment . methodVerifier ( ) . isMethodSubsignature ( otherMethod , method ) ) { if ( receiverType . isAnonymousType ( ) ) continue next ; if ( ! superCall ) { if ( ! canBePrefixed ) continue next ; prefixRequired = true ; } } } } } newMethodsFound . add ( new Object [ ] { method , receiverType } ) ; ReferenceBinding superTypeWithSameErasure = ( ReferenceBinding ) receiverType . findSuperTypeOriginatingFrom ( method . declaringClass ) ; if ( method . declaringClass != superTypeWithSameErasure ) { MethodBinding [ ] otherMethods = superTypeWithSameErasure . getMethods ( method . selector ) ; for ( int i = <NUM_LIT:0> ; i < otherMethods . length ; i ++ ) { if ( otherMethods [ i ] . original ( ) == method . original ( ) ) { method = otherMethods [ i ] ; } } } int length = method . parameters . length ; char [ ] [ ] parameterPackageNames = new char [ length ] [ ] ; char [ ] [ ] parameterTypeNames = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { TypeBinding type = method . original ( ) . parameters [ i ] ; parameterPackageNames [ i ] = type . qualifiedPackageName ( ) ; parameterTypeNames [ i ] = type . qualifiedSourceName ( ) ; } char [ ] [ ] parameterNames = findMethodParameterNames ( method , parameterTypeNames ) ; char [ ] completion = CharOperation . NO_CHAR ; int previousStartPosition = this . startPosition ; int previousTokenStart = this . tokenStart ; if ( this . assistNodeInJavadoc > <NUM_LIT:0> ) { Expression receiver = null ; if ( invocationSite instanceof CompletionOnJavadocMessageSend ) { CompletionOnJavadocMessageSend msg = ( CompletionOnJavadocMessageSend ) invocationSite ; receiver = msg . receiver ; } else if ( invocationSite instanceof CompletionOnJavadocFieldReference ) { CompletionOnJavadocFieldReference fieldRef = ( CompletionOnJavadocFieldReference ) invocationSite ; receiver = fieldRef . receiver ; } if ( receiver != null ) { StringBuffer javadocCompletion = new StringBuffer ( ) ; if ( receiver . isThis ( ) ) { if ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> ) { javadocCompletion . append ( '<CHAR_LIT>' ) ; } } else if ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> ) { if ( receiver instanceof JavadocSingleTypeReference ) { JavadocSingleTypeReference typeRef = ( JavadocSingleTypeReference ) receiver ; javadocCompletion . append ( typeRef . token ) ; javadocCompletion . append ( '<CHAR_LIT>' ) ; } else if ( receiver instanceof JavadocQualifiedTypeReference ) { JavadocQualifiedTypeReference typeRef = ( JavadocQualifiedTypeReference ) receiver ; completion = CharOperation . concat ( CharOperation . concatWith ( typeRef . tokens , '<CHAR_LIT:.>' ) , method . selector , '<CHAR_LIT>' ) ; for ( int t = <NUM_LIT:0> , nt = typeRef . tokens . length ; t < nt ; t ++ ) { if ( t > <NUM_LIT:0> ) javadocCompletion . append ( '<CHAR_LIT:.>' ) ; javadocCompletion . append ( typeRef . tokens [ t ] ) ; } javadocCompletion . append ( '<CHAR_LIT>' ) ; } } javadocCompletion . append ( method . selector ) ; javadocCompletion . append ( '<CHAR_LIT:(>' ) ; if ( method . parameters != null ) { boolean isVarargs = method . isVarargs ( ) ; for ( int p = <NUM_LIT:0> , ln = method . parameters . length ; p < ln ; p ++ ) { if ( p > <NUM_LIT:0> ) javadocCompletion . append ( "<STR_LIT:U+002CU+0020>" ) ; TypeBinding argTypeBinding = method . parameters [ p ] ; if ( isVarargs && p == ln - <NUM_LIT:1> ) { createVargsType ( argTypeBinding . erasure ( ) , scope , javadocCompletion ) ; } else { createType ( argTypeBinding . erasure ( ) , scope , javadocCompletion ) ; } } } javadocCompletion . append ( '<CHAR_LIT:)>' ) ; completion = javadocCompletion . toString ( ) . toCharArray ( ) ; } } else { if ( ! exactMatch ) { if ( this . source != null && this . source . length > this . endPosition && this . source [ this . endPosition ] == '<CHAR_LIT:(>' ) completion = method . selector ; else completion = CharOperation . concat ( method . selector , new char [ ] { '<CHAR_LIT:(>' , '<CHAR_LIT:)>' } ) ; if ( castedReceiver != null ) { completion = CharOperation . concat ( castedReceiver , completion ) ; } } else { if ( prefixRequired && ( this . source != null ) ) { completion = CharOperation . subarray ( this . source , this . startPosition , this . endPosition ) ; } else { this . startPosition = this . endPosition ; } this . tokenStart = this . tokenEnd ; } if ( prefixRequired || this . options . forceImplicitQualification ) { char [ ] prefix = computePrefix ( scope . enclosingSourceType ( ) , invocationScope . enclosingSourceType ( ) , method . isStatic ( ) ) ; completion = CharOperation . concat ( prefix , completion , '<CHAR_LIT:.>' ) ; } } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( methodName , method . selector ) ; relevance += computeRelevanceForExpectingType ( method . returnType ) ; relevance += computeRelevanceForEnumConstant ( method . returnType ) ; relevance += computeRelevanceForStatic ( onlyStaticMethods , method . isStatic ( ) ) ; relevance += computeRelevanceForQualification ( prefixRequired ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; if ( onlyStaticMethods && this . insideQualifiedReference ) { relevance += computeRelevanceForInheritance ( receiverType , method . declaringClass ) ; } if ( missingElements != null ) { relevance += computeRelevanceForMissingElements ( missingElementsHaveProblems ) ; } this . noProposal = false ; if ( castedReceiver == null ) { if ( ! this . isIgnored ( CompletionProposal . METHOD_REF , missingElements != null ) && ( this . assistNodeInJavadoc & CompletionOnJavadoc . ONLY_INLINE_TAG ) == <NUM_LIT:0> ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . METHOD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( method . declaringClass ) ) ; proposal . setSignature ( getSignature ( method ) ) ; MethodBinding original = method . original ( ) ; if ( original != method ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setDeclarationPackageName ( method . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( method . declaringClass . qualifiedSourceName ( ) ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; proposal . setPackageName ( method . returnType . qualifiedPackageName ( ) ) ; proposal . setTypeName ( method . returnType . qualifiedSourceName ( ) ) ; proposal . setName ( method . selector ) ; if ( missingElements != null ) { CompletionProposal [ ] subProposals = new CompletionProposal [ missingElements . length ] ; for ( int i = <NUM_LIT:0> ; i < missingElements . length ; i ++ ) { subProposals [ i ] = createRequiredTypeProposal ( missingElements [ i ] , missingElementsStarts [ i ] , missingElementsEnds [ i ] , relevance ) ; } proposal . setRequiredProposals ( subProposals ) ; } proposal . setCompletion ( completion ) ; proposal . setFlags ( method . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } if ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> && ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_METHOD_REF ) ) { char [ ] javadocCompletion = inlineTagCompletion ( completion , JavadocTagConstants . TAG_LINK ) ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . JAVADOC_METHOD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( method . declaringClass ) ) ; proposal . setSignature ( getSignature ( method ) ) ; MethodBinding original = method . original ( ) ; if ( original != method ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setDeclarationPackageName ( method . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( method . declaringClass . qualifiedSourceName ( ) ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; proposal . setPackageName ( method . returnType . qualifiedPackageName ( ) ) ; proposal . setTypeName ( method . returnType . qualifiedSourceName ( ) ) ; proposal . setName ( method . selector ) ; proposal . setCompletion ( javadocCompletion ) ; proposal . setFlags ( method . modifiers ) ; int start = ( this . assistNodeInJavadoc & CompletionOnJavadoc . REPLACE_TAG ) != <NUM_LIT:0> ? this . javadocTagPosition : this . startPosition ; proposal . setReplaceRange ( start - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance + R_INLINE_TAG ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } else { if ( ! this . isIgnored ( CompletionProposal . METHOD_REF_WITH_CASTED_RECEIVER , missingElements != null ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . METHOD_REF_WITH_CASTED_RECEIVER , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( method . declaringClass ) ) ; proposal . setSignature ( getSignature ( method ) ) ; MethodBinding original = method . original ( ) ; if ( original != method ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setReceiverSignature ( getSignature ( receiverType ) ) ; proposal . setDeclarationPackageName ( method . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( method . declaringClass . qualifiedSourceName ( ) ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; proposal . setPackageName ( method . returnType . qualifiedPackageName ( ) ) ; proposal . setTypeName ( method . returnType . qualifiedSourceName ( ) ) ; proposal . setName ( method . selector ) ; if ( missingElements != null ) { CompletionProposal [ ] subProposals = new CompletionProposal [ missingElements . length ] ; for ( int i = <NUM_LIT:0> ; i < missingElements . length ; i ++ ) { subProposals [ i ] = createRequiredTypeProposal ( missingElements [ i ] , missingElementsStarts [ i ] , missingElementsEnds [ i ] , relevance ) ; } proposal . setRequiredProposals ( subProposals ) ; } proposal . setCompletion ( completion ) ; proposal . setFlags ( method . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setReceiverRange ( receiverStart - this . offset , receiverEnd - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } this . startPosition = previousStartPosition ; this . tokenStart = previousTokenStart ; } methodsFound . addAll ( newMethodsFound ) ; } private void findLocalMethodsFromFavorites ( char [ ] methodName , MethodBinding [ ] methods , Scope scope , ObjectVector methodsFound , ObjectVector methodsFoundFromFavorites , ReferenceBinding receiverType , InvocationSite invocationSite , Scope invocationScope ) { char [ ] typeName = CharOperation . concatWith ( receiverType . compoundName , '<CHAR_LIT:.>' ) ; int methodLength = methodName . length ; next : for ( int f = methods . length ; -- f >= <NUM_LIT:0> ; ) { MethodBinding method = methods [ f ] ; if ( method . isSynthetic ( ) ) continue next ; if ( method . isDefaultAbstract ( ) ) continue next ; if ( method . isConstructor ( ) ) continue next ; if ( this . options . checkDeprecation && method . isViewedAsDeprecated ( ) && ! scope . isDefinedInSameUnit ( method . declaringClass ) ) continue next ; if ( ! method . isStatic ( ) ) continue next ; if ( this . options . checkVisibility && ! method . canBeSeenBy ( receiverType , invocationSite , scope ) ) continue next ; if ( methodLength > method . selector . length ) continue next ; if ( ! CharOperation . prefixEquals ( methodName , method . selector , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( methodName , method . selector ) ) ) { continue next ; } for ( int i = methodsFoundFromFavorites . size ; -- i >= <NUM_LIT:0> ; ) { Object [ ] other = ( Object [ ] ) methodsFoundFromFavorites . elementAt ( i ) ; MethodBinding otherMethod = ( MethodBinding ) other [ <NUM_LIT:0> ] ; if ( method == otherMethod ) continue next ; if ( CharOperation . equals ( method . selector , otherMethod . selector , true ) ) { if ( otherMethod . declaringClass == method . declaringClass && this . lookupEnvironment . methodVerifier ( ) . isMethodSubsignature ( otherMethod , method ) ) { continue next ; } } } for ( int i = methodsFound . size ; -- i >= <NUM_LIT:0> ; ) { Object [ ] other = ( Object [ ] ) methodsFound . elementAt ( i ) ; MethodBinding otherMethod = ( MethodBinding ) other [ <NUM_LIT:0> ] ; if ( method == otherMethod ) continue next ; if ( CharOperation . equals ( method . selector , otherMethod . selector , true ) ) { if ( this . lookupEnvironment . methodVerifier ( ) . isMethodSubsignature ( otherMethod , method ) ) { continue next ; } } } boolean proposeStaticImport = ! ( this . compilerOptions . complianceLevel < ClassFileConstants . JDK1_5 ) && this . options . suggestStaticImport ; boolean isAlreadyImported = false ; if ( ! proposeStaticImport ) { if ( ! this . importCachesInitialized ) { initializeImportCaches ( ) ; } for ( int j = <NUM_LIT:0> ; j < this . importCacheCount ; j ++ ) { char [ ] [ ] importName = this . importsCache [ j ] ; if ( CharOperation . equals ( receiverType . sourceName , importName [ <NUM_LIT:0> ] ) ) { if ( ! CharOperation . equals ( typeName , importName [ <NUM_LIT:1> ] ) ) { continue next ; } else { isAlreadyImported = true ; } } } } methodsFoundFromFavorites . add ( new Object [ ] { method , receiverType } ) ; ReferenceBinding superTypeWithSameErasure = ( ReferenceBinding ) receiverType . findSuperTypeOriginatingFrom ( method . declaringClass ) ; if ( method . declaringClass != superTypeWithSameErasure ) { MethodBinding [ ] otherMethods = superTypeWithSameErasure . getMethods ( method . selector ) ; for ( int i = <NUM_LIT:0> ; i < otherMethods . length ; i ++ ) { if ( otherMethods [ i ] . original ( ) == method . original ( ) ) { method = otherMethods [ i ] ; } } } int length = method . parameters . length ; char [ ] [ ] parameterPackageNames = new char [ length ] [ ] ; char [ ] [ ] parameterTypeNames = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { TypeBinding type = method . original ( ) . parameters [ i ] ; parameterPackageNames [ i ] = type . qualifiedPackageName ( ) ; parameterTypeNames [ i ] = type . qualifiedSourceName ( ) ; } char [ ] [ ] parameterNames = findMethodParameterNames ( method , parameterTypeNames ) ; char [ ] completion = CharOperation . NO_CHAR ; int previousStartPosition = this . startPosition ; int previousTokenStart = this . tokenStart ; if ( this . source != null && this . source . length > this . endPosition && this . source [ this . endPosition ] == '<CHAR_LIT:(>' ) { completion = method . selector ; } else { completion = CharOperation . concat ( method . selector , new char [ ] { '<CHAR_LIT:(>' , '<CHAR_LIT:)>' } ) ; } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( methodName , method . selector ) ; relevance += computeRelevanceForExpectingType ( method . returnType ) ; relevance += computeRelevanceForEnumConstant ( method . returnType ) ; relevance += computeRelevanceForStatic ( true , method . isStatic ( ) ) ; relevance += computeRelevanceForQualification ( true ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; CompilationUnitDeclaration cu = this . unitScope . referenceContext ; int importStart = cu . types [ <NUM_LIT:0> ] . declarationSourceStart ; int importEnd = importStart ; this . noProposal = false ; if ( ! proposeStaticImport ) { if ( isAlreadyImported ) { if ( ! isIgnored ( CompletionProposal . METHOD_REF ) ) { completion = CharOperation . concat ( receiverType . sourceName , completion , '<CHAR_LIT:.>' ) ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . METHOD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( method . declaringClass ) ) ; proposal . setSignature ( getSignature ( method ) ) ; MethodBinding original = method . original ( ) ; if ( original != method ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setDeclarationPackageName ( method . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( method . declaringClass . qualifiedSourceName ( ) ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; proposal . setPackageName ( method . returnType . qualifiedPackageName ( ) ) ; proposal . setTypeName ( method . returnType . qualifiedSourceName ( ) ) ; proposal . setName ( method . selector ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( method . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } else if ( ! this . isIgnored ( CompletionProposal . METHOD_REF , CompletionProposal . TYPE_IMPORT ) ) { completion = CharOperation . concat ( receiverType . sourceName , completion , '<CHAR_LIT:.>' ) ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . METHOD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( method . declaringClass ) ) ; proposal . setSignature ( getSignature ( method ) ) ; MethodBinding original = method . original ( ) ; if ( original != method ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setDeclarationPackageName ( method . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( method . declaringClass . qualifiedSourceName ( ) ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; proposal . setPackageName ( method . returnType . qualifiedPackageName ( ) ) ; proposal . setTypeName ( method . returnType . qualifiedSourceName ( ) ) ; proposal . setName ( method . selector ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( method . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; char [ ] typeImportCompletion = createImportCharArray ( typeName , false , false ) ; InternalCompletionProposal typeImportProposal = createProposal ( CompletionProposal . TYPE_IMPORT , this . actualCompletionPosition ) ; typeImportProposal . nameLookup = this . nameEnvironment . nameLookup ; typeImportProposal . completionEngine = this ; char [ ] packageName = receiverType . qualifiedPackageName ( ) ; typeImportProposal . setDeclarationSignature ( packageName ) ; typeImportProposal . setSignature ( getSignature ( receiverType ) ) ; typeImportProposal . setPackageName ( packageName ) ; typeImportProposal . setTypeName ( receiverType . qualifiedSourceName ( ) ) ; typeImportProposal . setCompletion ( typeImportCompletion ) ; typeImportProposal . setFlags ( receiverType . modifiers ) ; typeImportProposal . setAdditionalFlags ( CompletionFlags . Default ) ; typeImportProposal . setReplaceRange ( importStart - this . offset , importEnd - this . offset ) ; typeImportProposal . setTokenRange ( importStart - this . offset , importEnd - this . offset ) ; typeImportProposal . setRelevance ( relevance ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { typeImportProposal } ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } else { if ( ! this . isIgnored ( CompletionProposal . METHOD_REF , CompletionProposal . METHOD_IMPORT ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . METHOD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( method . declaringClass ) ) ; proposal . setSignature ( getSignature ( method ) ) ; MethodBinding original = method . original ( ) ; if ( original != method ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setDeclarationPackageName ( method . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( method . declaringClass . qualifiedSourceName ( ) ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; proposal . setPackageName ( method . returnType . qualifiedPackageName ( ) ) ; proposal . setTypeName ( method . returnType . qualifiedSourceName ( ) ) ; proposal . setName ( method . selector ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( method . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; char [ ] methodImportCompletion = createImportCharArray ( CharOperation . concat ( typeName , method . selector , '<CHAR_LIT:.>' ) , true , false ) ; InternalCompletionProposal methodImportProposal = createProposal ( CompletionProposal . METHOD_IMPORT , this . actualCompletionPosition ) ; methodImportProposal . setDeclarationSignature ( getSignature ( method . declaringClass ) ) ; methodImportProposal . setSignature ( getSignature ( method ) ) ; if ( original != method ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } methodImportProposal . setDeclarationPackageName ( method . declaringClass . qualifiedPackageName ( ) ) ; methodImportProposal . setDeclarationTypeName ( method . declaringClass . qualifiedSourceName ( ) ) ; methodImportProposal . setParameterPackageNames ( parameterPackageNames ) ; methodImportProposal . setParameterTypeNames ( parameterTypeNames ) ; methodImportProposal . setPackageName ( method . returnType . qualifiedPackageName ( ) ) ; methodImportProposal . setTypeName ( method . returnType . qualifiedSourceName ( ) ) ; methodImportProposal . setName ( method . selector ) ; methodImportProposal . setCompletion ( methodImportCompletion ) ; methodImportProposal . setFlags ( method . modifiers ) ; methodImportProposal . setAdditionalFlags ( CompletionFlags . StaticImport ) ; methodImportProposal . setReplaceRange ( importStart - this . offset , importEnd - this . offset ) ; methodImportProposal . setTokenRange ( importStart - this . offset , importEnd - this . offset ) ; methodImportProposal . setRelevance ( relevance ) ; if ( parameterNames != null ) methodImportProposal . setParameterNames ( parameterNames ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { methodImportProposal } ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } this . startPosition = previousStartPosition ; this . tokenStart = previousTokenStart ; } } private void findLocalMethodsFromStaticImports ( char [ ] methodName , MethodBinding [ ] methods , Scope scope , boolean exactMatch , ObjectVector methodsFound , ReferenceBinding receiverType , InvocationSite invocationSite ) { ObjectVector newMethodsFound = new ObjectVector ( ) ; next : for ( int f = methods . length ; -- f >= <NUM_LIT:0> ; ) { MethodBinding method = methods [ f ] ; if ( method . isSynthetic ( ) ) continue next ; if ( method . isDefaultAbstract ( ) ) continue next ; if ( method . isConstructor ( ) ) continue next ; if ( ! method . isStatic ( ) ) continue next ; if ( this . options . checkDeprecation && method . isViewedAsDeprecated ( ) && ! scope . isDefinedInSameUnit ( method . declaringClass ) ) continue next ; if ( this . options . checkVisibility && ! method . canBeSeenBy ( receiverType , invocationSite , scope ) ) continue next ; for ( int i = methodsFound . size ; -- i >= <NUM_LIT:0> ; ) { Object [ ] other = ( Object [ ] ) methodsFound . elementAt ( i ) ; MethodBinding otherMethod = ( MethodBinding ) other [ <NUM_LIT:0> ] ; ReferenceBinding otherReceiverType = ( ReferenceBinding ) other [ <NUM_LIT:1> ] ; if ( method == otherMethod && receiverType == otherReceiverType ) continue next ; if ( CharOperation . equals ( method . selector , otherMethod . selector , true ) ) { if ( this . lookupEnvironment . methodVerifier ( ) . isMethodSubsignature ( otherMethod , method ) ) { continue next ; } } } newMethodsFound . add ( new Object [ ] { method , receiverType } ) ; int length = method . parameters . length ; char [ ] [ ] parameterPackageNames = new char [ length ] [ ] ; char [ ] [ ] parameterTypeNames = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { TypeBinding type = method . original ( ) . parameters [ i ] ; parameterPackageNames [ i ] = type . qualifiedPackageName ( ) ; parameterTypeNames [ i ] = type . qualifiedSourceName ( ) ; } char [ ] [ ] parameterNames = findMethodParameterNames ( method , parameterTypeNames ) ; char [ ] completion = CharOperation . NO_CHAR ; int previousStartPosition = this . startPosition ; int previousTokenStart = this . tokenStart ; if ( ! exactMatch ) { if ( this . source != null && this . source . length > this . endPosition && this . source [ this . endPosition ] == '<CHAR_LIT:(>' ) { completion = method . selector ; } else { completion = CharOperation . concat ( method . selector , new char [ ] { '<CHAR_LIT:(>' , '<CHAR_LIT:)>' } ) ; } } else { this . startPosition = this . endPosition ; this . tokenStart = this . tokenEnd ; } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( methodName , method . selector ) ; relevance += computeRelevanceForExpectingType ( method . returnType ) ; relevance += computeRelevanceForEnumConstant ( method . returnType ) ; relevance += computeRelevanceForStatic ( true , method . isStatic ( ) ) ; relevance += computeRelevanceForQualification ( false ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . METHOD_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( method . declaringClass ) ) ; proposal . setSignature ( getSignature ( method ) ) ; MethodBinding original = method . original ( ) ; if ( original != method ) { proposal . setOriginalSignature ( getSignature ( original ) ) ; } proposal . setDeclarationPackageName ( method . declaringClass . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( method . declaringClass . qualifiedSourceName ( ) ) ; proposal . setParameterPackageNames ( parameterPackageNames ) ; proposal . setParameterTypeNames ( parameterTypeNames ) ; proposal . setPackageName ( method . returnType . qualifiedPackageName ( ) ) ; proposal . setTypeName ( method . returnType . qualifiedSourceName ( ) ) ; proposal . setName ( method . selector ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( method . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; if ( parameterNames != null ) proposal . setParameterNames ( parameterNames ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } this . startPosition = previousStartPosition ; this . tokenStart = previousTokenStart ; } methodsFound . addAll ( newMethodsFound ) ; } private void findLocalMethodsFromStaticImports ( char [ ] token , Scope scope , InvocationSite invocationSite , Scope invocationScope , boolean exactMatch , ObjectVector methodsFound , boolean proposeMethod ) { findFieldsAndMethodsFromStaticImports ( token , scope , invocationSite , invocationScope , exactMatch , false , new ObjectVector ( ) , new ObjectVector ( ) , methodsFound , false , proposeMethod ) ; } protected void findMembers ( char [ ] token , ReferenceBinding receiverType , Scope scope , InvocationSite invocationSite , boolean isInsideAnnotationAttribute , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems ) { if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { findMemberTypes ( token , receiverType , scope , scope . enclosingSourceType ( ) , false , true , new ObjectVector ( ) , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems ) ; } if ( ! this . requestor . isIgnored ( CompletionProposal . FIELD_REF ) ) { findClassField ( token , receiverType , scope , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems ) ; } MethodScope methodScope = null ; if ( ! isInsideAnnotationAttribute && ! this . requestor . isIgnored ( CompletionProposal . KEYWORD ) && ( ( scope instanceof MethodScope && ! ( ( MethodScope ) scope ) . isStatic ) || ( ( methodScope = scope . enclosingMethodScope ( ) ) != null && ! methodScope . isStatic ) ) ) { if ( token . length > <NUM_LIT:0> ) { findKeywords ( token , new char [ ] [ ] { Keywords . THIS } , false , true , false ) ; } else { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( this . completionToken , Keywords . THIS ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; relevance += R_NON_INHERITED ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . KEYWORD ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . KEYWORD , this . actualCompletionPosition ) ; proposal . setName ( Keywords . THIS ) ; proposal . setCompletion ( Keywords . THIS ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } if ( ! this . requestor . isIgnored ( CompletionProposal . FIELD_REF ) ) { findFields ( token , receiverType , scope , new ObjectVector ( ) , new ObjectVector ( ) , true , invocationSite , scope , false , false , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; } if ( ! isInsideAnnotationAttribute && ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) ) { findMethods ( token , null , null , receiverType , scope , new ObjectVector ( ) , true , false , invocationSite , scope , false , false , false , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; } } private void findMembersFromMissingType ( final char [ ] token , final long pos , TypeBinding resolveType , final Scope scope , final InvocationSite invocationSite , final boolean isInsideAnnotationAttribute ) { MissingTypesGuesser missingTypesConverter = new MissingTypesGuesser ( this ) ; MissingTypesGuesser . GuessedTypeRequestor substitutionRequestor = new MissingTypesGuesser . GuessedTypeRequestor ( ) { public void accept ( TypeBinding guessedType , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean hasProblems ) { if ( guessedType instanceof ReferenceBinding ) { findMembers ( CompletionEngine . this . completionToken , ( ReferenceBinding ) guessedType , scope , invocationSite , isInsideAnnotationAttribute , missingElements , missingElementsStarts , missingElementsEnds , hasProblems ) ; } } } ; SingleTypeReference typeRef = new SingleTypeReference ( token , pos ) ; typeRef . resolvedType = new ProblemReferenceBinding ( new char [ ] [ ] { token } , null , ProblemReasons . NotFound ) ; missingTypesConverter . guess ( typeRef , scope , substitutionRequestor ) ; } private void findMemberTypes ( char [ ] typeName , ReferenceBinding receiverType , Scope scope , SourceTypeBinding typeInvocation , boolean staticOnly , boolean staticFieldsAndMethodOnly , boolean fromStaticImport , boolean checkQualification , boolean proposeAllMemberTypes , SourceTypeBinding typeToIgnore , ObjectVector typesFound , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems ) { ReferenceBinding currentType = receiverType ; if ( typeName == null ) return ; if ( this . insideQualifiedReference || typeName . length == <NUM_LIT:0> ) { findMemberTypes ( typeName , currentType . memberTypes ( ) , typesFound , receiverType , typeInvocation , staticOnly , staticFieldsAndMethodOnly , fromStaticImport , checkQualification , scope , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems ) ; return ; } ReferenceBinding [ ] interfacesToVisit = null ; int nextPosition = <NUM_LIT:0> ; do { ReferenceBinding [ ] itsInterfaces = currentType . superInterfaces ( ) ; if ( itsInterfaces != null && itsInterfaces != Binding . NO_SUPERINTERFACES ) { if ( interfacesToVisit == null ) { interfacesToVisit = itsInterfaces ; nextPosition = interfacesToVisit . length ; } else { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + <NUM_LIT:5> ] , <NUM_LIT:0> , nextPosition ) ; nextInterface : for ( int a = <NUM_LIT:0> ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = <NUM_LIT:0> ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } findMemberTypes ( typeName , currentType . memberTypes ( ) , typesFound , receiverType , typeInvocation , staticOnly , staticFieldsAndMethodOnly , fromStaticImport , checkQualification , scope , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems ) ; currentType = currentType . superclass ( ) ; } while ( currentType != null ) ; if ( proposeAllMemberTypes ) { ReferenceBinding [ ] memberTypes = receiverType . memberTypes ( ) ; for ( int i = <NUM_LIT:0> ; i < memberTypes . length ; i ++ ) { if ( memberTypes [ i ] != typeToIgnore ) { findSubMemberTypes ( typeName , memberTypes [ i ] , scope , typeInvocation , staticOnly , staticFieldsAndMethodOnly , fromStaticImport , typesFound ) ; } } } if ( interfacesToVisit != null ) { for ( int i = <NUM_LIT:0> ; i < nextPosition ; i ++ ) { ReferenceBinding anInterface = interfacesToVisit [ i ] ; findMemberTypes ( typeName , anInterface . memberTypes ( ) , typesFound , receiverType , typeInvocation , staticOnly , staticFieldsAndMethodOnly , fromStaticImport , checkQualification , scope , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems ) ; ReferenceBinding [ ] itsInterfaces = anInterface . superInterfaces ( ) ; if ( itsInterfaces != null && itsInterfaces != Binding . NO_SUPERINTERFACES ) { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + <NUM_LIT:5> ] , <NUM_LIT:0> , nextPosition ) ; nextInterface : for ( int a = <NUM_LIT:0> ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = <NUM_LIT:0> ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } } } protected void findMemberTypes ( char [ ] typeName , ReferenceBinding receiverType , Scope scope , SourceTypeBinding typeInvocation , boolean staticOnly , boolean staticFieldsAndMethodOnly , ObjectVector typesFound , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems ) { findMemberTypes ( typeName , receiverType , scope , typeInvocation , staticOnly , staticFieldsAndMethodOnly , false , false , false , null , typesFound , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems ) ; } private void findMemberTypes ( char [ ] typeName , ReferenceBinding [ ] memberTypes , ObjectVector typesFound , ReferenceBinding receiverType , SourceTypeBinding invocationType , boolean staticOnly , boolean staticFieldsAndMethodOnly , boolean fromStaticImport , boolean checkQualification , Scope scope , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems ) { int typeLength = typeName . length ; next : for ( int m = memberTypes . length ; -- m >= <NUM_LIT:0> ; ) { ReferenceBinding memberType = memberTypes [ m ] ; if ( staticOnly && ! memberType . isStatic ( ) ) continue next ; if ( isForbidden ( memberType ) ) continue next ; if ( typeLength > memberType . sourceName . length ) continue next ; if ( ! CharOperation . prefixEquals ( typeName , memberType . sourceName , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( typeName , memberType . sourceName ) ) ) continue next ; if ( this . options . checkDeprecation && memberType . isViewedAsDeprecated ( ) && ! scope . isDefinedInSameUnit ( memberType ) ) continue next ; if ( this . options . checkVisibility ) { if ( invocationType != null && ! memberType . canBeSeenBy ( receiverType , invocationType ) ) { continue next ; } else if ( invocationType == null && ! memberType . canBeSeenBy ( this . unitScope . fPackage ) ) { continue next ; } } if ( this . insideQualifiedReference && receiverType . isParameterizedType ( ) && memberType . isStatic ( ) ) { continue next ; } for ( int i = typesFound . size ; -- i >= <NUM_LIT:0> ; ) { ReferenceBinding otherType = ( ReferenceBinding ) typesFound . elementAt ( i ) ; if ( memberType == otherType ) continue next ; if ( CharOperation . equals ( memberType . sourceName , otherType . sourceName , true ) ) { if ( memberType . enclosingType ( ) . isSuperclassOf ( otherType . enclosingType ( ) ) ) continue next ; if ( otherType . enclosingType ( ) . isInterface ( ) ) if ( memberType . enclosingType ( ) . implementsInterface ( otherType . enclosingType ( ) , true ) ) continue next ; if ( memberType . enclosingType ( ) . isInterface ( ) ) if ( otherType . enclosingType ( ) . implementsInterface ( memberType . enclosingType ( ) , true ) ) continue next ; } } typesFound . add ( memberType ) ; if ( this . assistNodeIsExtendedType && memberType . isFinal ( ) ) continue next ; if ( this . assistNodeIsInterfaceExcludingAnnotation && memberType . isAnnotationType ( ) ) continue next ; if ( ! this . insideQualifiedReference ) { if ( this . assistNodeIsClass || this . assistNodeIsException ) { if ( ! memberType . isClass ( ) ) continue next ; } else if ( this . assistNodeIsInterface ) { if ( ! memberType . isInterface ( ) && ! memberType . isAnnotationType ( ) ) continue next ; } else if ( this . assistNodeIsAnnotation ) { if ( ! memberType . isAnnotationType ( ) ) continue next ; } } char [ ] completionName = memberType . sourceName ( ) ; boolean isQualified = false ; if ( checkQualification && ! fromStaticImport ) { char [ ] memberPackageName = memberType . qualifiedPackageName ( ) ; char [ ] memberTypeName = memberType . sourceName ( ) ; char [ ] memberEnclosingTypeNames = memberType . enclosingType ( ) . qualifiedSourceName ( ) ; if ( mustQualifyType ( memberPackageName , memberTypeName , memberEnclosingTypeNames , memberType . modifiers ) ) { if ( memberPackageName == null || memberPackageName . length == <NUM_LIT:0> ) if ( this . unitScope != null && this . unitScope . fPackage . compoundName != CharOperation . NO_CHAR_CHAR ) break next ; isQualified = true ; completionName = CharOperation . concat ( memberPackageName , CharOperation . concat ( memberEnclosingTypeNames , memberTypeName , '<CHAR_LIT:.>' ) , '<CHAR_LIT:.>' ) ; } } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( memberType ) ; relevance += computeRelevanceForCaseMatching ( typeName , memberType . sourceName ) ; relevance += computeRelevanceForExpectingType ( memberType ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; if ( ! this . insideQualifiedReference ) { relevance += computeRelevanceForQualification ( isQualified ) ; } if ( staticFieldsAndMethodOnly && this . insideQualifiedReference ) relevance += R_NON_INHERITED ; if ( memberType . isAnnotationType ( ) ) { relevance += computeRelevanceForAnnotation ( ) ; relevance += computeRelevanceForAnnotationTarget ( memberType ) ; } else if ( memberType . isClass ( ) ) { relevance += computeRelevanceForClass ( ) ; relevance += computeRelevanceForException ( memberType . sourceName ) ; } else if ( memberType . isEnum ( ) ) { relevance += computeRelevanceForEnum ( ) ; } else if ( memberType . isInterface ( ) ) { relevance += computeRelevanceForInterface ( ) ; } if ( missingElements != null ) { relevance += computeRelevanceForMissingElements ( missingElementsHaveProblems ) ; } boolean allowingLongComputationProposals = isAllowingLongComputationProposals ( ) ; this . noProposal = false ; if ( ! this . assistNodeIsConstructor || ! allowingLongComputationProposals || hasStaticMemberTypes ( memberType , invocationType , this . unitScope ) || ( memberType instanceof SourceTypeBinding && hasMemberTypesInEnclosingScope ( ( SourceTypeBinding ) memberType , scope ) ) || hasArrayTypeAsExpectedSuperTypes ( ) ) { createTypeProposal ( memberType , memberType . qualifiedSourceName ( ) , IAccessRule . K_ACCESSIBLE , completionName , relevance , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems ) ; } if ( this . assistNodeIsConstructor && allowingLongComputationProposals ) { findConstructorsOrAnonymousTypes ( memberType , scope , FakeInvocationSite , isQualified , relevance ) ; } } } private void findMemberTypesFromMissingType ( char [ ] typeName , final long pos , final Scope scope ) { MissingTypesGuesser missingTypesConverter = new MissingTypesGuesser ( this ) ; MissingTypesGuesser . GuessedTypeRequestor substitutionRequestor = new MissingTypesGuesser . GuessedTypeRequestor ( ) { public void accept ( TypeBinding guessedType , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean hasProblems ) { if ( guessedType instanceof ReferenceBinding ) { findMemberTypes ( CompletionEngine . this . completionToken , ( ReferenceBinding ) guessedType , scope , scope . enclosingSourceType ( ) , false , false , new ObjectVector ( ) , missingElements , missingElementsStarts , missingElementsEnds , hasProblems ) ; } } } ; SingleTypeReference typeRef = new SingleTypeReference ( typeName , pos ) ; typeRef . resolvedType = new ProblemReferenceBinding ( new char [ ] [ ] { typeName } , null , ProblemReasons . NotFound ) ; missingTypesConverter . guess ( typeRef , scope , substitutionRequestor ) ; } private void findMemberTypesFromMissingType ( TypeReference typeRef , final long pos , final Scope scope ) { MissingTypesGuesser missingTypesConverter = new MissingTypesGuesser ( this ) ; MissingTypesGuesser . GuessedTypeRequestor substitutionRequestor = new MissingTypesGuesser . GuessedTypeRequestor ( ) { public void accept ( TypeBinding guessedType , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean hasProblems ) { if ( guessedType instanceof ReferenceBinding ) { findMemberTypes ( CompletionEngine . this . completionToken , ( ReferenceBinding ) guessedType , scope , scope . enclosingSourceType ( ) , false , false , new ObjectVector ( ) , missingElements , missingElementsStarts , missingElementsEnds , hasProblems ) ; } } } ; missingTypesConverter . guess ( typeRef , scope , substitutionRequestor ) ; } private void findMethodDeclarations ( char [ ] selector , ReferenceBinding receiverType , Scope scope , ObjectVector methodsFound , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems ) { if ( selector == null ) { return ; } MethodBinding [ ] receiverTypeMethods = receiverType . availableMethods ( ) ; if ( receiverTypeMethods != null ) { for ( int i = <NUM_LIT:0> ; i < receiverTypeMethods . length ; i ++ ) { if ( ! receiverTypeMethods [ i ] . isDefaultAbstract ( ) ) { methodsFound . add ( receiverTypeMethods [ i ] ) ; } } } ReferenceBinding currentType = receiverType ; findInterfacesMethodDeclarations ( selector , receiverType , currentType . superInterfaces ( ) , scope , methodsFound , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems ) ; if ( receiverType . isInterface ( ) ) { currentType = scope . getJavaLangObject ( ) ; } else { currentType = receiverType . superclass ( ) ; } boolean hasPotentialDefaultAbstractMethods = true ; while ( currentType != null ) { MethodBinding [ ] methods = currentType . availableMethods ( ) ; if ( methods != null ) { findLocalMethodDeclarations ( selector , methods , scope , methodsFound , false , receiverType ) ; } if ( hasPotentialDefaultAbstractMethods && ( currentType . isAbstract ( ) || currentType . isTypeVariable ( ) || currentType . isIntersectionType ( ) || currentType . isEnum ( ) ) ) { ReferenceBinding [ ] superInterfaces = currentType . superInterfaces ( ) ; findInterfacesMethodDeclarations ( selector , receiverType , superInterfaces , scope , methodsFound , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems ) ; } else { hasPotentialDefaultAbstractMethods = false ; } currentType = currentType . superclass ( ) ; } } private char [ ] [ ] findMethodParameterNames ( MethodBinding method , char [ ] [ ] parameterTypeNames ) { TypeBinding erasure = method . declaringClass . erasure ( ) ; if ( ! ( erasure instanceof ReferenceBinding ) ) return null ; char [ ] [ ] parameterNames = null ; int length = parameterTypeNames . length ; if ( length == <NUM_LIT:0> ) { return CharOperation . NO_CHAR_CHAR ; } if ( erasure instanceof SourceTypeBinding ) { SourceTypeBinding sourceType = ( SourceTypeBinding ) erasure ; if ( sourceType . scope != null ) { TypeDeclaration parsedType ; if ( ( parsedType = sourceType . scope . referenceContext ) != null ) { AbstractMethodDeclaration methodDecl = parsedType . declarationOf ( method . original ( ) ) ; if ( methodDecl != null ) { Argument [ ] arguments = methodDecl . arguments ; parameterNames = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { parameterNames [ i ] = arguments [ i ] . name ; } } } } } if ( parameterNames == null ) { ReferenceBinding bindingType = ( ReferenceBinding ) erasure ; char [ ] compoundName = CharOperation . concatWith ( bindingType . compoundName , '<CHAR_LIT:.>' ) ; Object type = this . typeCache . get ( compoundName ) ; ISourceType sourceType = null ; if ( type != null ) { if ( type instanceof ISourceType ) { sourceType = ( ISourceType ) type ; } } else { NameEnvironmentAnswer answer = this . nameEnvironment . findType ( bindingType . compoundName ) ; if ( answer != null && answer . isSourceType ( ) ) { sourceType = answer . getSourceTypes ( ) [ <NUM_LIT:0> ] ; this . typeCache . put ( compoundName , sourceType ) ; } } if ( sourceType != null ) { IType typeHandle = ( ( SourceTypeElementInfo ) sourceType ) . getHandle ( ) ; String [ ] parameterTypeSignatures = new String [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { parameterTypeSignatures [ i ] = Signature . createTypeSignature ( parameterTypeNames [ i ] , false ) ; } IMethod searchedMethod = typeHandle . getMethod ( String . valueOf ( method . selector ) , parameterTypeSignatures ) ; IMethod [ ] foundMethods = typeHandle . findMethods ( searchedMethod ) ; if ( foundMethods != null ) { int len = foundMethods . length ; if ( len == <NUM_LIT:1> ) { try { SourceMethod sourceMethod = ( SourceMethod ) foundMethods [ <NUM_LIT:0> ] ; parameterNames = ( ( SourceMethodElementInfo ) sourceMethod . getElementInfo ( ) ) . getArgumentNames ( ) ; } catch ( JavaModelException e ) { } } } } } return parameterNames ; } private void findMethods ( char [ ] selector , TypeBinding [ ] typeArgTypes , TypeBinding [ ] argTypes , ReferenceBinding receiverType , Scope scope , ObjectVector methodsFound , boolean onlyStaticMethods , boolean exactMatch , InvocationSite invocationSite , Scope invocationScope , boolean implicitCall , boolean superCall , boolean canBePrefixed , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean missingElementsHaveProblems , char [ ] castedReceiver , int receiverStart , int receiverEnd ) { boolean notInJavadoc = this . assistNodeInJavadoc == <NUM_LIT:0> ; if ( selector == null && notInJavadoc ) { return ; } if ( this . assistNodeIsInsideCase ) return ; ReferenceBinding currentType = receiverType ; if ( notInJavadoc ) { if ( receiverType . isInterface ( ) ) { findInterfacesMethods ( selector , typeArgTypes , argTypes , receiverType , new ReferenceBinding [ ] { currentType } , scope , methodsFound , onlyStaticMethods , exactMatch , invocationSite , invocationScope , implicitCall , superCall , canBePrefixed , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems , castedReceiver , receiverStart , receiverEnd ) ; currentType = scope . getJavaLangObject ( ) ; } } boolean hasPotentialDefaultAbstractMethods = true ; while ( currentType != null ) { MethodBinding [ ] methods = currentType . availableMethods ( ) ; if ( methods != null ) { findLocalMethods ( selector , typeArgTypes , argTypes , methods , scope , methodsFound , onlyStaticMethods , exactMatch , receiverType , invocationSite , invocationScope , implicitCall , superCall , canBePrefixed , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems , castedReceiver , receiverStart , receiverEnd ) ; } if ( hasPotentialDefaultAbstractMethods && ( currentType . isAbstract ( ) || currentType . isTypeVariable ( ) || currentType . isIntersectionType ( ) || currentType . isEnum ( ) ) ) { ReferenceBinding [ ] superInterfaces = currentType . superInterfaces ( ) ; if ( superInterfaces != null && currentType . isIntersectionType ( ) ) { for ( int i = <NUM_LIT:0> ; i < superInterfaces . length ; i ++ ) { superInterfaces [ i ] = ( ReferenceBinding ) superInterfaces [ i ] . capture ( invocationScope , invocationSite . sourceEnd ( ) ) ; } } findInterfacesMethods ( selector , typeArgTypes , argTypes , receiverType , superInterfaces , scope , methodsFound , onlyStaticMethods , exactMatch , invocationSite , invocationScope , implicitCall , superCall , canBePrefixed , missingElements , missingElementsStarts , missingElementsEnds , missingElementsHaveProblems , castedReceiver , receiverStart , receiverEnd ) ; } else { hasPotentialDefaultAbstractMethods = false ; } currentType = currentType . superclass ( ) ; } } private void findNestedTypes ( char [ ] typeName , SourceTypeBinding currentType , Scope scope , boolean proposeAllMemberTypes , ObjectVector typesFound ) { if ( typeName == null ) return ; int typeLength = typeName . length ; SourceTypeBinding nextTypeToIgnore = null ; while ( scope != null ) { switch ( scope . kind ) { case Scope . METHOD_SCOPE : case Scope . BLOCK_SCOPE : BlockScope blockScope = ( BlockScope ) scope ; next : for ( int i = <NUM_LIT:0> , length = blockScope . subscopeCount ; i < length ; i ++ ) { if ( blockScope . subscopes [ i ] instanceof ClassScope ) { SourceTypeBinding localType = ( ( ClassScope ) blockScope . subscopes [ i ] ) . referenceContext . binding ; if ( ! localType . isAnonymousType ( ) ) { if ( isForbidden ( localType ) ) continue next ; if ( typeLength > localType . sourceName . length ) continue next ; if ( ! CharOperation . prefixEquals ( typeName , localType . sourceName , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( typeName , localType . sourceName ) ) ) continue next ; for ( int j = typesFound . size ; -- j >= <NUM_LIT:0> ; ) { ReferenceBinding otherType = ( ReferenceBinding ) typesFound . elementAt ( j ) ; if ( localType == otherType ) continue next ; } if ( this . assistNodeIsExtendedType && localType . isFinal ( ) ) continue next ; if ( this . assistNodeIsInterfaceExcludingAnnotation && localType . isAnnotationType ( ) ) continue next ; if ( this . assistNodeIsClass ) { if ( ! localType . isClass ( ) ) continue next ; } else if ( this . assistNodeIsInterface ) { if ( ! localType . isInterface ( ) && ! localType . isAnnotationType ( ) ) continue next ; } else if ( this . assistNodeIsAnnotation ) { if ( ! localType . isAnnotationType ( ) ) continue next ; } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( localType ) ; relevance += computeRelevanceForCaseMatching ( typeName , localType . sourceName ) ; relevance += computeRelevanceForExpectingType ( localType ) ; relevance += computeRelevanceForException ( localType . sourceName ) ; relevance += computeRelevanceForClass ( ) ; relevance += computeRelevanceForQualification ( false ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; relevance += computeRelevanceForAnnotationTarget ( localType ) ; boolean allowingLongComputationProposals = isAllowingLongComputationProposals ( ) ; if ( ! this . assistNodeIsConstructor || ! allowingLongComputationProposals || hasArrayTypeAsExpectedSuperTypes ( ) ) { this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { createTypeProposal ( localType , localType . sourceName , IAccessRule . K_ACCESSIBLE , localType . sourceName , relevance , null , null , null , false ) ; } } if ( this . assistNodeIsConstructor && allowingLongComputationProposals ) { findConstructorsOrAnonymousTypes ( localType , blockScope , FakeInvocationSite , false , relevance ) ; } } } } break ; case Scope . CLASS_SCOPE : SourceTypeBinding enclosingSourceType = scope . enclosingSourceType ( ) ; findMemberTypes ( typeName , enclosingSourceType , scope , currentType , false , false , false , false , proposeAllMemberTypes , nextTypeToIgnore , typesFound , null , null , null , false ) ; nextTypeToIgnore = enclosingSourceType ; if ( typeLength == <NUM_LIT:0> ) return ; break ; case Scope . COMPILATION_UNIT_SCOPE : return ; } scope = scope . parent ; } } private void findPackages ( CompletionOnPackageReference packageStatement ) { this . completionToken = CharOperation . concatWith ( packageStatement . tokens , '<CHAR_LIT:.>' ) ; if ( this . completionToken . length == <NUM_LIT:0> ) return ; setSourceRange ( packageStatement . sourceStart , packageStatement . sourceEnd ) ; long completionPosition = packageStatement . sourcePositions [ packageStatement . sourcePositions . length - <NUM_LIT:1> ] ; setTokenRange ( ( int ) ( completionPosition > > > <NUM_LIT:32> ) , ( int ) completionPosition ) ; this . nameEnvironment . findPackages ( CharOperation . toLowerCase ( this . completionToken ) , this ) ; } private void findParameterizedType ( TypeReference ref , Scope scope ) { ReferenceBinding refBinding = ( ReferenceBinding ) ref . resolvedType ; if ( refBinding != null ) { if ( this . options . checkDeprecation && refBinding . isViewedAsDeprecated ( ) && ! scope . isDefinedInSameUnit ( refBinding ) ) return ; int accessibility = IAccessRule . K_ACCESSIBLE ; if ( refBinding . hasRestrictedAccess ( ) ) { AccessRestriction accessRestriction = this . lookupEnvironment . getAccessRestriction ( refBinding ) ; if ( accessRestriction != null ) { switch ( accessRestriction . getProblemId ( ) ) { case IProblem . ForbiddenReference : if ( this . options . checkForbiddenReference ) { return ; } accessibility = IAccessRule . K_NON_ACCESSIBLE ; break ; case IProblem . DiscouragedReference : if ( this . options . checkDiscouragedReference ) { return ; } accessibility = IAccessRule . K_DISCOURAGED ; break ; } } } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( refBinding . sourceName , refBinding . sourceName ) ; relevance += computeRelevanceForExpectingType ( refBinding ) ; relevance += computeRelevanceForQualification ( false ) ; relevance += computeRelevanceForRestrictions ( accessibility ) ; if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { createTypeProposal ( refBinding , refBinding . qualifiedSourceName ( ) , IAccessRule . K_ACCESSIBLE , CharOperation . NO_CHAR , relevance , null , null , null , false ) ; } } } private void findSubMemberTypes ( char [ ] typeName , ReferenceBinding receiverType , Scope scope , SourceTypeBinding typeInvocation , boolean staticOnly , boolean staticFieldsAndMethodOnly , boolean fromStaticImport , ObjectVector typesFound ) { ReferenceBinding currentType = receiverType ; if ( typeName == null ) return ; if ( this . assistNodeIsSuperType && ! this . insideQualifiedReference && isForbidden ( currentType ) ) return ; findMemberTypes ( typeName , currentType . memberTypes ( ) , typesFound , receiverType , typeInvocation , staticOnly , staticFieldsAndMethodOnly , fromStaticImport , true , scope , null , null , null , false ) ; ReferenceBinding [ ] memberTypes = receiverType . memberTypes ( ) ; next : for ( int i = <NUM_LIT:0> ; i < memberTypes . length ; i ++ ) { if ( this . options . checkVisibility ) { if ( typeInvocation != null && ! memberTypes [ i ] . canBeSeenBy ( receiverType , typeInvocation ) ) { continue next ; } else if ( typeInvocation == null && ! memberTypes [ i ] . canBeSeenBy ( this . unitScope . fPackage ) ) { continue next ; } } findSubMemberTypes ( typeName , memberTypes [ i ] , scope , typeInvocation , staticOnly , staticFieldsAndMethodOnly , fromStaticImport , typesFound ) ; } } private void findTrueOrFalseKeywords ( char [ ] [ ] choices ) { if ( choices == null || choices . length == <NUM_LIT:0> ) return ; if ( this . expectedTypesPtr != <NUM_LIT:0> || this . expectedTypes [ <NUM_LIT:0> ] != TypeBinding . BOOLEAN ) return ; for ( int i = <NUM_LIT:0> ; i < choices . length ; i ++ ) { if ( CharOperation . equals ( choices [ i ] , Keywords . TRUE ) || CharOperation . equals ( choices [ i ] , Keywords . FALSE ) ) { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( CharOperation . NO_CHAR , choices [ i ] ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; relevance += computeRelevanceForExpectingType ( TypeBinding . BOOLEAN ) ; relevance += computeRelevanceForQualification ( false ) ; relevance += R_TRUE_OR_FALSE ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . KEYWORD ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . KEYWORD , this . actualCompletionPosition ) ; proposal . setName ( choices [ i ] ) ; proposal . setCompletion ( choices [ i ] ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } } private void findTypeParameters ( char [ ] token , Scope scope ) { if ( this . compilerOptions . sourceLevel < ClassFileConstants . JDK1_5 ) return ; TypeParameter [ ] typeParameters = null ; while ( scope != null ) { typeParameters = null ; switch ( scope . kind ) { case Scope . METHOD_SCOPE : MethodScope methodScope = ( MethodScope ) scope ; if ( methodScope . referenceContext instanceof MethodDeclaration ) { MethodDeclaration methodDeclaration = ( MethodDeclaration ) methodScope . referenceContext ; typeParameters = methodDeclaration . typeParameters ; } else if ( methodScope . referenceContext instanceof ConstructorDeclaration ) { ConstructorDeclaration methodDeclaration = ( ConstructorDeclaration ) methodScope . referenceContext ; typeParameters = methodDeclaration . typeParameters ; } break ; case Scope . CLASS_SCOPE : ClassScope classScope = ( ClassScope ) scope ; typeParameters = classScope . referenceContext . typeParameters ; break ; case Scope . COMPILATION_UNIT_SCOPE : return ; } if ( typeParameters != null ) { for ( int i = <NUM_LIT:0> ; i < typeParameters . length ; i ++ ) { int typeLength = token . length ; TypeParameter typeParameter = typeParameters [ i ] ; if ( typeParameter . binding == null ) continue ; if ( typeLength > typeParameter . name . length ) continue ; if ( ! CharOperation . prefixEquals ( token , typeParameter . name , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( token , typeParameter . name ) ) ) continue ; int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( token , typeParameter . name ) ; relevance += computeRelevanceForExpectingType ( typeParameter . type == null ? null : typeParameter . type . resolvedType ) ; relevance += computeRelevanceForQualification ( false ) ; relevance += computeRelevanceForException ( typeParameter . name ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { createTypeParameterProposal ( typeParameter , relevance ) ; } } } scope = scope . parent ; } } private void findTypesAndPackages ( char [ ] token , Scope scope , boolean proposeBaseTypes , boolean proposeVoidType , ObjectVector typesFound ) { if ( token == null ) return ; boolean allowingLongComputationProposals = isAllowingLongComputationProposals ( ) ; boolean proposeType = ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) || ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> && ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_TYPE_REF ) ) ; boolean proposeAllMemberTypes = ! this . assistNodeIsConstructor ; boolean proposeConstructor = allowingLongComputationProposals && this . assistNodeIsConstructor && ( ! isIgnored ( CompletionProposal . CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) || ! isIgnored ( CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) ) ; if ( ( proposeType || proposeConstructor ) && scope . enclosingSourceType ( ) != null ) { checkCancel ( ) ; findNestedTypes ( token , scope . enclosingSourceType ( ) , scope , proposeAllMemberTypes , typesFound ) ; if ( ! this . assistNodeIsInterface && ! this . assistNodeIsConstructor && ! this . assistNodeIsAnnotation && this . assistNodeInJavadoc == <NUM_LIT:0> ) { checkCancel ( ) ; findTypeParameters ( token , scope ) ; } } boolean isEmptyPrefix = token . length == <NUM_LIT:0> ; if ( ( proposeType || proposeConstructor ) && this . unitScope != null ) { ReferenceBinding outerInvocationType = scope . enclosingSourceType ( ) ; if ( outerInvocationType != null ) { ReferenceBinding temp = outerInvocationType . enclosingType ( ) ; while ( temp != null ) { outerInvocationType = temp ; temp = temp . enclosingType ( ) ; } } int typeLength = token . length ; SourceTypeBinding [ ] types = this . unitScope . topLevelTypes ; next : for ( int i = <NUM_LIT:0> , length = types . length ; i < length ; i ++ ) { checkCancel ( ) ; SourceTypeBinding sourceType = types [ i ] ; if ( isForbidden ( sourceType ) ) continue next ; if ( proposeAllMemberTypes && sourceType != outerInvocationType ) { findSubMemberTypes ( token , sourceType , scope , scope . enclosingSourceType ( ) , false , false , false , typesFound ) ; } if ( sourceType . sourceName == CompletionParser . FAKE_TYPE_NAME ) continue next ; if ( sourceType . sourceName == TypeConstants . PACKAGE_INFO_NAME ) continue next ; if ( typeLength > sourceType . sourceName . length ) continue next ; if ( ! CharOperation . prefixEquals ( token , sourceType . sourceName , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( token , sourceType . sourceName ) ) ) continue next ; if ( this . assistNodeIsAnnotation && ! hasPossibleAnnotationTarget ( sourceType , scope ) ) { continue next ; } for ( int j = typesFound . size ; -- j >= <NUM_LIT:0> ; ) { ReferenceBinding otherType = ( ReferenceBinding ) typesFound . elementAt ( j ) ; if ( sourceType == otherType ) continue next ; } typesFound . add ( sourceType ) ; if ( this . assistNodeIsExtendedType && sourceType . isFinal ( ) ) continue next ; if ( this . assistNodeIsInterfaceExcludingAnnotation && sourceType . isAnnotationType ( ) ) continue next ; if ( this . assistNodeIsClass ) { if ( ! sourceType . isClass ( ) ) continue next ; } else if ( this . assistNodeIsInterface ) { if ( ! sourceType . isInterface ( ) && ! sourceType . isAnnotationType ( ) ) continue next ; } else if ( this . assistNodeIsAnnotation ) { if ( ! sourceType . isAnnotationType ( ) ) continue next ; } else if ( this . assistNodeIsException ) { if ( ! sourceType . isClass ( ) ) continue next ; if ( isEmptyPrefix ) { if ( sourceType . findSuperTypeOriginatingFrom ( TypeIds . T_JavaLangThrowable , true ) == null ) { continue next ; } } } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( sourceType ) ; relevance += computeRelevanceForCaseMatching ( token , sourceType . sourceName ) ; relevance += computeRelevanceForExpectingType ( sourceType ) ; relevance += computeRelevanceForQualification ( false ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; if ( sourceType . isAnnotationType ( ) ) { relevance += computeRelevanceForAnnotation ( ) ; relevance += computeRelevanceForAnnotationTarget ( sourceType ) ; } else if ( sourceType . isInterface ( ) ) { relevance += computeRelevanceForInterface ( ) ; } else if ( sourceType . isClass ( ) ) { relevance += computeRelevanceForClass ( ) ; relevance += computeRelevanceForException ( sourceType . sourceName ) ; } this . noProposal = false ; if ( proposeType && ( ! this . assistNodeIsConstructor || ! allowingLongComputationProposals || hasStaticMemberTypes ( sourceType , null , this . unitScope ) || hasMemberTypesInEnclosingScope ( sourceType , scope ) ) || hasArrayTypeAsExpectedSuperTypes ( ) ) { char [ ] typeName = sourceType . sourceName ( ) ; createTypeProposal ( sourceType , typeName , IAccessRule . K_ACCESSIBLE , typeName , relevance , null , null , null , false ) ; } if ( proposeConstructor ) { findConstructorsOrAnonymousTypes ( sourceType , scope , FakeInvocationSite , false , relevance ) ; } } } if ( proposeConstructor && ! isEmptyPrefix ) { checkCancel ( ) ; findTypesFromImports ( token , scope , proposeType , typesFound ) ; } else if ( proposeType ) { checkCancel ( ) ; findTypesFromStaticImports ( token , scope , proposeAllMemberTypes , typesFound ) ; } if ( proposeConstructor ) { checkCancel ( ) ; findTypesFromExpectedTypes ( token , scope , typesFound , proposeType , proposeConstructor ) ; } if ( isEmptyPrefix && ! this . assistNodeIsAnnotation ) { if ( ! proposeConstructor ) { findTypesFromExpectedTypes ( token , scope , typesFound , proposeType , proposeConstructor ) ; } } else { if ( ! isEmptyPrefix && ! this . requestor . isIgnored ( CompletionProposal . KEYWORD ) ) { if ( this . assistNodeInJavadoc == <NUM_LIT:0> || ( this . assistNodeInJavadoc & CompletionOnJavadoc . BASE_TYPES ) != <NUM_LIT:0> ) { if ( proposeBaseTypes ) { if ( proposeVoidType ) { findKeywords ( token , BASE_TYPE_NAMES , false , false , false ) ; } else { findKeywords ( token , BASE_TYPE_NAMES_WITHOUT_VOID , false , false , false ) ; } } } } if ( proposeConstructor ) { int l = typesFound . size ( ) ; for ( int i = <NUM_LIT:0> ; i < l ; i ++ ) { ReferenceBinding typeFound = ( ReferenceBinding ) typesFound . elementAt ( i ) ; char [ ] fullyQualifiedTypeName = CharOperation . concat ( typeFound . qualifiedPackageName ( ) , typeFound . qualifiedSourceName ( ) , '<CHAR_LIT:.>' ) ; this . knownTypes . put ( fullyQualifiedTypeName , KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS ) ; } checkCancel ( ) ; this . foundConstructorsCount = <NUM_LIT:0> ; this . nameEnvironment . findConstructorDeclarations ( token , this . options . camelCaseMatch , this , this . monitor ) ; acceptConstructors ( scope ) ; } else if ( proposeType ) { int l = typesFound . size ( ) ; for ( int i = <NUM_LIT:0> ; i < l ; i ++ ) { ReferenceBinding typeFound = ( ReferenceBinding ) typesFound . elementAt ( i ) ; char [ ] fullyQualifiedTypeName = CharOperation . concat ( typeFound . qualifiedPackageName ( ) , typeFound . qualifiedSourceName ( ) , '<CHAR_LIT:.>' ) ; this . knownTypes . put ( fullyQualifiedTypeName , KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS ) ; } int searchFor = IJavaSearchConstants . TYPE ; if ( this . assistNodeIsClass || this . assistNodeIsException ) { searchFor = IJavaSearchConstants . CLASS ; } else if ( this . assistNodeIsInterfaceExcludingAnnotation ) { searchFor = IJavaSearchConstants . INTERFACE ; } else if ( this . assistNodeIsInterface ) { searchFor = IJavaSearchConstants . INTERFACE_AND_ANNOTATION ; } else if ( this . assistNodeIsEnum ) { searchFor = IJavaSearchConstants . ENUM ; } else if ( this . assistNodeIsAnnotation ) { searchFor = IJavaSearchConstants . ANNOTATION_TYPE ; } checkCancel ( ) ; this . foundTypesCount = <NUM_LIT:0> ; this . nameEnvironment . findTypes ( token , proposeAllMemberTypes , this . options . camelCaseMatch , searchFor , this , this . monitor ) ; acceptTypes ( scope ) ; } if ( ! isEmptyPrefix && ! this . requestor . isIgnored ( CompletionProposal . PACKAGE_REF ) ) { checkCancel ( ) ; this . nameEnvironment . findPackages ( token , this ) ; } } } private void findTypesAndSubpackages ( char [ ] token , PackageBinding packageBinding , Scope scope ) { boolean allowingLongComputationProposals = isAllowingLongComputationProposals ( ) ; boolean proposeType = ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) || ( ( this . assistNodeInJavadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> && ! this . requestor . isIgnored ( CompletionProposal . JAVADOC_TYPE_REF ) ) ; boolean proposeConstructor = allowingLongComputationProposals && this . assistNodeIsConstructor && ( ! isIgnored ( CompletionProposal . CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) || ! isIgnored ( CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) ) ; char [ ] qualifiedName = CharOperation . concatWith ( packageBinding . compoundName , token , '<CHAR_LIT:.>' ) ; if ( token == null || token . length == <NUM_LIT:0> ) { int length = qualifiedName . length ; System . arraycopy ( qualifiedName , <NUM_LIT:0> , qualifiedName = new char [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; qualifiedName [ length ] = '<CHAR_LIT:.>' ; } this . qualifiedCompletionToken = qualifiedName ; if ( ( proposeType || proposeConstructor ) && this . unitScope != null ) { int typeLength = qualifiedName . length ; SourceTypeBinding [ ] types = this . unitScope . topLevelTypes ; for ( int i = <NUM_LIT:0> , length = types . length ; i < length ; i ++ ) { checkCancel ( ) ; SourceTypeBinding sourceType = types [ i ] ; if ( isForbidden ( sourceType ) ) continue ; if ( this . assistNodeIsClass && sourceType . isInterface ( ) ) continue ; if ( this . assistNodeIsInterface && sourceType . isClass ( ) ) continue ; char [ ] qualifiedSourceTypeName = CharOperation . concatWith ( sourceType . compoundName , '<CHAR_LIT:.>' ) ; if ( sourceType . sourceName == CompletionParser . FAKE_TYPE_NAME ) continue ; if ( sourceType . sourceName == TypeConstants . PACKAGE_INFO_NAME ) continue ; if ( typeLength > qualifiedSourceTypeName . length ) continue ; if ( ! ( packageBinding == sourceType . getPackage ( ) ) ) continue ; if ( ! CharOperation . prefixEquals ( qualifiedName , qualifiedSourceTypeName , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( token , sourceType . sourceName ) ) ) continue ; if ( this . options . checkDeprecation && sourceType . isViewedAsDeprecated ( ) && ! scope . isDefinedInSameUnit ( sourceType ) ) continue ; if ( this . assistNodeIsExtendedType && sourceType . isFinal ( ) ) continue ; if ( this . assistNodeIsInterfaceExcludingAnnotation && sourceType . isAnnotationType ( ) ) continue ; int accessibility = IAccessRule . K_ACCESSIBLE ; if ( sourceType . hasRestrictedAccess ( ) ) { AccessRestriction accessRestriction = this . lookupEnvironment . getAccessRestriction ( sourceType ) ; if ( accessRestriction != null ) { switch ( accessRestriction . getProblemId ( ) ) { case IProblem . ForbiddenReference : if ( this . options . checkForbiddenReference ) { continue ; } accessibility = IAccessRule . K_NON_ACCESSIBLE ; break ; case IProblem . DiscouragedReference : if ( this . options . checkDiscouragedReference ) { continue ; } accessibility = IAccessRule . K_DISCOURAGED ; break ; } } } this . knownTypes . put ( CharOperation . concat ( sourceType . qualifiedPackageName ( ) , sourceType . sourceName ( ) , '<CHAR_LIT:.>' ) , KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS ) ; int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( sourceType ) ; relevance += computeRelevanceForCaseMatching ( qualifiedName , qualifiedSourceTypeName ) ; relevance += computeRelevanceForExpectingType ( sourceType ) ; relevance += computeRelevanceForQualification ( false ) ; relevance += computeRelevanceForRestrictions ( accessibility ) ; if ( sourceType . isAnnotationType ( ) ) { relevance += computeRelevanceForAnnotation ( ) ; } else if ( sourceType . isInterface ( ) ) { relevance += computeRelevanceForInterface ( ) ; } else if ( sourceType . isClass ( ) ) { relevance += computeRelevanceForClass ( ) ; relevance += computeRelevanceForException ( sourceType . sourceName ) ; } this . noProposal = false ; if ( proposeType && ( ! this . assistNodeIsConstructor || ! allowingLongComputationProposals || hasStaticMemberTypes ( sourceType , null , this . unitScope ) || hasMemberTypesInEnclosingScope ( sourceType , scope ) ) || hasArrayTypeAsExpectedSuperTypes ( ) ) { char [ ] typeName = sourceType . sourceName ( ) ; createTypeProposal ( sourceType , typeName , IAccessRule . K_ACCESSIBLE , typeName , relevance , null , null , null , false ) ; } if ( proposeConstructor ) { findConstructorsOrAnonymousTypes ( sourceType , scope , FakeInvocationSite , false , relevance ) ; } } } if ( proposeConstructor ) { checkCancel ( ) ; this . foundConstructorsCount = <NUM_LIT:0> ; this . nameEnvironment . findConstructorDeclarations ( qualifiedName , this . options . camelCaseMatch , this , this . monitor ) ; acceptConstructors ( scope ) ; } if ( proposeType ) { int searchFor = IJavaSearchConstants . TYPE ; if ( this . assistNodeIsClass ) { searchFor = IJavaSearchConstants . CLASS ; } else if ( this . assistNodeIsInterfaceExcludingAnnotation ) { searchFor = IJavaSearchConstants . INTERFACE ; } else if ( this . assistNodeIsInterface ) { searchFor = IJavaSearchConstants . INTERFACE_AND_ANNOTATION ; } else if ( this . assistNodeIsEnum ) { searchFor = IJavaSearchConstants . ENUM ; } else if ( this . assistNodeIsAnnotation ) { searchFor = IJavaSearchConstants . ANNOTATION_TYPE ; } checkCancel ( ) ; this . foundTypesCount = <NUM_LIT:0> ; this . nameEnvironment . findTypes ( qualifiedName , false , this . options . camelCaseMatch , searchFor , this , this . monitor ) ; acceptTypes ( scope ) ; } if ( ! this . requestor . isIgnored ( CompletionProposal . PACKAGE_REF ) ) { this . nameEnvironment . findPackages ( qualifiedName , this ) ; } } private void findTypesFromExpectedTypes ( char [ ] token , Scope scope , ObjectVector typesFound , boolean proposeType , boolean proposeConstructor ) { if ( this . expectedTypesPtr > - <NUM_LIT:1> ) { boolean allowingLongComputationProposals = isAllowingLongComputationProposals ( ) ; int typeLength = token == null ? <NUM_LIT:0> : token . length ; next : for ( int i = <NUM_LIT:0> ; i <= this . expectedTypesPtr ; i ++ ) { checkCancel ( ) ; if ( this . expectedTypes [ i ] instanceof ReferenceBinding ) { ReferenceBinding refBinding = ( ReferenceBinding ) this . expectedTypes [ i ] ; if ( typeLength > <NUM_LIT:0> ) { if ( typeLength > refBinding . sourceName . length ) continue next ; if ( ! CharOperation . prefixEquals ( token , refBinding . sourceName , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( token , refBinding . sourceName ) ) ) continue next ; } if ( refBinding . isTypeVariable ( ) && this . assistNodeIsConstructor ) { continue next ; } if ( this . options . checkDeprecation && refBinding . isViewedAsDeprecated ( ) && ! scope . isDefinedInSameUnit ( refBinding ) ) continue next ; int accessibility = IAccessRule . K_ACCESSIBLE ; if ( refBinding . hasRestrictedAccess ( ) ) { AccessRestriction accessRestriction = this . lookupEnvironment . getAccessRestriction ( refBinding ) ; if ( accessRestriction != null ) { switch ( accessRestriction . getProblemId ( ) ) { case IProblem . ForbiddenReference : if ( this . options . checkForbiddenReference ) { continue next ; } accessibility = IAccessRule . K_NON_ACCESSIBLE ; break ; case IProblem . DiscouragedReference : if ( this . options . checkDiscouragedReference ) { continue next ; } accessibility = IAccessRule . K_DISCOURAGED ; break ; } } } if ( isForbidden ( refBinding ) ) continue next ; for ( int j = <NUM_LIT:0> ; j < typesFound . size ( ) ; j ++ ) { ReferenceBinding typeFound = ( ReferenceBinding ) typesFound . elementAt ( j ) ; if ( typeFound == refBinding . erasure ( ) ) { continue next ; } } typesFound . add ( refBinding ) ; boolean inSameUnit = this . unitScope . isDefinedInSameUnit ( refBinding ) ; if ( ! inSameUnit || ( inSameUnit && refBinding . isMemberType ( ) ) ) { char [ ] packageName = refBinding . qualifiedPackageName ( ) ; char [ ] typeName = refBinding . sourceName ( ) ; char [ ] completionName = typeName ; boolean isQualified = false ; if ( ! this . insideQualifiedReference && ! refBinding . isMemberType ( ) ) { if ( mustQualifyType ( packageName , typeName , null , refBinding . modifiers ) ) { if ( packageName == null || packageName . length == <NUM_LIT:0> ) if ( this . unitScope != null && this . unitScope . fPackage . compoundName != CharOperation . NO_CHAR_CHAR ) continue next ; completionName = CharOperation . concat ( packageName , typeName , '<CHAR_LIT:.>' ) ; isQualified = true ; } } if ( this . assistNodeIsExtendedType && refBinding . isFinal ( ) ) continue next ; if ( this . assistNodeIsInterfaceExcludingAnnotation && refBinding . isAnnotationType ( ) ) continue next ; if ( this . assistNodeIsClass ) { if ( ! refBinding . isClass ( ) ) continue next ; } else if ( this . assistNodeIsInterface ) { if ( ! refBinding . isInterface ( ) && ! refBinding . isAnnotationType ( ) ) continue next ; } else if ( this . assistNodeIsAnnotation ) { if ( ! refBinding . isAnnotationType ( ) ) continue next ; } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( refBinding ) ; relevance += computeRelevanceForCaseMatching ( token , typeName ) ; relevance += computeRelevanceForExpectingType ( refBinding ) ; relevance += computeRelevanceForQualification ( isQualified ) ; relevance += computeRelevanceForRestrictions ( accessibility ) ; if ( refBinding . isClass ( ) ) { relevance += computeRelevanceForClass ( ) ; relevance += computeRelevanceForException ( typeName ) ; } else if ( refBinding . isEnum ( ) ) { relevance += computeRelevanceForEnum ( ) ; } else if ( refBinding . isInterface ( ) ) { relevance += computeRelevanceForInterface ( ) ; } if ( proposeType && ( ! this . assistNodeIsConstructor || ! allowingLongComputationProposals || hasStaticMemberTypes ( refBinding , scope . enclosingSourceType ( ) , this . unitScope ) ) || hasArrayTypeAsExpectedSuperTypes ( ) ) { this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . TYPE_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( packageName ) ; proposal . setSignature ( getSignature ( refBinding ) ) ; proposal . setPackageName ( packageName ) ; proposal . setTypeName ( typeName ) ; proposal . setCompletion ( completionName ) ; proposal . setFlags ( refBinding . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; proposal . setAccessibility ( accessibility ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } if ( proposeConstructor ) { findConstructorsOrAnonymousTypes ( refBinding , scope , FakeInvocationSite , isQualified , relevance ) ; } } } } } } private void findTypesFromImports ( char [ ] token , Scope scope , boolean proposeType , ObjectVector typesFound ) { ImportBinding [ ] importBindings = scope . compilationUnitScope ( ) . imports ; next : for ( int i = <NUM_LIT:0> ; i < importBindings . length ; i ++ ) { ImportBinding importBinding = importBindings [ i ] ; if ( importBinding . isValidBinding ( ) ) { Binding binding = importBinding . resolvedImport ; if ( binding != null && binding . isValidBinding ( ) ) { if ( importBinding . onDemand ) { if ( importBinding . isStatic ( ) ) { if ( ( binding . kind ( ) & Binding . TYPE ) != <NUM_LIT:0> ) { this . findMemberTypes ( token , ( ReferenceBinding ) binding , scope , scope . enclosingSourceType ( ) , true , false , true , true , false , null , typesFound , null , null , null , false ) ; } } } else { if ( ( binding . kind ( ) & Binding . TYPE ) != <NUM_LIT:0> ) { ReferenceBinding typeBinding = ( ReferenceBinding ) binding ; int typeLength = token . length ; if ( ! typeBinding . isStatic ( ) ) continue next ; if ( typeLength > typeBinding . sourceName . length ) continue next ; if ( ! CharOperation . prefixEquals ( token , typeBinding . sourceName , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( token , typeBinding . sourceName ) ) ) continue next ; int accessibility = IAccessRule . K_ACCESSIBLE ; if ( typeBinding . hasRestrictedAccess ( ) ) { AccessRestriction accessRestriction = this . lookupEnvironment . getAccessRestriction ( typeBinding ) ; if ( accessRestriction != null ) { switch ( accessRestriction . getProblemId ( ) ) { case IProblem . ForbiddenReference : if ( this . options . checkForbiddenReference ) { continue next ; } accessibility = IAccessRule . K_NON_ACCESSIBLE ; break ; case IProblem . DiscouragedReference : if ( this . options . checkDiscouragedReference ) { continue next ; } accessibility = IAccessRule . K_DISCOURAGED ; break ; } } } if ( typesFound . contains ( typeBinding ) ) continue next ; typesFound . add ( typeBinding ) ; if ( this . assistNodeIsExtendedType && typeBinding . isFinal ( ) ) continue ; if ( this . assistNodeIsInterfaceExcludingAnnotation && typeBinding . isAnnotationType ( ) ) continue ; if ( this . assistNodeIsClass ) { if ( ! typeBinding . isClass ( ) ) continue ; } else if ( this . assistNodeIsInterface ) { if ( ! typeBinding . isInterface ( ) && ! typeBinding . isAnnotationType ( ) ) continue ; } else if ( this . assistNodeIsAnnotation ) { if ( ! typeBinding . isAnnotationType ( ) ) continue ; } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( typeBinding ) ; relevance += computeRelevanceForCaseMatching ( token , typeBinding . sourceName ) ; relevance += computeRelevanceForExpectingType ( typeBinding ) ; relevance += computeRelevanceForQualification ( false ) ; relevance += computeRelevanceForRestrictions ( accessibility ) ; if ( typeBinding . isAnnotationType ( ) ) { relevance += computeRelevanceForAnnotation ( ) ; relevance += computeRelevanceForAnnotationTarget ( typeBinding ) ; } else if ( typeBinding . isInterface ( ) ) { relevance += computeRelevanceForInterface ( ) ; } else if ( typeBinding . isClass ( ) ) { relevance += computeRelevanceForClass ( ) ; relevance += computeRelevanceForException ( typeBinding . sourceName ) ; } if ( proposeType && ( hasStaticMemberTypes ( typeBinding , scope . enclosingSourceType ( ) , this . unitScope ) || hasArrayTypeAsExpectedSuperTypes ( ) ) ) { this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . TYPE_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( typeBinding . qualifiedPackageName ( ) ) ; proposal . setSignature ( getSignature ( typeBinding ) ) ; proposal . setPackageName ( typeBinding . qualifiedPackageName ( ) ) ; proposal . setTypeName ( typeBinding . qualifiedSourceName ( ) ) ; proposal . setCompletion ( typeBinding . sourceName ( ) ) ; proposal . setFlags ( typeBinding . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } findConstructorsOrAnonymousTypes ( typeBinding , scope , FakeInvocationSite , false , relevance ) ; } } } } } } private void findTypesFromStaticImports ( char [ ] token , Scope scope , boolean proposeAllMemberTypes , ObjectVector typesFound ) { ImportBinding [ ] importBindings = scope . compilationUnitScope ( ) . imports ; for ( int i = <NUM_LIT:0> ; i < importBindings . length ; i ++ ) { ImportBinding importBinding = importBindings [ i ] ; if ( importBinding . isValidBinding ( ) && importBinding . isStatic ( ) ) { Binding binding = importBinding . resolvedImport ; if ( binding != null && binding . isValidBinding ( ) ) { if ( importBinding . onDemand ) { if ( ( binding . kind ( ) & Binding . TYPE ) != <NUM_LIT:0> ) { this . findMemberTypes ( token , ( ReferenceBinding ) binding , scope , scope . enclosingSourceType ( ) , true , false , true , true , proposeAllMemberTypes , null , typesFound , null , null , null , false ) ; } } else { if ( ( binding . kind ( ) & Binding . TYPE ) != <NUM_LIT:0> ) { ReferenceBinding typeBinding = ( ReferenceBinding ) binding ; int typeLength = token . length ; if ( ! typeBinding . isStatic ( ) ) continue ; if ( typeLength > typeBinding . sourceName . length ) continue ; if ( ! CharOperation . prefixEquals ( token , typeBinding . sourceName , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( token , typeBinding . sourceName ) ) ) continue ; if ( typesFound . contains ( typeBinding ) ) continue ; typesFound . add ( typeBinding ) ; if ( this . assistNodeIsExtendedType && typeBinding . isFinal ( ) ) continue ; if ( this . assistNodeIsInterfaceExcludingAnnotation && typeBinding . isAnnotationType ( ) ) continue ; if ( this . assistNodeIsClass || this . assistNodeIsException ) { if ( ! typeBinding . isClass ( ) ) continue ; } else if ( this . assistNodeIsInterface ) { if ( ! typeBinding . isInterface ( ) && ! typeBinding . isAnnotationType ( ) ) continue ; } else if ( this . assistNodeIsAnnotation ) { if ( ! typeBinding . isAnnotationType ( ) ) continue ; } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( typeBinding ) ; relevance += computeRelevanceForCaseMatching ( token , typeBinding . sourceName ) ; relevance += computeRelevanceForExpectingType ( typeBinding ) ; relevance += computeRelevanceForQualification ( false ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; if ( typeBinding . isClass ( ) ) { relevance += computeRelevanceForClass ( ) ; relevance += computeRelevanceForException ( typeBinding . sourceName ) ; } else if ( typeBinding . isEnum ( ) ) { relevance += computeRelevanceForEnum ( ) ; } else if ( typeBinding . isInterface ( ) ) { relevance += computeRelevanceForInterface ( ) ; } this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . TYPE_REF , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( typeBinding . qualifiedPackageName ( ) ) ; proposal . setSignature ( getSignature ( typeBinding ) ) ; proposal . setPackageName ( typeBinding . qualifiedPackageName ( ) ) ; proposal . setTypeName ( typeBinding . qualifiedSourceName ( ) ) ; proposal . setCompletion ( typeBinding . sourceName ( ) ) ; proposal . setFlags ( typeBinding . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } } } } } } private void findUnresolvedReference ( int completedNameStart , int completedNameEnd , BlockScope scope , char [ ] [ ] discouragedNames ) { char [ ] [ ] foundNames = findUnresolvedReferenceBefore ( completedNameStart - <NUM_LIT:1> , completedNameEnd , scope , discouragedNames ) ; if ( foundNames != null && foundNames . length > <NUM_LIT:1> ) { int discouragedNamesLength = discouragedNames . length ; int foundNamesLength = foundNames . length ; int newLength = discouragedNamesLength + foundNamesLength ; System . arraycopy ( discouragedNames , <NUM_LIT:0> , discouragedNames = new char [ newLength ] [ ] , <NUM_LIT:0> , discouragedNamesLength ) ; System . arraycopy ( foundNames , <NUM_LIT:0> , discouragedNames , discouragedNamesLength , foundNamesLength ) ; } findUnresolvedReferenceAfter ( completedNameEnd + <NUM_LIT:1> , scope , discouragedNames ) ; } private char [ ] [ ] findUnresolvedReferenceAfter ( int from , BlockScope scope , final char [ ] [ ] discouragedNames ) { final ArrayList proposedNames = new ArrayList ( ) ; UnresolvedReferenceNameFinder . UnresolvedReferenceNameRequestor nameRequestor = new UnresolvedReferenceNameFinder . UnresolvedReferenceNameRequestor ( ) { public void acceptName ( char [ ] name ) { CompletionEngine . this . acceptUnresolvedName ( name ) ; proposedNames . add ( name ) ; } } ; ReferenceContext referenceContext = scope . referenceContext ( ) ; if ( referenceContext instanceof AbstractMethodDeclaration ) { AbstractMethodDeclaration md = ( AbstractMethodDeclaration ) referenceContext ; UnresolvedReferenceNameFinder nameFinder = new UnresolvedReferenceNameFinder ( this ) ; nameFinder . findAfter ( this . completionToken , md . scope , md . scope . classScope ( ) , from , md . bodyEnd , discouragedNames , nameRequestor ) ; } else if ( referenceContext instanceof TypeDeclaration ) { TypeDeclaration typeDeclaration = ( TypeDeclaration ) referenceContext ; FieldDeclaration [ ] fields = typeDeclaration . fields ; if ( fields != null ) { done : for ( int i = <NUM_LIT:0> ; i < fields . length ; i ++ ) { if ( fields [ i ] instanceof Initializer ) { Initializer initializer = ( Initializer ) fields [ i ] ; if ( initializer . block . sourceStart <= from && from < initializer . bodyEnd ) { UnresolvedReferenceNameFinder nameFinder = new UnresolvedReferenceNameFinder ( this ) ; nameFinder . findAfter ( this . completionToken , typeDeclaration . scope , typeDeclaration . scope , from , initializer . bodyEnd , discouragedNames , nameRequestor ) ; break done ; } } } } } int proposedNamesCount = proposedNames . size ( ) ; if ( proposedNamesCount > <NUM_LIT:0> ) { return ( char [ ] [ ] ) proposedNames . toArray ( new char [ proposedNamesCount ] [ ] ) ; } return null ; } private char [ ] [ ] findUnresolvedReferenceBefore ( int recordTo , int parseTo , BlockScope scope , final char [ ] [ ] discouragedNames ) { final ArrayList proposedNames = new ArrayList ( ) ; UnresolvedReferenceNameFinder . UnresolvedReferenceNameRequestor nameRequestor = new UnresolvedReferenceNameFinder . UnresolvedReferenceNameRequestor ( ) { public void acceptName ( char [ ] name ) { CompletionEngine . this . acceptUnresolvedName ( name ) ; proposedNames . add ( name ) ; } } ; BlockScope upperScope = scope ; while ( upperScope . enclosingMethodScope ( ) != null ) { upperScope = upperScope . enclosingMethodScope ( ) ; } ReferenceContext referenceContext = upperScope . referenceContext ( ) ; if ( referenceContext instanceof AbstractMethodDeclaration ) { AbstractMethodDeclaration md = ( AbstractMethodDeclaration ) referenceContext ; UnresolvedReferenceNameFinder nameFinder = new UnresolvedReferenceNameFinder ( this ) ; nameFinder . findBefore ( this . completionToken , md . scope , md . scope . classScope ( ) , md . bodyStart , recordTo , parseTo , discouragedNames , nameRequestor ) ; } else if ( referenceContext instanceof TypeDeclaration ) { TypeDeclaration typeDeclaration = ( TypeDeclaration ) referenceContext ; done : { FieldDeclaration [ ] fields = typeDeclaration . fields ; if ( fields != null ) { for ( int i = <NUM_LIT:0> ; i < fields . length ; i ++ ) { if ( fields [ i ] instanceof Initializer ) { Initializer initializer = ( Initializer ) fields [ i ] ; if ( initializer . block . sourceStart <= recordTo && recordTo < initializer . bodyEnd ) { UnresolvedReferenceNameFinder nameFinder = new UnresolvedReferenceNameFinder ( this ) ; nameFinder . findBefore ( this . completionToken , typeDeclaration . scope , typeDeclaration . scope , initializer . block . sourceStart , recordTo , parseTo , discouragedNames , nameRequestor ) ; break done ; } } } } } } int proposedNamesCount = proposedNames . size ( ) ; if ( proposedNamesCount > <NUM_LIT:0> ) { return ( char [ ] [ ] ) proposedNames . toArray ( new char [ proposedNamesCount ] [ ] ) ; } return null ; } private char [ ] [ ] findVariableFromUnresolvedReference ( LocalDeclaration variable , BlockScope scope , final char [ ] [ ] discouragedNames ) { final TypeReference type = variable . type ; if ( type != null && type . resolvedType != null && type . resolvedType . problemId ( ) == ProblemReasons . NoError ) { final ArrayList proposedNames = new ArrayList ( ) ; UnresolvedReferenceNameFinder . UnresolvedReferenceNameRequestor nameRequestor = new UnresolvedReferenceNameFinder . UnresolvedReferenceNameRequestor ( ) { public void acceptName ( char [ ] name ) { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( CompletionEngine . this . completionToken , name ) ; relevance += R_NAME_FIRST_PREFIX ; relevance += R_NAME_FIRST_SUFFIX ; relevance += R_NAME_LESS_NEW_CHARACTERS ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; CompletionEngine . this . noProposal = false ; if ( ! CompletionEngine . this . requestor . isIgnored ( CompletionProposal . VARIABLE_DECLARATION ) ) { InternalCompletionProposal proposal = CompletionEngine . this . createProposal ( CompletionProposal . VARIABLE_DECLARATION , CompletionEngine . this . actualCompletionPosition ) ; proposal . setSignature ( getSignature ( type . resolvedType ) ) ; proposal . setPackageName ( type . resolvedType . qualifiedPackageName ( ) ) ; proposal . setTypeName ( type . resolvedType . qualifiedSourceName ( ) ) ; proposal . setName ( name ) ; proposal . setCompletion ( name ) ; proposal . setReplaceRange ( CompletionEngine . this . startPosition - CompletionEngine . this . offset , CompletionEngine . this . endPosition - CompletionEngine . this . offset ) ; proposal . setTokenRange ( CompletionEngine . this . tokenStart - CompletionEngine . this . offset , CompletionEngine . this . tokenEnd - CompletionEngine . this . offset ) ; proposal . setRelevance ( relevance ) ; CompletionEngine . this . requestor . accept ( proposal ) ; if ( DEBUG ) { CompletionEngine . this . printDebug ( proposal ) ; } } proposedNames . add ( name ) ; } } ; ReferenceContext referenceContext = scope . referenceContext ( ) ; if ( referenceContext instanceof AbstractMethodDeclaration ) { AbstractMethodDeclaration md = ( AbstractMethodDeclaration ) referenceContext ; UnresolvedReferenceNameFinder nameFinder = new UnresolvedReferenceNameFinder ( this ) ; nameFinder . find ( this . completionToken , md , variable . declarationSourceEnd + <NUM_LIT:1> , discouragedNames , nameRequestor ) ; } else if ( referenceContext instanceof TypeDeclaration ) { TypeDeclaration typeDeclaration = ( TypeDeclaration ) referenceContext ; FieldDeclaration [ ] fields = typeDeclaration . fields ; if ( fields != null ) { done : for ( int i = <NUM_LIT:0> ; i < fields . length ; i ++ ) { if ( fields [ i ] instanceof Initializer ) { Initializer initializer = ( Initializer ) fields [ i ] ; if ( initializer . bodyStart <= variable . sourceStart && variable . sourceStart < initializer . bodyEnd ) { UnresolvedReferenceNameFinder nameFinder = new UnresolvedReferenceNameFinder ( this ) ; nameFinder . find ( this . completionToken , initializer , typeDeclaration . scope , variable . declarationSourceEnd + <NUM_LIT:1> , discouragedNames , nameRequestor ) ; break done ; } } } } } int proposedNamesCount = proposedNames . size ( ) ; if ( proposedNamesCount > <NUM_LIT:0> ) { return ( char [ ] [ ] ) proposedNames . toArray ( new char [ proposedNamesCount ] [ ] ) ; } } return null ; } private void findVariableName ( char [ ] token , char [ ] qualifiedPackageName , char [ ] qualifiedSourceName , char [ ] sourceName , final TypeBinding typeBinding , char [ ] [ ] discouragedNames , final char [ ] [ ] forbiddenNames , boolean forCollection , int dim , int kind ) { if ( sourceName == null || sourceName . length == <NUM_LIT:0> ) return ; final char [ ] displayName ; if ( ! forCollection ) { if ( dim > <NUM_LIT:0> ) { int l = qualifiedSourceName . length ; displayName = new char [ l + ( <NUM_LIT:2> * dim ) ] ; System . arraycopy ( qualifiedSourceName , <NUM_LIT:0> , displayName , <NUM_LIT:0> , l ) ; for ( int i = <NUM_LIT:0> ; i < dim ; i ++ ) { displayName [ l + ( i * <NUM_LIT:2> ) ] = '<CHAR_LIT:[>' ; displayName [ l + ( i * <NUM_LIT:2> ) + <NUM_LIT:1> ] = '<CHAR_LIT:]>' ; } } else { displayName = qualifiedSourceName ; } } else { displayName = typeBinding . qualifiedSourceName ( ) ; } final char [ ] t = token ; final char [ ] q = qualifiedPackageName ; INamingRequestor namingRequestor = new INamingRequestor ( ) { void accept ( char [ ] name , int prefixAndSuffixRelevance , int reusedCharacters ) { int l = forbiddenNames == null ? <NUM_LIT:0> : forbiddenNames . length ; for ( int i = <NUM_LIT:0> ; i < l ; i ++ ) { if ( CharOperation . equals ( forbiddenNames [ i ] , name , false ) ) return ; } if ( CharOperation . prefixEquals ( t , name , false ) ) { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForCaseMatching ( t , name ) ; relevance += prefixAndSuffixRelevance ; if ( reusedCharacters > <NUM_LIT:0> ) relevance += R_NAME_LESS_NEW_CHARACTERS ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; CompletionEngine . this . noProposal = false ; if ( ! CompletionEngine . this . requestor . isIgnored ( CompletionProposal . VARIABLE_DECLARATION ) ) { InternalCompletionProposal proposal = CompletionEngine . this . createProposal ( CompletionProposal . VARIABLE_DECLARATION , CompletionEngine . this . actualCompletionPosition ) ; proposal . setSignature ( getSignature ( typeBinding ) ) ; proposal . setPackageName ( q ) ; proposal . setTypeName ( displayName ) ; proposal . setName ( name ) ; proposal . setCompletion ( name ) ; proposal . setReplaceRange ( CompletionEngine . this . startPosition - CompletionEngine . this . offset , CompletionEngine . this . endPosition - CompletionEngine . this . offset ) ; proposal . setTokenRange ( CompletionEngine . this . tokenStart - CompletionEngine . this . offset , CompletionEngine . this . tokenEnd - CompletionEngine . this . offset ) ; proposal . setRelevance ( relevance ) ; CompletionEngine . this . requestor . accept ( proposal ) ; if ( DEBUG ) { CompletionEngine . this . printDebug ( proposal ) ; } } } } public void acceptNameWithoutPrefixAndSuffix ( char [ ] name , int reusedCharacters ) { accept ( name , <NUM_LIT:0> , reusedCharacters ) ; } public void acceptNameWithPrefix ( char [ ] name , boolean isFirstPrefix , int reusedCharacters ) { accept ( name , isFirstPrefix ? R_NAME_FIRST_PREFIX : R_NAME_PREFIX , reusedCharacters ) ; } public void acceptNameWithPrefixAndSuffix ( char [ ] name , boolean isFirstPrefix , boolean isFirstSuffix , int reusedCharacters ) { accept ( name , ( isFirstPrefix ? R_NAME_FIRST_PREFIX : R_NAME_PREFIX ) + ( isFirstSuffix ? R_NAME_FIRST_SUFFIX : R_NAME_SUFFIX ) , reusedCharacters ) ; } public void acceptNameWithSuffix ( char [ ] name , boolean isFirstSuffix , int reusedCharacters ) { accept ( name , isFirstSuffix ? R_NAME_FIRST_SUFFIX : R_NAME_SUFFIX , reusedCharacters ) ; } } ; InternalNamingConventions . suggestVariableNames ( kind , InternalNamingConventions . BK_SIMPLE_TYPE_NAME , qualifiedSourceName , this . javaProject , dim , token , discouragedNames , true , namingRequestor ) ; } private void findVariableName ( char [ ] token , char [ ] qualifiedPackageName , char [ ] qualifiedSourceName , char [ ] sourceName , final TypeBinding typeBinding , char [ ] [ ] discouragedNames , final char [ ] [ ] forbiddenNames , int dim , int kind ) { findVariableName ( token , qualifiedPackageName , qualifiedSourceName , sourceName , typeBinding , discouragedNames , forbiddenNames , false , dim , kind ) ; } private void findVariableNameForCollection ( char [ ] token , char [ ] qualifiedPackageName , char [ ] qualifiedSourceName , char [ ] sourceName , final TypeBinding typeBinding , char [ ] [ ] discouragedNames , final char [ ] [ ] forbiddenNames , int kind ) { findVariableName ( token , qualifiedPackageName , qualifiedSourceName , sourceName , typeBinding , discouragedNames , forbiddenNames , false , <NUM_LIT:1> , kind ) ; } private void findVariableNames ( char [ ] name , TypeReference type , char [ ] [ ] discouragedNames , char [ ] [ ] forbiddenNames , int kind ) { if ( type != null && type . resolvedType != null ) { TypeBinding tb = type . resolvedType ; if ( tb . problemId ( ) == ProblemReasons . NoError && tb != Scope . getBaseType ( VOID ) ) { findVariableName ( name , tb . leafComponentType ( ) . qualifiedPackageName ( ) , tb . leafComponentType ( ) . qualifiedSourceName ( ) , tb . leafComponentType ( ) . sourceName ( ) , tb , discouragedNames , forbiddenNames , type . dimensions ( ) , kind ) ; if ( tb . isParameterizedType ( ) && tb . findSuperTypeOriginatingFrom ( TypeIds . T_JavaUtilCollection , false ) != null ) { ParameterizedTypeBinding ptb = ( ( ParameterizedTypeBinding ) tb ) ; TypeBinding [ ] arguments = ptb . arguments ; if ( arguments != null && arguments . length == <NUM_LIT:1> ) { TypeBinding argument = arguments [ <NUM_LIT:0> ] ; findVariableNameForCollection ( name , argument . leafComponentType ( ) . qualifiedPackageName ( ) , argument . leafComponentType ( ) . qualifiedSourceName ( ) , argument . leafComponentType ( ) . sourceName ( ) , tb , discouragedNames , forbiddenNames , kind ) ; } } } } } private void findVariablesAndMethods ( char [ ] token , Scope scope , InvocationSite invocationSite , Scope invocationScope , boolean insideTypeAnnotation , boolean insideAnnotationAttribute ) { if ( token == null ) return ; boolean staticsOnly = false ; int tokenLength = token . length ; ObjectVector localsFound = new ObjectVector ( ) ; ObjectVector fieldsFound = new ObjectVector ( ) ; ObjectVector methodsFound = new ObjectVector ( ) ; Scope currentScope = scope ; if ( ! this . requestor . isIgnored ( CompletionProposal . LOCAL_VARIABLE_REF ) ) { done1 : while ( true ) { switch ( currentScope . kind ) { case Scope . METHOD_SCOPE : MethodScope methodScope = ( MethodScope ) currentScope ; staticsOnly |= methodScope . isStatic | methodScope . isConstructorCall ; case Scope . BLOCK_SCOPE : BlockScope blockScope = ( BlockScope ) currentScope ; next : for ( int i = <NUM_LIT:0> , length = blockScope . locals . length ; i < length ; i ++ ) { LocalVariableBinding local = blockScope . locals [ i ] ; if ( local == null ) break next ; if ( tokenLength > local . name . length ) continue next ; if ( ! CharOperation . prefixEquals ( token , local . name , false ) && ! ( this . options . camelCaseMatch && CharOperation . camelCaseMatch ( token , local . name ) ) ) continue next ; if ( local . isSecret ( ) ) continue next ; if ( local . declaration . initialization != null ) { continue next ; } if ( this . assistNodeIsInsideCase ) { if ( local . isFinal ( ) ) { if ( this . assistNodeIsString ) { if ( local . type == null || local . type . id != TypeIds . T_JavaLangString ) continue next ; } else if ( ! ( local . type instanceof BaseTypeBinding ) ) continue next ; } else { continue next ; } } int ptr = this . uninterestingBindingsPtr ; while ( ptr >= <NUM_LIT:0> ) { if ( this . uninterestingBindings [ ptr ] == local ) { continue next ; } ptr -- ; } for ( int f = <NUM_LIT:0> ; f < localsFound . size ; f ++ ) { LocalVariableBinding otherLocal = ( LocalVariableBinding ) localsFound . elementAt ( f ) ; if ( CharOperation . equals ( otherLocal . name , local . name , true ) ) continue next ; } localsFound . add ( local ) ; int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( local ) ; relevance += computeRelevanceForCaseMatching ( token , local . name ) ; relevance += computeRelevanceForExpectingType ( local . type ) ; relevance += computeRelevanceForEnumConstant ( local . type ) ; relevance += computeRelevanceForQualification ( false ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; relevance += computeRelevanceForFinal ( this . assistNodeIsInsideCase , local . isFinal ( ) ) ; this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . LOCAL_VARIABLE_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . LOCAL_VARIABLE_REF , this . actualCompletionPosition ) ; proposal . setSignature ( local . type == null ? createTypeSignature ( CharOperation . NO_CHAR , local . declaration . type . toString ( ) . toCharArray ( ) ) : getSignature ( local . type ) ) ; if ( local . type == null ) { proposal . setTypeName ( local . declaration . type . toString ( ) . toCharArray ( ) ) ; } else { proposal . setPackageName ( local . type . qualifiedPackageName ( ) ) ; proposal . setTypeName ( local . type . qualifiedSourceName ( ) ) ; } proposal . setName ( local . name ) ; proposal . setCompletion ( local . name ) ; proposal . setFlags ( local . modifiers ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } break ; case Scope . COMPILATION_UNIT_SCOPE : break done1 ; } currentScope = currentScope . parent ; } } checkCancel ( ) ; boolean proposeField = ! this . requestor . isIgnored ( CompletionProposal . FIELD_REF ) ; boolean proposeMethod = ! this . requestor . isIgnored ( CompletionProposal . METHOD_REF ) ; staticsOnly = false ; currentScope = scope ; if ( proposeField || proposeMethod ) { done2 : while ( true ) { switch ( currentScope . kind ) { case Scope . METHOD_SCOPE : MethodScope methodScope = ( MethodScope ) currentScope ; staticsOnly |= methodScope . isStatic | methodScope . isConstructorCall ; break ; case Scope . CLASS_SCOPE : ClassScope classScope = ( ClassScope ) currentScope ; SourceTypeBinding enclosingType = classScope . referenceContext . binding ; if ( ! insideTypeAnnotation ) { if ( proposeField ) { findFields ( token , enclosingType , classScope , fieldsFound , localsFound , staticsOnly , invocationSite , invocationScope , true , true , null , null , null , false , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; } if ( proposeMethod && ! insideAnnotationAttribute ) { findMethods ( token , null , null , enclosingType , classScope , methodsFound , staticsOnly , false , invocationSite , invocationScope , true , false , true , null , null , null , false , null , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; } } staticsOnly |= enclosingType . isStatic ( ) ; insideTypeAnnotation = false ; break ; case Scope . COMPILATION_UNIT_SCOPE : break done2 ; } currentScope = currentScope . parent ; } checkCancel ( ) ; findFieldsAndMethodsFromStaticImports ( token , scope , invocationSite , invocationScope , false , insideAnnotationAttribute , localsFound , fieldsFound , methodsFound , proposeField , proposeMethod ) ; if ( this . assistNodeInJavadoc == <NUM_LIT:0> ) { checkCancel ( ) ; findFieldsAndMethodsFromFavorites ( token , scope , invocationSite , invocationScope , localsFound , fieldsFound , methodsFound ) ; } checkCancel ( ) ; findEnumConstantsFromExpectedTypes ( token , invocationScope , fieldsFound ) ; } } private char [ ] getCompletedTypeSignature ( ReferenceBinding referenceBinding ) { char [ ] result = null ; StringBuffer sig = new StringBuffer ( <NUM_LIT:10> ) ; if ( ! referenceBinding . isMemberType ( ) ) { char [ ] typeSig = referenceBinding . genericTypeSignature ( ) ; sig . append ( typeSig , <NUM_LIT:0> , typeSig . length ) ; } else if ( ! this . insideQualifiedReference ) { if ( referenceBinding . isStatic ( ) ) { char [ ] typeSig = referenceBinding . signature ( ) ; sig . append ( typeSig , <NUM_LIT:0> , typeSig . length - <NUM_LIT:1> ) ; TypeVariableBinding [ ] typeVariables = referenceBinding . typeVariables ( ) ; if ( typeVariables != Binding . NO_TYPE_VARIABLES ) { sig . append ( Signature . C_GENERIC_START ) ; for ( int i = <NUM_LIT:0> , length = typeVariables . length ; i < length ; i ++ ) { sig . append ( typeVariables [ i ] . genericTypeSignature ( ) ) ; } sig . append ( Signature . C_GENERIC_END ) ; } sig . append ( Signature . C_SEMICOLON ) ; } else { char [ ] typeSig = referenceBinding . genericTypeSignature ( ) ; sig . append ( typeSig , <NUM_LIT:0> , typeSig . length ) ; } } else { ReferenceBinding enclosingType = referenceBinding . enclosingType ( ) ; if ( enclosingType . isParameterizedType ( ) ) { char [ ] typeSig = referenceBinding . genericTypeSignature ( ) ; sig . append ( typeSig , <NUM_LIT:0> , typeSig . length - <NUM_LIT:1> ) ; TypeVariableBinding [ ] typeVariables = referenceBinding . typeVariables ( ) ; if ( typeVariables != Binding . NO_TYPE_VARIABLES ) { sig . append ( Signature . C_GENERIC_START ) ; for ( int i = <NUM_LIT:0> , length = typeVariables . length ; i < length ; i ++ ) { sig . append ( typeVariables [ i ] . genericTypeSignature ( ) ) ; } sig . append ( Signature . C_GENERIC_END ) ; } } else { char [ ] typeSig = referenceBinding . signature ( ) ; sig . append ( typeSig , <NUM_LIT:0> , typeSig . length - <NUM_LIT:1> ) ; if ( referenceBinding . isStatic ( ) ) { TypeVariableBinding [ ] typeVariables = referenceBinding . typeVariables ( ) ; if ( typeVariables != Binding . NO_TYPE_VARIABLES ) { sig . append ( Signature . C_GENERIC_START ) ; for ( int i = <NUM_LIT:0> , length = typeVariables . length ; i < length ; i ++ ) { sig . append ( typeVariables [ i ] . genericTypeSignature ( ) ) ; } sig . append ( Signature . C_GENERIC_END ) ; } } } sig . append ( Signature . C_SEMICOLON ) ; } int sigLength = sig . length ( ) ; result = new char [ sigLength ] ; sig . getChars ( <NUM_LIT:0> , sigLength , result , <NUM_LIT:0> ) ; result = CharOperation . replaceOnCopy ( result , '<CHAR_LIT:/>' , Signature . C_DOT ) ; return result ; } private ImportBinding [ ] getFavoriteReferenceBindings ( Scope scope ) { if ( this . favoriteReferenceBindings != null ) return this . favoriteReferenceBindings ; String [ ] favoriteReferences = this . requestor . getFavoriteReferences ( ) ; if ( favoriteReferences == null || favoriteReferences . length == <NUM_LIT:0> ) return null ; ImportBinding [ ] resolvedImports = new ImportBinding [ favoriteReferences . length ] ; int count = <NUM_LIT:0> ; next : for ( int i = <NUM_LIT:0> ; i < favoriteReferences . length ; i ++ ) { String favoriteReference = favoriteReferences [ i ] ; int length ; if ( favoriteReference == null || ( length = favoriteReference . length ( ) ) == <NUM_LIT:0> ) continue next ; boolean onDemand = favoriteReference . charAt ( length - <NUM_LIT:1> ) == '<CHAR_LIT>' ; char [ ] [ ] compoundName = CharOperation . splitOn ( '<CHAR_LIT:.>' , favoriteReference . toCharArray ( ) ) ; if ( onDemand ) { compoundName = CharOperation . subarray ( compoundName , <NUM_LIT:0> , compoundName . length - <NUM_LIT:1> ) ; } for ( int j = <NUM_LIT:0> ; j < count ; j ++ ) { ImportReference f = resolvedImports [ j ] . reference ; if ( CharOperation . equals ( f . tokens , compoundName ) ) continue next ; if ( ! onDemand && ( ( f . bits & ASTNode . OnDemand ) == <NUM_LIT:0> ) ) { if ( CharOperation . equals ( f . tokens [ f . tokens . length - <NUM_LIT:1> ] , compoundName [ compoundName . length - <NUM_LIT:1> ] ) ) continue next ; } } boolean isStatic = true ; ImportReference importReference = new ImportReference ( compoundName , new long [ compoundName . length ] , onDemand , isStatic ? ClassFileConstants . AccStatic : ClassFileConstants . AccDefault ) ; Binding importBinding = this . unitScope . findImport ( compoundName , isStatic , onDemand ) ; if ( ! importBinding . isValidBinding ( ) ) { continue next ; } if ( importBinding instanceof PackageBinding ) { continue next ; } resolvedImports [ count ++ ] = new ImportBinding ( compoundName , onDemand , importBinding , importReference ) ; } if ( resolvedImports . length > count ) System . arraycopy ( resolvedImports , <NUM_LIT:0> , resolvedImports = new ImportBinding [ count ] , <NUM_LIT:0> , count ) ; return this . favoriteReferenceBindings = resolvedImports ; } private INameEnvironment getNoCacheNameEnvironment ( ) { if ( this . noCacheNameEnvironment == null ) { JavaModelManager . getJavaModelManager ( ) . cacheZipFiles ( this ) ; this . noCacheNameEnvironment = new JavaSearchNameEnvironment ( this . javaProject , this . owner == null ? null : JavaModelManager . getJavaModelManager ( ) . getWorkingCopies ( this . owner , true ) ) ; } return this . noCacheNameEnvironment ; } public AssistParser getParser ( ) { return this . parser ; } protected boolean hasArrayTypeAsExpectedSuperTypes ( ) { if ( ( this . expectedTypesFilter & ~ SUBTYPE ) != <NUM_LIT:0> ) return false ; if ( ! this . hasComputedExpectedArrayTypes ) { if ( this . expectedTypes != null ) { done : for ( int i = <NUM_LIT:0> ; i <= this . expectedTypesPtr ; i ++ ) { if ( this . expectedTypes [ i ] . isArrayType ( ) ) { this . hasExpectedArrayTypes = true ; break done ; } } } this . hasComputedExpectedArrayTypes = true ; } return this . hasExpectedArrayTypes ; } protected boolean hasPossibleAnnotationTarget ( TypeBinding typeBinding , Scope scope ) { if ( this . targetedElement == TagBits . AnnotationForPackage ) { long target = typeBinding . getAnnotationTagBits ( ) & TagBits . AnnotationTargetMASK ; if ( target != <NUM_LIT:0> && ( target & TagBits . AnnotationForPackage ) == <NUM_LIT:0> ) { return false ; } } else if ( ( this . targetedElement & TagBits . AnnotationForType ) != <NUM_LIT:0> ) { if ( scope . parent != null && scope . parent . parent != null && scope . parent . referenceContext ( ) instanceof CompletionOnAnnotationOfType && scope . parent . parent instanceof CompilationUnitScope ) { long target = typeBinding . getAnnotationTagBits ( ) & TagBits . AnnotationTargetMASK ; if ( ( this . targetedElement & TagBits . AnnotationForAnnotationType ) != <NUM_LIT:0> ) { if ( target != <NUM_LIT:0> && ( target & ( TagBits . AnnotationForType | TagBits . AnnotationForAnnotationType ) ) == <NUM_LIT:0> ) { return false ; } } else { if ( target != <NUM_LIT:0> && ( target & ( TagBits . AnnotationForType ) ) == <NUM_LIT:0> ) { return false ; } } } } return true ; } private char [ ] inlineTagCompletion ( char [ ] completionName , char [ ] inlineTag ) { int tagLength = inlineTag . length ; int completionLength = completionName . length ; int inlineLength = <NUM_LIT:2> + tagLength + <NUM_LIT:1> + completionLength + <NUM_LIT:1> ; char [ ] inlineCompletion = new char [ inlineLength ] ; inlineCompletion [ <NUM_LIT:0> ] = '<CHAR_LIT>' ; inlineCompletion [ <NUM_LIT:1> ] = '<CHAR_LIT>' ; System . arraycopy ( inlineTag , <NUM_LIT:0> , inlineCompletion , <NUM_LIT:2> , tagLength ) ; inlineCompletion [ tagLength + <NUM_LIT:2> ] = '<CHAR_LIT:U+0020>' ; System . arraycopy ( completionName , <NUM_LIT:0> , inlineCompletion , tagLength + <NUM_LIT:3> , completionLength ) ; inlineCompletion [ inlineLength - <NUM_LIT:1> ] = '<CHAR_LIT:}>' ; return inlineCompletion ; } private boolean isAllowingLongComputationProposals ( ) { return this . monitor != null ; } private boolean isForbidden ( Binding binding ) { for ( int i = <NUM_LIT:0> ; i <= this . forbbidenBindingsPtr ; i ++ ) { if ( this . forbbidenBindings [ i ] == binding ) { return true ; } } return false ; } private boolean isForbiddenType ( char [ ] givenPkgName , char [ ] givenTypeName , char [ ] [ ] enclosingTypeNames ) { char [ ] fullTypeName = CharOperation . concatWith ( enclosingTypeNames , givenTypeName , '<CHAR_LIT:.>' ) ; for ( int i = <NUM_LIT:0> ; i <= this . forbbidenBindingsPtr ; i ++ ) { if ( this . forbbidenBindings [ i ] instanceof TypeBinding ) { TypeBinding typeBinding = ( TypeBinding ) this . forbbidenBindings [ i ] ; char [ ] currPkgName = typeBinding . qualifiedPackageName ( ) ; if ( CharOperation . equals ( givenPkgName , currPkgName ) ) { char [ ] currTypeName = typeBinding . qualifiedSourceName ( ) ; if ( CharOperation . equals ( fullTypeName , currTypeName ) ) { return true ; } } } } if ( this . compilerOptions . sourceLevel >= ClassFileConstants . JDK1_5 && CharOperation . endsWith ( givenPkgName , DOT_ENUM ) ) { return true ; } return false ; } private boolean isIgnored ( int kind ) { return this . requestor . isIgnored ( kind ) ; } boolean isIgnored ( int kind , boolean missingTypes ) { return this . requestor . isIgnored ( kind ) || ( missingTypes && ! this . requestor . isAllowingRequiredProposals ( kind , CompletionProposal . TYPE_REF ) ) ; } private boolean isIgnored ( int kind , int requiredProposalKind ) { return this . requestor . isIgnored ( kind ) || ! this . requestor . isAllowingRequiredProposals ( kind , requiredProposalKind ) ; } private boolean isValidParent ( ASTNode parent , ASTNode node , Scope scope ) { if ( parent instanceof ParameterizedSingleTypeReference ) { ParameterizedSingleTypeReference ref = ( ParameterizedSingleTypeReference ) parent ; TypeVariableBinding [ ] typeVariables = ( ( ReferenceBinding ) ref . resolvedType ) . typeVariables ( ) ; int length = ref . typeArguments == null ? <NUM_LIT:0> : ref . typeArguments . length ; int nodeIndex = - <NUM_LIT:1> ; for ( int i = length - <NUM_LIT:1> ; i > - <NUM_LIT:1> ; i -- ) { if ( node == ref . typeArguments [ i ] ) { nodeIndex = i ; break ; } } if ( nodeIndex > - <NUM_LIT:1> && ( typeVariables == null || typeVariables . length < nodeIndex + <NUM_LIT:1> ) ) { TypeBinding [ ] typeBindings = new TypeBinding [ nodeIndex + <NUM_LIT:1> ] ; for ( int i = <NUM_LIT:0> ; i < nodeIndex ; i ++ ) { typeBindings [ i ] = ref . typeArguments [ i ] . resolvedType ; } typeBindings [ nodeIndex ] = scope . getJavaLangObject ( ) ; if ( typeVariables == null || typeVariables . length == <NUM_LIT:0> ) { scope . problemReporter ( ) . nonGenericTypeCannotBeParameterized ( <NUM_LIT:0> , ref , ref . resolvedType , typeBindings ) ; } else { scope . problemReporter ( ) . incorrectArityForParameterizedType ( ref , ref . resolvedType , typeBindings ) ; } return false ; } } else if ( parent instanceof ParameterizedQualifiedTypeReference ) { ParameterizedQualifiedTypeReference ref = ( ParameterizedQualifiedTypeReference ) parent ; TypeVariableBinding [ ] typeVariables = ( ( ReferenceBinding ) ref . resolvedType ) . typeVariables ( ) ; TypeReference [ ] [ ] arguments = ref . typeArguments ; int iLength = arguments == null ? <NUM_LIT:0> : arguments . length ; for ( int i = <NUM_LIT:0> ; i < iLength ; i ++ ) { int jLength = arguments [ i ] == null ? <NUM_LIT:0> : arguments [ i ] . length ; for ( int j = <NUM_LIT:0> ; j < jLength ; j ++ ) { if ( arguments [ i ] [ j ] == node && ( typeVariables == null || typeVariables . length <= j ) ) { TypeBinding [ ] typeBindings = new TypeBinding [ j + <NUM_LIT:1> ] ; for ( int k = <NUM_LIT:0> ; k < j ; k ++ ) { typeBindings [ k ] = ref . typeArguments [ i ] [ k ] . resolvedType ; } typeBindings [ j ] = scope . getJavaLangObject ( ) ; if ( typeVariables == null || typeVariables . length == <NUM_LIT:0> ) { scope . problemReporter ( ) . nonGenericTypeCannotBeParameterized ( <NUM_LIT:0> , ref , ref . resolvedType , typeBindings ) ; } else { scope . problemReporter ( ) . incorrectArityForParameterizedType ( ref , ref . resolvedType , typeBindings ) ; } return false ; } } } } return true ; } private boolean mustQualifyType ( ReferenceBinding type , char [ ] packageName , Scope scope ) { if ( ! mustQualifyType ( packageName , type . sourceName ( ) , type . isMemberType ( ) ? type . enclosingType ( ) . qualifiedSourceName ( ) : null , type . modifiers ) ) { return false ; } ReferenceBinding enclosingType = scope . enclosingSourceType ( ) ; while ( enclosingType != null ) { ReferenceBinding currentType = enclosingType ; while ( currentType != null ) { ReferenceBinding [ ] memberTypes = currentType . memberTypes ( ) ; if ( memberTypes != null ) { for ( int i = <NUM_LIT:0> ; i < memberTypes . length ; i ++ ) { if ( CharOperation . equals ( memberTypes [ i ] . sourceName , type . sourceName ( ) ) && memberTypes [ i ] . canBeSeenBy ( scope ) ) { return memberTypes [ i ] != type ; } } } currentType = currentType . superclass ( ) ; } enclosingType = enclosingType . enclosingType ( ) ; } return true ; } private Initializer parseSnippeInitializer ( char [ ] snippet , int position , char [ ] [ ] localVariableTypeNames , char [ ] [ ] localVariableNames , int [ ] localVariableModifiers , boolean isStatic ) { StringBuffer prefix = new StringBuffer ( ) ; prefix . append ( "<STR_LIT>" ) ; if ( isStatic ) { prefix . append ( "<STR_LIT>" ) ; } prefix . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < localVariableTypeNames . length ; i ++ ) { ASTNode . printModifiers ( localVariableModifiers [ i ] , prefix ) ; prefix . append ( '<CHAR_LIT:U+0020>' ) ; prefix . append ( localVariableTypeNames [ i ] ) ; prefix . append ( '<CHAR_LIT:U+0020>' ) ; prefix . append ( localVariableNames [ i ] ) ; prefix . append ( '<CHAR_LIT:;>' ) ; } char [ ] fakeSource = CharOperation . concat ( prefix . toString ( ) . toCharArray ( ) , snippet , "<STR_LIT>" . toCharArray ( ) ) ; this . offset = prefix . length ( ) ; String encoding = this . compilerOptions . defaultEncoding ; BasicCompilationUnit fakeUnit = new BasicCompilationUnit ( fakeSource , null , "<STR_LIT>" , encoding ) ; this . actualCompletionPosition = prefix . length ( ) + position - <NUM_LIT:1> ; CompilationResult fakeResult = new CompilationResult ( fakeUnit , <NUM_LIT:1> , <NUM_LIT:1> , this . compilerOptions . maxProblemsPerUnit ) ; CompilationUnitDeclaration fakeAST = this . parser . dietParse ( fakeUnit , fakeResult , this . actualCompletionPosition ) ; parseBlockStatements ( fakeAST , this . actualCompletionPosition ) ; return ( Initializer ) fakeAST . types [ <NUM_LIT:0> ] . fields [ <NUM_LIT:0> ] ; } protected void printDebug ( CategorizedProblem error ) { if ( CompletionEngine . DEBUG ) { System . out . print ( "<STR_LIT>" ) ; System . out . print ( error ) ; System . out . println ( "<STR_LIT:)>" ) ; } } protected void printDebug ( CompletionProposal proposal ) { StringBuffer buffer = new StringBuffer ( ) ; printDebug ( proposal , <NUM_LIT:0> , buffer ) ; System . out . println ( buffer . toString ( ) ) ; } private void printDebug ( CompletionProposal proposal , int tab , StringBuffer buffer ) { printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) ; switch ( proposal . getKind ( ) ) { case CompletionProposal . ANONYMOUS_CLASS_DECLARATION : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . FIELD_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . FIELD_REF_WITH_CASTED_RECEIVER : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . KEYWORD : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . LABEL_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . LOCAL_VARIABLE_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . METHOD_DECLARATION : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . METHOD_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . METHOD_REF_WITH_CASTED_RECEIVER : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . PACKAGE_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . TYPE_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . VARIABLE_DECLARATION : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . POTENTIAL_METHOD_DECLARATION : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . METHOD_NAME_REFERENCE : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . ANNOTATION_ATTRIBUTE_REF : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . FIELD_IMPORT : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . METHOD_IMPORT : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . TYPE_IMPORT : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . CONSTRUCTOR_INVOCATION : buffer . append ( "<STR_LIT>" ) ; break ; case CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION : buffer . append ( "<STR_LIT>" ) ; break ; default : buffer . append ( "<STR_LIT>" ) ; break ; } buffer . append ( "<STR_LIT>" ) ; printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) . append ( proposal . getCompletion ( ) == null ? "<STR_LIT:null>" . toCharArray ( ) : proposal . getCompletion ( ) ) . append ( "<STR_LIT>" ) ; printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) . append ( proposal . getDeclarationSignature ( ) == null ? "<STR_LIT:null>" . toCharArray ( ) : proposal . getDeclarationSignature ( ) ) . append ( "<STR_LIT>" ) ; printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) . append ( proposal . getDeclarationKey ( ) == null ? "<STR_LIT:null>" . toCharArray ( ) : proposal . getDeclarationKey ( ) ) . append ( "<STR_LIT>" ) ; printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) . append ( proposal . getSignature ( ) == null ? "<STR_LIT:null>" . toCharArray ( ) : proposal . getSignature ( ) ) . append ( "<STR_LIT>" ) ; printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) . append ( proposal . getKey ( ) == null ? "<STR_LIT:null>" . toCharArray ( ) : proposal . getKey ( ) ) . append ( "<STR_LIT>" ) ; printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) . append ( proposal . getName ( ) == null ? "<STR_LIT:null>" . toCharArray ( ) : proposal . getName ( ) ) . append ( "<STR_LIT>" ) ; printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) ; int flags = proposal . getFlags ( ) ; buffer . append ( Flags . toString ( flags ) ) ; if ( ( flags & Flags . AccInterface ) != <NUM_LIT:0> ) buffer . append ( "<STR_LIT>" ) ; if ( ( flags & Flags . AccEnum ) != <NUM_LIT:0> ) buffer . append ( "<STR_LIT>" ) ; buffer . append ( "<STR_LIT>" ) ; CompletionProposal [ ] proposals = proposal . getRequiredProposals ( ) ; if ( proposals != null ) { printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < proposals . length ; i ++ ) { buffer . append ( "<STR_LIT:n>" ) ; printDebug ( proposals [ i ] , tab + <NUM_LIT:2> , buffer ) ; } printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) ; } printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) . append ( proposal . getCompletionLocation ( ) ) . append ( "<STR_LIT>" ) ; int start = proposal . getReplaceStart ( ) ; int end = proposal . getReplaceEnd ( ) ; printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) . append ( start ) . append ( "<STR_LIT:]>" ) ; buffer . append ( "<STR_LIT>" ) . append ( end ) . append ( "<STR_LIT>" ) ; start = proposal . getTokenStart ( ) ; end = proposal . getTokenEnd ( ) ; printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) . append ( start ) . append ( "<STR_LIT:]>" ) ; buffer . append ( "<STR_LIT>" ) . append ( end ) . append ( "<STR_LIT>" ) ; if ( this . source != null ) { printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) . append ( this . source , start , end - start ) . append ( "<STR_LIT>" ) ; } printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) . append ( proposal . getTokenStart ( ) ) . append ( "<STR_LIT:]>" ) ; buffer . append ( "<STR_LIT>" ) . append ( proposal . getTokenEnd ( ) ) . append ( "<STR_LIT>" ) ; printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) . append ( proposal . getRelevance ( ) ) . append ( "<STR_LIT>" ) ; printDebugTab ( tab , buffer ) ; buffer . append ( "<STR_LIT>" ) ; } private void printDebugTab ( int tab , StringBuffer buffer ) { for ( int i = <NUM_LIT:0> ; i < tab ; i ++ ) { buffer . append ( '<STR_LIT:\t>' ) ; } } private void proposeConstructor ( AcceptedConstructor deferredProposal , Scope scope ) { if ( deferredProposal . proposeConstructor ) { proposeConstructor ( deferredProposal . simpleTypeName , deferredProposal . parameterCount , deferredProposal . signature , deferredProposal . parameterTypes , deferredProposal . parameterNames , deferredProposal . modifiers , deferredProposal . packageName , deferredProposal . typeModifiers , deferredProposal . accessibility , deferredProposal . simpleTypeName , deferredProposal . fullyQualifiedName , deferredProposal . mustBeQualified , scope , deferredProposal . extraFlags ) ; } } private void proposeConstructor ( char [ ] simpleTypeName , int parameterCount , char [ ] signature , char [ ] [ ] parameterTypes , char [ ] [ ] parameterNames , int modifiers , char [ ] packageName , int typeModifiers , int accessibility , char [ ] typeName , char [ ] fullyQualifiedName , boolean isQualified , Scope scope , int extraFlags ) { char [ ] typeCompletion = fullyQualifiedName ; if ( isQualified ) { if ( packageName == null || packageName . length == <NUM_LIT:0> ) if ( this . unitScope != null && this . unitScope . fPackage . compoundName != CharOperation . NO_CHAR_CHAR ) return ; } else { typeCompletion = simpleTypeName ; } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForRestrictions ( accessibility ) ; relevance += computeRelevanceForCaseMatching ( this . completionToken , simpleTypeName ) ; relevance += computeRelevanceForExpectingType ( packageName , simpleTypeName ) ; relevance += computeRelevanceForQualification ( isQualified ) ; relevance += computeRelevanceForConstructor ( ) ; boolean isInterface = false ; int kind = typeModifiers & ( ClassFileConstants . AccInterface | ClassFileConstants . AccEnum | ClassFileConstants . AccAnnotation ) ; switch ( kind ) { case ClassFileConstants . AccAnnotation : case ClassFileConstants . AccAnnotation | ClassFileConstants . AccInterface : relevance += computeRelevanceForAnnotation ( ) ; relevance += computeRelevanceForInterface ( ) ; isInterface = true ; break ; case ClassFileConstants . AccEnum : relevance += computeRelevanceForEnum ( ) ; break ; case ClassFileConstants . AccInterface : relevance += computeRelevanceForInterface ( ) ; isInterface = true ; break ; default : relevance += computeRelevanceForClass ( ) ; relevance += computeRelevanceForException ( simpleTypeName ) ; break ; } char [ ] completion ; if ( this . source != null && this . source . length > this . endPosition && this . source [ this . endPosition ] == '<CHAR_LIT:(>' ) { completion = CharOperation . NO_CHAR ; } else { completion = new char [ ] { '<CHAR_LIT:(>' , '<CHAR_LIT:)>' } ; } InternalCompletionProposal typeProposal = createProposal ( CompletionProposal . TYPE_REF , this . actualCompletionPosition ) ; typeProposal . nameLookup = this . nameEnvironment . nameLookup ; typeProposal . completionEngine = this ; typeProposal . setDeclarationSignature ( packageName ) ; typeProposal . setSignature ( createNonGenericTypeSignature ( packageName , typeName ) ) ; typeProposal . setPackageName ( packageName ) ; typeProposal . setTypeName ( typeName ) ; typeProposal . setCompletion ( typeCompletion ) ; typeProposal . setFlags ( typeModifiers ) ; typeProposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; typeProposal . setTokenRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; typeProposal . setRelevance ( relevance ) ; switch ( parameterCount ) { case - <NUM_LIT:1> : int flags = Flags . AccPublic ; if ( Flags . isDeprecated ( typeModifiers ) ) { flags |= Flags . AccDeprecated ; } if ( isInterface || ( typeModifiers & ClassFileConstants . AccAbstract ) != <NUM_LIT:0> ) { this . noProposal = false ; if ( ! isIgnored ( CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( createNonGenericTypeSignature ( packageName , typeName ) ) ; proposal . setDeclarationKey ( createBindingKey ( packageName , typeName ) ) ; proposal . setSignature ( DEFAULT_CONSTRUCTOR_SIGNATURE ) ; proposal . setDeclarationPackageName ( packageName ) ; proposal . setDeclarationTypeName ( typeName ) ; proposal . setParameterPackageNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setParameterTypeNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setParameterNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setName ( simpleTypeName ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { typeProposal } ) ; proposal . setIsContructor ( true ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( flags ) ; proposal . setReplaceRange ( this . endPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } else { this . noProposal = false ; if ( ! isIgnored ( CompletionProposal . CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . CONSTRUCTOR_INVOCATION , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( createNonGenericTypeSignature ( packageName , typeName ) ) ; proposal . setSignature ( DEFAULT_CONSTRUCTOR_SIGNATURE ) ; proposal . setDeclarationPackageName ( packageName ) ; proposal . setDeclarationTypeName ( typeName ) ; proposal . setParameterPackageNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setParameterTypeNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setParameterNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setName ( simpleTypeName ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { typeProposal } ) ; proposal . setIsContructor ( true ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( flags ) ; proposal . setReplaceRange ( this . endPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } break ; case <NUM_LIT:0> : if ( ( typeModifiers & ClassFileConstants . AccAbstract ) != <NUM_LIT:0> ) { this . noProposal = false ; if ( ! isIgnored ( CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( createNonGenericTypeSignature ( packageName , typeName ) ) ; proposal . setDeclarationKey ( createBindingKey ( packageName , typeName ) ) ; proposal . setSignature ( DEFAULT_CONSTRUCTOR_SIGNATURE ) ; proposal . setDeclarationPackageName ( packageName ) ; proposal . setDeclarationTypeName ( typeName ) ; proposal . setParameterPackageNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setParameterTypeNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setParameterNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setName ( simpleTypeName ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { typeProposal } ) ; proposal . setIsContructor ( true ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( modifiers ) ; proposal . setReplaceRange ( this . endPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } else { this . noProposal = false ; if ( ! isIgnored ( CompletionProposal . CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . CONSTRUCTOR_INVOCATION , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( createNonGenericTypeSignature ( packageName , typeName ) ) ; proposal . setSignature ( DEFAULT_CONSTRUCTOR_SIGNATURE ) ; proposal . setDeclarationPackageName ( packageName ) ; proposal . setDeclarationTypeName ( typeName ) ; proposal . setParameterPackageNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setParameterTypeNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setParameterNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setName ( simpleTypeName ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { typeProposal } ) ; proposal . setIsContructor ( true ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( modifiers ) ; proposal . setReplaceRange ( this . endPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } break ; default : if ( signature == null ) { signature = getResolvedSignature ( parameterTypes , fullyQualifiedName , parameterCount , scope ) ; if ( signature == null ) return ; } else { signature = CharOperation . replaceOnCopy ( signature , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; } int parameterNamesLength = parameterNames == null ? <NUM_LIT:0> : parameterNames . length ; if ( parameterCount != parameterNamesLength ) { parameterNames = null ; } if ( ( typeModifiers & ClassFileConstants . AccAbstract ) != <NUM_LIT:0> ) { this . noProposal = false ; if ( ! isIgnored ( CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( createNonGenericTypeSignature ( packageName , typeName ) ) ; proposal . setDeclarationKey ( createBindingKey ( packageName , typeName ) ) ; proposal . setSignature ( signature ) ; proposal . setDeclarationPackageName ( packageName ) ; proposal . setDeclarationTypeName ( typeName ) ; proposal . setParameterPackageNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setParameterTypeNames ( CharOperation . NO_CHAR_CHAR ) ; if ( parameterNames != null ) { proposal . setParameterNames ( parameterNames ) ; } else { proposal . setHasNoParameterNamesFromIndex ( true ) ; } proposal . setName ( simpleTypeName ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { typeProposal } ) ; proposal . setIsContructor ( true ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( modifiers ) ; proposal . setReplaceRange ( this . endPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } else { this . noProposal = false ; if ( ! isIgnored ( CompletionProposal . CONSTRUCTOR_INVOCATION , CompletionProposal . TYPE_REF ) ) { InternalCompletionProposal proposal = createProposal ( CompletionProposal . CONSTRUCTOR_INVOCATION , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( createNonGenericTypeSignature ( packageName , typeName ) ) ; proposal . setSignature ( signature ) ; proposal . setDeclarationPackageName ( packageName ) ; proposal . setDeclarationTypeName ( typeName ) ; proposal . setParameterPackageNames ( CharOperation . NO_CHAR_CHAR ) ; proposal . setParameterTypeNames ( CharOperation . NO_CHAR_CHAR ) ; if ( parameterNames != null ) { proposal . setParameterNames ( parameterNames ) ; } else { proposal . setHasNoParameterNamesFromIndex ( true ) ; } proposal . setName ( simpleTypeName ) ; proposal . setRequiredProposals ( new CompletionProposal [ ] { typeProposal } ) ; proposal . setIsContructor ( true ) ; proposal . setCompletion ( completion ) ; proposal . setFlags ( modifiers ) ; proposal . setReplaceRange ( this . endPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } break ; } } private void proposeNewMethod ( char [ ] token , ReferenceBinding reference ) { if ( ! this . requestor . isIgnored ( CompletionProposal . POTENTIAL_METHOD_DECLARATION ) ) { int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( ) ; relevance += computeRelevanceForRestrictions ( IAccessRule . K_ACCESSIBLE ) ; InternalCompletionProposal proposal = createProposal ( CompletionProposal . POTENTIAL_METHOD_DECLARATION , this . actualCompletionPosition ) ; proposal . setDeclarationSignature ( getSignature ( reference ) ) ; proposal . setSignature ( createMethodSignature ( CharOperation . NO_CHAR_CHAR , CharOperation . NO_CHAR_CHAR , CharOperation . NO_CHAR , VOID ) ) ; proposal . setDeclarationPackageName ( reference . qualifiedPackageName ( ) ) ; proposal . setDeclarationTypeName ( reference . qualifiedSourceName ( ) ) ; proposal . setTypeName ( VOID ) ; proposal . setName ( token ) ; proposal . setCompletion ( token ) ; proposal . setFlags ( Flags . AccPublic ) ; proposal . setReplaceRange ( this . startPosition - this . offset , this . endPosition - this . offset ) ; proposal . setTokenRange ( this . tokenStart - this . offset , this . tokenEnd - this . offset ) ; proposal . setRelevance ( relevance ) ; this . requestor . accept ( proposal ) ; if ( DEBUG ) { this . printDebug ( proposal ) ; } } } private void proposeType ( char [ ] packageName , char [ ] simpleTypeName , int modifiers , int accessibility , char [ ] typeName , char [ ] fullyQualifiedName , boolean isQualified , Scope scope ) { char [ ] completionName = fullyQualifiedName ; if ( isQualified ) { if ( packageName == null || packageName . length == <NUM_LIT:0> ) if ( this . unitScope != null && this . unitScope . fPackage . compoundName != CharOperation . NO_CHAR_CHAR ) return ; } else { completionName = simpleTypeName ; } TypeBinding guessedType = null ; if ( ( modifiers & ClassFileConstants . AccAnnotation ) != <NUM_LIT:0> && this . assistNodeIsAnnotation && ( this . targetedElement & TagBits . AnnotationTargetMASK ) != <NUM_LIT:0> ) { char [ ] [ ] cn = CharOperation . splitOn ( '<CHAR_LIT:.>' , fullyQualifiedName ) ; TypeReference ref ; if ( cn . length == <NUM_LIT:1> ) { ref = new SingleTypeReference ( simpleTypeName , <NUM_LIT:0> ) ; } else { ref = new QualifiedTypeReference ( cn , new long [ cn . length ] ) ; } switch ( scope . kind ) { case Scope . METHOD_SCOPE : case Scope . BLOCK_SCOPE : guessedType = ref . resolveType ( ( BlockScope ) scope ) ; break ; case Scope . CLASS_SCOPE : guessedType = ref . resolveType ( ( ClassScope ) scope ) ; break ; } if ( guessedType == null || ! guessedType . isValidBinding ( ) ) return ; if ( ! hasPossibleAnnotationTarget ( guessedType , scope ) ) return ; } int relevance = computeBaseRelevance ( ) ; relevance += computeRelevanceForResolution ( ) ; relevance += computeRelevanceForInterestingProposal ( packageName , fullyQualifiedName ) ; relevance += computeRelevanceForRestrictions ( accessibility ) ; relevance += computeRelevanceForCaseMatching ( this . completionToken , simpleTypeName ) ; relevance += computeRelevanceForExpectingType ( packageName , simpleTypeName ) ; relevance += computeRelevanceForQualification ( isQualified ) ; int kind = modifiers & ( ClassFileConstants . AccInterface | ClassFileConstants . AccEnum | ClassFileConstants . AccAnnotation ) ; switch ( kind ) { case ClassFileConstants . AccAnnotation : case ClassFileConstants . AccAnnotation | ClassFileConstants . AccInterface : relevance += computeRelevanceForAnnotation ( ) ; if ( guessedType != null ) relevance += computeRelevanceForAnnotationTarget ( guessedType ) ; relevance += computeRelevanceForInterface ( ) ; break ; case ClassFileConstants . AccEnum : relevance += computeRelevanceForEnum ( ) ; break ; case ClassFileConstants . AccInterface : relevance += computeRelevanceForInterface ( ) ; break ; default : relevance += computeRelevanceForClass ( ) ; relevance += computeRelevanceForException ( simpleTypeName ) ; break ; } this . noProposal = false ; if ( ! this . requestor . isIgnored ( CompletionProposal . TYPE_REF ) ) { createTypeProposal ( packageName , typeName , modifiers , accessibility , completionName , relevance ) ; } } protected void reset ( ) { super . reset ( false ) ; this . knownPkgs = new HashtableOfObject ( <NUM_LIT:10> ) ; this . knownTypes = new HashtableOfObject ( <NUM_LIT:10> ) ; if ( this . noCacheNameEnvironment != null ) { this . noCacheNameEnvironment . cleanup ( ) ; this . noCacheNameEnvironment = null ; JavaModelManager . getJavaModelManager ( ) . flushZipFiles ( this ) ; } } private void setSourceAndTokenRange ( int start , int end ) { this . setSourceAndTokenRange ( start , end , true ) ; } private void setSourceAndTokenRange ( int start , int end , boolean emptyTokenAdjstment ) { this . setSourceRange ( start , end , emptyTokenAdjstment ) ; this . setTokenRange ( start , end , emptyTokenAdjstment ) ; } private void setSourceRange ( int start , int end ) { this . setSourceRange ( start , end , true ) ; } private void setSourceRange ( int start , int end , boolean emptyTokenAdjstment ) { this . startPosition = start ; if ( emptyTokenAdjstment ) { int endOfEmptyToken = ( ( CompletionScanner ) this . parser . scanner ) . endOfEmptyToken ; this . endPosition = endOfEmptyToken > end ? endOfEmptyToken + <NUM_LIT:1> : end + <NUM_LIT:1> ; } else { this . endPosition = end + <NUM_LIT:1> ; } } private void setTokenRange ( int start , int end ) { this . setTokenRange ( start , end , true ) ; } private void setTokenRange ( int start , int end , boolean emptyTokenAdjstment ) { this . tokenStart = start ; if ( emptyTokenAdjstment ) { int endOfEmptyToken = ( ( CompletionScanner ) this . parser . scanner ) . endOfEmptyToken ; this . tokenEnd = endOfEmptyToken > end ? endOfEmptyToken + <NUM_LIT:1> : end + <NUM_LIT:1> ; } else { this . tokenEnd = end + <NUM_LIT:1> ; } } private char [ ] substituteMethodTypeParameterName ( char firstName , char startChar , char endChar , char [ ] [ ] excludedNames , char [ ] [ ] otherParameterNames ) { char name = firstName ; next : while ( true ) { for ( int i = <NUM_LIT:0> ; i < excludedNames . length ; i ++ ) { if ( excludedNames [ i ] . length == <NUM_LIT:1> && ScannerHelper . toLowerCase ( excludedNames [ i ] [ <NUM_LIT:0> ] ) == ScannerHelper . toLowerCase ( name ) ) { name ++ ; if ( name > endChar ) name = startChar ; if ( name == firstName ) return substituteMethodTypeParameterName ( new char [ ] { firstName } , excludedNames , otherParameterNames ) ; continue next ; } } for ( int i = <NUM_LIT:0> ; i < otherParameterNames . length ; i ++ ) { if ( otherParameterNames [ i ] . length == <NUM_LIT:1> && ScannerHelper . toLowerCase ( otherParameterNames [ i ] [ <NUM_LIT:0> ] ) == ScannerHelper . toLowerCase ( name ) ) { name ++ ; if ( name > endChar ) name = startChar ; if ( name == firstName ) return substituteMethodTypeParameterName ( new char [ ] { firstName } , excludedNames , otherParameterNames ) ; continue next ; } } break next ; } return new char [ ] { name } ; } private char [ ] substituteMethodTypeParameterName ( char [ ] firstName , char [ ] [ ] excludedNames , char [ ] [ ] otherParameterNames ) { char [ ] name = firstName ; int count = <NUM_LIT:2> ; next : while ( true ) { for ( int k = <NUM_LIT:0> ; k < excludedNames . length ; k ++ ) { if ( CharOperation . equals ( name , excludedNames [ k ] , false ) ) { name = CharOperation . concat ( firstName , String . valueOf ( count ++ ) . toCharArray ( ) ) ; continue next ; } } for ( int i = <NUM_LIT:0> ; i < otherParameterNames . length ; i ++ ) { if ( CharOperation . equals ( name , otherParameterNames [ i ] , false ) ) { name = CharOperation . concat ( firstName , String . valueOf ( count ++ ) . toCharArray ( ) ) ; continue next ; } } break next ; } return name ; } private char [ ] [ ] substituteMethodTypeParameterNames ( TypeVariableBinding [ ] typeVariables , char [ ] [ ] excludedNames ) { char [ ] [ ] substituedParameterNames = new char [ typeVariables . length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < substituedParameterNames . length ; i ++ ) { substituedParameterNames [ i ] = typeVariables [ i ] . sourceName ; } boolean foundConflicts = false ; nextTypeParameter : for ( int i = <NUM_LIT:0> ; i < typeVariables . length ; i ++ ) { TypeVariableBinding typeVariableBinding = typeVariables [ i ] ; char [ ] methodParameterName = typeVariableBinding . sourceName ; for ( int j = <NUM_LIT:0> ; j < excludedNames . length ; j ++ ) { char [ ] typeParameterName = excludedNames [ j ] ; if ( CharOperation . equals ( typeParameterName , methodParameterName , false ) ) { char [ ] substitution ; if ( methodParameterName . length == <NUM_LIT:1> ) { if ( ScannerHelper . isUpperCase ( methodParameterName [ <NUM_LIT:0> ] ) ) { substitution = substituteMethodTypeParameterName ( methodParameterName [ <NUM_LIT:0> ] , '<CHAR_LIT:A>' , '<CHAR_LIT:Z>' , excludedNames , substituedParameterNames ) ; } else { substitution = substituteMethodTypeParameterName ( methodParameterName [ <NUM_LIT:0> ] , '<CHAR_LIT:a>' , '<CHAR_LIT>' , excludedNames , substituedParameterNames ) ; } } else { substitution = substituteMethodTypeParameterName ( methodParameterName , excludedNames , substituedParameterNames ) ; } substituedParameterNames [ i ] = substitution ; foundConflicts = true ; continue nextTypeParameter ; } } } if ( foundConflicts ) return substituedParameterNames ; return null ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist ; import java . util . ArrayList ; import java . util . Iterator ; import java . util . Locale ; import java . util . Map ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . jdt . core . IBuffer ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . core . IOpenable ; import org . eclipse . jdt . core . ISourceRange ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . core . search . IJavaSearchConstants ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . core . search . SearchPattern ; import org . eclipse . jdt . core . search . TypeNameMatch ; import org . eclipse . jdt . core . search . TypeNameMatchRequestor ; import org . eclipse . jdt . internal . codeassist . impl . * ; import org . eclipse . jdt . internal . codeassist . select . * ; import org . eclipse . jdt . internal . compiler . * ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . env . * ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; import org . eclipse . jdt . internal . compiler . parser . * ; import org . eclipse . jdt . internal . compiler . problem . * ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObject ; import org . eclipse . jdt . internal . compiler . util . ObjectVector ; import org . eclipse . jdt . internal . core . BinaryTypeConverter ; import org . eclipse . jdt . internal . core . ClassFile ; import org . eclipse . jdt . internal . core . JavaModelManager ; import org . eclipse . jdt . internal . core . SearchableEnvironment ; import org . eclipse . jdt . internal . core . SelectionRequestor ; import org . eclipse . jdt . internal . core . SourceType ; import org . eclipse . jdt . internal . core . SourceTypeElementInfo ; import org . eclipse . jdt . internal . core . search . BasicSearchEngine ; import org . eclipse . jdt . internal . core . search . TypeNameMatchRequestorWrapper ; import org . eclipse . jdt . internal . core . util . ASTNodeFinder ; import org . eclipse . jdt . internal . core . util . HashSetOfCharArrayArray ; public final class SelectionEngine extends Engine implements ISearchRequestor { private static class SelectionTypeNameMatchRequestorWrapper extends TypeNameMatchRequestorWrapper { class AcceptedType { public int modifiers ; public char [ ] packageName ; public char [ ] simpleTypeName ; public String path ; public AccessRestriction access ; public AcceptedType ( int modifiers , char [ ] packageName , char [ ] simpleTypeName , String path , AccessRestriction access ) { this . modifiers = modifiers ; this . packageName = packageName ; this . simpleTypeName = simpleTypeName ; this . path = path ; this . access = access ; } } private ImportReference [ ] importReferences ; private boolean importCachesNodeInitialized = false ; private ImportReference [ ] onDemandImportsNodeCache ; private int onDemandImportsNodeCacheCount ; private char [ ] [ ] [ ] importsNodeCache ; private int importsNodeCacheCount ; private HashtableOfObject onDemandFound = new HashtableOfObject ( ) ; private ObjectVector notImportedFound = new ObjectVector ( ) ; public SelectionTypeNameMatchRequestorWrapper ( TypeNameMatchRequestor requestor , IJavaSearchScope scope , ImportReference [ ] importReferences ) { super ( requestor , scope ) ; this . importReferences = importReferences ; } public void acceptType ( int modifiers , char [ ] packageName , char [ ] simpleTypeName , char [ ] [ ] enclosingTypeNames , String path , AccessRestriction access ) { if ( enclosingTypeNames != null && enclosingTypeNames . length > <NUM_LIT:0> ) return ; if ( ! this . importCachesNodeInitialized ) initializeImportNodeCaches ( ) ; char [ ] fullyQualifiedTypeName = CharOperation . concat ( packageName , simpleTypeName , '<CHAR_LIT:.>' ) ; for ( int i = <NUM_LIT:0> ; i < this . importsNodeCacheCount ; i ++ ) { char [ ] [ ] importName = this . importsNodeCache [ i ] ; if ( CharOperation . equals ( importName [ <NUM_LIT:0> ] , simpleTypeName ) ) { if ( CharOperation . equals ( importName [ <NUM_LIT:1> ] , fullyQualifiedTypeName ) ) { super . acceptType ( modifiers , packageName , simpleTypeName , enclosingTypeNames , path , access ) ; } return ; } } for ( int i = <NUM_LIT:0> ; i < this . onDemandImportsNodeCacheCount ; i ++ ) { char [ ] [ ] importName = this . onDemandImportsNodeCache [ i ] . tokens ; char [ ] importFlatName = CharOperation . concatWith ( importName , '<CHAR_LIT:.>' ) ; if ( CharOperation . equals ( importFlatName , packageName ) ) { this . onDemandFound . put ( simpleTypeName , simpleTypeName ) ; super . acceptType ( modifiers , packageName , simpleTypeName , enclosingTypeNames , path , access ) ; return ; } } this . notImportedFound . add ( new AcceptedType ( modifiers , packageName , simpleTypeName , path , access ) ) ; } public void acceptNotImported ( ) { int size = this . notImportedFound . size ( ) ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { AcceptedType acceptedType = ( AcceptedType ) this . notImportedFound . elementAt ( i ) ; if ( this . onDemandFound . get ( acceptedType . simpleTypeName ) == null ) { super . acceptType ( acceptedType . modifiers , acceptedType . packageName , acceptedType . simpleTypeName , null , acceptedType . path , acceptedType . access ) ; } } } public void initializeImportNodeCaches ( ) { int length = this . importReferences == null ? <NUM_LIT:0> : this . importReferences . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ImportReference importReference = this . importReferences [ i ] ; if ( ( importReference . bits & ASTNode . OnDemand ) != <NUM_LIT:0> ) { if ( this . onDemandImportsNodeCache == null ) { this . onDemandImportsNodeCache = new ImportReference [ length - i ] ; } this . onDemandImportsNodeCache [ this . onDemandImportsNodeCacheCount ++ ] = importReference ; } else { if ( this . importsNodeCache == null ) { this . importsNodeCache = new char [ length - i ] [ ] [ ] ; } this . importsNodeCache [ this . importsNodeCacheCount ++ ] = new char [ ] [ ] { importReference . tokens [ importReference . tokens . length - <NUM_LIT:1> ] , CharOperation . concatWith ( importReference . tokens , '<CHAR_LIT:.>' ) } ; } } this . importCachesNodeInitialized = true ; } } public static boolean DEBUG = false ; public static boolean PERF = false ; SelectionParser parser ; ISelectionRequestor requestor ; WorkingCopyOwner owner ; boolean acceptedAnswer ; private int actualSelectionStart ; private int actualSelectionEnd ; private char [ ] selectedIdentifier ; private char [ ] [ ] [ ] acceptedClasses ; private int [ ] acceptedClassesModifiers ; private char [ ] [ ] [ ] acceptedInterfaces ; private int [ ] acceptedInterfacesModifiers ; private char [ ] [ ] [ ] acceptedEnums ; private int [ ] acceptedEnumsModifiers ; private char [ ] [ ] [ ] acceptedAnnotations ; private int [ ] acceptedAnnotationsModifiers ; int acceptedClassesCount ; int acceptedInterfacesCount ; int acceptedEnumsCount ; int acceptedAnnotationsCount ; boolean noProposal = true ; CategorizedProblem problem = null ; public SelectionEngine ( SearchableEnvironment nameEnvironment , ISelectionRequestor requestor , Map settings , WorkingCopyOwner owner ) { super ( settings ) ; this . requestor = requestor ; this . nameEnvironment = nameEnvironment ; ProblemReporter problemReporter = new ProblemReporter ( DefaultErrorHandlingPolicies . proceedWithAllProblems ( ) , this . compilerOptions , new DefaultProblemFactory ( Locale . getDefault ( ) ) ) { public CategorizedProblem createProblem ( char [ ] fileName , int problemId , String [ ] problemArguments , String [ ] messageArguments , int severity , int problemStartPosition , int problemEndPosition , int lineNumber , int columnNumber ) { CategorizedProblem pb = super . createProblem ( fileName , problemId , problemArguments , messageArguments , severity , problemStartPosition , problemEndPosition , lineNumber , columnNumber ) ; if ( SelectionEngine . this . problem == null && pb . isError ( ) && ( pb . getID ( ) & IProblem . Syntax ) == <NUM_LIT:0> ) { SelectionEngine . this . problem = pb ; } return pb ; } } ; this . lookupEnvironment = new LookupEnvironment ( this , this . compilerOptions , problemReporter , nameEnvironment ) ; this . parser = new SelectionParser ( problemReporter ) ; this . owner = owner ; } public void acceptConstructor ( int modifiers , char [ ] simpleTypeName , int parameterCount , char [ ] signature , char [ ] [ ] parameterTypes , char [ ] [ ] parameterNames , int typeModifiers , char [ ] packageName , int extraFlags , String path , AccessRestriction access ) { } public void acceptType ( char [ ] packageName , char [ ] simpleTypeName , char [ ] [ ] enclosingTypeNames , int modifiers , AccessRestriction accessRestriction ) { char [ ] typeName = enclosingTypeNames == null ? simpleTypeName : CharOperation . concat ( CharOperation . concatWith ( enclosingTypeNames , '<CHAR_LIT:.>' ) , simpleTypeName , '<CHAR_LIT:.>' ) ; if ( CharOperation . equals ( simpleTypeName , this . selectedIdentifier ) ) { char [ ] flatEnclosingTypeNames = enclosingTypeNames == null || enclosingTypeNames . length == <NUM_LIT:0> ? null : CharOperation . concatWith ( enclosingTypeNames , '<CHAR_LIT:.>' ) ; if ( mustQualifyType ( packageName , simpleTypeName , flatEnclosingTypeNames , modifiers ) ) { int length = <NUM_LIT:0> ; int kind = modifiers & ( ClassFileConstants . AccInterface | ClassFileConstants . AccEnum | ClassFileConstants . AccAnnotation ) ; switch ( kind ) { case ClassFileConstants . AccAnnotation : case ClassFileConstants . AccAnnotation | ClassFileConstants . AccInterface : char [ ] [ ] acceptedAnnotation = new char [ <NUM_LIT:2> ] [ ] ; acceptedAnnotation [ <NUM_LIT:0> ] = packageName ; acceptedAnnotation [ <NUM_LIT:1> ] = typeName ; if ( this . acceptedAnnotations == null ) { this . acceptedAnnotations = new char [ <NUM_LIT:10> ] [ ] [ ] ; this . acceptedAnnotationsModifiers = new int [ <NUM_LIT:10> ] ; this . acceptedAnnotationsCount = <NUM_LIT:0> ; } length = this . acceptedAnnotations . length ; if ( length == this . acceptedAnnotationsCount ) { int newLength = ( length + <NUM_LIT:1> ) * <NUM_LIT:2> ; System . arraycopy ( this . acceptedAnnotations , <NUM_LIT:0> , this . acceptedAnnotations = new char [ newLength ] [ ] [ ] , <NUM_LIT:0> , length ) ; System . arraycopy ( this . acceptedAnnotationsModifiers , <NUM_LIT:0> , this . acceptedAnnotationsModifiers = new int [ newLength ] , <NUM_LIT:0> , length ) ; } this . acceptedAnnotationsModifiers [ this . acceptedAnnotationsCount ] = modifiers ; this . acceptedAnnotations [ this . acceptedAnnotationsCount ++ ] = acceptedAnnotation ; break ; case ClassFileConstants . AccEnum : char [ ] [ ] acceptedEnum = new char [ <NUM_LIT:2> ] [ ] ; acceptedEnum [ <NUM_LIT:0> ] = packageName ; acceptedEnum [ <NUM_LIT:1> ] = typeName ; if ( this . acceptedEnums == null ) { this . acceptedEnums = new char [ <NUM_LIT:10> ] [ ] [ ] ; this . acceptedEnumsModifiers = new int [ <NUM_LIT:10> ] ; this . acceptedEnumsCount = <NUM_LIT:0> ; } length = this . acceptedEnums . length ; if ( length == this . acceptedEnumsCount ) { int newLength = ( length + <NUM_LIT:1> ) * <NUM_LIT:2> ; System . arraycopy ( this . acceptedEnums , <NUM_LIT:0> , this . acceptedEnums = new char [ newLength ] [ ] [ ] , <NUM_LIT:0> , length ) ; System . arraycopy ( this . acceptedEnumsModifiers , <NUM_LIT:0> , this . acceptedEnumsModifiers = new int [ newLength ] , <NUM_LIT:0> , length ) ; } this . acceptedEnumsModifiers [ this . acceptedEnumsCount ] = modifiers ; this . acceptedEnums [ this . acceptedEnumsCount ++ ] = acceptedEnum ; break ; case ClassFileConstants . AccInterface : char [ ] [ ] acceptedInterface = new char [ <NUM_LIT:2> ] [ ] ; acceptedInterface [ <NUM_LIT:0> ] = packageName ; acceptedInterface [ <NUM_LIT:1> ] = typeName ; if ( this . acceptedInterfaces == null ) { this . acceptedInterfaces = new char [ <NUM_LIT:10> ] [ ] [ ] ; this . acceptedInterfacesModifiers = new int [ <NUM_LIT:10> ] ; this . acceptedInterfacesCount = <NUM_LIT:0> ; } length = this . acceptedInterfaces . length ; if ( length == this . acceptedInterfacesCount ) { int newLength = ( length + <NUM_LIT:1> ) * <NUM_LIT:2> ; System . arraycopy ( this . acceptedInterfaces , <NUM_LIT:0> , this . acceptedInterfaces = new char [ newLength ] [ ] [ ] , <NUM_LIT:0> , length ) ; System . arraycopy ( this . acceptedInterfacesModifiers , <NUM_LIT:0> , this . acceptedInterfacesModifiers = new int [ newLength ] , <NUM_LIT:0> , length ) ; } this . acceptedInterfacesModifiers [ this . acceptedInterfacesCount ] = modifiers ; this . acceptedInterfaces [ this . acceptedInterfacesCount ++ ] = acceptedInterface ; break ; default : char [ ] [ ] acceptedClass = new char [ <NUM_LIT:2> ] [ ] ; acceptedClass [ <NUM_LIT:0> ] = packageName ; acceptedClass [ <NUM_LIT:1> ] = typeName ; if ( this . acceptedClasses == null ) { this . acceptedClasses = new char [ <NUM_LIT:10> ] [ ] [ ] ; this . acceptedClassesModifiers = new int [ <NUM_LIT:10> ] ; this . acceptedClassesCount = <NUM_LIT:0> ; } length = this . acceptedClasses . length ; if ( length == this . acceptedClassesCount ) { int newLength = ( length + <NUM_LIT:1> ) * <NUM_LIT:2> ; System . arraycopy ( this . acceptedClasses , <NUM_LIT:0> , this . acceptedClasses = new char [ newLength ] [ ] [ ] , <NUM_LIT:0> , length ) ; System . arraycopy ( this . acceptedClassesModifiers , <NUM_LIT:0> , this . acceptedClassesModifiers = new int [ newLength ] , <NUM_LIT:0> , length ) ; } this . acceptedClassesModifiers [ this . acceptedClassesCount ] = modifiers ; this . acceptedClasses [ this . acceptedClassesCount ++ ] = acceptedClass ; break ; } } else { this . noProposal = false ; this . requestor . acceptType ( packageName , typeName , modifiers , false , null , this . actualSelectionStart , this . actualSelectionEnd ) ; this . acceptedAnswer = true ; } } } public void acceptPackage ( char [ ] packageName ) { } private void acceptQualifiedTypes ( ) { if ( this . acceptedClasses != null ) { this . acceptedAnswer = true ; for ( int i = <NUM_LIT:0> ; i < this . acceptedClassesCount ; i ++ ) { this . noProposal = false ; this . requestor . acceptType ( this . acceptedClasses [ i ] [ <NUM_LIT:0> ] , this . acceptedClasses [ i ] [ <NUM_LIT:1> ] , this . acceptedClassesModifiers [ i ] , false , null , this . actualSelectionStart , this . actualSelectionEnd ) ; } this . acceptedClasses = null ; this . acceptedClassesModifiers = null ; this . acceptedClassesCount = <NUM_LIT:0> ; } if ( this . acceptedInterfaces != null ) { this . acceptedAnswer = true ; for ( int i = <NUM_LIT:0> ; i < this . acceptedInterfacesCount ; i ++ ) { this . noProposal = false ; this . requestor . acceptType ( this . acceptedInterfaces [ i ] [ <NUM_LIT:0> ] , this . acceptedInterfaces [ i ] [ <NUM_LIT:1> ] , this . acceptedInterfacesModifiers [ i ] , false , null , this . actualSelectionStart , this . actualSelectionEnd ) ; } this . acceptedInterfaces = null ; this . acceptedInterfacesModifiers = null ; this . acceptedInterfacesCount = <NUM_LIT:0> ; } if ( this . acceptedAnnotations != null ) { this . acceptedAnswer = true ; for ( int i = <NUM_LIT:0> ; i < this . acceptedAnnotationsCount ; i ++ ) { this . noProposal = false ; this . requestor . acceptType ( this . acceptedAnnotations [ i ] [ <NUM_LIT:0> ] , this . acceptedAnnotations [ i ] [ <NUM_LIT:1> ] , this . acceptedAnnotationsModifiers [ i ] , false , null , this . actualSelectionStart , this . actualSelectionEnd ) ; } this . acceptedAnnotations = null ; this . acceptedAnnotationsModifiers = null ; this . acceptedAnnotationsCount = <NUM_LIT:0> ; } if ( this . acceptedEnums != null ) { this . acceptedAnswer = true ; for ( int i = <NUM_LIT:0> ; i < this . acceptedEnumsCount ; i ++ ) { this . noProposal = false ; this . requestor . acceptType ( this . acceptedEnums [ i ] [ <NUM_LIT:0> ] , this . acceptedEnums [ i ] [ <NUM_LIT:1> ] , this . acceptedEnumsModifiers [ i ] , false , null , this . actualSelectionStart , this . actualSelectionEnd ) ; } this . acceptedEnums = null ; this . acceptedEnumsModifiers = null ; this . acceptedEnumsCount = <NUM_LIT:0> ; } } private boolean checkSelection ( char [ ] source , int selectionStart , int selectionEnd ) { Scanner scanner = new Scanner ( false , false , false , this . compilerOptions . sourceLevel , this . compilerOptions . complianceLevel , null , null , true ) ; scanner . setSource ( source ) ; int lastIdentifierStart = - <NUM_LIT:1> ; int lastIdentifierEnd = - <NUM_LIT:1> ; char [ ] lastIdentifier = null ; int token ; if ( selectionStart > selectionEnd ) { int end = source . length - <NUM_LIT:1> ; int currentPosition = selectionStart - <NUM_LIT:1> ; int nextCharacterPosition = selectionStart ; char currentCharacter = '<CHAR_LIT:U+0020>' ; try { lineLoop : while ( currentPosition > <NUM_LIT:0> ) { if ( source [ currentPosition ] == '<STR_LIT:\\>' && source [ currentPosition + <NUM_LIT:1> ] == '<CHAR_LIT>' ) { int pos = currentPosition + <NUM_LIT:2> ; int c1 = <NUM_LIT:0> , c2 = <NUM_LIT:0> , c3 = <NUM_LIT:0> , c4 = <NUM_LIT:0> ; while ( source [ pos ] == '<CHAR_LIT>' ) { pos ++ ; } int endOfUnicode = pos + <NUM_LIT:3> ; if ( end < endOfUnicode ) { if ( endOfUnicode < source . length ) { end = endOfUnicode ; } else { return false ; } } if ( ( c1 = ScannerHelper . getHexadecimalValue ( source [ pos ++ ] ) ) > <NUM_LIT:15> || c1 < <NUM_LIT:0> || ( c2 = ScannerHelper . getHexadecimalValue ( source [ pos ++ ] ) ) > <NUM_LIT:15> || c2 < <NUM_LIT:0> || ( c3 = ScannerHelper . getHexadecimalValue ( source [ pos ++ ] ) ) > <NUM_LIT:15> || c3 < <NUM_LIT:0> || ( c4 = ScannerHelper . getHexadecimalValue ( source [ pos ++ ] ) ) > <NUM_LIT:15> || c4 < <NUM_LIT:0> ) { return false ; } else { currentCharacter = ( char ) ( ( ( c1 * <NUM_LIT:16> + c2 ) * <NUM_LIT:16> + c3 ) * <NUM_LIT:16> + c4 ) ; nextCharacterPosition = pos ; } } else { currentCharacter = source [ currentPosition ] ; nextCharacterPosition = currentPosition + <NUM_LIT:1> ; } switch ( currentCharacter ) { case '<STR_LIT>' : case '<STR_LIT:\n>' : case '<CHAR_LIT:/>' : case '<CHAR_LIT:">' : case '<STR_LIT>' : break lineLoop ; } currentPosition -- ; } } catch ( ArrayIndexOutOfBoundsException e ) { return false ; } scanner . resetTo ( nextCharacterPosition , end ) ; isolateLastName : do { try { token = scanner . getNextToken ( ) ; } catch ( InvalidInputException e ) { return false ; } switch ( token ) { case TerminalTokens . TokenNamethis : case TerminalTokens . TokenNamesuper : case TerminalTokens . TokenNameIdentifier : if ( scanner . startPosition <= selectionStart && selectionStart <= scanner . currentPosition ) { if ( scanner . currentPosition == scanner . eofPosition ) { int temp = scanner . eofPosition ; scanner . eofPosition = scanner . source . length ; while ( scanner . getNextCharAsJavaIdentifierPart ( ) ) { } scanner . eofPosition = temp ; } lastIdentifierStart = scanner . startPosition ; lastIdentifierEnd = scanner . currentPosition - <NUM_LIT:1> ; lastIdentifier = scanner . getCurrentTokenSource ( ) ; break isolateLastName ; } break ; } } while ( token != TerminalTokens . TokenNameEOF ) ; } else { scanner . resetTo ( selectionStart , selectionEnd ) ; boolean expectingIdentifier = true ; do { try { token = scanner . getNextToken ( ) ; } catch ( InvalidInputException e ) { return false ; } switch ( token ) { case TerminalTokens . TokenNamethis : case TerminalTokens . TokenNamesuper : case TerminalTokens . TokenNameIdentifier : if ( ! expectingIdentifier ) return false ; lastIdentifier = scanner . getCurrentTokenSource ( ) ; lastIdentifierStart = scanner . startPosition ; lastIdentifierEnd = scanner . currentPosition - <NUM_LIT:1> ; if ( lastIdentifierEnd > selectionEnd ) { lastIdentifierEnd = selectionEnd ; lastIdentifier = CharOperation . subarray ( lastIdentifier , <NUM_LIT:0> , lastIdentifierEnd - lastIdentifierStart + <NUM_LIT:1> ) ; } expectingIdentifier = false ; break ; case TerminalTokens . TokenNameDOT : if ( expectingIdentifier ) return false ; expectingIdentifier = true ; break ; case TerminalTokens . TokenNameEOF : if ( expectingIdentifier ) return false ; break ; case TerminalTokens . TokenNameLESS : if ( ! checkTypeArgument ( scanner ) ) return false ; break ; case TerminalTokens . TokenNameAT : if ( scanner . startPosition != scanner . initialPosition ) return false ; break ; default : return false ; } } while ( token != TerminalTokens . TokenNameEOF ) ; } if ( lastIdentifierStart > <NUM_LIT:0> ) { this . actualSelectionStart = lastIdentifierStart ; this . actualSelectionEnd = lastIdentifierEnd ; this . selectedIdentifier = lastIdentifier ; return true ; } return false ; } private boolean checkTypeArgument ( Scanner scanner ) { int depth = <NUM_LIT:1> ; int token ; StringBuffer buffer = new StringBuffer ( ) ; do { try { token = scanner . getNextToken ( ) ; } catch ( InvalidInputException e ) { return false ; } switch ( token ) { case TerminalTokens . TokenNameLESS : depth ++ ; buffer . append ( scanner . getCurrentTokenSource ( ) ) ; break ; case TerminalTokens . TokenNameGREATER : depth -- ; buffer . append ( scanner . getCurrentTokenSource ( ) ) ; break ; case TerminalTokens . TokenNameRIGHT_SHIFT : depth -= <NUM_LIT:2> ; buffer . append ( scanner . getCurrentTokenSource ( ) ) ; break ; case TerminalTokens . TokenNameUNSIGNED_RIGHT_SHIFT : depth -= <NUM_LIT:3> ; buffer . append ( scanner . getCurrentTokenSource ( ) ) ; break ; case TerminalTokens . TokenNameextends : case TerminalTokens . TokenNamesuper : buffer . append ( '<CHAR_LIT:U+0020>' ) ; buffer . append ( scanner . getCurrentTokenSource ( ) ) ; buffer . append ( '<CHAR_LIT:U+0020>' ) ; break ; case TerminalTokens . TokenNameCOMMA : if ( depth == <NUM_LIT:1> ) { int length = buffer . length ( ) ; char [ ] typeRef = new char [ length ] ; buffer . getChars ( <NUM_LIT:0> , length , typeRef , <NUM_LIT:0> ) ; try { Signature . createTypeSignature ( typeRef , true ) ; buffer = new StringBuffer ( ) ; } catch ( IllegalArgumentException e ) { return false ; } } break ; default : buffer . append ( scanner . getCurrentTokenSource ( ) ) ; break ; } if ( depth < <NUM_LIT:0> ) { return false ; } } while ( depth != <NUM_LIT:0> && token != TerminalTokens . TokenNameEOF ) ; if ( depth == <NUM_LIT:0> ) { int length = buffer . length ( ) - <NUM_LIT:1> ; char [ ] typeRef = new char [ length ] ; buffer . getChars ( <NUM_LIT:0> , length , typeRef , <NUM_LIT:0> ) ; try { Signature . createTypeSignature ( typeRef , true ) ; return true ; } catch ( IllegalArgumentException e ) { return false ; } } return false ; } private void findAllTypes ( char [ ] prefix ) { try { IProgressMonitor progressMonitor = new IProgressMonitor ( ) { boolean isCanceled = false ; public void beginTask ( String name , int totalWork ) { } public void done ( ) { } public void internalWorked ( double work ) { } public boolean isCanceled ( ) { return this . isCanceled ; } public void setCanceled ( boolean value ) { this . isCanceled = value ; } public void setTaskName ( String name ) { } public void subTask ( String name ) { } public void worked ( int work ) { } } ; TypeNameMatchRequestor typeNameMatchRequestor = new TypeNameMatchRequestor ( ) { public void acceptTypeNameMatch ( TypeNameMatch match ) { if ( SelectionEngine . this . requestor instanceof SelectionRequestor ) { SelectionEngine . this . noProposal = false ; ( ( SelectionRequestor ) SelectionEngine . this . requestor ) . acceptType ( match . getType ( ) ) ; } } } ; IJavaSearchScope scope = BasicSearchEngine . createWorkspaceScope ( ) ; SelectionTypeNameMatchRequestorWrapper requestorWrapper = new SelectionTypeNameMatchRequestorWrapper ( typeNameMatchRequestor , scope , this . unitScope == null ? null : this . unitScope . referenceContext . imports ) ; org . eclipse . jdt . core . ICompilationUnit [ ] workingCopies = this . owner == null ? null : JavaModelManager . getJavaModelManager ( ) . getWorkingCopies ( this . owner , true ) ; try { new BasicSearchEngine ( workingCopies ) . searchAllTypeNames ( null , SearchPattern . R_EXACT_MATCH , prefix , SearchPattern . R_EXACT_MATCH | SearchPattern . R_CASE_SENSITIVE , IJavaSearchConstants . TYPE , scope , requestorWrapper , IJavaSearchConstants . CANCEL_IF_NOT_READY_TO_SEARCH , progressMonitor ) ; } catch ( OperationCanceledException e ) { } requestorWrapper . acceptNotImported ( ) ; } catch ( JavaModelException e ) { } } public AssistParser getParser ( ) { return this . parser ; } private boolean isLocal ( ReferenceBinding binding ) { if ( binding instanceof ParameterizedTypeBinding ) { return isLocal ( ( ( ParameterizedTypeBinding ) binding ) . genericType ( ) ) ; } if ( ! ( binding instanceof SourceTypeBinding ) ) return false ; if ( binding instanceof LocalTypeBinding ) return true ; if ( binding instanceof MemberTypeBinding ) { return isLocal ( ( ( MemberTypeBinding ) binding ) . enclosingType ) ; } return false ; } public void select ( ICompilationUnit sourceUnit , int selectionSourceStart , int selectionSourceEnd ) { char [ ] source = sourceUnit . getContents ( ) ; if ( DEBUG ) { System . out . print ( "<STR_LIT>" ) ; System . out . print ( sourceUnit . getFileName ( ) ) ; System . out . print ( "<STR_LIT>" ) ; System . out . print ( selectionSourceStart ) ; System . out . print ( "<STR_LIT>" ) ; System . out . println ( selectionSourceEnd ) ; System . out . println ( "<STR_LIT>" ) ; System . out . println ( source ) ; } if ( ! checkSelection ( source , selectionSourceStart , selectionSourceEnd ) ) { return ; } if ( DEBUG ) { System . out . print ( "<STR_LIT>" ) ; System . out . print ( new String ( source , this . actualSelectionStart , this . actualSelectionEnd - this . actualSelectionStart + <NUM_LIT:1> ) ) ; System . out . println ( '<CHAR_LIT:">' ) ; } try { this . acceptedAnswer = false ; CompilationResult result = new CompilationResult ( sourceUnit , <NUM_LIT:1> , <NUM_LIT:1> , this . compilerOptions . maxProblemsPerUnit ) ; CompilationUnitDeclaration parsedUnit = this . parser . dietParse ( sourceUnit , result , this . actualSelectionStart , this . actualSelectionEnd ) ; if ( parsedUnit != null ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; System . out . println ( parsedUnit . toString ( ) ) ; } if ( parsedUnit . currentPackage instanceof SelectionOnPackageReference ) { char [ ] [ ] tokens = ( ( SelectionOnPackageReference ) parsedUnit . currentPackage ) . tokens ; this . noProposal = false ; this . requestor . acceptPackage ( CharOperation . concatWith ( tokens , '<CHAR_LIT:.>' ) ) ; return ; } ImportReference [ ] imports = parsedUnit . imports ; if ( imports != null ) { for ( int i = <NUM_LIT:0> , length = imports . length ; i < length ; i ++ ) { ImportReference importReference = imports [ i ] ; if ( importReference instanceof SelectionOnImportReference ) { char [ ] [ ] tokens = ( ( SelectionOnImportReference ) importReference ) . tokens ; this . noProposal = false ; this . requestor . acceptPackage ( CharOperation . concatWith ( tokens , '<CHAR_LIT:.>' ) ) ; this . nameEnvironment . findTypes ( CharOperation . concatWith ( tokens , '<CHAR_LIT:.>' ) , false , false , IJavaSearchConstants . TYPE , this ) ; this . lookupEnvironment . buildTypeBindings ( parsedUnit , null ) ; if ( ( this . unitScope = parsedUnit . scope ) != null ) { int tokenCount = tokens . length ; char [ ] lastToken = tokens [ tokenCount - <NUM_LIT:1> ] ; char [ ] [ ] qualifierTokens = CharOperation . subarray ( tokens , <NUM_LIT:0> , tokenCount - <NUM_LIT:1> ) ; if ( qualifierTokens != null && qualifierTokens . length > <NUM_LIT:0> ) { Binding binding = this . unitScope . getTypeOrPackage ( qualifierTokens ) ; if ( binding != null && binding instanceof ReferenceBinding ) { ReferenceBinding ref = ( ReferenceBinding ) binding ; selectMemberTypeFromImport ( parsedUnit , lastToken , ref , importReference . isStatic ( ) ) ; if ( importReference . isStatic ( ) ) { selectStaticFieldFromStaticImport ( parsedUnit , lastToken , ref ) ; selectStaticMethodFromStaticImport ( parsedUnit , lastToken , ref ) ; } } } } if ( ! this . acceptedAnswer ) { acceptQualifiedTypes ( ) ; if ( ! this . acceptedAnswer ) { this . nameEnvironment . findTypes ( this . selectedIdentifier , false , false , IJavaSearchConstants . TYPE , this ) ; if ( ! this . acceptedAnswer ) { acceptQualifiedTypes ( ) ; } } } if ( this . noProposal && this . problem != null ) { this . requestor . acceptError ( this . problem ) ; } return ; } } } if ( parsedUnit . types != null || parsedUnit . isPackageInfo ( ) ) { if ( selectDeclaration ( parsedUnit ) ) return ; this . lookupEnvironment . buildTypeBindings ( parsedUnit , null ) ; if ( ( this . unitScope = parsedUnit . scope ) != null ) { try { this . lookupEnvironment . completeTypeBindings ( parsedUnit , true ) ; CompilationUnitDeclaration previousUnitBeingCompleted = this . lookupEnvironment . unitBeingCompleted ; this . lookupEnvironment . unitBeingCompleted = parsedUnit ; parsedUnit . scope . faultInTypes ( ) ; this . lookupEnvironment . unitBeingCompleted = previousUnitBeingCompleted ; ASTNode node = null ; if ( parsedUnit . types != null ) node = parseBlockStatements ( parsedUnit , selectionSourceStart ) ; if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; System . out . println ( parsedUnit . toString ( ) ) ; } parsedUnit . resolve ( ) ; if ( node != null ) { selectLocalDeclaration ( node ) ; } } catch ( SelectionNodeFound e ) { if ( e . binding != null ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; System . out . println ( e . binding . toString ( ) ) ; } selectFrom ( e . binding , parsedUnit , e . isDeclaration ) ; } } } } } if ( ! this . acceptedAnswer ) { this . nameEnvironment . findTypes ( this . selectedIdentifier , false , false , IJavaSearchConstants . TYPE , this ) ; if ( ! this . acceptedAnswer ) { acceptQualifiedTypes ( ) ; if ( this . noProposal ) { findAllTypes ( this . selectedIdentifier ) ; } } } if ( this . noProposal && this . problem != null ) { this . requestor . acceptError ( this . problem ) ; } } catch ( IndexOutOfBoundsException e ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; e . printStackTrace ( System . out ) ; } } catch ( AbortCompilation e ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; e . printStackTrace ( System . out ) ; } } finally { reset ( true ) ; } } private void selectMemberTypeFromImport ( CompilationUnitDeclaration parsedUnit , char [ ] lastToken , ReferenceBinding ref , boolean staticOnly ) { int fieldLength = lastToken . length ; ReferenceBinding [ ] memberTypes = ref . memberTypes ( ) ; next : for ( int j = <NUM_LIT:0> ; j < memberTypes . length ; j ++ ) { ReferenceBinding memberType = memberTypes [ j ] ; if ( fieldLength > memberType . sourceName . length ) continue next ; if ( staticOnly && ! memberType . isStatic ( ) ) continue next ; if ( ! CharOperation . equals ( lastToken , memberType . sourceName , true ) ) continue next ; selectFrom ( memberType , parsedUnit , false ) ; } } private void selectStaticFieldFromStaticImport ( CompilationUnitDeclaration parsedUnit , char [ ] lastToken , ReferenceBinding ref ) { int fieldLength = lastToken . length ; FieldBinding [ ] fields = ref . availableFields ( ) ; next : for ( int j = <NUM_LIT:0> ; j < fields . length ; j ++ ) { FieldBinding field = fields [ j ] ; if ( fieldLength > field . name . length ) continue next ; if ( field . isSynthetic ( ) ) continue next ; if ( ! field . isStatic ( ) ) continue next ; if ( ! CharOperation . equals ( lastToken , field . name , true ) ) continue next ; selectFrom ( field , parsedUnit , false ) ; } } private void selectStaticMethodFromStaticImport ( CompilationUnitDeclaration parsedUnit , char [ ] lastToken , ReferenceBinding ref ) { int methodLength = lastToken . length ; MethodBinding [ ] methods = ref . availableMethods ( ) ; next : for ( int j = <NUM_LIT:0> ; j < methods . length ; j ++ ) { MethodBinding method = methods [ j ] ; if ( method . isSynthetic ( ) ) continue next ; if ( method . isDefaultAbstract ( ) ) continue next ; if ( method . isConstructor ( ) ) continue next ; if ( ! method . isStatic ( ) ) continue next ; if ( methodLength > method . selector . length ) continue next ; if ( ! CharOperation . equals ( lastToken , method . selector , true ) ) continue next ; selectFrom ( method , parsedUnit , false ) ; } } private void selectFrom ( Binding binding , CompilationUnitDeclaration parsedUnit , boolean isDeclaration ) { if ( binding instanceof TypeVariableBinding ) { TypeVariableBinding typeVariableBinding = ( TypeVariableBinding ) binding ; Binding enclosingElement = typeVariableBinding . declaringElement ; this . noProposal = false ; if ( enclosingElement instanceof SourceTypeBinding ) { SourceTypeBinding enclosingType = ( SourceTypeBinding ) enclosingElement ; if ( isLocal ( enclosingType ) && this . requestor instanceof SelectionRequestor ) { ( ( SelectionRequestor ) this . requestor ) . acceptLocalTypeParameter ( typeVariableBinding ) ; } else { this . requestor . acceptTypeParameter ( enclosingType . qualifiedPackageName ( ) , enclosingType . qualifiedSourceName ( ) , typeVariableBinding . sourceName ( ) , false , this . actualSelectionStart , this . actualSelectionEnd ) ; } } else if ( enclosingElement instanceof MethodBinding ) { MethodBinding enclosingMethod = ( MethodBinding ) enclosingElement ; if ( isLocal ( enclosingMethod . declaringClass ) && this . requestor instanceof SelectionRequestor ) { ( ( SelectionRequestor ) this . requestor ) . acceptLocalMethodTypeParameter ( typeVariableBinding ) ; } else { this . requestor . acceptMethodTypeParameter ( enclosingMethod . declaringClass . qualifiedPackageName ( ) , enclosingMethod . declaringClass . qualifiedSourceName ( ) , enclosingMethod . isConstructor ( ) ? enclosingMethod . declaringClass . sourceName ( ) : enclosingMethod . selector , enclosingMethod . sourceStart ( ) , enclosingMethod . sourceEnd ( ) , typeVariableBinding . sourceName ( ) , false , this . actualSelectionStart , this . actualSelectionEnd ) ; } } this . acceptedAnswer = true ; } else if ( binding instanceof ReferenceBinding ) { ReferenceBinding typeBinding = ( ReferenceBinding ) binding ; if ( typeBinding instanceof ProblemReferenceBinding ) { TypeBinding closestMatch = typeBinding . closestMatch ( ) ; if ( closestMatch instanceof ReferenceBinding ) { typeBinding = ( ReferenceBinding ) closestMatch ; } else { typeBinding = null ; } } if ( typeBinding == null ) return ; if ( isLocal ( typeBinding ) && this . requestor instanceof SelectionRequestor ) { this . noProposal = false ; ( ( SelectionRequestor ) this . requestor ) . acceptLocalType ( typeBinding ) ; } else { this . noProposal = false ; this . requestor . acceptType ( typeBinding . qualifiedPackageName ( ) , typeBinding . qualifiedSourceName ( ) , typeBinding . modifiers , false , typeBinding . computeUniqueKey ( ) , this . actualSelectionStart , this . actualSelectionEnd ) ; } this . acceptedAnswer = true ; } else if ( binding instanceof MethodBinding ) { MethodBinding methodBinding = getCorrectMethodBinding ( ( MethodBinding ) binding ) ; this . noProposal = false ; boolean isValuesOrValueOf = false ; if ( binding instanceof SyntheticMethodBinding ) { SyntheticMethodBinding syntheticMethodBinding = ( SyntheticMethodBinding ) binding ; if ( syntheticMethodBinding . purpose == SyntheticMethodBinding . EnumValues || syntheticMethodBinding . purpose == SyntheticMethodBinding . EnumValueOf ) { isValuesOrValueOf = true ; } } if ( ! isValuesOrValueOf && ! methodBinding . isSynthetic ( ) ) { TypeBinding [ ] parameterTypes = methodBinding . original ( ) . parameters ; int length = parameterTypes . length ; char [ ] [ ] parameterPackageNames = new char [ length ] [ ] ; char [ ] [ ] parameterTypeNames = new char [ length ] [ ] ; String [ ] parameterSignatures = new String [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { parameterPackageNames [ i ] = parameterTypes [ i ] . qualifiedPackageName ( ) ; parameterTypeNames [ i ] = parameterTypes [ i ] . qualifiedSourceName ( ) ; parameterSignatures [ i ] = new String ( getSignature ( parameterTypes [ i ] ) ) . replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; } TypeVariableBinding [ ] typeVariables = methodBinding . original ( ) . typeVariables ; length = typeVariables == null ? <NUM_LIT:0> : typeVariables . length ; char [ ] [ ] typeParameterNames = new char [ length ] [ ] ; char [ ] [ ] [ ] typeParameterBoundNames = new char [ length ] [ ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { TypeVariableBinding typeVariable = typeVariables [ i ] ; typeParameterNames [ i ] = typeVariable . sourceName ; if ( typeVariable . firstBound == null ) { typeParameterBoundNames [ i ] = new char [ <NUM_LIT:0> ] [ ] ; } else if ( typeVariable . firstBound == typeVariable . superclass ) { int boundCount = <NUM_LIT:1> + ( typeVariable . superInterfaces == null ? <NUM_LIT:0> : typeVariable . superInterfaces . length ) ; typeParameterBoundNames [ i ] = new char [ boundCount ] [ ] ; typeParameterBoundNames [ i ] [ <NUM_LIT:0> ] = typeVariable . superclass . sourceName ; for ( int j = <NUM_LIT:1> ; j < boundCount ; j ++ ) { typeParameterBoundNames [ i ] [ j ] = typeVariables [ i ] . superInterfaces [ j - <NUM_LIT:1> ] . sourceName ; } } else { int boundCount = typeVariable . superInterfaces == null ? <NUM_LIT:0> : typeVariable . superInterfaces . length ; typeParameterBoundNames [ i ] = new char [ boundCount ] [ ] ; for ( int j = <NUM_LIT:0> ; j < boundCount ; j ++ ) { typeParameterBoundNames [ i ] [ j ] = typeVariables [ i ] . superInterfaces [ j ] . sourceName ; } } } ReferenceBinding declaringClass = methodBinding . declaringClass ; if ( isLocal ( declaringClass ) && this . requestor instanceof SelectionRequestor ) { ( ( SelectionRequestor ) this . requestor ) . acceptLocalMethod ( methodBinding ) ; } else { this . requestor . acceptMethod ( declaringClass . qualifiedPackageName ( ) , declaringClass . qualifiedSourceName ( ) , declaringClass . enclosingType ( ) == null ? null : new String ( getSignature ( declaringClass . enclosingType ( ) ) ) , methodBinding . isConstructor ( ) ? declaringClass . sourceName ( ) : methodBinding . selector , parameterPackageNames , parameterTypeNames , parameterSignatures , typeParameterNames , typeParameterBoundNames , methodBinding . isConstructor ( ) , isDeclaration , methodBinding . computeUniqueKey ( ) , this . actualSelectionStart , this . actualSelectionEnd ) ; } } this . acceptedAnswer = true ; } else if ( binding instanceof FieldBinding ) { FieldBinding fieldBinding = ( FieldBinding ) binding ; ReferenceBinding declaringClass = fieldBinding . declaringClass ; if ( declaringClass != null ) { this . noProposal = false ; if ( isLocal ( declaringClass ) && this . requestor instanceof SelectionRequestor ) { ( ( SelectionRequestor ) this . requestor ) . acceptLocalField ( fieldBinding ) ; } else { FieldBinding currentFieldBinding = fieldBinding ; while ( currentFieldBinding instanceof ProblemFieldBinding ) { ProblemFieldBinding problemFieldBinding = ( ProblemFieldBinding ) currentFieldBinding ; if ( problemFieldBinding . problemId ( ) == ProblemReasons . NotVisible ) { currentFieldBinding = problemFieldBinding . closestMatch ; } else { currentFieldBinding = null ; } } char [ ] fieldName = null ; char [ ] key = null ; if ( currentFieldBinding != null ) { fieldName = currentFieldBinding . name ; key = currentFieldBinding . computeUniqueKey ( ) ; } else { fieldName = fieldBinding . name ; key = fieldBinding . computeUniqueKey ( ) ; } this . requestor . acceptField ( declaringClass . qualifiedPackageName ( ) , declaringClass . qualifiedSourceName ( ) , fieldName , false , key , this . actualSelectionStart , this . actualSelectionEnd ) ; } this . acceptedAnswer = true ; } } else if ( binding instanceof LocalVariableBinding ) { if ( this . requestor instanceof SelectionRequestor ) { ( ( SelectionRequestor ) this . requestor ) . acceptLocalVariable ( ( LocalVariableBinding ) binding ) ; this . acceptedAnswer = true ; } else { selectFrom ( ( ( LocalVariableBinding ) binding ) . type , parsedUnit , false ) ; } } else if ( binding instanceof ArrayBinding ) { selectFrom ( ( ( ArrayBinding ) binding ) . leafComponentType , parsedUnit , false ) ; } else if ( binding instanceof PackageBinding ) { PackageBinding packageBinding = ( PackageBinding ) binding ; this . noProposal = false ; this . requestor . acceptPackage ( packageBinding . readableName ( ) ) ; this . acceptedAnswer = true ; } else if ( binding instanceof BaseTypeBinding ) { this . acceptedAnswer = true ; } } private void selectLocalDeclaration ( ASTNode node ) { final char [ ] assistIdentifier = getParser ( ) . assistIdentifier ( ) ; if ( assistIdentifier == null ) return ; class Visitor extends ASTVisitor { public boolean visit ( ConstructorDeclaration constructorDeclaration , ClassScope scope ) { if ( constructorDeclaration . selector == assistIdentifier ) { if ( constructorDeclaration . binding != null ) { throw new SelectionNodeFound ( constructorDeclaration . binding ) ; } else { if ( constructorDeclaration . scope != null ) { throw new SelectionNodeFound ( new MethodBinding ( constructorDeclaration . modifiers , constructorDeclaration . selector , null , null , null , constructorDeclaration . scope . referenceType ( ) . binding ) ) ; } } } return true ; } public boolean visit ( FieldDeclaration fieldDeclaration , MethodScope scope ) { if ( fieldDeclaration . name == assistIdentifier ) { throw new SelectionNodeFound ( fieldDeclaration . binding ) ; } return true ; } public boolean visit ( TypeDeclaration localTypeDeclaration , BlockScope scope ) { if ( localTypeDeclaration . name == assistIdentifier ) { throw new SelectionNodeFound ( localTypeDeclaration . binding ) ; } return true ; } public boolean visit ( TypeDeclaration memberTypeDeclaration , ClassScope scope ) { if ( memberTypeDeclaration . name == assistIdentifier ) { throw new SelectionNodeFound ( memberTypeDeclaration . binding ) ; } return true ; } public boolean visit ( MethodDeclaration methodDeclaration , ClassScope scope ) { if ( methodDeclaration . selector == assistIdentifier ) { if ( methodDeclaration . binding != null ) { throw new SelectionNodeFound ( methodDeclaration . binding ) ; } else { if ( methodDeclaration . scope != null ) { throw new SelectionNodeFound ( new MethodBinding ( methodDeclaration . modifiers , methodDeclaration . selector , null , null , null , methodDeclaration . scope . referenceType ( ) . binding ) ) ; } } } return true ; } public boolean visit ( TypeDeclaration typeDeclaration , CompilationUnitScope scope ) { if ( typeDeclaration . name == assistIdentifier ) { throw new SelectionNodeFound ( typeDeclaration . binding ) ; } return true ; } public boolean visit ( TypeParameter typeParameter , BlockScope scope ) { if ( typeParameter . name == assistIdentifier ) { throw new SelectionNodeFound ( typeParameter . binding ) ; } return true ; } public boolean visit ( TypeParameter typeParameter , ClassScope scope ) { if ( typeParameter . name == assistIdentifier ) { throw new SelectionNodeFound ( typeParameter . binding ) ; } return true ; } } if ( node instanceof AbstractMethodDeclaration ) { ( ( AbstractMethodDeclaration ) node ) . traverse ( new Visitor ( ) , ( ClassScope ) null ) ; } else { ( ( FieldDeclaration ) node ) . traverse ( new Visitor ( ) , ( MethodScope ) null ) ; } } public void selectType ( char [ ] typeName , IType context ) throws JavaModelException { try { this . acceptedAnswer = false ; if ( CharOperation . indexOf ( '<CHAR_LIT>' , typeName ) != - <NUM_LIT:1> ) { char [ ] typeSig = Signature . createCharArrayTypeSignature ( typeName , false ) ; typeSig = Signature . getTypeErasure ( typeSig ) ; typeName = Signature . toCharArray ( typeSig ) ; } IType outerType = context ; IType parent = context . getDeclaringType ( ) ; while ( parent != null ) { outerType = parent ; parent = parent . getDeclaringType ( ) ; } CompilationUnitDeclaration parsedUnit = null ; TypeDeclaration typeDeclaration = null ; org . eclipse . jdt . core . ICompilationUnit cu = context . getCompilationUnit ( ) ; if ( cu != null ) { IType [ ] topLevelTypes = cu . getTypes ( ) ; int length = topLevelTypes . length ; SourceTypeElementInfo [ ] topLevelInfos = new SourceTypeElementInfo [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { topLevelInfos [ i ] = ( SourceTypeElementInfo ) ( ( SourceType ) topLevelTypes [ i ] ) . getElementInfo ( ) ; } ISourceType outerTypeInfo = ( ISourceType ) ( ( SourceType ) outerType ) . getElementInfo ( ) ; CompilationResult result = new CompilationResult ( outerTypeInfo . getFileName ( ) , <NUM_LIT:1> , <NUM_LIT:1> , this . compilerOptions . maxProblemsPerUnit ) ; int flags = SourceTypeConverter . FIELD_AND_METHOD | SourceTypeConverter . MEMBER_TYPE ; if ( context . isAnonymous ( ) || context . isLocal ( ) ) flags |= SourceTypeConverter . LOCAL_TYPE ; parsedUnit = SourceTypeConverter . buildCompilationUnit ( topLevelInfos , flags , this . parser . problemReporter ( ) , result ) ; if ( parsedUnit != null && parsedUnit . types != null ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; System . out . println ( parsedUnit . toString ( ) ) ; } typeDeclaration = new ASTNodeFinder ( parsedUnit ) . findType ( context ) ; } } else { ClassFile classFile = ( ClassFile ) context . getClassFile ( ) ; ClassFileReader reader = ( ClassFileReader ) classFile . getBinaryTypeInfo ( ( IFile ) classFile . resource ( ) , false ) ; CompilationResult result = new CompilationResult ( reader . getFileName ( ) , <NUM_LIT:1> , <NUM_LIT:1> , this . compilerOptions . maxProblemsPerUnit ) ; parsedUnit = new CompilationUnitDeclaration ( this . parser . problemReporter ( ) , result , <NUM_LIT:0> ) ; HashSetOfCharArrayArray typeNames = new HashSetOfCharArrayArray ( ) ; BinaryTypeConverter converter = new BinaryTypeConverter ( this . parser . problemReporter ( ) , result , typeNames ) ; typeDeclaration = converter . buildTypeDeclaration ( context , parsedUnit ) ; parsedUnit . imports = converter . buildImports ( reader ) ; } if ( typeDeclaration != null ) { FieldDeclaration field = new FieldDeclaration ( ) ; int dot ; if ( ( dot = CharOperation . lastIndexOf ( '<CHAR_LIT:.>' , typeName ) ) == - <NUM_LIT:1> ) { this . selectedIdentifier = typeName ; field . type = new SelectionOnSingleTypeReference ( typeName , - <NUM_LIT:1> ) ; } else { char [ ] [ ] previousIdentifiers = CharOperation . splitOn ( '<CHAR_LIT:.>' , typeName , <NUM_LIT:0> , dot ) ; char [ ] selectionIdentifier = CharOperation . subarray ( typeName , dot + <NUM_LIT:1> , typeName . length ) ; this . selectedIdentifier = selectionIdentifier ; field . type = new SelectionOnQualifiedTypeReference ( previousIdentifiers , selectionIdentifier , new long [ previousIdentifiers . length + <NUM_LIT:1> ] ) ; } field . name = "<STR_LIT>" . toCharArray ( ) ; typeDeclaration . fields = new FieldDeclaration [ ] { field } ; this . lookupEnvironment . buildTypeBindings ( parsedUnit , null ) ; if ( ( this . unitScope = parsedUnit . scope ) != null ) { try { this . lookupEnvironment . completeTypeBindings ( parsedUnit , true ) ; parsedUnit . scope . faultInTypes ( ) ; parsedUnit . resolve ( ) ; } catch ( SelectionNodeFound e ) { if ( e . binding != null ) { if ( DEBUG ) { System . out . println ( "<STR_LIT>" ) ; System . out . println ( e . binding . toString ( ) ) ; } selectFrom ( e . binding , parsedUnit , e . isDeclaration ) ; } } } } if ( this . noProposal && this . problem != null ) { this . requestor . acceptError ( this . problem ) ; } } catch ( AbortCompilation e ) { } finally { reset ( true ) ; } } private boolean selectDeclaration ( CompilationUnitDeclaration compilationUnit ) { char [ ] assistIdentifier = getParser ( ) . assistIdentifier ( ) ; if ( assistIdentifier == null ) return false ; ImportReference currentPackage = compilationUnit . currentPackage ; char [ ] packageName = currentPackage == null ? CharOperation . NO_CHAR : CharOperation . concatWith ( currentPackage . tokens , '<CHAR_LIT:.>' ) ; TypeDeclaration [ ] types = compilationUnit . types ; for ( int i = <NUM_LIT:0> , length = types == null ? <NUM_LIT:0> : types . length ; i < length ; i ++ ) { if ( selectDeclaration ( types [ i ] , assistIdentifier , packageName ) ) return true ; } return false ; } private boolean selectDeclaration ( TypeDeclaration typeDeclaration , char [ ] assistIdentifier , char [ ] packageName ) { if ( typeDeclaration . name == assistIdentifier ) { char [ ] qualifiedSourceName = null ; TypeDeclaration enclosingType = typeDeclaration ; while ( enclosingType != null ) { qualifiedSourceName = CharOperation . concat ( enclosingType . name , qualifiedSourceName , '<CHAR_LIT:.>' ) ; enclosingType = enclosingType . enclosingType ; } char [ ] uniqueKey = typeDeclaration . binding != null ? typeDeclaration . binding . computeUniqueKey ( ) : null ; this . requestor . acceptType ( packageName , qualifiedSourceName , typeDeclaration . modifiers , true , uniqueKey , this . actualSelectionStart , this . actualSelectionEnd ) ; this . noProposal = false ; return true ; } TypeDeclaration [ ] memberTypes = typeDeclaration . memberTypes ; for ( int i = <NUM_LIT:0> , length = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; i < length ; i ++ ) { if ( selectDeclaration ( memberTypes [ i ] , assistIdentifier , packageName ) ) return true ; } FieldDeclaration [ ] fields = typeDeclaration . fields ; for ( int i = <NUM_LIT:0> , length = fields == null ? <NUM_LIT:0> : fields . length ; i < length ; i ++ ) { if ( fields [ i ] . name == assistIdentifier ) { char [ ] qualifiedSourceName = null ; TypeDeclaration enclosingType = typeDeclaration ; while ( enclosingType != null ) { qualifiedSourceName = CharOperation . concat ( enclosingType . name , qualifiedSourceName , '<CHAR_LIT:.>' ) ; enclosingType = enclosingType . enclosingType ; } FieldDeclaration field = fields [ i ] ; this . requestor . acceptField ( packageName , qualifiedSourceName , field . name , true , field . binding != null ? field . binding . computeUniqueKey ( ) : null , this . actualSelectionStart , this . actualSelectionEnd ) ; this . noProposal = false ; return true ; } } AbstractMethodDeclaration [ ] methods = typeDeclaration . methods ; for ( int i = <NUM_LIT:0> , length = methods == null ? <NUM_LIT:0> : methods . length ; i < length ; i ++ ) { AbstractMethodDeclaration method = methods [ i ] ; if ( method . selector == assistIdentifier ) { char [ ] qualifiedSourceName = null ; TypeDeclaration enclosingType = typeDeclaration ; while ( enclosingType != null ) { qualifiedSourceName = CharOperation . concat ( enclosingType . name , qualifiedSourceName , '<CHAR_LIT:.>' ) ; enclosingType = enclosingType . enclosingType ; } this . requestor . acceptMethod ( packageName , qualifiedSourceName , null , method . selector , null , null , null , null , null , method . isConstructor ( ) , true , method . binding != null ? method . binding . computeUniqueKey ( ) : null , this . actualSelectionStart , this . actualSelectionEnd ) ; this . noProposal = false ; return true ; } TypeParameter [ ] methodTypeParameters = method . typeParameters ( ) ; for ( int j = <NUM_LIT:0> , length2 = methodTypeParameters == null ? <NUM_LIT:0> : methodTypeParameters . length ; j < length2 ; j ++ ) { TypeParameter methodTypeParameter = methodTypeParameters [ j ] ; if ( methodTypeParameter . name == assistIdentifier ) { char [ ] qualifiedSourceName = null ; TypeDeclaration enclosingType = typeDeclaration ; while ( enclosingType != null ) { qualifiedSourceName = CharOperation . concat ( enclosingType . name , qualifiedSourceName , '<CHAR_LIT:.>' ) ; enclosingType = enclosingType . enclosingType ; } this . requestor . acceptMethodTypeParameter ( packageName , qualifiedSourceName , method . selector , method . sourceStart , method . sourceEnd , methodTypeParameter . name , true , this . actualSelectionStart , this . actualSelectionEnd ) ; this . noProposal = false ; return true ; } } } TypeParameter [ ] typeParameters = typeDeclaration . typeParameters ; for ( int i = <NUM_LIT:0> , length = typeParameters == null ? <NUM_LIT:0> : typeParameters . length ; i < length ; i ++ ) { TypeParameter typeParameter = typeParameters [ i ] ; if ( typeParameter . name == assistIdentifier ) { char [ ] qualifiedSourceName = null ; TypeDeclaration enclosingType = typeDeclaration ; while ( enclosingType != null ) { qualifiedSourceName = CharOperation . concat ( enclosingType . name , qualifiedSourceName , '<CHAR_LIT:.>' ) ; enclosingType = enclosingType . enclosingType ; } this . requestor . acceptTypeParameter ( packageName , qualifiedSourceName , typeParameter . name , true , this . actualSelectionStart , this . actualSelectionEnd ) ; this . noProposal = false ; return true ; } } return false ; } private MethodBinding getCorrectMethodBinding ( MethodBinding binding ) { if ( this . parser . javadocParser instanceof SelectionJavadocParser ) { if ( ( ( SelectionJavadocParser ) this . parser . javadocParser ) . inheritDocTagSelected ) { try { Object res = findMethodWithAttachedDocInHierarchy ( binding ) ; if ( res instanceof MethodBinding ) { return ( MethodBinding ) res ; } } catch ( JavaModelException e ) { return null ; } } } return binding ; } protected MethodBinding findOverriddenMethodInType ( ReferenceBinding overriddenType , MethodBinding overriding ) throws JavaModelException { if ( overriddenType == null ) return null ; MethodBinding [ ] overriddenMethods = overriddenType . availableMethods ( ) ; LookupEnvironment lookupEnv = this . lookupEnvironment ; if ( lookupEnv != null && overriddenMethods != null ) { for ( int i = <NUM_LIT:0> ; i < overriddenMethods . length ; i ++ ) { if ( lookupEnv . methodVerifier ( ) . isMethodSubsignature ( overriding , overriddenMethods [ i ] ) ) { return overriddenMethods [ i ] ; } } } return null ; } private Object findMethodWithAttachedDocInHierarchy ( final MethodBinding method ) throws JavaModelException { ReferenceBinding type = method . declaringClass ; final SelectionRequestor requestor1 = ( SelectionRequestor ) this . requestor ; return new InheritDocVisitor ( ) { public Object visit ( ReferenceBinding currType ) throws JavaModelException { MethodBinding overridden = findOverriddenMethodInType ( currType , method ) ; if ( overridden == null ) return InheritDocVisitor . CONTINUE ; TypeBinding args [ ] = overridden . parameters ; String names [ ] = new String [ args . length ] ; for ( int i = <NUM_LIT:0> ; i < args . length ; i ++ ) { names [ i ] = Signature . createTypeSignature ( args [ i ] . sourceName ( ) , false ) ; } IMember member = ( IMember ) requestor1 . findMethodFromBinding ( overridden , names , overridden . declaringClass ) ; if ( member == null ) return InheritDocVisitor . CONTINUE ; if ( member . getAttachedJavadoc ( null ) != null ) { return overridden ; } IOpenable openable = member . getOpenable ( ) ; if ( openable == null ) return InheritDocVisitor . CONTINUE ; IBuffer buf = openable . getBuffer ( ) ; if ( buf == null ) { return InheritDocVisitor . STOP_BRANCH ; } ISourceRange javadocRange = member . getJavadocRange ( ) ; if ( javadocRange == null ) return InheritDocVisitor . CONTINUE ; String rawJavadoc = buf . getText ( javadocRange . getOffset ( ) , javadocRange . getLength ( ) ) ; if ( rawJavadoc != null ) { return overridden ; } return InheritDocVisitor . CONTINUE ; } } . visitInheritDoc ( type ) ; } static abstract class InheritDocVisitor { public static final Object STOP_BRANCH = new Object ( ) { public String toString ( ) { return "<STR_LIT>" ; } } ; public static final Object CONTINUE = new Object ( ) { public String toString ( ) { return "<STR_LIT>" ; } } ; public abstract Object visit ( ReferenceBinding currType ) throws JavaModelException ; public Object visitInheritDoc ( ReferenceBinding currentType ) throws JavaModelException { ArrayList visited = new ArrayList ( ) ; visited . add ( currentType ) ; Object result = visitInheritDocInterfaces ( visited , currentType ) ; if ( result != InheritDocVisitor . CONTINUE ) return result ; ReferenceBinding superClass = currentType . superclass ( ) ; while ( superClass != null && ! visited . contains ( superClass ) ) { result = visit ( superClass ) ; if ( result == InheritDocVisitor . STOP_BRANCH ) { return null ; } else if ( result == InheritDocVisitor . CONTINUE ) { visited . add ( superClass ) ; result = visitInheritDocInterfaces ( visited , superClass ) ; if ( result != InheritDocVisitor . CONTINUE ) return result ; else superClass = superClass . superclass ( ) ; } else { return result ; } } return null ; } private Object visitInheritDocInterfaces ( ArrayList visited , ReferenceBinding currentType ) throws JavaModelException { ArrayList toVisitChildren = new ArrayList ( ) ; ReferenceBinding [ ] superInterfaces = currentType . superInterfaces ( ) ; for ( int i = <NUM_LIT:0> ; i < superInterfaces . length ; i ++ ) { ReferenceBinding superInterface = superInterfaces [ i ] ; if ( visited . contains ( superInterface ) ) continue ; visited . add ( superInterface ) ; Object result = visit ( superInterface ) ; if ( result == InheritDocVisitor . STOP_BRANCH ) { } else if ( result == InheritDocVisitor . CONTINUE ) { toVisitChildren . add ( superInterface ) ; } else { return result ; } } for ( Iterator iter = toVisitChildren . iterator ( ) ; iter . hasNext ( ) ; ) { ReferenceBinding child = ( ReferenceBinding ) iter . next ( ) ; Object result = visitInheritDocInterfaces ( visited , child ) ; if ( result != InheritDocVisitor . CONTINUE ) return result ; } return InheritDocVisitor . CONTINUE ; } } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . Set ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . search . IJavaSearchConstants ; import org . eclipse . jdt . internal . compiler . ASTVisitor ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . env . AccessRestriction ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . Scope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObjectToInt ; import org . eclipse . jdt . internal . core . SearchableEnvironment ; public class MissingTypesGuesser extends ASTVisitor { public static interface GuessedTypeRequestor { public void accept ( TypeBinding guessedType , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds , boolean hasProblems ) ; } private static class ResolutionCleaner extends ASTVisitor { private HashtableOfObjectToInt bitsMap = new HashtableOfObjectToInt ( ) ; private boolean firstCall = true ; public ResolutionCleaner ( ) { super ( ) ; } private void cleanUp ( TypeReference typeReference ) { if ( this . firstCall ) { this . bitsMap . put ( typeReference , typeReference . bits ) ; } else { typeReference . bits = this . bitsMap . get ( typeReference ) ; } typeReference . resolvedType = null ; } private void cleanUp ( ParameterizedSingleTypeReference typeReference ) { this . cleanUp ( ( TypeReference ) typeReference ) ; typeReference . bits &= ~ ASTNode . DidResolve ; } private void cleanUp ( ParameterizedQualifiedTypeReference typeReference ) { this . cleanUp ( ( TypeReference ) typeReference ) ; typeReference . bits &= ~ ASTNode . DidResolve ; } public void cleanUp ( TypeReference convertedType , BlockScope scope ) { convertedType . traverse ( this , scope ) ; this . firstCall = false ; } public void cleanUp ( TypeReference convertedType , ClassScope scope ) { convertedType . traverse ( this , scope ) ; this . firstCall = false ; } public boolean visit ( SingleTypeReference singleTypeReference , BlockScope scope ) { this . cleanUp ( singleTypeReference ) ; return true ; } public boolean visit ( SingleTypeReference singleTypeReference , ClassScope scope ) { this . cleanUp ( singleTypeReference ) ; return true ; } public boolean visit ( Wildcard wildcard , BlockScope scope ) { this . cleanUp ( wildcard ) ; return true ; } public boolean visit ( Wildcard wildcard , ClassScope scope ) { this . cleanUp ( wildcard ) ; return true ; } public boolean visit ( ArrayTypeReference arrayTypeReference , BlockScope scope ) { this . cleanUp ( arrayTypeReference ) ; return true ; } public boolean visit ( ArrayTypeReference arrayTypeReference , ClassScope scope ) { this . cleanUp ( arrayTypeReference ) ; return true ; } public boolean visit ( ParameterizedSingleTypeReference parameterizedSingleTypeReference , BlockScope scope ) { this . cleanUp ( parameterizedSingleTypeReference ) ; return true ; } public boolean visit ( ParameterizedSingleTypeReference parameterizedSingleTypeReference , ClassScope scope ) { this . cleanUp ( parameterizedSingleTypeReference ) ; return true ; } public boolean visit ( QualifiedTypeReference qualifiedTypeReference , BlockScope scope ) { this . cleanUp ( qualifiedTypeReference ) ; return true ; } public boolean visit ( QualifiedTypeReference qualifiedTypeReference , ClassScope scope ) { this . cleanUp ( qualifiedTypeReference ) ; return true ; } public boolean visit ( ArrayQualifiedTypeReference arrayQualifiedTypeReference , BlockScope scope ) { this . cleanUp ( arrayQualifiedTypeReference ) ; return true ; } public boolean visit ( ArrayQualifiedTypeReference arrayQualifiedTypeReference , ClassScope scope ) { this . cleanUp ( arrayQualifiedTypeReference ) ; return true ; } public boolean visit ( ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference , BlockScope scope ) { this . cleanUp ( parameterizedQualifiedTypeReference ) ; return true ; } public boolean visit ( ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference , ClassScope scope ) { this . cleanUp ( parameterizedQualifiedTypeReference ) ; return true ; } } private CompletionEngine . CompletionProblemFactory problemFactory ; private SearchableEnvironment nameEnvironment ; private HashMap substituedTypes ; private HashMap originalTypes ; private int combinationsCount ; public MissingTypesGuesser ( CompletionEngine completionEngine ) { this . problemFactory = completionEngine . problemFactory ; this . nameEnvironment = completionEngine . nameEnvironment ; } private boolean computeMissingElements ( QualifiedTypeReference [ ] substituedTypeNodes , char [ ] [ ] [ ] originalTypeNames , Binding [ ] missingElements , int [ ] missingElementsStarts , int [ ] missingElementsEnds ) { int length = substituedTypeNodes . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { TypeReference substituedType = substituedTypeNodes [ i ] ; if ( substituedType . resolvedType == null ) return false ; ReferenceBinding erasure = ( ReferenceBinding ) substituedType . resolvedType . leafComponentType ( ) . erasure ( ) ; Binding missingElement ; int depthToRemove = originalTypeNames [ i ] . length - <NUM_LIT:1> ; if ( depthToRemove == <NUM_LIT:0> ) { missingElement = erasure ; } else { int depth = erasure . depth ( ) + <NUM_LIT:1> ; if ( depth > depthToRemove ) { missingElement = erasure . enclosingTypeAt ( depthToRemove ) ; } else { return false ; } } missingElements [ i ] = missingElement ; missingElementsStarts [ i ] = substituedType . sourceStart ; missingElementsEnds [ i ] = substituedType . sourceEnd + <NUM_LIT:1> ; } return true ; } private TypeReference convert ( ArrayQualifiedTypeReference typeRef ) { if ( typeRef . resolvedType != null ) { if ( typeRef . resolvedType . isValidBinding ( ) ) { ArrayQualifiedTypeReference convertedType = new ArrayQualifiedTypeReference ( typeRef . tokens , typeRef . dimensions ( ) , typeRef . sourcePositions ) ; convertedType . sourceStart = typeRef . sourceStart ; convertedType . sourceEnd = typeRef . sourceEnd ; return convertedType ; } else if ( ( typeRef . resolvedType . problemId ( ) & ProblemReasons . NotFound ) != <NUM_LIT:0> ) { if ( ( ( ReferenceBinding ) typeRef . resolvedType . leafComponentType ( ) ) . compoundName . length != <NUM_LIT:1> ) return null ; char [ ] [ ] typeName = typeRef . getTypeName ( ) ; char [ ] [ ] [ ] typeNames = findTypeNames ( typeName ) ; if ( typeNames == null || typeNames . length == <NUM_LIT:0> ) return null ; ArrayQualifiedTypeReference convertedType = new ArrayQualifiedTypeReference ( typeNames [ <NUM_LIT:0> ] , typeRef . dimensions ( ) , new long [ typeNames [ <NUM_LIT:0> ] . length ] ) ; convertedType . sourceStart = typeRef . sourceStart ; convertedType . sourceEnd = ( int ) ( typeRef . sourcePositions [ <NUM_LIT:0> ] & <NUM_LIT> ) ; this . substituedTypes . put ( convertedType , typeNames ) ; this . originalTypes . put ( convertedType , typeName ) ; this . combinationsCount *= typeNames . length ; return convertedType ; } } return null ; } private TypeReference convert ( ArrayTypeReference typeRef ) { if ( typeRef . resolvedType != null ) { if ( typeRef . resolvedType . isValidBinding ( ) ) { ArrayTypeReference convertedType = new ArrayTypeReference ( typeRef . token , typeRef . dimensions , <NUM_LIT:0> ) ; convertedType . sourceStart = typeRef . sourceStart ; convertedType . sourceEnd = typeRef . originalSourceEnd ; return convertedType ; } else if ( ( typeRef . resolvedType . problemId ( ) & ProblemReasons . NotFound ) != <NUM_LIT:0> ) { char [ ] [ ] typeName = typeRef . getTypeName ( ) ; char [ ] [ ] [ ] typeNames = findTypeNames ( typeName ) ; if ( typeNames == null || typeNames . length == <NUM_LIT:0> ) return null ; ArrayQualifiedTypeReference convertedType = new ArrayQualifiedTypeReference ( typeNames [ <NUM_LIT:0> ] , typeRef . dimensions , new long [ typeNames [ <NUM_LIT:0> ] . length ] ) ; convertedType . sourceStart = typeRef . sourceStart ; convertedType . sourceEnd = typeRef . originalSourceEnd ; this . substituedTypes . put ( convertedType , typeNames ) ; this . originalTypes . put ( convertedType , typeName ) ; this . combinationsCount *= typeNames . length ; return convertedType ; } } return null ; } private TypeReference convert ( ParameterizedQualifiedTypeReference typeRef ) { if ( typeRef . resolvedType != null ) { TypeReference [ ] [ ] typeArguments = typeRef . typeArguments ; int length = typeArguments . length ; TypeReference [ ] [ ] convertedTypeArguments = new TypeReference [ length ] [ ] ; next : for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( typeArguments [ i ] == null ) continue next ; int length2 = typeArguments [ i ] . length ; convertedTypeArguments [ i ] = new TypeReference [ length2 ] ; for ( int j = <NUM_LIT:0> ; j < length2 ; j ++ ) { convertedTypeArguments [ i ] [ j ] = convert ( typeArguments [ i ] [ j ] ) ; if ( convertedTypeArguments [ i ] [ j ] == null ) return null ; } } if ( typeRef . resolvedType . isValidBinding ( ) ) { ParameterizedQualifiedTypeReference convertedType = new ParameterizedQualifiedTypeReference ( typeRef . tokens , convertedTypeArguments , typeRef . dimensions ( ) , new long [ typeRef . tokens . length ] ) ; convertedType . sourceStart = typeRef . sourceStart ; convertedType . sourceEnd = typeRef . sourceEnd ; return convertedType ; } else if ( ( typeRef . resolvedType . problemId ( ) & ProblemReasons . NotFound ) != <NUM_LIT:0> ) { if ( ( ( ReferenceBinding ) typeRef . resolvedType . leafComponentType ( ) ) . compoundName . length != <NUM_LIT:1> ) return null ; char [ ] [ ] typeName = typeRef . getTypeName ( ) ; char [ ] [ ] [ ] typeNames = findTypeNames ( typeName ) ; if ( typeNames == null || typeNames . length == <NUM_LIT:0> ) return null ; TypeReference [ ] [ ] newConvertedTypeArguments = new TypeReference [ typeNames [ <NUM_LIT:0> ] . length ] [ ] ; for ( int k = newConvertedTypeArguments . length - <NUM_LIT:1> , l = convertedTypeArguments . length - <NUM_LIT:1> ; k > - <NUM_LIT:1> && l > - <NUM_LIT:1> ; ) { newConvertedTypeArguments [ k ] = convertedTypeArguments [ l ] ; k -- ; l -- ; } ParameterizedQualifiedTypeReference convertedType = new ParameterizedQualifiedTypeReference ( typeNames [ <NUM_LIT:0> ] , newConvertedTypeArguments , typeRef . dimensions ( ) , new long [ typeNames [ <NUM_LIT:0> ] . length ] ) ; convertedType . sourceStart = typeRef . sourceStart ; convertedType . sourceEnd = ( int ) ( typeRef . sourcePositions [ <NUM_LIT:0> ] & <NUM_LIT> ) ; this . substituedTypes . put ( convertedType , typeNames ) ; this . originalTypes . put ( convertedType , typeName ) ; this . combinationsCount *= typeNames . length ; return convertedType ; } } return null ; } private TypeReference convert ( ParameterizedSingleTypeReference typeRef ) { if ( typeRef . resolvedType != null ) { TypeReference [ ] typeArguments = typeRef . typeArguments ; int length = typeArguments . length ; TypeReference [ ] convertedTypeArguments = new TypeReference [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { convertedTypeArguments [ i ] = convert ( typeArguments [ i ] ) ; if ( convertedTypeArguments [ i ] == null ) return null ; } if ( typeRef . resolvedType . isValidBinding ( ) ) { ParameterizedSingleTypeReference convertedType = new ParameterizedSingleTypeReference ( typeRef . token , convertedTypeArguments , typeRef . dimensions , <NUM_LIT:0> ) ; convertedType . sourceStart = typeRef . sourceStart ; convertedType . sourceEnd = typeRef . sourceEnd ; return convertedType ; } else if ( ( typeRef . resolvedType . problemId ( ) & ProblemReasons . NotFound ) != <NUM_LIT:0> ) { char [ ] [ ] typeName = typeRef . getTypeName ( ) ; char [ ] [ ] [ ] typeNames = findTypeNames ( typeName ) ; if ( typeNames == null || typeNames . length == <NUM_LIT:0> ) return null ; TypeReference [ ] [ ] allConvertedTypeArguments = new TypeReference [ typeNames [ <NUM_LIT:0> ] . length ] [ ] ; allConvertedTypeArguments [ allConvertedTypeArguments . length - <NUM_LIT:1> ] = convertedTypeArguments ; ParameterizedQualifiedTypeReference convertedType = new ParameterizedQualifiedTypeReference ( typeNames [ <NUM_LIT:0> ] , allConvertedTypeArguments , typeRef . dimensions , new long [ typeNames [ <NUM_LIT:0> ] . length ] ) ; convertedType . sourceStart = typeRef . sourceStart ; convertedType . sourceEnd = typeRef . sourceEnd ; this . substituedTypes . put ( convertedType , typeNames ) ; this . originalTypes . put ( convertedType , typeName ) ; this . combinationsCount *= typeNames . length ; return convertedType ; } } return null ; } private TypeReference convert ( QualifiedTypeReference typeRef ) { if ( typeRef . resolvedType != null ) { if ( typeRef . resolvedType . isValidBinding ( ) ) { QualifiedTypeReference convertedType = new QualifiedTypeReference ( typeRef . tokens , typeRef . sourcePositions ) ; convertedType . sourceStart = typeRef . sourceStart ; convertedType . sourceEnd = typeRef . sourceEnd ; return convertedType ; } else if ( ( typeRef . resolvedType . problemId ( ) & ProblemReasons . NotFound ) != <NUM_LIT:0> ) { if ( ( ( ReferenceBinding ) typeRef . resolvedType ) . compoundName . length != <NUM_LIT:1> ) return null ; char [ ] [ ] typeName = typeRef . getTypeName ( ) ; char [ ] [ ] [ ] typeNames = findTypeNames ( typeName ) ; if ( typeNames == null || typeNames . length == <NUM_LIT:0> ) return null ; QualifiedTypeReference convertedType = new QualifiedTypeReference ( typeNames [ <NUM_LIT:0> ] , new long [ typeNames [ <NUM_LIT:0> ] . length ] ) ; convertedType . sourceStart = typeRef . sourceStart ; convertedType . sourceEnd = ( int ) ( typeRef . sourcePositions [ <NUM_LIT:0> ] & <NUM_LIT> ) ; this . substituedTypes . put ( convertedType , typeNames ) ; this . originalTypes . put ( convertedType , typeName ) ; this . combinationsCount *= typeNames . length ; return convertedType ; } } return null ; } private TypeReference convert ( SingleTypeReference typeRef ) { if ( typeRef . resolvedType != null ) { if ( typeRef . resolvedType . isValidBinding ( ) ) { SingleTypeReference convertedType = new SingleTypeReference ( typeRef . token , <NUM_LIT:0> ) ; convertedType . sourceStart = typeRef . sourceStart ; convertedType . sourceEnd = typeRef . sourceEnd ; return convertedType ; } else if ( ( typeRef . resolvedType . problemId ( ) & ProblemReasons . NotFound ) != <NUM_LIT:0> ) { char [ ] [ ] typeName = typeRef . getTypeName ( ) ; char [ ] [ ] [ ] typeNames = findTypeNames ( typeName ) ; if ( typeNames == null || typeNames . length == <NUM_LIT:0> ) return null ; QualifiedTypeReference convertedType = new QualifiedTypeReference ( typeNames [ <NUM_LIT:0> ] , new long [ typeNames [ <NUM_LIT:0> ] . length ] ) ; convertedType . sourceStart = typeRef . sourceStart ; convertedType . sourceEnd = typeRef . sourceEnd ; this . substituedTypes . put ( convertedType , typeNames ) ; this . originalTypes . put ( convertedType , typeName ) ; this . combinationsCount *= typeNames . length ; return convertedType ; } } return null ; } private TypeReference convert ( TypeReference typeRef ) { if ( typeRef instanceof ParameterizedSingleTypeReference ) { return convert ( ( ParameterizedSingleTypeReference ) typeRef ) ; } else if ( typeRef instanceof ParameterizedQualifiedTypeReference ) { return convert ( ( ParameterizedQualifiedTypeReference ) typeRef ) ; } else if ( typeRef instanceof ArrayTypeReference ) { return convert ( ( ArrayTypeReference ) typeRef ) ; } else if ( typeRef instanceof ArrayQualifiedTypeReference ) { return convert ( ( ArrayQualifiedTypeReference ) typeRef ) ; } else if ( typeRef instanceof Wildcard ) { return convert ( ( Wildcard ) typeRef ) ; } else if ( typeRef instanceof SingleTypeReference ) { return convert ( ( SingleTypeReference ) typeRef ) ; } else if ( typeRef instanceof QualifiedTypeReference ) { return convert ( ( QualifiedTypeReference ) typeRef ) ; } return null ; } private TypeReference convert ( Wildcard typeRef ) { TypeReference bound = typeRef . bound ; TypeReference convertedBound = null ; if ( bound != null ) { convertedBound = convert ( bound ) ; if ( convertedBound == null ) return null ; } Wildcard convertedType = new Wildcard ( typeRef . kind ) ; convertedType . bound = convertedBound ; convertedType . sourceStart = typeRef . sourceStart ; convertedType . sourceEnd = typeRef . sourceEnd ; return convertedType ; } private char [ ] [ ] [ ] findTypeNames ( char [ ] [ ] missingTypeName ) { char [ ] missingSimpleName = missingTypeName [ missingTypeName . length - <NUM_LIT:1> ] ; final boolean isQualified = missingTypeName . length > <NUM_LIT:1> ; final char [ ] missingFullyQualifiedName = isQualified ? CharOperation . concatWith ( missingTypeName , '<CHAR_LIT:.>' ) : null ; final ArrayList results = new ArrayList ( ) ; ISearchRequestor storage = new ISearchRequestor ( ) { public void acceptConstructor ( int modifiers , char [ ] simpleTypeName , int parameterCount , char [ ] signature , char [ ] [ ] parameterTypes , char [ ] [ ] parameterNames , int typeModifiers , char [ ] packageName , int extraFlags , String path , AccessRestriction access ) { } public void acceptPackage ( char [ ] packageName ) { } public void acceptType ( char [ ] packageName , char [ ] typeName , char [ ] [ ] enclosingTypeNames , int modifiers , AccessRestriction accessRestriction ) { char [ ] fullyQualifiedName = CharOperation . concat ( packageName , CharOperation . concat ( CharOperation . concatWith ( enclosingTypeNames , '<CHAR_LIT:.>' ) , typeName , '<CHAR_LIT:.>' ) , '<CHAR_LIT:.>' ) ; if ( isQualified && ! CharOperation . endsWith ( fullyQualifiedName , missingFullyQualifiedName ) ) return ; char [ ] [ ] compoundName = CharOperation . splitOn ( '<CHAR_LIT:.>' , fullyQualifiedName ) ; results . add ( compoundName ) ; } } ; this . nameEnvironment . findExactTypes ( missingSimpleName , true , IJavaSearchConstants . TYPE , storage ) ; if ( results . size ( ) == <NUM_LIT:0> ) return null ; return ( char [ ] [ ] [ ] ) results . toArray ( new char [ results . size ( ) ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] ) ; } private char [ ] [ ] getOriginal ( TypeReference typeRef ) { return ( char [ ] [ ] ) this . originalTypes . get ( typeRef ) ; } private QualifiedTypeReference [ ] getSubstituedTypes ( ) { Set types = this . substituedTypes . keySet ( ) ; return ( QualifiedTypeReference [ ] ) types . toArray ( new QualifiedTypeReference [ types . size ( ) ] ) ; } private char [ ] [ ] [ ] getSubstitution ( TypeReference typeRef ) { return ( char [ ] [ ] [ ] ) this . substituedTypes . get ( typeRef ) ; } public void guess ( TypeReference typeRef , Scope scope , GuessedTypeRequestor requestor ) { this . substituedTypes = new HashMap ( ) ; this . originalTypes = new HashMap ( ) ; this . combinationsCount = <NUM_LIT:1> ; TypeReference convertedType = convert ( typeRef ) ; if ( convertedType == null ) return ; QualifiedTypeReference [ ] substituedTypeNodes = getSubstituedTypes ( ) ; int length = substituedTypeNodes . length ; int [ ] substitutionsIndexes = new int [ substituedTypeNodes . length ] ; char [ ] [ ] [ ] [ ] subtitutions = new char [ substituedTypeNodes . length ] [ ] [ ] [ ] ; char [ ] [ ] [ ] originalTypeNames = new char [ substituedTypeNodes . length ] [ ] [ ] ; for ( int i = <NUM_LIT:0> ; i < substituedTypeNodes . length ; i ++ ) { subtitutions [ i ] = getSubstitution ( substituedTypeNodes [ i ] ) ; originalTypeNames [ i ] = getOriginal ( substituedTypeNodes [ i ] ) ; } ResolutionCleaner resolutionCleaner = new ResolutionCleaner ( ) ; for ( int i = <NUM_LIT:0> ; i < this . combinationsCount ; i ++ ) { nextSubstitution ( substituedTypeNodes , subtitutions , substitutionsIndexes ) ; this . problemFactory . startCheckingProblems ( ) ; TypeBinding guessedType = null ; switch ( scope . kind ) { case Scope . METHOD_SCOPE : case Scope . BLOCK_SCOPE : resolutionCleaner . cleanUp ( convertedType , ( BlockScope ) scope ) ; guessedType = convertedType . resolveType ( ( BlockScope ) scope ) ; break ; case Scope . CLASS_SCOPE : resolutionCleaner . cleanUp ( convertedType , ( ClassScope ) scope ) ; guessedType = convertedType . resolveType ( ( ClassScope ) scope ) ; break ; } this . problemFactory . stopCheckingProblems ( ) ; if ( ! this . problemFactory . hasForbiddenProblems ) { if ( guessedType != null ) { Binding [ ] missingElements = new Binding [ length ] ; int [ ] missingElementsStarts = new int [ length ] ; int [ ] missingElementsEnds = new int [ length ] ; if ( computeMissingElements ( substituedTypeNodes , originalTypeNames , missingElements , missingElementsStarts , missingElementsEnds ) ) { requestor . accept ( guessedType . capture ( scope , typeRef . sourceEnd ) , missingElements , missingElementsStarts , missingElementsEnds , this . problemFactory . hasAllowedProblems ) ; } } } } } private void nextSubstitution ( QualifiedTypeReference [ ] substituedTypeNodes , char [ ] [ ] [ ] [ ] subtitutions , int [ ] substitutionsIndexes ) { int length = substituedTypeNodes . length ; done : for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( substitutionsIndexes [ i ] < subtitutions [ i ] . length - <NUM_LIT:1> ) { substitutionsIndexes [ i ] ++ ; break done ; } else { substitutionsIndexes [ i ] = <NUM_LIT:0> ; } } for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { QualifiedTypeReference qualifiedTypeReference = substituedTypeNodes [ i ] ; qualifiedTypeReference . tokens = subtitutions [ i ] [ substitutionsIndexes [ i ] ] ; qualifiedTypeReference . sourcePositions = new long [ qualifiedTypeReference . tokens . length ] ; if ( qualifiedTypeReference instanceof ParameterizedQualifiedTypeReference ) { ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference = ( ParameterizedQualifiedTypeReference ) qualifiedTypeReference ; TypeReference [ ] [ ] typeArguments = parameterizedQualifiedTypeReference . typeArguments ; TypeReference [ ] [ ] newTypeArguments = new TypeReference [ qualifiedTypeReference . tokens . length ] [ ] ; for ( int j = newTypeArguments . length - <NUM_LIT:1> , k = typeArguments . length - <NUM_LIT:1> ; j > - <NUM_LIT:1> && k > - <NUM_LIT:1> ; ) { newTypeArguments [ j ] = typeArguments [ k ] ; j -- ; k -- ; } } } } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist ; import org . eclipse . jdt . core . CompletionContext ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IField ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . ILocalVariable ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . ITypeRoot ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnJavadoc ; import org . eclipse . jdt . internal . codeassist . complete . CompletionParser ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . LocalVariableBinding ; import org . eclipse . jdt . internal . compiler . lookup . LookupEnvironment ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . Scope ; import org . eclipse . jdt . internal . compiler . util . ObjectVector ; public class InternalCompletionContext extends CompletionContext { protected char [ ] [ ] expectedTypesSignatures ; protected char [ ] [ ] expectedTypesKeys ; protected int javadoc ; protected int offset = - <NUM_LIT:1> ; protected int tokenStart = - <NUM_LIT:1> ; protected int tokenEnd = - <NUM_LIT:1> ; protected char [ ] token = null ; protected int tokenKind ; protected int tokenLocation ; protected boolean isExtended ; protected InternalExtendedCompletionContext extendedContext ; protected void setExpectedTypesKeys ( char [ ] [ ] expectedTypesKeys ) { this . expectedTypesKeys = expectedTypesKeys ; } protected void setExpectedTypesSignatures ( char [ ] [ ] expectedTypesSignatures ) { this . expectedTypesSignatures = expectedTypesSignatures ; } protected void setExtended ( ) { this . isExtended = true ; } protected void setExtendedData ( ITypeRoot typeRoot , CompilationUnitDeclaration compilationUnitDeclaration , LookupEnvironment lookupEnvironment , Scope scope , ASTNode astNode , ASTNode astNodeParent , WorkingCopyOwner owner , CompletionParser parser ) { this . isExtended = true ; this . extendedContext = new InternalExtendedCompletionContext ( this , typeRoot , compilationUnitDeclaration , lookupEnvironment , scope , astNode , astNodeParent , owner , parser ) ; } protected void setJavadoc ( int javadoc ) { this . javadoc = javadoc ; } protected void setOffset ( int offset ) { this . offset = offset ; } protected void setToken ( char [ ] token ) { this . token = token ; } protected void setTokenKind ( int tokenKind ) { this . tokenKind = tokenKind ; } protected void setTokenLocation ( int tokenLocation ) { this . tokenLocation = tokenLocation ; } protected void setTokenRange ( int start , int end ) { this . setTokenRange ( start , end , - <NUM_LIT:1> ) ; } protected void setTokenRange ( int start , int end , int endOfEmptyToken ) { this . tokenStart = start ; this . tokenEnd = endOfEmptyToken > end ? endOfEmptyToken : end ; if ( this . tokenEnd == - <NUM_LIT:1> ) { this . tokenEnd = <NUM_LIT:0> ; } } public IJavaElement getEnclosingElement ( ) { if ( ! this . isExtended ) throw new UnsupportedOperationException ( "<STR_LIT>" ) ; if ( this . extendedContext == null ) return null ; return this . extendedContext . getEnclosingElement ( ) ; } public char [ ] [ ] getExpectedTypesKeys ( ) { return this . expectedTypesKeys ; } public char [ ] [ ] getExpectedTypesSignatures ( ) { return this . expectedTypesSignatures ; } public int getOffset ( ) { return this . offset ; } public char [ ] getToken ( ) { return this . token ; } public int getTokenEnd ( ) { return this . tokenEnd ; } public int getTokenKind ( ) { return this . tokenKind ; } public int getTokenLocation ( ) { return this . tokenLocation ; } public int getTokenStart ( ) { return this . tokenStart ; } public IJavaElement [ ] getVisibleElements ( String typeSignature ) { if ( ! this . isExtended ) throw new UnsupportedOperationException ( "<STR_LIT>" ) ; if ( this . extendedContext == null ) return new IJavaElement [ <NUM_LIT:0> ] ; return this . extendedContext . getVisibleElements ( typeSignature ) ; } public boolean isExtended ( ) { return this . isExtended ; } public boolean isInJavadoc ( ) { return this . javadoc != <NUM_LIT:0> ; } public boolean isInJavadocFormalReference ( ) { return ( this . javadoc & CompletionOnJavadoc . FORMAL_REFERENCE ) != <NUM_LIT:0> ; } public boolean isInJavadocText ( ) { return ( this . javadoc & CompletionOnJavadoc . TEXT ) != <NUM_LIT:0> ; } public ASTNode getCompletionNode ( ) { if ( ! this . isExtended ) throw new UnsupportedOperationException ( "<STR_LIT>" ) ; if ( this . extendedContext == null ) return null ; return this . extendedContext . getCompletionNode ( ) ; } public ASTNode getCompletionNodeParent ( ) { if ( ! this . isExtended ) throw new UnsupportedOperationException ( "<STR_LIT>" ) ; if ( this . extendedContext == null ) return null ; return this . extendedContext . getCompletionNodeParent ( ) ; } public ObjectVector getVisibleLocalVariables ( ) { if ( ! this . isExtended ) throw new UnsupportedOperationException ( "<STR_LIT>" ) ; if ( this . extendedContext == null ) return null ; return this . extendedContext . getVisibleLocalVariables ( ) ; } public ObjectVector getVisibleFields ( ) { if ( ! this . isExtended ) throw new UnsupportedOperationException ( "<STR_LIT>" ) ; if ( this . extendedContext == null ) return null ; return this . extendedContext . getVisibleFields ( ) ; } public ObjectVector getVisibleMethods ( ) { if ( ! this . isExtended ) throw new UnsupportedOperationException ( "<STR_LIT>" ) ; if ( this . extendedContext == null ) return null ; return this . extendedContext . getVisibleMethods ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . QualifiedSuperReference ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class SelectionOnQualifiedSuperReference extends QualifiedSuperReference { public SelectionOnQualifiedSuperReference ( TypeReference name , int pos , int sourceEnd ) { super ( name , pos , sourceEnd ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; return super . printExpression ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:>>' ) ; } public TypeBinding resolveType ( BlockScope scope ) { TypeBinding binding = super . resolveType ( scope ) ; if ( binding == null || ! binding . isValidBinding ( ) ) throw new SelectionNodeFound ( ) ; else throw new SelectionNodeFound ( binding ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . SuperReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class SelectionOnSuperReference extends SuperReference { public SelectionOnSuperReference ( int pos , int sourceEnd ) { super ( pos , sourceEnd ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; return super . printExpression ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:>>' ) ; } public TypeBinding resolveType ( BlockScope scope ) { TypeBinding binding = super . resolveType ( scope ) ; if ( binding == null || ! binding . isValidBinding ( ) ) throw new SelectionNodeFound ( ) ; else throw new SelectionNodeFound ( binding ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; public class SelectionScanner extends Scanner { public char [ ] selectionIdentifier ; public int selectionStart , selectionEnd ; public SelectionScanner ( long sourceLevel ) { super ( false , false , false , sourceLevel , null , null , true ) ; } public char [ ] getCurrentIdentifierSource ( ) { if ( this . selectionIdentifier == null ) { if ( this . selectionStart == this . startPosition && this . selectionEnd == this . currentPosition - <NUM_LIT:1> ) { if ( this . withoutUnicodePtr != <NUM_LIT:0> ) { System . arraycopy ( this . withoutUnicodeBuffer , <NUM_LIT:1> , this . selectionIdentifier = new char [ this . withoutUnicodePtr ] , <NUM_LIT:0> , this . withoutUnicodePtr ) ; } else { int length = this . currentPosition - this . startPosition ; System . arraycopy ( this . source , this . startPosition , ( this . selectionIdentifier = new char [ length ] ) , <NUM_LIT:0> , length ) ; } return this . selectionIdentifier ; } } return super . getCurrentIdentifierSource ( ) ; } public int scanIdentifierOrKeyword ( ) { int id = super . scanIdentifierOrKeyword ( ) ; if ( id != TokenNameIdentifier && this . startPosition == this . selectionStart && this . currentPosition == this . selectionEnd + <NUM_LIT:1> ) { return TokenNameIdentifier ; } return id ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; public class SelectionOnFieldType extends FieldDeclaration { public SelectionOnFieldType ( TypeReference type ) { super ( ) ; this . sourceStart = type . sourceStart ; this . sourceEnd = type . sourceEnd ; this . type = type ; this . name = CharOperation . NO_CHAR ; } public StringBuffer printStatement ( int tab , StringBuffer output ) { return this . type . print ( tab , output ) . append ( '<CHAR_LIT:;>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . SingleTypeReference ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . PackageBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . Scope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class SelectionOnSingleTypeReference extends SingleTypeReference { public SelectionOnSingleTypeReference ( char [ ] source , long pos ) { super ( source , pos ) ; } public void aboutToResolve ( Scope scope ) { getTypeBinding ( scope . parent ) ; } protected TypeBinding getTypeBinding ( Scope scope ) { Binding binding = scope . getTypeOrPackage ( new char [ ] [ ] { this . token } ) ; if ( ! binding . isValidBinding ( ) ) { if ( binding instanceof TypeBinding ) { scope . problemReporter ( ) . invalidType ( this , ( TypeBinding ) binding ) ; } else if ( binding instanceof PackageBinding ) { ProblemReferenceBinding problemBinding = new ProblemReferenceBinding ( ( ( PackageBinding ) binding ) . compoundName , null , binding . problemId ( ) ) ; scope . problemReporter ( ) . invalidType ( this , problemBinding ) ; } throw new SelectionNodeFound ( ) ; } throw new SelectionNodeFound ( binding ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { return output . append ( "<STR_LIT>" ) . append ( this . token ) . append ( '<CHAR_LIT:>>' ) ; } public TypeBinding resolveTypeEnclosing ( BlockScope scope , ReferenceBinding enclosingType ) { super . resolveTypeEnclosing ( scope , enclosingType ) ; if ( this . resolvedType == null || ! ( this . resolvedType . isValidBinding ( ) || this . resolvedType . problemId ( ) == ProblemReasons . NotVisible ) ) throw new SelectionNodeFound ( ) ; else throw new SelectionNodeFound ( this . resolvedType ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import java . util . List ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . codeassist . SelectionEngine ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . parser . JavadocParser ; public class SelectionJavadocParser extends JavadocParser { int selectionStart ; int selectionEnd ; ASTNode selectedNode ; public boolean inheritDocTagSelected ; public SelectionJavadocParser ( SelectionParser sourceParser ) { super ( sourceParser ) ; this . shouldReportProblems = false ; this . reportProblems = false ; this . kind = SELECTION_PARSER | TEXT_PARSE ; this . inheritDocTagSelected = false ; } public boolean checkDeprecation ( int commentPtr ) { this . selectionStart = ( ( SelectionParser ) this . sourceParser ) . selectionStart ; this . selectionEnd = ( ( SelectionParser ) this . sourceParser ) . selectionEnd ; this . javadocStart = this . sourceParser . scanner . commentStarts [ commentPtr ] ; this . javadocEnd = this . sourceParser . scanner . commentStops [ commentPtr ] ; if ( this . javadocStart <= this . selectionStart && this . selectionEnd <= this . javadocEnd ) { if ( SelectionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" ) ; } super . checkDeprecation ( commentPtr ) ; } else { this . docComment = null ; } return false ; } protected boolean commentParse ( ) { this . docComment = new SelectionJavadoc ( this . javadocStart , this . javadocEnd ) ; return super . commentParse ( ) ; } protected Object createArgumentReference ( char [ ] name , int dim , boolean isVarargs , Object typeRef , long [ ] dimPositions , long argNamePos ) throws InvalidInputException { Expression expression = ( Expression ) super . createArgumentReference ( name , dim , isVarargs , typeRef , dimPositions , argNamePos ) ; int start = ( ( TypeReference ) typeRef ) . sourceStart ; int end = ( ( TypeReference ) typeRef ) . sourceEnd ; if ( start <= this . selectionStart && this . selectionEnd <= end ) { this . selectedNode = expression ; this . abort = true ; if ( SelectionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . selectedNode ) ; } } return expression ; } protected Object createFieldReference ( Object receiver ) throws InvalidInputException { int start = ( int ) ( this . identifierPositionStack [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; int end = ( int ) this . identifierPositionStack [ <NUM_LIT:0> ] ; if ( start <= this . selectionStart && this . selectionEnd <= end ) { this . selectedNode = ( ASTNode ) super . createFieldReference ( receiver ) ; this . abort = true ; if ( SelectionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . selectedNode ) ; } } return null ; } protected Object createMethodReference ( Object receiver , List arguments ) throws InvalidInputException { int memberPtr = this . identifierLengthStack [ <NUM_LIT:0> ] - <NUM_LIT:1> ; int start = ( int ) ( this . identifierPositionStack [ memberPtr ] > > > <NUM_LIT:32> ) ; int end = ( int ) this . identifierPositionStack [ memberPtr ] ; if ( start <= this . selectionStart && this . selectionEnd <= end ) { this . selectedNode = ( ASTNode ) super . createMethodReference ( receiver , arguments ) ; this . abort = true ; if ( SelectionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . selectedNode ) ; } } return null ; } protected Object createTypeReference ( int primitiveToken ) { TypeReference typeRef = ( TypeReference ) super . createTypeReference ( primitiveToken ) ; if ( typeRef . sourceStart <= this . selectionStart && this . selectionEnd <= typeRef . sourceEnd ) { if ( typeRef instanceof JavadocQualifiedTypeReference ) { JavadocQualifiedTypeReference qualifiedTypeRef = ( JavadocQualifiedTypeReference ) typeRef ; int size = qualifiedTypeRef . tokens . length - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { int start = ( int ) ( qualifiedTypeRef . sourcePositions [ i ] > > > <NUM_LIT:32> ) ; int end = ( int ) qualifiedTypeRef . sourcePositions [ i ] ; if ( start <= this . selectionStart && this . selectionEnd <= end ) { int pos = i + <NUM_LIT:1> ; char [ ] [ ] tokens = new char [ pos ] [ ] ; int ptr = this . identifierPtr - size ; System . arraycopy ( this . identifierStack , ptr , tokens , <NUM_LIT:0> , pos ) ; long [ ] positions = new long [ pos ] ; System . arraycopy ( this . identifierPositionStack , ptr , positions , <NUM_LIT:0> , pos ) ; this . selectedNode = new JavadocQualifiedTypeReference ( tokens , positions , this . tagSourceStart , this . tagSourceEnd ) ; this . abort = true ; if ( SelectionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . selectedNode ) ; } return typeRef ; } } } this . selectedNode = typeRef ; this . abort = true ; if ( SelectionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . selectedNode ) ; } } return typeRef ; } protected boolean pushParamName ( boolean isTypeParam ) { if ( super . pushParamName ( isTypeParam ) ) { Expression expression = ( Expression ) this . astStack [ this . astPtr -- ] ; if ( expression . sourceStart <= this . selectionStart && this . selectionEnd <= expression . sourceEnd ) { this . selectedNode = expression ; this . abort = true ; if ( SelectionEngine . DEBUG ) { System . out . println ( "<STR_LIT>" + this . selectedNode ) ; } } } return false ; } protected void updateDocComment ( ) { if ( this . selectedNode instanceof Expression ) { ( ( SelectionJavadoc ) this . docComment ) . selectedNode = ( Expression ) this . selectedNode ; } else if ( this . inheritDocTagSelected ) { ( ( SelectionJavadoc ) this . docComment ) . inheritDocSelected = true ; } } protected void parseInheritDocTag ( ) { if ( this . tagSourceStart == this . selectionStart && this . tagSourceEnd == this . selectionEnd ) this . inheritDocTagSelected = true ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; public class SelectionOnPackageReference extends ImportReference { public SelectionOnPackageReference ( char [ ] [ ] tokens , long [ ] positions ) { super ( tokens , positions , false , ClassFileConstants . AccDefault ) ; } public StringBuffer print ( int tab , StringBuffer output , boolean withOnDemand ) { printIndent ( tab , output ) . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < this . tokens . length ; i ++ ) { if ( i > <NUM_LIT:0> ) output . append ( '<CHAR_LIT:.>' ) ; output . append ( this . tokens [ i ] ) ; } return output . append ( '<CHAR_LIT:>>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; public class SelectionOnImportReference extends ImportReference { public SelectionOnImportReference ( char [ ] [ ] tokens , long [ ] positions , int modifiers ) { super ( tokens , positions , false , modifiers ) ; } public StringBuffer print ( int indent , StringBuffer output , boolean withOnDemand ) { printIndent ( indent , output ) . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < this . tokens . length ; i ++ ) { if ( i > <NUM_LIT:0> ) output . append ( '<CHAR_LIT:.>' ) ; output . append ( this . tokens [ i ] ) ; } return output . append ( '<CHAR_LIT:>>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . SingleNameReference ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . MissingTypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemFieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class SelectionOnSingleNameReference extends SingleNameReference { public SelectionOnSingleNameReference ( char [ ] source , long pos ) { super ( source , pos ) ; } public TypeBinding resolveType ( BlockScope scope ) { if ( this . actualReceiverType != null ) { this . binding = scope . getField ( this . actualReceiverType , this . token , this ) ; if ( this . binding != null && this . binding . isValidBinding ( ) ) { throw new SelectionNodeFound ( this . binding ) ; } } this . binding = scope . getBinding ( this . token , Binding . VARIABLE | Binding . TYPE | Binding . PACKAGE , this , true ) ; if ( ! this . binding . isValidBinding ( ) ) { if ( this . binding instanceof ProblemFieldBinding ) { if ( this . binding . problemId ( ) == ProblemReasons . NotVisible || this . binding . problemId ( ) == ProblemReasons . InheritedNameHidesEnclosingName || this . binding . problemId ( ) == ProblemReasons . NonStaticReferenceInConstructorInvocation || this . binding . problemId ( ) == ProblemReasons . NonStaticReferenceInStaticContext ) { throw new SelectionNodeFound ( this . binding ) ; } scope . problemReporter ( ) . invalidField ( this , ( FieldBinding ) this . binding ) ; } else if ( this . binding instanceof ProblemReferenceBinding || this . binding instanceof MissingTypeBinding ) { if ( this . binding . problemId ( ) == ProblemReasons . NotVisible ) { throw new SelectionNodeFound ( this . binding ) ; } scope . problemReporter ( ) . invalidType ( this , ( TypeBinding ) this . binding ) ; } else { scope . problemReporter ( ) . unresolvableReference ( this , this . binding ) ; } throw new SelectionNodeFound ( ) ; } throw new SelectionNodeFound ( this . binding ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; return super . printExpression ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:>>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . ConstructorDeclaration ; import org . eclipse . jdt . internal . compiler . ast . QualifiedAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . LocalTypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class SelectionOnQualifiedAllocationExpression extends QualifiedAllocationExpression { public SelectionOnQualifiedAllocationExpression ( ) { } public SelectionOnQualifiedAllocationExpression ( TypeDeclaration anonymous ) { super ( anonymous ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { if ( this . enclosingInstance == null ) output . append ( "<STR_LIT>" ) ; else output . append ( "<STR_LIT>" ) ; return super . printExpression ( indent , output ) . append ( '<CHAR_LIT:>>' ) ; } public TypeBinding resolveType ( BlockScope scope ) { super . resolveType ( scope ) ; if ( this . binding == null ) { throw new SelectionNodeFound ( ) ; } if ( ! this . binding . isValidBinding ( ) ) { switch ( this . binding . problemId ( ) ) { case ProblemReasons . NotVisible : break ; case ProblemReasons . NotFound : if ( this . resolvedType != null && this . resolvedType . isValidBinding ( ) ) { throw new SelectionNodeFound ( this . resolvedType ) ; } throw new SelectionNodeFound ( ) ; default : throw new SelectionNodeFound ( ) ; } } if ( this . anonymousType == null ) throw new SelectionNodeFound ( this . binding ) ; if ( this . anonymousType . binding != null ) { LocalTypeBinding localType = ( LocalTypeBinding ) this . anonymousType . binding ; if ( localType . superInterfaces == Binding . NO_SUPERINTERFACES ) { ConstructorDeclaration constructor = ( ConstructorDeclaration ) this . anonymousType . declarationOf ( this . binding . original ( ) ) ; if ( constructor != null ) { throw new SelectionNodeFound ( constructor . constructorCall . binding ) ; } throw new SelectionNodeFound ( this . binding ) ; } throw new SelectionNodeFound ( localType . superInterfaces [ <NUM_LIT:0> ] ) ; } else { if ( this . resolvedType . isInterface ( ) ) { throw new SelectionNodeFound ( this . resolvedType ) ; } throw new SelectionNodeFound ( this . binding ) ; } } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . MemberValuePair ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class SelectionOnNameOfMemberValuePair extends MemberValuePair { public SelectionOnNameOfMemberValuePair ( char [ ] token , int sourceStart , int sourceEnd , Expression value ) { super ( token , sourceStart , sourceEnd , value ) ; } public StringBuffer print ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; output . append ( this . name ) ; output . append ( "<STR_LIT:>>" ) ; return output ; } public void resolveTypeExpecting ( BlockScope scope , TypeBinding requiredType ) { super . resolveTypeExpecting ( scope , requiredType ) ; if ( this . binding != null ) { throw new SelectionNodeFound ( this . binding ) ; } throw new SelectionNodeFound ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . lookup . * ; public class SelectionNodeFound extends RuntimeException { public Binding binding ; public boolean isDeclaration ; private static final long serialVersionUID = - <NUM_LIT> ; public SelectionNodeFound ( ) { this ( null , false ) ; } public SelectionNodeFound ( Binding binding ) { this ( binding , false ) ; } public SelectionNodeFound ( Binding binding , boolean isDeclaration ) { this . binding = binding ; this . isDeclaration = isDeclaration ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class SelectionOnParameterizedQualifiedTypeReference extends ParameterizedQualifiedTypeReference { public SelectionOnParameterizedQualifiedTypeReference ( char [ ] [ ] previousIdentifiers , char [ ] selectionIdentifier , TypeReference [ ] [ ] typeArguments , TypeReference [ ] assistTypeArguments , long [ ] positions ) { super ( CharOperation . arrayConcat ( previousIdentifiers , selectionIdentifier ) , typeArguments , <NUM_LIT:0> , positions ) ; int length = this . typeArguments . length ; System . arraycopy ( this . typeArguments , <NUM_LIT:0> , this . typeArguments = new TypeReference [ length + <NUM_LIT:1> ] [ ] , <NUM_LIT:0> , length ) ; this . typeArguments [ length ] = assistTypeArguments ; } public TypeBinding resolveType ( BlockScope scope , boolean checkBounds ) { super . resolveType ( scope , checkBounds ) ; throw new SelectionNodeFound ( this . resolvedType ) ; } public TypeBinding resolveType ( ClassScope scope ) { super . resolveType ( scope ) ; throw new SelectionNodeFound ( this . resolvedType ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; int length = this . tokens . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( i != <NUM_LIT:0> ) { output . append ( '<CHAR_LIT:.>' ) ; } output . append ( this . tokens [ i ] ) ; TypeReference [ ] typeArgument = this . typeArguments [ i ] ; if ( typeArgument != null ) { output . append ( '<CHAR_LIT>' ) ; int max = typeArgument . length - <NUM_LIT:1> ; for ( int j = <NUM_LIT:0> ; j < max ; j ++ ) { typeArgument [ j ] . print ( <NUM_LIT:0> , output ) ; output . append ( "<STR_LIT:U+002CU+0020>" ) ; } typeArgument [ max ] . print ( <NUM_LIT:0> , output ) ; output . append ( '<CHAR_LIT:>>' ) ; } } output . append ( '<CHAR_LIT:>>' ) ; return output ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . QualifiedNameReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . MissingTypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemFieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class SelectionOnQualifiedNameReference extends QualifiedNameReference { public SelectionOnQualifiedNameReference ( char [ ] [ ] previousIdentifiers , char [ ] selectionIdentifier , long [ ] positions ) { super ( CharOperation . arrayConcat ( previousIdentifiers , selectionIdentifier ) , positions , ( int ) ( positions [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) , ( int ) positions [ positions . length - <NUM_LIT:1> ] ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> , length = this . tokens . length ; i < length ; i ++ ) { if ( i > <NUM_LIT:0> ) output . append ( '<CHAR_LIT:.>' ) ; output . append ( this . tokens [ i ] ) ; } return output . append ( '<CHAR_LIT:>>' ) ; } public TypeBinding resolveType ( BlockScope scope ) { this . binding = scope . getBinding ( this . tokens , this ) ; if ( ! this . binding . isValidBinding ( ) ) { if ( this . binding instanceof ProblemFieldBinding ) { if ( this . binding . problemId ( ) == ProblemReasons . NotVisible || this . binding . problemId ( ) == ProblemReasons . InheritedNameHidesEnclosingName || this . binding . problemId ( ) == ProblemReasons . NonStaticReferenceInConstructorInvocation || this . binding . problemId ( ) == ProblemReasons . NonStaticReferenceInStaticContext ) { throw new SelectionNodeFound ( this . binding ) ; } scope . problemReporter ( ) . invalidField ( this , ( FieldBinding ) this . binding ) ; } else if ( this . binding instanceof ProblemReferenceBinding || this . binding instanceof MissingTypeBinding ) { if ( this . binding . problemId ( ) == ProblemReasons . NotVisible ) { throw new SelectionNodeFound ( this . binding ) ; } scope . problemReporter ( ) . invalidType ( this , ( TypeBinding ) this . binding ) ; } else { scope . problemReporter ( ) . unresolvableReference ( this , this . binding ) ; } throw new SelectionNodeFound ( ) ; } throw new SelectionNodeFound ( this . binding ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . impl . ReferenceContext ; import org . eclipse . jdt . internal . compiler . lookup . * ; public class SelectionJavadoc extends Javadoc { Expression selectedNode ; boolean inheritDocSelected ; public SelectionJavadoc ( int sourceStart , int sourceEnd ) { super ( sourceStart , sourceEnd ) ; this . inheritDocSelected = false ; } public StringBuffer print ( int indent , StringBuffer output ) { super . print ( indent , output ) ; if ( this . selectedNode != null ) { String selectedString = null ; if ( this . selectedNode instanceof JavadocFieldReference ) { JavadocFieldReference fieldRef = ( JavadocFieldReference ) this . selectedNode ; if ( fieldRef . methodBinding != null ) { selectedString = "<STR_LIT>" ; } else { selectedString = "<STR_LIT>" ; } } else if ( this . selectedNode instanceof JavadocMessageSend ) { selectedString = "<STR_LIT>" ; } else if ( this . selectedNode instanceof JavadocAllocationExpression ) { selectedString = "<STR_LIT>" ; } else if ( this . selectedNode instanceof JavadocSingleNameReference ) { selectedString = "<STR_LIT>" ; } else if ( this . selectedNode instanceof JavadocSingleTypeReference ) { JavadocSingleTypeReference typeRef = ( JavadocSingleTypeReference ) this . selectedNode ; if ( typeRef . packageBinding == null ) { selectedString = "<STR_LIT>" ; } } else if ( this . selectedNode instanceof JavadocQualifiedTypeReference ) { JavadocQualifiedTypeReference typeRef = ( JavadocQualifiedTypeReference ) this . selectedNode ; if ( typeRef . packageBinding == null ) { selectedString = "<STR_LIT>" ; } } else { selectedString = "<STR_LIT>" ; } int pos = output . length ( ) - <NUM_LIT:3> ; output . replace ( pos - <NUM_LIT:2> , pos , selectedString + this . selectedNode + '<CHAR_LIT:>>' ) ; } return output ; } private void internalResolve ( Scope scope ) { if ( this . selectedNode != null ) { switch ( scope . kind ) { case Scope . CLASS_SCOPE : this . selectedNode . resolveType ( ( ClassScope ) scope ) ; break ; case Scope . METHOD_SCOPE : this . selectedNode . resolveType ( ( MethodScope ) scope ) ; break ; } Binding binding = null ; if ( this . selectedNode instanceof JavadocFieldReference ) { JavadocFieldReference fieldRef = ( JavadocFieldReference ) this . selectedNode ; binding = fieldRef . binding ; if ( binding == null && fieldRef . methodBinding != null ) { binding = fieldRef . methodBinding ; } } else if ( this . selectedNode instanceof JavadocMessageSend ) { binding = ( ( JavadocMessageSend ) this . selectedNode ) . binding ; } else if ( this . selectedNode instanceof JavadocAllocationExpression ) { binding = ( ( JavadocAllocationExpression ) this . selectedNode ) . binding ; } else if ( this . selectedNode instanceof JavadocSingleNameReference ) { binding = ( ( JavadocSingleNameReference ) this . selectedNode ) . binding ; } else if ( this . selectedNode instanceof JavadocSingleTypeReference ) { JavadocSingleTypeReference typeRef = ( JavadocSingleTypeReference ) this . selectedNode ; if ( typeRef . packageBinding == null ) { binding = typeRef . resolvedType ; } } else if ( this . selectedNode instanceof JavadocQualifiedTypeReference ) { JavadocQualifiedTypeReference typeRef = ( JavadocQualifiedTypeReference ) this . selectedNode ; if ( typeRef . packageBinding == null ) { binding = typeRef . resolvedType ; } } else { binding = this . selectedNode . resolvedType ; } throw new SelectionNodeFound ( binding ) ; } else if ( this . inheritDocSelected ) { ReferenceContext referenceContext = scope . referenceContext ( ) ; if ( referenceContext instanceof MethodDeclaration ) { throw new SelectionNodeFound ( ( ( MethodDeclaration ) referenceContext ) . binding ) ; } } } public void resolve ( ClassScope scope ) { internalResolve ( scope ) ; } public void resolve ( MethodScope scope ) { internalResolve ( scope ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . * ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . env . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . codeassist . impl . * ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; import org . eclipse . jdt . internal . compiler . parser . * ; import org . eclipse . jdt . internal . compiler . problem . * ; import org . eclipse . jdt . internal . compiler . util . Util ; public class SelectionParser extends AssistParser { protected static final int SELECTION_PARSER = <NUM_LIT> ; protected static final int SELECTION_OR_ASSIST_PARSER = ASSIST_PARSER + SELECTION_PARSER ; protected static final int K_BETWEEN_CASE_AND_COLON = SELECTION_PARSER + <NUM_LIT:1> ; protected static final int K_INSIDE_RETURN_STATEMENT = SELECTION_PARSER + <NUM_LIT:2> ; protected static final int K_CAST_STATEMENT = SELECTION_PARSER + <NUM_LIT:3> ; public ASTNode assistNodeParent ; public int selectionStart , selectionEnd ; public static final char [ ] SUPER = "<STR_LIT>" . toCharArray ( ) ; public static final char [ ] THIS = "<STR_LIT>" . toCharArray ( ) ; public SelectionParser ( ProblemReporter problemReporter ) { super ( problemReporter ) ; this . javadocParser . checkDocComment = true ; } public char [ ] assistIdentifier ( ) { return ( ( SelectionScanner ) this . scanner ) . selectionIdentifier ; } protected void attachOrphanCompletionNode ( ) { if ( this . isOrphanCompletionNode ) { ASTNode orphan = this . assistNode ; this . isOrphanCompletionNode = false ; if ( this . currentElement instanceof RecoveredType ) { RecoveredType recoveredType = ( RecoveredType ) this . currentElement ; if ( recoveredType . foundOpeningBrace ) { if ( orphan instanceof TypeReference ) { this . currentElement = this . currentElement . add ( new SelectionOnFieldType ( ( TypeReference ) orphan ) , <NUM_LIT:0> ) ; return ; } } } if ( orphan instanceof Expression ) { buildMoreCompletionContext ( ( Expression ) orphan ) ; } else { Statement statement = ( Statement ) orphan ; this . currentElement = this . currentElement . add ( statement , <NUM_LIT:0> ) ; } this . currentToken = <NUM_LIT:0> ; } } private void buildMoreCompletionContext ( Expression expression ) { ASTNode parentNode = null ; int kind = topKnownElementKind ( SELECTION_OR_ASSIST_PARSER ) ; if ( kind != <NUM_LIT:0> ) { int info = topKnownElementInfo ( SELECTION_OR_ASSIST_PARSER ) ; nextElement : switch ( kind ) { case K_BETWEEN_CASE_AND_COLON : if ( this . expressionPtr > <NUM_LIT:0> ) { SwitchStatement switchStatement = new SwitchStatement ( ) ; switchStatement . expression = this . expressionStack [ this . expressionPtr - <NUM_LIT:1> ] ; if ( this . astLengthPtr > - <NUM_LIT:1> && this . astPtr > - <NUM_LIT:1> ) { int length = this . astLengthStack [ this . astLengthPtr ] ; int newAstPtr = this . astPtr - length ; ASTNode firstNode = this . astStack [ newAstPtr + <NUM_LIT:1> ] ; if ( length != <NUM_LIT:0> && firstNode . sourceStart > switchStatement . expression . sourceEnd ) { switchStatement . statements = new Statement [ length + <NUM_LIT:1> ] ; System . arraycopy ( this . astStack , newAstPtr + <NUM_LIT:1> , switchStatement . statements , <NUM_LIT:0> , length ) ; } } CaseStatement caseStatement = new CaseStatement ( expression , expression . sourceStart , expression . sourceEnd ) ; if ( switchStatement . statements == null ) { switchStatement . statements = new Statement [ ] { caseStatement } ; } else { switchStatement . statements [ switchStatement . statements . length - <NUM_LIT:1> ] = caseStatement ; } parentNode = switchStatement ; this . assistNodeParent = parentNode ; } break nextElement ; case K_INSIDE_RETURN_STATEMENT : if ( info == this . bracketDepth ) { ReturnStatement returnStatement = new ReturnStatement ( expression , expression . sourceStart , expression . sourceEnd ) ; parentNode = returnStatement ; this . assistNodeParent = parentNode ; } break nextElement ; case K_CAST_STATEMENT : Expression castType ; if ( this . expressionPtr > <NUM_LIT:0> && ( ( castType = this . expressionStack [ this . expressionPtr - <NUM_LIT:1> ] ) instanceof TypeReference ) ) { CastExpression cast = new CastExpression ( expression , ( TypeReference ) castType ) ; cast . sourceStart = castType . sourceStart ; cast . sourceEnd = expression . sourceEnd ; parentNode = cast ; this . assistNodeParent = parentNode ; } break nextElement ; } } if ( parentNode != null ) { this . currentElement = this . currentElement . add ( ( Statement ) parentNode , <NUM_LIT:0> ) ; } else { this . currentElement = this . currentElement . add ( ( Statement ) wrapWithExplicitConstructorCallIfNeeded ( expression ) , <NUM_LIT:0> ) ; if ( this . lastCheckPoint < expression . sourceEnd ) { this . lastCheckPoint = expression . sourceEnd + <NUM_LIT:1> ; } } } private boolean checkRecoveredType ( ) { if ( this . currentElement instanceof RecoveredType ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) return false ; if ( ( this . lastErrorEndPosition >= this . selectionStart ) && ( this . lastErrorEndPosition <= this . selectionEnd + <NUM_LIT:1> ) ) { return false ; } RecoveredType recoveredType = ( RecoveredType ) this . currentElement ; if ( recoveredType . foundOpeningBrace ) { this . assistNode = this . getTypeReference ( <NUM_LIT:0> ) ; this . lastCheckPoint = this . assistNode . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; return true ; } } return false ; } protected void classInstanceCreation ( boolean hasClassBody ) { if ( ( this . astLengthStack [ this . astLengthPtr ] == <NUM_LIT:1> ) && ( this . astStack [ this . astPtr ] == null ) ) { int index ; if ( ( index = this . indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . classInstanceCreation ( hasClassBody ) ; return ; } else if ( this . identifierLengthPtr > - <NUM_LIT:1> && ( this . identifierLengthStack [ this . identifierLengthPtr ] - <NUM_LIT:1> ) != index ) { super . classInstanceCreation ( hasClassBody ) ; return ; } QualifiedAllocationExpression alloc ; this . astPtr -- ; this . astLengthPtr -- ; alloc = new SelectionOnQualifiedAllocationExpression ( ) ; alloc . sourceEnd = this . endPosition ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { this . expressionPtr -= length ; System . arraycopy ( this . expressionStack , this . expressionPtr + <NUM_LIT:1> , alloc . arguments = new Expression [ length ] , <NUM_LIT:0> , length ) ; } char [ ] oldIdent = assistIdentifier ( ) ; setAssistIdentifier ( null ) ; alloc . type = getTypeReference ( <NUM_LIT:0> ) ; checkForDiamond ( alloc . type ) ; setAssistIdentifier ( oldIdent ) ; alloc . sourceStart = this . intStack [ this . intPtr -- ] ; pushOnExpressionStack ( alloc ) ; this . assistNode = alloc ; this . lastCheckPoint = alloc . sourceEnd + <NUM_LIT:1> ; if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . isOrphanCompletionNode = true ; } else { super . classInstanceCreation ( hasClassBody ) ; } } protected void consumeArrayCreationExpressionWithoutInitializer ( ) { super . consumeArrayCreationExpressionWithoutInitializer ( ) ; ArrayAllocationExpression alloc = ( ArrayAllocationExpression ) this . expressionStack [ this . expressionPtr ] ; if ( alloc . type == this . assistNode ) { if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . isOrphanCompletionNode = true ; } } protected void consumeArrayCreationExpressionWithInitializer ( ) { super . consumeArrayCreationExpressionWithInitializer ( ) ; ArrayAllocationExpression alloc = ( ArrayAllocationExpression ) this . expressionStack [ this . expressionPtr ] ; if ( alloc . type == this . assistNode ) { if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . isOrphanCompletionNode = true ; } } protected void consumeCastExpressionLL1 ( ) { popElement ( K_CAST_STATEMENT ) ; super . consumeCastExpressionLL1 ( ) ; } protected void consumeCastExpressionWithGenericsArray ( ) { popElement ( K_CAST_STATEMENT ) ; super . consumeCastExpressionWithGenericsArray ( ) ; } protected void consumeCastExpressionWithNameArray ( ) { popElement ( K_CAST_STATEMENT ) ; super . consumeCastExpressionWithNameArray ( ) ; } protected void consumeCastExpressionWithPrimitiveType ( ) { popElement ( K_CAST_STATEMENT ) ; super . consumeCastExpressionWithPrimitiveType ( ) ; } protected void consumeCastExpressionWithQualifiedGenericsArray ( ) { popElement ( K_CAST_STATEMENT ) ; super . consumeCastExpressionWithQualifiedGenericsArray ( ) ; } protected void consumeCatchFormalParameter ( ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { super . consumeCatchFormalParameter ( ) ; if ( ( ! this . diet || this . dietInt != <NUM_LIT:0> ) && this . astPtr > - <NUM_LIT:1> ) { Argument argument = ( Argument ) this . astStack [ this . astPtr ] ; if ( argument . type == this . assistNode ) { this . isOrphanCompletionNode = true ; this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } } } else { this . identifierLengthPtr -- ; char [ ] identifierName = this . identifierStack [ this . identifierPtr ] ; long namePositions = this . identifierPositionStack [ this . identifierPtr -- ] ; this . intPtr -- ; TypeReference type = ( TypeReference ) this . astStack [ this . astPtr -- ] ; int modifierPositions = this . intStack [ this . intPtr -- ] ; this . intPtr -- ; Argument arg = new SelectionOnArgumentName ( identifierName , namePositions , type , this . intStack [ this . intPtr + <NUM_LIT:1> ] & ~ ClassFileConstants . AccDeprecated ) ; arg . bits &= ~ ASTNode . IsArgument ; arg . declarationSourceStart = modifierPositions ; 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 . assistNode = arg ; this . lastCheckPoint = ( int ) namePositions ; this . isOrphanCompletionNode = true ; if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . listLength ++ ; } } protected void consumeClassInstanceCreationExpressionQualifiedWithTypeArguments ( ) { QualifiedAllocationExpression alloc ; int length ; if ( ( ( length = this . astLengthStack [ this . astLengthPtr ] ) == <NUM_LIT:1> ) && ( this . astStack [ this . astPtr ] == null ) ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { super . consumeClassInstanceCreationExpressionQualifiedWithTypeArguments ( ) ; return ; } this . astPtr -- ; this . astLengthPtr -- ; alloc = new SelectionOnQualifiedAllocationExpression ( ) ; alloc . sourceEnd = this . endPosition ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { this . expressionPtr -= length ; System . arraycopy ( this . expressionStack , this . expressionPtr + <NUM_LIT:1> , alloc . arguments = new Expression [ length ] , <NUM_LIT:0> , length ) ; } char [ ] oldIdent = assistIdentifier ( ) ; setAssistIdentifier ( null ) ; alloc . type = getTypeReference ( <NUM_LIT:0> ) ; checkForDiamond ( alloc . type ) ; setAssistIdentifier ( oldIdent ) ; length = this . genericsLengthStack [ this . genericsLengthPtr -- ] ; this . genericsPtr -= length ; System . arraycopy ( this . genericsStack , this . genericsPtr + <NUM_LIT:1> , alloc . typeArguments = new TypeReference [ length ] , <NUM_LIT:0> , length ) ; this . intPtr -- ; alloc . sourceStart = this . intStack [ this . intPtr -- ] ; pushOnExpressionStack ( alloc ) ; this . assistNode = alloc ; this . lastCheckPoint = alloc . sourceEnd + <NUM_LIT:1> ; if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . isOrphanCompletionNode = true ; } else { super . consumeClassInstanceCreationExpressionQualifiedWithTypeArguments ( ) ; } this . expressionLengthPtr -- ; QualifiedAllocationExpression qae = ( QualifiedAllocationExpression ) this . expressionStack [ this . expressionPtr -- ] ; qae . enclosingInstance = this . expressionStack [ this . expressionPtr ] ; this . expressionStack [ this . expressionPtr ] = qae ; qae . sourceStart = qae . enclosingInstance . sourceStart ; } protected void consumeClassInstanceCreationExpressionWithTypeArguments ( ) { AllocationExpression alloc ; int length ; if ( ( ( length = this . astLengthStack [ this . astLengthPtr ] ) == <NUM_LIT:1> ) && ( this . astStack [ this . astPtr ] == null ) ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { super . consumeClassInstanceCreationExpressionWithTypeArguments ( ) ; return ; } this . astPtr -- ; this . astLengthPtr -- ; alloc = new SelectionOnQualifiedAllocationExpression ( ) ; alloc . sourceEnd = this . endPosition ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { this . expressionPtr -= length ; System . arraycopy ( this . expressionStack , this . expressionPtr + <NUM_LIT:1> , alloc . arguments = new Expression [ length ] , <NUM_LIT:0> , length ) ; } char [ ] oldIdent = assistIdentifier ( ) ; setAssistIdentifier ( null ) ; alloc . type = getTypeReference ( <NUM_LIT:0> ) ; checkForDiamond ( alloc . type ) ; setAssistIdentifier ( oldIdent ) ; length = this . genericsLengthStack [ this . genericsLengthPtr -- ] ; this . genericsPtr -= length ; System . arraycopy ( this . genericsStack , this . genericsPtr + <NUM_LIT:1> , alloc . typeArguments = new TypeReference [ length ] , <NUM_LIT:0> , length ) ; this . intPtr -- ; alloc . sourceStart = this . intStack [ this . intPtr -- ] ; pushOnExpressionStack ( alloc ) ; this . assistNode = alloc ; this . lastCheckPoint = alloc . sourceEnd + <NUM_LIT:1> ; if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . isOrphanCompletionNode = true ; } else { super . consumeClassInstanceCreationExpressionWithTypeArguments ( ) ; } } protected void consumeEnterAnonymousClassBody ( boolean qualified ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { super . consumeEnterAnonymousClassBody ( qualified ) ; return ; } char [ ] oldIdent = assistIdentifier ( ) ; setAssistIdentifier ( null ) ; TypeReference typeReference = getTypeReference ( <NUM_LIT:0> ) ; setAssistIdentifier ( oldIdent ) ; TypeDeclaration anonymousType = new TypeDeclaration ( this . compilationUnit . compilationResult ) ; anonymousType . name = CharOperation . NO_CHAR ; anonymousType . bits |= ( ASTNode . IsAnonymousType | ASTNode . IsLocalType ) ; QualifiedAllocationExpression alloc = new SelectionOnQualifiedAllocationExpression ( anonymousType ) ; markEnclosingMemberWithLocalType ( ) ; pushOnAstStack ( anonymousType ) ; alloc . sourceEnd = this . rParenPos ; int argumentLength ; if ( ( argumentLength = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { this . expressionPtr -= argumentLength ; System . arraycopy ( this . expressionStack , this . expressionPtr + <NUM_LIT:1> , alloc . arguments = new Expression [ argumentLength ] , <NUM_LIT:0> , argumentLength ) ; } if ( qualified ) { this . expressionLengthPtr -- ; alloc . enclosingInstance = this . expressionStack [ this . expressionPtr -- ] ; } alloc . type = typeReference ; anonymousType . sourceEnd = alloc . sourceEnd ; anonymousType . sourceStart = anonymousType . declarationSourceStart = alloc . type . sourceStart ; alloc . sourceStart = this . intStack [ this . intPtr -- ] ; pushOnExpressionStack ( alloc ) ; this . assistNode = alloc ; this . lastCheckPoint = alloc . sourceEnd + <NUM_LIT:1> ; if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . currentToken = <NUM_LIT:0> ; this . hasReportedError = true ; } anonymousType . bodyStart = this . scanner . currentPosition ; this . listLength = <NUM_LIT:0> ; if ( this . currentElement != null ) { this . lastCheckPoint = anonymousType . bodyStart ; this . currentElement = this . currentElement . add ( anonymousType , <NUM_LIT:0> ) ; this . currentToken = <NUM_LIT:0> ; this . lastIgnoredToken = - <NUM_LIT:1> ; } } protected void consumeEnterVariable ( ) { super . consumeEnterVariable ( ) ; AbstractVariableDeclaration variable = ( AbstractVariableDeclaration ) this . astStack [ this . astPtr ] ; if ( variable . type == this . assistNode ) { if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . isOrphanCompletionNode = false ; } } protected void consumeExitVariableWithInitialization ( ) { super . consumeExitVariableWithInitialization ( ) ; AbstractVariableDeclaration variable = ( AbstractVariableDeclaration ) this . astStack [ this . astPtr ] ; int start = variable . initialization . sourceStart ; int end = variable . initialization . sourceEnd ; if ( ( this . selectionStart < start ) && ( this . selectionEnd < start ) || ( this . selectionStart > end ) && ( this . selectionEnd > end ) ) { variable . initialization = null ; } } protected void consumeFieldAccess ( boolean isSuperAccess ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { super . consumeFieldAccess ( isSuperAccess ) ; return ; } FieldReference fieldReference = new SelectionOnFieldReference ( this . identifierStack [ this . identifierPtr ] , this . identifierPositionStack [ this . identifierPtr -- ] ) ; this . identifierLengthPtr -- ; if ( isSuperAccess ) { fieldReference . sourceStart = this . intStack [ this . intPtr -- ] ; fieldReference . receiver = new SuperReference ( fieldReference . sourceStart , this . endPosition ) ; pushOnExpressionStack ( fieldReference ) ; } else { if ( ( fieldReference . receiver = this . expressionStack [ this . expressionPtr ] ) . isThis ( ) ) { fieldReference . sourceStart = fieldReference . receiver . sourceStart ; } this . expressionStack [ this . expressionPtr ] = fieldReference ; } this . assistNode = fieldReference ; this . lastCheckPoint = fieldReference . sourceEnd + <NUM_LIT:1> ; if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . isOrphanCompletionNode = true ; } protected void consumeFormalParameter ( boolean isVarArgs ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { super . consumeFormalParameter ( isVarArgs ) ; if ( ( ! this . diet || this . dietInt != <NUM_LIT:0> ) && this . astPtr > - <NUM_LIT:1> ) { Argument argument = ( Argument ) this . astStack [ this . astPtr ] ; if ( argument . type == this . assistNode ) { this . isOrphanCompletionNode = true ; this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } } } else { this . identifierLengthPtr -- ; char [ ] identifierName = 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 ; } int modifierPositions = this . intStack [ this . intPtr -- ] ; this . intPtr -- ; Argument arg = new SelectionOnArgumentName ( identifierName , namePositions , type , this . intStack [ this . intPtr + <NUM_LIT:1> ] & ~ ClassFileConstants . AccDeprecated ) ; arg . declarationSourceStart = modifierPositions ; 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 . assistNode = arg ; this . lastCheckPoint = ( int ) namePositions ; this . isOrphanCompletionNode = true ; if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . listLength ++ ; } } protected void consumeInsideCastExpression ( ) { super . consumeInsideCastExpression ( ) ; pushOnElementStack ( K_CAST_STATEMENT ) ; } protected void consumeInsideCastExpressionLL1 ( ) { super . consumeInsideCastExpressionLL1 ( ) ; pushOnElementStack ( K_CAST_STATEMENT ) ; } protected void consumeInsideCastExpressionWithQualifiedGenerics ( ) { super . consumeInsideCastExpressionWithQualifiedGenerics ( ) ; pushOnElementStack ( K_CAST_STATEMENT ) ; } protected void consumeInstanceOfExpression ( ) { if ( indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { super . consumeInstanceOfExpression ( ) ; } else { getTypeReference ( this . intStack [ this . intPtr -- ] ) ; this . isOrphanCompletionNode = true ; this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } } protected void consumeInstanceOfExpressionWithName ( ) { if ( indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { super . consumeInstanceOfExpressionWithName ( ) ; } else { getTypeReference ( this . intStack [ this . intPtr -- ] ) ; this . isOrphanCompletionNode = true ; this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } } protected void consumeLocalVariableDeclarationStatement ( ) { super . consumeLocalVariableDeclarationStatement ( ) ; if ( ! this . diet ) { LocalDeclaration localDeclaration = ( LocalDeclaration ) this . astStack [ this . astPtr ] ; if ( ( this . selectionStart >= localDeclaration . sourceStart ) && ( this . selectionEnd <= localDeclaration . sourceEnd ) ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } } } protected void consumeMarkerAnnotation ( ) { int index ; if ( ( index = this . indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . consumeMarkerAnnotation ( ) ; return ; } MarkerAnnotation markerAnnotation = null ; int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; TypeReference typeReference ; char [ ] [ ] subset = identifierSubSet ( index ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; if ( index == <NUM_LIT:0> ) { typeReference = createSingleAssistTypeReference ( assistIdentifier ( ) , positions [ <NUM_LIT:0> ] ) ; } else { typeReference = createQualifiedAssistTypeReference ( subset , assistIdentifier ( ) , positions ) ; } this . assistNode = typeReference ; this . lastCheckPoint = typeReference . sourceEnd + <NUM_LIT:1> ; markerAnnotation = new MarkerAnnotation ( typeReference , this . intStack [ this . intPtr -- ] ) ; markerAnnotation . declarationSourceEnd = markerAnnotation . sourceEnd ; pushOnExpressionStack ( markerAnnotation ) ; } protected void consumeMemberValuePair ( ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { super . consumeMemberValuePair ( ) ; return ; } char [ ] simpleName = this . identifierStack [ this . identifierPtr ] ; long position = this . identifierPositionStack [ this . identifierPtr -- ] ; this . identifierLengthPtr -- ; int end = ( int ) position ; int start = ( int ) ( position > > > <NUM_LIT:32> ) ; Expression value = this . expressionStack [ this . expressionPtr -- ] ; this . expressionLengthPtr -- ; MemberValuePair memberValuePair = new SelectionOnNameOfMemberValuePair ( simpleName , start , end , value ) ; pushOnAstStack ( memberValuePair ) ; this . assistNode = memberValuePair ; this . lastCheckPoint = memberValuePair . sourceEnd + <NUM_LIT:1> ; } protected void consumeMethodInvocationName ( ) { char [ ] selector = this . identifierStack [ this . identifierPtr ] ; int accessMode ; if ( selector == assistIdentifier ( ) ) { if ( CharOperation . equals ( selector , SUPER ) ) { accessMode = ExplicitConstructorCall . Super ; } else if ( CharOperation . equals ( selector , THIS ) ) { accessMode = ExplicitConstructorCall . This ; } else { super . consumeMethodInvocationName ( ) ; return ; } } else { super . consumeMethodInvocationName ( ) ; return ; } final ExplicitConstructorCall constructorCall = new SelectionOnExplicitConstructorCall ( accessMode ) ; constructorCall . sourceEnd = this . rParenPos ; constructorCall . sourceStart = ( int ) ( this . identifierPositionStack [ this . identifierPtr ] > > > <NUM_LIT:32> ) ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { this . expressionPtr -= length ; System . arraycopy ( this . expressionStack , this . expressionPtr + <NUM_LIT:1> , constructorCall . arguments = new Expression [ length ] , <NUM_LIT:0> , length ) ; } if ( ! this . diet ) { pushOnAstStack ( constructorCall ) ; this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } else { pushOnExpressionStack ( new Expression ( ) { public TypeBinding resolveType ( BlockScope scope ) { constructorCall . resolve ( scope ) ; return null ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { return output ; } } ) ; } this . assistNode = constructorCall ; this . lastCheckPoint = constructorCall . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; } protected void consumeMethodInvocationPrimary ( ) { char [ ] selector = this . identifierStack [ this . identifierPtr ] ; int accessMode ; if ( selector == assistIdentifier ( ) ) { if ( CharOperation . equals ( selector , SUPER ) ) { accessMode = ExplicitConstructorCall . Super ; } else if ( CharOperation . equals ( selector , THIS ) ) { accessMode = ExplicitConstructorCall . This ; } else { super . consumeMethodInvocationPrimary ( ) ; return ; } } else { super . consumeMethodInvocationPrimary ( ) ; return ; } final ExplicitConstructorCall constructorCall = new SelectionOnExplicitConstructorCall ( accessMode ) ; constructorCall . sourceEnd = this . rParenPos ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { this . expressionPtr -= length ; System . arraycopy ( this . expressionStack , this . expressionPtr + <NUM_LIT:1> , constructorCall . arguments = new Expression [ length ] , <NUM_LIT:0> , length ) ; } constructorCall . qualification = this . expressionStack [ this . expressionPtr -- ] ; constructorCall . sourceStart = constructorCall . qualification . sourceStart ; if ( ! this . diet ) { pushOnAstStack ( constructorCall ) ; this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } else { pushOnExpressionStack ( new Expression ( ) { public TypeBinding resolveType ( BlockScope scope ) { constructorCall . resolve ( scope ) ; return null ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { return output ; } } ) ; } this . assistNode = constructorCall ; this . lastCheckPoint = constructorCall . sourceEnd + <NUM_LIT:1> ; this . isOrphanCompletionNode = true ; } protected void consumeNormalAnnotation ( ) { int index ; if ( ( index = this . indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . consumeNormalAnnotation ( ) ; return ; } NormalAnnotation normalAnnotation = null ; int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; TypeReference typeReference ; char [ ] [ ] subset = identifierSubSet ( index ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; if ( index == <NUM_LIT:0> ) { typeReference = createSingleAssistTypeReference ( assistIdentifier ( ) , positions [ <NUM_LIT:0> ] ) ; } else { typeReference = createQualifiedAssistTypeReference ( subset , assistIdentifier ( ) , positions ) ; } this . assistNode = typeReference ; this . lastCheckPoint = typeReference . sourceEnd + <NUM_LIT:1> ; normalAnnotation = new NormalAnnotation ( typeReference , this . intStack [ this . intPtr -- ] ) ; if ( ( length = this . astLengthStack [ this . astLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . astStack , ( this . astPtr -= length ) + <NUM_LIT:1> , normalAnnotation . memberValuePairs = new MemberValuePair [ length ] , <NUM_LIT:0> , length ) ; } normalAnnotation . declarationSourceEnd = this . rParenPos ; pushOnExpressionStack ( normalAnnotation ) ; } protected void consumeSingleMemberAnnotation ( ) { int index ; if ( ( index = this . indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . consumeSingleMemberAnnotation ( ) ; return ; } SingleMemberAnnotation singleMemberAnnotation = null ; int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; TypeReference typeReference ; char [ ] [ ] subset = identifierSubSet ( index ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; if ( index == <NUM_LIT:0> ) { typeReference = createSingleAssistTypeReference ( assistIdentifier ( ) , positions [ <NUM_LIT:0> ] ) ; } else { typeReference = createQualifiedAssistTypeReference ( subset , assistIdentifier ( ) , positions ) ; } this . assistNode = typeReference ; this . lastCheckPoint = typeReference . sourceEnd + <NUM_LIT:1> ; singleMemberAnnotation = new SingleMemberAnnotation ( typeReference , this . intStack [ this . intPtr -- ] ) ; singleMemberAnnotation . memberValue = this . expressionStack [ this . expressionPtr -- ] ; this . expressionLengthPtr -- ; singleMemberAnnotation . declarationSourceEnd = this . rParenPos ; pushOnExpressionStack ( singleMemberAnnotation ) ; } protected void consumeStaticImportOnDemandDeclarationName ( ) { int index ; if ( ( index = indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . consumeStaticImportOnDemandDeclarationName ( ) ; return ; } int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; char [ ] [ ] subset = identifierSubSet ( index + <NUM_LIT:1> ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; ImportReference reference = createAssistImportReference ( subset , positions , ClassFileConstants . AccStatic ) ; reference . bits |= ASTNode . OnDemand ; reference . trailingStarPosition = this . intStack [ this . intPtr -- ] ; this . assistNode = reference ; this . lastCheckPoint = reference . sourceEnd + <NUM_LIT:1> ; pushOnAstStack ( reference ) ; if ( this . currentToken == TokenNameSEMICOLON ) { reference . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { reference . declarationSourceEnd = ( int ) positions [ length - <NUM_LIT:1> ] ; } reference . declarationSourceStart = this . intStack [ this . intPtr -- ] ; reference . declarationSourceEnd = flushCommentsDefinedPriorTo ( reference . declarationSourceEnd ) ; if ( this . currentElement != null ) { this . lastCheckPoint = reference . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( reference , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } } protected void consumeToken ( int token ) { super . consumeToken ( token ) ; if ( isInsideMethod ( ) || isInsideFieldInitialization ( ) ) { switch ( token ) { case TokenNamecase : pushOnElementStack ( K_BETWEEN_CASE_AND_COLON ) ; break ; case TokenNameCOLON : if ( topKnownElementKind ( SELECTION_OR_ASSIST_PARSER ) == K_BETWEEN_CASE_AND_COLON ) { popElement ( K_BETWEEN_CASE_AND_COLON ) ; } break ; case TokenNamereturn : pushOnElementStack ( K_INSIDE_RETURN_STATEMENT , this . bracketDepth ) ; break ; case TokenNameSEMICOLON : switch ( topKnownElementKind ( SELECTION_OR_ASSIST_PARSER ) ) { case K_INSIDE_RETURN_STATEMENT : if ( topKnownElementInfo ( SELECTION_OR_ASSIST_PARSER ) == this . bracketDepth ) { popElement ( K_INSIDE_RETURN_STATEMENT ) ; } break ; } break ; } } } protected void consumeTypeImportOnDemandDeclarationName ( ) { int index ; if ( ( index = indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . consumeTypeImportOnDemandDeclarationName ( ) ; return ; } int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; char [ ] [ ] subset = identifierSubSet ( index + <NUM_LIT:1> ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; ImportReference reference = createAssistImportReference ( subset , positions , ClassFileConstants . AccDefault ) ; reference . bits |= ASTNode . OnDemand ; reference . trailingStarPosition = this . intStack [ this . intPtr -- ] ; this . assistNode = reference ; this . lastCheckPoint = reference . sourceEnd + <NUM_LIT:1> ; pushOnAstStack ( reference ) ; if ( this . currentToken == TokenNameSEMICOLON ) { reference . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { reference . declarationSourceEnd = ( int ) positions [ length - <NUM_LIT:1> ] ; } reference . declarationSourceStart = this . intStack [ this . intPtr -- ] ; reference . declarationSourceEnd = flushCommentsDefinedPriorTo ( reference . declarationSourceEnd ) ; if ( this . currentElement != null ) { this . lastCheckPoint = reference . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( reference , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } } public ImportReference createAssistImportReference ( char [ ] [ ] tokens , long [ ] positions , int mod ) { return new SelectionOnImportReference ( tokens , positions , mod ) ; } public ImportReference createAssistPackageReference ( char [ ] [ ] tokens , long [ ] positions ) { return new SelectionOnPackageReference ( tokens , positions ) ; } protected JavadocParser createJavadocParser ( ) { return new SelectionJavadocParser ( this ) ; } protected LocalDeclaration createLocalDeclaration ( char [ ] assistName , int sourceStart , int sourceEnd ) { if ( this . indexOfAssistIdentifier ( ) < <NUM_LIT:0> ) { return super . createLocalDeclaration ( assistName , sourceStart , sourceEnd ) ; } else { SelectionOnLocalName local = new SelectionOnLocalName ( assistName , sourceStart , sourceEnd ) ; this . assistNode = local ; this . lastCheckPoint = sourceEnd + <NUM_LIT:1> ; return local ; } } public NameReference createQualifiedAssistNameReference ( char [ ] [ ] previousIdentifiers , char [ ] assistName , long [ ] positions ) { return new SelectionOnQualifiedNameReference ( previousIdentifiers , assistName , positions ) ; } public TypeReference createQualifiedAssistTypeReference ( char [ ] [ ] previousIdentifiers , char [ ] assistName , long [ ] positions ) { return new SelectionOnQualifiedTypeReference ( previousIdentifiers , assistName , positions ) ; } public TypeReference createParameterizedQualifiedAssistTypeReference ( char [ ] [ ] tokens , TypeReference [ ] [ ] typeArguments , char [ ] assistname , TypeReference [ ] assistTypeArguments , long [ ] positions ) { return new SelectionOnParameterizedQualifiedTypeReference ( tokens , assistname , typeArguments , assistTypeArguments , positions ) ; } public NameReference createSingleAssistNameReference ( char [ ] assistName , long position ) { return new SelectionOnSingleNameReference ( assistName , position ) ; } public TypeReference createSingleAssistTypeReference ( char [ ] assistName , long position ) { return new SelectionOnSingleTypeReference ( assistName , position ) ; } public TypeReference createParameterizedSingleAssistTypeReference ( TypeReference [ ] typeArguments , char [ ] assistName , long position ) { return new SelectionOnParameterizedSingleTypeReference ( assistName , typeArguments , position ) ; } public CompilationUnitDeclaration dietParse ( ICompilationUnit sourceUnit , CompilationResult compilationResult , int start , int end ) { this . selectionStart = start ; this . selectionEnd = end ; SelectionScanner selectionScanner = ( SelectionScanner ) this . scanner ; selectionScanner . selectionIdentifier = null ; selectionScanner . selectionStart = start ; selectionScanner . selectionEnd = end ; return this . dietParse ( sourceUnit , compilationResult ) ; } protected NameReference getUnspecifiedReference ( ) { int completionIndex ; if ( ( completionIndex = indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { return super . getUnspecifiedReference ( ) ; } int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; if ( CharOperation . equals ( assistIdentifier ( ) , SUPER ) ) { Reference reference ; if ( completionIndex > <NUM_LIT:0> ) { this . identifierLengthStack [ this . identifierLengthPtr ] = completionIndex ; int ptr = this . identifierPtr -= ( length - completionIndex ) ; pushOnGenericsLengthStack ( <NUM_LIT:0> ) ; pushOnGenericsIdentifiersLengthStack ( this . identifierLengthStack [ this . identifierLengthPtr ] ) ; reference = new SelectionOnQualifiedSuperReference ( getTypeReference ( <NUM_LIT:0> ) , ( int ) ( this . identifierPositionStack [ ptr + <NUM_LIT:1> ] > > > <NUM_LIT:32> ) , ( int ) this . identifierPositionStack [ ptr + <NUM_LIT:1> ] ) ; } else { this . identifierPtr -= length ; this . identifierLengthPtr -- ; reference = new SelectionOnSuperReference ( ( int ) ( this . identifierPositionStack [ this . identifierPtr + <NUM_LIT:1> ] > > > <NUM_LIT:32> ) , ( int ) this . identifierPositionStack [ this . identifierPtr + <NUM_LIT:1> ] ) ; } pushOnAstStack ( reference ) ; this . assistNode = reference ; this . lastCheckPoint = reference . sourceEnd + <NUM_LIT:1> ; if ( ! this . diet || this . dietInt != <NUM_LIT:0> ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . isOrphanCompletionNode = true ; return new SingleNameReference ( CharOperation . NO_CHAR , <NUM_LIT:0> ) ; } NameReference nameReference ; char [ ] [ ] subset = identifierSubSet ( completionIndex ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; if ( completionIndex == <NUM_LIT:0> ) { nameReference = createSingleAssistNameReference ( assistIdentifier ( ) , positions [ <NUM_LIT:0> ] ) ; } else { nameReference = createQualifiedAssistNameReference ( subset , assistIdentifier ( ) , positions ) ; } this . assistNode = nameReference ; this . lastCheckPoint = nameReference . sourceEnd + <NUM_LIT:1> ; if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . isOrphanCompletionNode = true ; return nameReference ; } protected NameReference getUnspecifiedReferenceOptimized ( ) { int index = indexOfAssistIdentifier ( ) ; NameReference reference = super . getUnspecifiedReferenceOptimized ( ) ; if ( index >= <NUM_LIT:0> ) { if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . isOrphanCompletionNode = true ; } return reference ; } public void initializeScanner ( ) { this . scanner = new SelectionScanner ( this . options . sourceLevel ) ; } protected MessageSend newMessageSend ( ) { char [ ] selector = this . identifierStack [ this . identifierPtr ] ; if ( selector != assistIdentifier ( ) ) { return super . newMessageSend ( ) ; } MessageSend messageSend = new SelectionOnMessageSend ( ) ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { this . expressionPtr -= length ; System . arraycopy ( this . expressionStack , this . expressionPtr + <NUM_LIT:1> , messageSend . arguments = new Expression [ length ] , <NUM_LIT:0> , length ) ; } this . assistNode = messageSend ; if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . isOrphanCompletionNode = true ; return messageSend ; } protected MessageSend newMessageSendWithTypeArguments ( ) { char [ ] selector = this . identifierStack [ this . identifierPtr ] ; if ( selector != assistIdentifier ( ) ) { return super . newMessageSendWithTypeArguments ( ) ; } MessageSend messageSend = new SelectionOnMessageSend ( ) ; int length ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { this . expressionPtr -= length ; System . arraycopy ( this . expressionStack , this . expressionPtr + <NUM_LIT:1> , messageSend . arguments = new Expression [ length ] , <NUM_LIT:0> , length ) ; } this . assistNode = messageSend ; if ( ! this . diet ) { this . restartRecovery = true ; this . lastIgnoredToken = - <NUM_LIT:1> ; } this . isOrphanCompletionNode = true ; return messageSend ; } public CompilationUnitDeclaration parse ( ICompilationUnit sourceUnit , CompilationResult compilationResult , int start , int end ) { if ( end == - <NUM_LIT:1> ) return super . parse ( sourceUnit , compilationResult , start , end ) ; this . selectionStart = start ; this . selectionEnd = end ; SelectionScanner selectionScanner = ( SelectionScanner ) this . scanner ; selectionScanner . selectionIdentifier = null ; selectionScanner . selectionStart = start ; selectionScanner . selectionEnd = end ; return super . parse ( sourceUnit , compilationResult , - <NUM_LIT:1> , - <NUM_LIT:1> ) ; } protected boolean resumeAfterRecovery ( ) { if ( this . assistNode != null && ! ( this . referenceContext instanceof CompilationUnitDeclaration ) ) { this . currentElement . preserveEnclosingBlocks ( ) ; if ( this . currentElement . enclosingType ( ) == null ) { if ( ! ( this . currentElement instanceof RecoveredType ) ) { resetStacks ( ) ; return false ; } RecoveredType recoveredType = ( RecoveredType ) this . currentElement ; if ( recoveredType . typeDeclaration != null && recoveredType . typeDeclaration . allocation == this . assistNode ) { resetStacks ( ) ; return false ; } } } return super . resumeAfterRecovery ( ) ; } public void selectionIdentifierCheck ( ) { if ( checkRecoveredType ( ) ) return ; } public void setAssistIdentifier ( char [ ] assistIdent ) { ( ( SelectionScanner ) this . scanner ) . selectionIdentifier = assistIdent ; } protected void updateRecoveryState ( ) { this . currentElement . updateFromParserState ( ) ; selectionIdentifierCheck ( ) ; attachOrphanCompletionNode ( ) ; if ( this . assistNode != null && this . currentElement != null ) { this . currentElement . preserveEnclosingBlocks ( ) ; } recoveryTokenCheck ( ) ; } public String toString ( ) { String s = Util . EMPTY_STRING ; s = s + "<STR_LIT>" ; for ( int i = <NUM_LIT:0> ; i <= this . elementPtr ; i ++ ) { s = s + String . valueOf ( this . elementKindStack [ i ] ) + "<STR_LIT:U+002C>" ; } s = s + "<STR_LIT>" ; s = s + "<STR_LIT>" ; for ( int i = <NUM_LIT:0> ; i <= this . elementPtr ; i ++ ) { s = s + String . valueOf ( this . elementInfoStack [ i ] ) + "<STR_LIT:U+002C>" ; } s = s + "<STR_LIT>" ; return s + super . toString ( ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; public class SelectionOnLocalName extends LocalDeclaration { public SelectionOnLocalName ( char [ ] name , int sourceStart , int sourceEnd ) { super ( name , sourceStart , sourceEnd ) ; } public void resolve ( BlockScope scope ) { super . resolve ( scope ) ; throw new SelectionNodeFound ( this . binding ) ; } public StringBuffer printAsExpression ( int indent , StringBuffer output ) { printIndent ( indent , output ) ; output . append ( "<STR_LIT>" ) ; printModifiers ( this . modifiers , output ) ; this . type . print ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:U+0020>' ) . append ( this . name ) ; if ( this . initialization != null ) { output . append ( "<STR_LIT:U+0020=U+0020>" ) ; this . initialization . printExpression ( <NUM_LIT:0> , output ) ; } return output . append ( '<CHAR_LIT:>>' ) ; } public StringBuffer printStatement ( int indent , StringBuffer output ) { printAsExpression ( indent , output ) ; return output . append ( '<CHAR_LIT:;>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . MessageSend ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class SelectionOnMessageSend extends MessageSend { private MethodBinding findNonDefaultAbstractMethod ( MethodBinding methodBinding ) { ReferenceBinding [ ] itsInterfaces = methodBinding . declaringClass . superInterfaces ( ) ; if ( itsInterfaces != Binding . NO_SUPERINTERFACES ) { ReferenceBinding [ ] interfacesToVisit = itsInterfaces ; int nextPosition = interfacesToVisit . length ; for ( int i = <NUM_LIT:0> ; i < nextPosition ; i ++ ) { ReferenceBinding currentType = interfacesToVisit [ i ] ; MethodBinding [ ] methods = currentType . getMethods ( methodBinding . selector ) ; if ( methods != null ) { for ( int k = <NUM_LIT:0> ; k < methods . length ; k ++ ) { if ( methodBinding . areParametersEqual ( methods [ k ] ) ) return methods [ k ] ; } } if ( ( itsInterfaces = currentType . superInterfaces ( ) ) != Binding . NO_SUPERINTERFACES ) { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + <NUM_LIT:5> ] , <NUM_LIT:0> , nextPosition ) ; nextInterface : for ( int a = <NUM_LIT:0> ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = <NUM_LIT:0> ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } } return methodBinding ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; if ( ! this . receiver . isImplicitThis ( ) ) this . receiver . printExpression ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:.>' ) ; output . append ( this . selector ) . append ( '<CHAR_LIT:(>' ) ; if ( this . arguments != null ) { for ( int i = <NUM_LIT:0> ; i < this . arguments . length ; i ++ ) { if ( i > <NUM_LIT:0> ) output . append ( "<STR_LIT:U+002CU+0020>" ) ; this . arguments [ i ] . printExpression ( <NUM_LIT:0> , output ) ; } } return output . append ( "<STR_LIT>" ) ; } public TypeBinding resolveType ( BlockScope scope ) { super . resolveType ( scope ) ; if ( this . binding == null || ! ( this . binding . isValidBinding ( ) || this . binding . problemId ( ) == ProblemReasons . NotVisible || this . binding . problemId ( ) == ProblemReasons . InheritedNameHidesEnclosingName || this . binding . problemId ( ) == ProblemReasons . NonStaticReferenceInConstructorInvocation || this . binding . problemId ( ) == ProblemReasons . NonStaticReferenceInStaticContext ) ) { throw new SelectionNodeFound ( ) ; } else { if ( this . binding . isDefaultAbstract ( ) ) { throw new SelectionNodeFound ( findNonDefaultAbstractMethod ( this . binding ) ) ; } else { throw new SelectionNodeFound ( this . binding ) ; } } } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; public class SelectionOnExplicitConstructorCall extends ExplicitConstructorCall { public SelectionOnExplicitConstructorCall ( int accessMode ) { super ( accessMode ) ; } public StringBuffer printStatement ( int tab , StringBuffer output ) { printIndent ( tab , output ) ; output . append ( "<STR_LIT>" ) ; if ( this . qualification != null ) this . qualification . printExpression ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:.>' ) ; if ( this . accessMode == This ) { output . append ( "<STR_LIT>" ) ; } else { output . append ( "<STR_LIT>" ) ; } if ( this . arguments != null ) { for ( int i = <NUM_LIT:0> ; i < this . arguments . length ; i ++ ) { if ( i > <NUM_LIT:0> ) output . append ( "<STR_LIT:U+002CU+0020>" ) ; this . arguments [ i ] . printExpression ( <NUM_LIT:0> , output ) ; } } return output . append ( "<STR_LIT>" ) ; } public void resolve ( BlockScope scope ) { super . resolve ( scope ) ; if ( this . binding == null || ! ( this . binding . isValidBinding ( ) || this . binding . problemId ( ) == ProblemReasons . NotVisible ) ) throw new SelectionNodeFound ( ) ; else throw new SelectionNodeFound ( this . binding ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . MethodScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class SelectionOnArgumentName extends Argument { public SelectionOnArgumentName ( char [ ] name , long posNom , TypeReference tr , int modifiers ) { super ( name , posNom , tr , modifiers ) ; } public void bind ( MethodScope scope , TypeBinding typeBinding , boolean used ) { super . bind ( scope , typeBinding , used ) ; throw new SelectionNodeFound ( this . binding ) ; } public StringBuffer print ( int indent , StringBuffer output ) { printIndent ( indent , output ) ; output . append ( "<STR_LIT>" ) ; if ( this . type != null ) this . type . print ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:U+0020>' ) ; output . append ( this . name ) ; if ( this . initialization != null ) { output . append ( "<STR_LIT:U+0020=U+0020>" ) ; this . initialization . printExpression ( <NUM_LIT:0> , output ) ; } return output . append ( '<CHAR_LIT:>>' ) ; } public void resolve ( BlockScope scope ) { super . resolve ( scope ) ; throw new SelectionNodeFound ( this . binding ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . FieldReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class SelectionOnFieldReference extends FieldReference { public SelectionOnFieldReference ( char [ ] source , long pos ) { super ( source , pos ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; return super . printExpression ( <NUM_LIT:0> , output ) . append ( '<CHAR_LIT:>>' ) ; } public TypeBinding resolveType ( BlockScope scope ) { super . resolveType ( scope ) ; if ( this . binding == null || ! ( this . binding . isValidBinding ( ) || this . binding . problemId ( ) == ProblemReasons . NotVisible || this . binding . problemId ( ) == ProblemReasons . InheritedNameHidesEnclosingName || this . binding . problemId ( ) == ProblemReasons . NonStaticReferenceInConstructorInvocation || this . binding . problemId ( ) == ProblemReasons . NonStaticReferenceInStaticContext ) ) throw new SelectionNodeFound ( ) ; else throw new SelectionNodeFound ( this . binding ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . PackageBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . Scope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class SelectionOnQualifiedTypeReference extends QualifiedTypeReference { public SelectionOnQualifiedTypeReference ( char [ ] [ ] previousIdentifiers , char [ ] selectionIdentifier , long [ ] positions ) { super ( CharOperation . arrayConcat ( previousIdentifiers , selectionIdentifier ) , positions ) ; } public void aboutToResolve ( Scope scope ) { getTypeBinding ( scope . parent ) ; } protected TypeBinding getTypeBinding ( Scope scope ) { Binding binding = scope . getTypeOrPackage ( this . tokens ) ; if ( ! binding . isValidBinding ( ) ) { if ( binding . problemId ( ) == ProblemReasons . NotVisible ) { throw new SelectionNodeFound ( binding ) ; } if ( binding instanceof TypeBinding ) { scope . problemReporter ( ) . invalidType ( this , ( TypeBinding ) binding ) ; } else if ( binding instanceof PackageBinding ) { ProblemReferenceBinding problemBinding = new ProblemReferenceBinding ( ( ( PackageBinding ) binding ) . compoundName , null , binding . problemId ( ) ) ; scope . problemReporter ( ) . invalidType ( this , problemBinding ) ; } throw new SelectionNodeFound ( ) ; } throw new SelectionNodeFound ( binding ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> , length = this . tokens . length ; i < length ; i ++ ) { if ( i > <NUM_LIT:0> ) output . append ( '<CHAR_LIT:.>' ) ; output . append ( this . tokens [ i ] ) ; } return output . append ( '<CHAR_LIT:>>' ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . select ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedSingleTypeReference ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; public class SelectionOnParameterizedSingleTypeReference extends ParameterizedSingleTypeReference { public SelectionOnParameterizedSingleTypeReference ( char [ ] name , TypeReference [ ] typeArguments , long pos ) { super ( name , typeArguments , <NUM_LIT:0> , pos ) ; } public TypeBinding resolveType ( BlockScope scope , boolean checkBounds ) { super . resolveType ( scope , checkBounds ) ; throw new SelectionNodeFound ( this . resolvedType ) ; } public TypeBinding resolveType ( ClassScope scope ) { super . resolveType ( scope ) ; throw new SelectionNodeFound ( this . resolvedType ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { output . append ( "<STR_LIT>" ) ; output . append ( this . token ) ; output . append ( '<CHAR_LIT>' ) ; int max = this . typeArguments . length - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) { this . typeArguments [ i ] . print ( <NUM_LIT:0> , output ) ; output . append ( "<STR_LIT:U+002CU+0020>" ) ; } this . typeArguments [ max ] . print ( <NUM_LIT:0> , output ) ; output . append ( '<CHAR_LIT:>>' ) ; output . append ( '<CHAR_LIT:>>' ) ; return output ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist ; import org . eclipse . jdt . internal . compiler . env . AccessRestriction ; public interface ISearchRequestor { public void acceptConstructor ( int modifiers , char [ ] simpleTypeName , int parameterCount , char [ ] signature , char [ ] [ ] parameterTypes , char [ ] [ ] parameterNames , int typeModifiers , char [ ] packageName , int extraFlags , String path , AccessRestriction access ) ; public void acceptType ( char [ ] packageName , char [ ] typeName , char [ ] [ ] enclosingTypeNames , int modifiers , AccessRestriction accessRestriction ) ; public void acceptPackage ( char [ ] packageName ) ; } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; import java . util . Map ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . CompilationUnit ; import org . eclipse . jdt . internal . core . PackageDeclaration ; public class AssistPackageDeclaration extends PackageDeclaration { private Map infoCache ; public AssistPackageDeclaration ( CompilationUnit parent , String name , Map infoCache ) { super ( parent , name ) ; this . infoCache = infoCache ; } public Object getElementInfo ( IProgressMonitor monitor ) throws JavaModelException { return this . infoCache . get ( this ) ; } public IAnnotation getAnnotation ( String name ) { return new AssistAnnotation ( this , name , this . infoCache ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; public interface Keywords { int COUNT = <NUM_LIT> ; char [ ] ABSTRACT = "<STR_LIT>" . toCharArray ( ) ; char [ ] ASSERT = "<STR_LIT>" . toCharArray ( ) ; char [ ] BREAK = "<STR_LIT>" . toCharArray ( ) ; char [ ] CASE = "<STR_LIT>" . toCharArray ( ) ; char [ ] CATCH = "<STR_LIT>" . toCharArray ( ) ; char [ ] CLASS = "<STR_LIT:class>" . toCharArray ( ) ; char [ ] CONTINUE = "<STR_LIT>" . toCharArray ( ) ; char [ ] DEFAULT = "<STR_LIT:default>" . toCharArray ( ) ; char [ ] DO = "<STR_LIT>" . toCharArray ( ) ; char [ ] ELSE = "<STR_LIT>" . toCharArray ( ) ; char [ ] ENUM = "<STR_LIT>" . toCharArray ( ) ; char [ ] EXTENDS = "<STR_LIT>" . toCharArray ( ) ; char [ ] FINAL = "<STR_LIT>" . toCharArray ( ) ; char [ ] FINALLY = "<STR_LIT>" . toCharArray ( ) ; char [ ] FOR = "<STR_LIT>" . toCharArray ( ) ; char [ ] IF = "<STR_LIT>" . toCharArray ( ) ; char [ ] IMPLEMENTS = "<STR_LIT>" . toCharArray ( ) ; char [ ] IMPORT = "<STR_LIT>" . toCharArray ( ) ; char [ ] INSTANCEOF = "<STR_LIT>" . toCharArray ( ) ; char [ ] INTERFACE = "<STR_LIT>" . toCharArray ( ) ; char [ ] NATIVE = "<STR_LIT>" . toCharArray ( ) ; char [ ] NEW = "<STR_LIT>" . toCharArray ( ) ; char [ ] PACKAGE = "<STR_LIT>" . toCharArray ( ) ; char [ ] PRIVATE = "<STR_LIT>" . toCharArray ( ) ; char [ ] PROTECTED = "<STR_LIT>" . toCharArray ( ) ; char [ ] PUBLIC = "<STR_LIT>" . toCharArray ( ) ; char [ ] RETURN = "<STR_LIT>" . toCharArray ( ) ; char [ ] STATIC = "<STR_LIT>" . toCharArray ( ) ; char [ ] STRICTFP = "<STR_LIT>" . toCharArray ( ) ; char [ ] SUPER = "<STR_LIT>" . toCharArray ( ) ; char [ ] SWITCH = "<STR_LIT>" . toCharArray ( ) ; char [ ] SYNCHRONIZED = "<STR_LIT>" . toCharArray ( ) ; char [ ] THIS = "<STR_LIT>" . toCharArray ( ) ; char [ ] THROW = "<STR_LIT>" . toCharArray ( ) ; char [ ] THROWS = "<STR_LIT>" . toCharArray ( ) ; char [ ] TRANSIENT = "<STR_LIT>" . toCharArray ( ) ; char [ ] TRY = "<STR_LIT>" . toCharArray ( ) ; char [ ] VOLATILE = "<STR_LIT>" . toCharArray ( ) ; char [ ] WHILE = "<STR_LIT>" . toCharArray ( ) ; char [ ] TRUE = "<STR_LIT:true>" . toCharArray ( ) ; char [ ] FALSE = "<STR_LIT:false>" . toCharArray ( ) ; char [ ] NULL = "<STR_LIT:null>" . toCharArray ( ) ; } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . ExtraCompilerModifiers ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . parser . RecoveredBlock ; import org . eclipse . jdt . internal . compiler . parser . RecoveredElement ; import org . eclipse . jdt . internal . compiler . parser . RecoveredField ; import org . eclipse . jdt . internal . compiler . parser . RecoveredInitializer ; import org . eclipse . jdt . internal . compiler . parser . RecoveredMethod ; import org . eclipse . jdt . internal . compiler . parser . RecoveredType ; import org . eclipse . jdt . internal . compiler . parser . RecoveredUnit ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; public abstract class AssistParser extends Parser { public ASTNode assistNode ; public boolean isOrphanCompletionNode ; protected int lastModifiers = ClassFileConstants . AccDefault ; protected int lastModifiersStart = - <NUM_LIT:1> ; int [ ] blockStarts = new int [ <NUM_LIT:30> ] ; protected int previousToken ; protected int previousIdentifierPtr ; protected int bracketDepth ; protected static final int ElementStackIncrement = <NUM_LIT:100> ; protected int elementPtr ; protected int [ ] elementKindStack = new int [ ElementStackIncrement ] ; protected int [ ] elementInfoStack = new int [ ElementStackIncrement ] ; protected Object [ ] elementObjectInfoStack = new Object [ ElementStackIncrement ] ; protected int previousKind ; protected int previousInfo ; protected Object previousObjectInfo ; protected static final int ASSIST_PARSER = <NUM_LIT> ; protected static final int K_SELECTOR = ASSIST_PARSER + <NUM_LIT:1> ; protected static final int K_TYPE_DELIMITER = ASSIST_PARSER + <NUM_LIT:2> ; protected static final int K_METHOD_DELIMITER = ASSIST_PARSER + <NUM_LIT:3> ; protected static final int K_FIELD_INITIALIZER_DELIMITER = ASSIST_PARSER + <NUM_LIT:4> ; protected static final int K_ATTRIBUTE_VALUE_DELIMITER = ASSIST_PARSER + <NUM_LIT:5> ; protected static final int K_ENUM_CONSTANT_DELIMITER = ASSIST_PARSER + <NUM_LIT:6> ; protected static final int THIS_CONSTRUCTOR = - <NUM_LIT:1> ; protected static final int SUPER_CONSTRUCTOR = - <NUM_LIT:2> ; protected static final int NO_BODY = <NUM_LIT:0> ; protected static final int WITH_BODY = <NUM_LIT:1> ; protected boolean isFirst = false ; public AssistParser ( ProblemReporter problemReporter ) { super ( problemReporter , true ) ; this . javadocParser . checkDocComment = false ; setMethodsFullRecovery ( false ) ; setStatementsRecovery ( false ) ; } public abstract char [ ] assistIdentifier ( ) ; public Object becomeSimpleParser ( ) { return null ; } public void restoreAssistParser ( Object parserState ) { } public int bodyEnd ( AbstractMethodDeclaration method ) { return method . bodyEnd ; } public int bodyEnd ( Initializer initializer ) { return initializer . declarationSourceEnd ; } public RecoveredElement buildInitialRecoveryState ( ) { if ( this . referenceContext instanceof CompilationUnitDeclaration ) { RecoveredElement element = super . buildInitialRecoveryState ( ) ; flushAssistState ( ) ; flushElementStack ( ) ; return element ; } this . lastCheckPoint = <NUM_LIT:0> ; RecoveredElement element = null ; if ( this . referenceContext instanceof AbstractMethodDeclaration ) { element = new RecoveredMethod ( ( AbstractMethodDeclaration ) this . referenceContext , null , <NUM_LIT:0> , this ) ; this . lastCheckPoint = ( ( AbstractMethodDeclaration ) this . referenceContext ) . bodyStart ; } else { if ( this . referenceContext instanceof TypeDeclaration ) { TypeDeclaration type = ( TypeDeclaration ) this . referenceContext ; FieldDeclaration [ ] fields = type . fields ; int length = fields == null ? <NUM_LIT:0> : fields . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { FieldDeclaration field = fields [ i ] ; if ( field != null && field . getKind ( ) == AbstractVariableDeclaration . INITIALIZER && field . declarationSourceStart <= this . scanner . initialPosition && this . scanner . initialPosition <= field . declarationSourceEnd && this . scanner . eofPosition <= field . declarationSourceEnd + <NUM_LIT:1> ) { element = new RecoveredInitializer ( field , null , <NUM_LIT:1> , this ) ; this . lastCheckPoint = field . declarationSourceStart ; break ; } } } } if ( element == null ) return element ; Block block = new Block ( <NUM_LIT:0> ) ; int lastStart = this . blockStarts [ <NUM_LIT:0> ] ; block . sourceStart = lastStart ; element = element . add ( block , <NUM_LIT:1> ) ; int blockIndex = <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i <= this . astPtr ; i ++ ) { ASTNode node = this . astStack [ i ] ; if ( node instanceof ForeachStatement && ( ( ForeachStatement ) node ) . action == null ) { node = ( ( ForeachStatement ) node ) . elementVariable ; } int nodeStart = node . sourceStart ; for ( int j = blockIndex ; j <= this . realBlockPtr ; j ++ ) { if ( this . blockStarts [ j ] >= <NUM_LIT:0> ) { if ( this . blockStarts [ j ] > nodeStart ) { blockIndex = j ; break ; } if ( this . blockStarts [ j ] != lastStart ) { block = new Block ( <NUM_LIT:0> ) ; block . sourceStart = lastStart = this . blockStarts [ j ] ; element = element . add ( block , <NUM_LIT:1> ) ; } } else { if ( - this . blockStarts [ j ] > nodeStart ) { blockIndex = j ; break ; } block = new Block ( <NUM_LIT:0> ) ; block . sourceStart = lastStart = - this . blockStarts [ j ] ; element = element . add ( block , <NUM_LIT:1> ) ; } blockIndex = j + <NUM_LIT:1> ; } if ( node instanceof LocalDeclaration ) { LocalDeclaration local = ( LocalDeclaration ) node ; if ( local . declarationSourceEnd == <NUM_LIT:0> ) { element = element . add ( local , <NUM_LIT:0> ) ; if ( local . initialization == null ) { this . lastCheckPoint = local . sourceEnd + <NUM_LIT:1> ; } else { this . lastCheckPoint = local . initialization . sourceEnd + <NUM_LIT:1> ; } } else { element = element . add ( local , <NUM_LIT:0> ) ; this . lastCheckPoint = local . declarationSourceEnd + <NUM_LIT:1> ; } continue ; } if ( node instanceof AbstractMethodDeclaration ) { AbstractMethodDeclaration method = ( AbstractMethodDeclaration ) node ; if ( method . declarationSourceEnd == <NUM_LIT:0> ) { element = element . add ( method , <NUM_LIT:0> ) ; this . lastCheckPoint = method . bodyStart ; } else { element = element . add ( method , <NUM_LIT:0> ) ; this . lastCheckPoint = method . declarationSourceEnd + <NUM_LIT:1> ; } continue ; } if ( node instanceof Initializer ) { Initializer initializer = ( Initializer ) node ; if ( initializer . declarationSourceEnd == <NUM_LIT:0> ) { element = element . add ( initializer , <NUM_LIT:1> ) ; this . lastCheckPoint = initializer . sourceStart ; } else { element = element . add ( initializer , <NUM_LIT:0> ) ; this . lastCheckPoint = initializer . declarationSourceEnd + <NUM_LIT:1> ; } continue ; } if ( node instanceof FieldDeclaration ) { FieldDeclaration field = ( FieldDeclaration ) node ; if ( field . declarationSourceEnd == <NUM_LIT:0> ) { element = element . add ( field , <NUM_LIT:0> ) ; if ( field . initialization == null ) { this . lastCheckPoint = field . sourceEnd + <NUM_LIT:1> ; } else { this . lastCheckPoint = field . initialization . sourceEnd + <NUM_LIT:1> ; } } else { element = element . add ( field , <NUM_LIT:0> ) ; this . lastCheckPoint = field . declarationSourceEnd + <NUM_LIT:1> ; } continue ; } if ( node instanceof TypeDeclaration ) { TypeDeclaration type = ( TypeDeclaration ) node ; if ( type . declarationSourceEnd == <NUM_LIT:0> ) { element = element . add ( type , <NUM_LIT:0> ) ; this . lastCheckPoint = type . bodyStart ; } else { element = element . add ( type , <NUM_LIT:0> ) ; this . lastCheckPoint = type . declarationSourceEnd + <NUM_LIT:1> ; } continue ; } if ( node instanceof ImportReference ) { ImportReference importRef = ( ImportReference ) node ; element = element . add ( importRef , <NUM_LIT:0> ) ; this . lastCheckPoint = importRef . declarationSourceEnd + <NUM_LIT:1> ; } } if ( this . currentToken == TokenNameRBRACE ) { this . currentToken = <NUM_LIT:0> ; } int pos = this . assistNode == null ? this . lastCheckPoint : this . assistNode . sourceStart ; for ( int j = blockIndex ; j <= this . realBlockPtr ; j ++ ) { if ( this . blockStarts [ j ] >= <NUM_LIT:0> ) { if ( ( this . blockStarts [ j ] < pos ) && ( this . blockStarts [ j ] != lastStart ) ) { block = new Block ( <NUM_LIT:0> ) ; block . sourceStart = lastStart = this . blockStarts [ j ] ; element = element . add ( block , <NUM_LIT:1> ) ; } } else { if ( ( this . blockStarts [ j ] < pos ) ) { block = new Block ( <NUM_LIT:0> ) ; block . sourceStart = lastStart = - this . blockStarts [ j ] ; element = element . add ( block , <NUM_LIT:1> ) ; } } } return element ; } protected void consumeAnnotationTypeDeclarationHeader ( ) { super . consumeAnnotationTypeDeclarationHeader ( ) ; pushOnElementStack ( K_TYPE_DELIMITER ) ; } protected void consumeClassBodyDeclaration ( ) { popElement ( K_METHOD_DELIMITER ) ; super . consumeClassBodyDeclaration ( ) ; } protected void consumeClassBodyopt ( ) { super . consumeClassBodyopt ( ) ; popElement ( K_SELECTOR ) ; } protected void consumeClassHeader ( ) { super . consumeClassHeader ( ) ; pushOnElementStack ( K_TYPE_DELIMITER ) ; } protected void consumeConstructorBody ( ) { super . consumeConstructorBody ( ) ; popElement ( K_METHOD_DELIMITER ) ; } protected void consumeConstructorHeader ( ) { super . consumeConstructorHeader ( ) ; pushOnElementStack ( K_METHOD_DELIMITER ) ; } protected void consumeEnhancedForStatementHeaderInit ( boolean hasModifiers ) { super . consumeEnhancedForStatementHeaderInit ( hasModifiers ) ; if ( this . currentElement != null ) { LocalDeclaration localDecl = ( ( ForeachStatement ) this . astStack [ this . astPtr ] ) . elementVariable ; this . lastCheckPoint = localDecl . sourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( localDecl , <NUM_LIT:0> ) ; } } protected void consumeEnterAnonymousClassBody ( boolean qualified ) { super . consumeEnterAnonymousClassBody ( qualified ) ; popElement ( K_SELECTOR ) ; pushOnElementStack ( K_TYPE_DELIMITER ) ; } protected void consumeEnterMemberValue ( ) { super . consumeEnterMemberValue ( ) ; pushOnElementStack ( K_ATTRIBUTE_VALUE_DELIMITER , this . identifierPtr ) ; } protected void consumeEnumConstantHeader ( ) { if ( this . currentToken == TokenNameLBRACE ) { popElement ( K_ENUM_CONSTANT_DELIMITER ) ; pushOnElementStack ( K_ENUM_CONSTANT_DELIMITER , WITH_BODY ) ; pushOnElementStack ( K_FIELD_INITIALIZER_DELIMITER ) ; pushOnElementStack ( K_TYPE_DELIMITER ) ; } super . consumeEnumConstantHeader ( ) ; } protected void consumeEnumConstantHeaderName ( ) { super . consumeEnumConstantHeaderName ( ) ; pushOnElementStack ( K_ENUM_CONSTANT_DELIMITER ) ; } protected void consumeEnumConstantWithClassBody ( ) { popElement ( K_TYPE_DELIMITER ) ; popElement ( K_FIELD_INITIALIZER_DELIMITER ) ; popElement ( K_ENUM_CONSTANT_DELIMITER ) ; super . consumeEnumConstantWithClassBody ( ) ; } protected void consumeEnumConstantNoClassBody ( ) { popElement ( K_ENUM_CONSTANT_DELIMITER ) ; super . consumeEnumConstantNoClassBody ( ) ; } protected void consumeEnumHeader ( ) { super . consumeEnumHeader ( ) ; pushOnElementStack ( K_TYPE_DELIMITER ) ; } protected void consumeExitMemberValue ( ) { super . consumeExitMemberValue ( ) ; popElement ( K_ATTRIBUTE_VALUE_DELIMITER ) ; } protected void consumeExplicitConstructorInvocation ( int flag , int recFlag ) { super . consumeExplicitConstructorInvocation ( flag , recFlag ) ; popElement ( K_SELECTOR ) ; } protected void consumeForceNoDiet ( ) { super . consumeForceNoDiet ( ) ; if ( ! isInsideMethod ( ) ) { if ( topKnownElementKind ( ASSIST_PARSER ) != K_ENUM_CONSTANT_DELIMITER ) { if ( topKnownElementKind ( ASSIST_PARSER , <NUM_LIT:2> ) != K_ENUM_CONSTANT_DELIMITER ) { pushOnElementStack ( K_FIELD_INITIALIZER_DELIMITER ) ; } } else { int info = topKnownElementInfo ( ASSIST_PARSER ) ; if ( info != NO_BODY ) { pushOnElementStack ( K_FIELD_INITIALIZER_DELIMITER ) ; } } } } protected void consumeInterfaceHeader ( ) { super . consumeInterfaceHeader ( ) ; pushOnElementStack ( K_TYPE_DELIMITER ) ; } protected void consumeMethodBody ( ) { super . consumeMethodBody ( ) ; popElement ( K_METHOD_DELIMITER ) ; } protected void consumeMethodDeclaration ( boolean isNotAbstract ) { if ( ! isNotAbstract ) { popElement ( K_METHOD_DELIMITER ) ; } super . consumeMethodDeclaration ( isNotAbstract ) ; } protected void consumeMethodHeader ( ) { super . consumeMethodHeader ( ) ; pushOnElementStack ( K_METHOD_DELIMITER ) ; } protected void consumeMethodInvocationName ( ) { super . consumeMethodInvocationName ( ) ; popElement ( K_SELECTOR ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; if ( messageSend == this . assistNode ) { this . lastCheckPoint = messageSend . sourceEnd + <NUM_LIT:1> ; } } protected void consumeMethodInvocationNameWithTypeArguments ( ) { super . consumeMethodInvocationNameWithTypeArguments ( ) ; popElement ( K_SELECTOR ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; if ( messageSend == this . assistNode ) { this . lastCheckPoint = messageSend . sourceEnd + <NUM_LIT:1> ; } } protected void consumeMethodInvocationPrimary ( ) { super . consumeMethodInvocationPrimary ( ) ; popElement ( K_SELECTOR ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; if ( messageSend == this . assistNode ) { this . lastCheckPoint = messageSend . sourceEnd + <NUM_LIT:1> ; } } protected void consumeMethodInvocationPrimaryWithTypeArguments ( ) { super . consumeMethodInvocationPrimaryWithTypeArguments ( ) ; popElement ( K_SELECTOR ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; if ( messageSend == this . assistNode ) { this . lastCheckPoint = messageSend . sourceEnd + <NUM_LIT:1> ; } } protected void consumeMethodInvocationSuper ( ) { super . consumeMethodInvocationSuper ( ) ; popElement ( K_SELECTOR ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; if ( messageSend == this . assistNode ) { this . lastCheckPoint = messageSend . sourceEnd + <NUM_LIT:1> ; } } protected void consumeMethodInvocationSuperWithTypeArguments ( ) { super . consumeMethodInvocationSuperWithTypeArguments ( ) ; popElement ( K_SELECTOR ) ; MessageSend messageSend = ( MessageSend ) this . expressionStack [ this . expressionPtr ] ; if ( messageSend == this . assistNode ) { this . lastCheckPoint = messageSend . sourceEnd + <NUM_LIT:1> ; } } protected void consumeNestedMethod ( ) { super . consumeNestedMethod ( ) ; if ( ! isInsideMethod ( ) ) pushOnElementStack ( K_METHOD_DELIMITER ) ; } protected void consumeOpenBlock ( ) { super . consumeOpenBlock ( ) ; int stackLength = this . blockStarts . length ; if ( this . realBlockPtr >= stackLength ) { System . arraycopy ( this . blockStarts , <NUM_LIT:0> , this . blockStarts = new int [ stackLength + StackIncrement ] , <NUM_LIT:0> , stackLength ) ; } this . blockStarts [ this . realBlockPtr ] = this . scanner . startPosition ; } protected void consumeOpenFakeBlock ( ) { super . consumeOpenBlock ( ) ; int stackLength = this . blockStarts . length ; if ( this . realBlockPtr >= stackLength ) { System . arraycopy ( this . blockStarts , <NUM_LIT:0> , this . blockStarts = new int [ stackLength + StackIncrement ] , <NUM_LIT:0> , stackLength ) ; } this . blockStarts [ this . realBlockPtr ] = - this . scanner . startPosition ; } protected void consumePackageDeclarationName ( ) { int index ; if ( ( index = indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . consumePackageDeclarationName ( ) ; return ; } int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; char [ ] [ ] subset = identifierSubSet ( index + <NUM_LIT:1> ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; ImportReference reference = createAssistPackageReference ( subset , positions ) ; this . assistNode = reference ; this . lastCheckPoint = reference . sourceEnd + <NUM_LIT:1> ; this . compilationUnit . currentPackage = reference ; if ( this . currentToken == TokenNameSEMICOLON ) { reference . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { reference . declarationSourceEnd = ( int ) positions [ length - <NUM_LIT:1> ] ; } reference . declarationSourceStart = this . intStack [ this . intPtr -- ] ; reference . declarationSourceEnd = flushCommentsDefinedPriorTo ( reference . declarationSourceEnd ) ; if ( this . currentElement != null ) { this . lastCheckPoint = reference . declarationSourceEnd + <NUM_LIT:1> ; this . restartRecovery = true ; } } protected void consumePackageDeclarationNameWithModifiers ( ) { int index ; if ( ( index = indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . consumePackageDeclarationNameWithModifiers ( ) ; return ; } int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; char [ ] [ ] subset = identifierSubSet ( index + <NUM_LIT:1> ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; this . intPtr -- ; this . intPtr -- ; ImportReference reference = createAssistPackageReference ( subset , positions ) ; if ( ( length = this . expressionLengthStack [ this . expressionLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . expressionStack , ( this . expressionPtr -= length ) + <NUM_LIT:1> , reference . annotations = new Annotation [ length ] , <NUM_LIT:0> , length ) ; } this . assistNode = reference ; this . lastCheckPoint = reference . sourceEnd + <NUM_LIT:1> ; this . compilationUnit . currentPackage = reference ; if ( this . currentToken == TokenNameSEMICOLON ) { reference . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { reference . declarationSourceEnd = ( int ) positions [ length - <NUM_LIT:1> ] ; } reference . declarationSourceStart = this . intStack [ this . intPtr -- ] ; reference . declarationSourceEnd = flushCommentsDefinedPriorTo ( reference . declarationSourceEnd ) ; if ( this . currentElement != null ) { this . lastCheckPoint = reference . declarationSourceEnd + <NUM_LIT:1> ; this . restartRecovery = true ; } } protected void consumeRestoreDiet ( ) { super . consumeRestoreDiet ( ) ; if ( ! isInsideMethod ( ) ) { popElement ( K_FIELD_INITIALIZER_DELIMITER ) ; } } protected void consumeSingleStaticImportDeclarationName ( ) { int index ; if ( ( index = indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . consumeSingleStaticImportDeclarationName ( ) ; return ; } int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; char [ ] [ ] subset = identifierSubSet ( index + <NUM_LIT:1> ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; ImportReference reference = createAssistImportReference ( subset , positions , ClassFileConstants . AccStatic ) ; this . assistNode = reference ; this . lastCheckPoint = reference . sourceEnd + <NUM_LIT:1> ; pushOnAstStack ( reference ) ; if ( this . currentToken == TokenNameSEMICOLON ) { reference . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { reference . declarationSourceEnd = ( int ) positions [ length - <NUM_LIT:1> ] ; } reference . declarationSourceStart = this . intStack [ this . intPtr -- ] ; reference . declarationSourceEnd = flushCommentsDefinedPriorTo ( reference . declarationSourceEnd ) ; if ( this . currentElement != null ) { this . lastCheckPoint = reference . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( reference , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } } protected void consumeSingleTypeImportDeclarationName ( ) { int index ; if ( ( index = indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . consumeSingleTypeImportDeclarationName ( ) ; return ; } int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; char [ ] [ ] subset = identifierSubSet ( index + <NUM_LIT:1> ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; ImportReference reference = createAssistImportReference ( subset , positions , ClassFileConstants . AccDefault ) ; this . assistNode = reference ; this . lastCheckPoint = reference . sourceEnd + <NUM_LIT:1> ; pushOnAstStack ( reference ) ; if ( this . currentToken == TokenNameSEMICOLON ) { reference . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { reference . declarationSourceEnd = ( int ) positions [ length - <NUM_LIT:1> ] ; } reference . declarationSourceStart = this . intStack [ this . intPtr -- ] ; reference . declarationSourceEnd = flushCommentsDefinedPriorTo ( reference . declarationSourceEnd ) ; if ( this . currentElement != null ) { this . lastCheckPoint = reference . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( reference , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } } protected void consumeStaticImportOnDemandDeclarationName ( ) { int index ; if ( ( index = indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . consumeStaticImportOnDemandDeclarationName ( ) ; return ; } int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; char [ ] [ ] subset = identifierSubSet ( index + <NUM_LIT:1> ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; ImportReference reference = createAssistImportReference ( subset , positions , ClassFileConstants . AccStatic ) ; reference . bits |= ASTNode . OnDemand ; reference . trailingStarPosition = this . intStack [ this . intPtr -- ] ; this . assistNode = reference ; this . lastCheckPoint = reference . sourceEnd + <NUM_LIT:1> ; pushOnAstStack ( reference ) ; if ( this . currentToken == TokenNameSEMICOLON ) { reference . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { reference . declarationSourceEnd = ( int ) positions [ length - <NUM_LIT:1> ] ; } reference . declarationSourceStart = this . intStack [ this . intPtr -- ] ; reference . declarationSourceEnd = flushCommentsDefinedPriorTo ( reference . declarationSourceEnd ) ; if ( this . currentElement != null ) { this . lastCheckPoint = reference . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( reference , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } } protected void consumeStaticInitializer ( ) { super . consumeStaticInitializer ( ) ; popElement ( K_METHOD_DELIMITER ) ; } protected void consumeStaticOnly ( ) { super . consumeStaticOnly ( ) ; pushOnElementStack ( K_METHOD_DELIMITER ) ; } protected void consumeToken ( int token ) { super . consumeToken ( token ) ; if ( this . isFirst ) { this . isFirst = false ; return ; } if ( isInsideMethod ( ) || isInsideFieldInitialization ( ) || isInsideAttributeValue ( ) ) { switch ( token ) { case TokenNameLPAREN : this . bracketDepth ++ ; switch ( this . previousToken ) { case TokenNameIdentifier : this . pushOnElementStack ( K_SELECTOR , this . identifierPtr ) ; break ; case TokenNamethis : this . pushOnElementStack ( K_SELECTOR , THIS_CONSTRUCTOR ) ; break ; case TokenNamesuper : this . pushOnElementStack ( K_SELECTOR , SUPER_CONSTRUCTOR ) ; break ; case TokenNameGREATER : case TokenNameRIGHT_SHIFT : case TokenNameUNSIGNED_RIGHT_SHIFT : if ( this . identifierPtr > - <NUM_LIT:1> ) { this . pushOnElementStack ( K_SELECTOR , this . identifierPtr ) ; } break ; } break ; case TokenNameLBRACE : this . bracketDepth ++ ; break ; case TokenNameLBRACKET : this . bracketDepth ++ ; break ; case TokenNameRBRACE : this . bracketDepth -- ; break ; case TokenNameRBRACKET : this . bracketDepth -- ; break ; case TokenNameRPAREN : this . bracketDepth -- ; break ; } } else { switch ( token ) { case TokenNameRBRACE : if ( topKnownElementKind ( ASSIST_PARSER ) == K_TYPE_DELIMITER ) { popElement ( K_TYPE_DELIMITER ) ; } break ; } } this . previousToken = token ; if ( token == TokenNameIdentifier ) { this . previousIdentifierPtr = this . identifierPtr ; } } protected void consumeTypeImportOnDemandDeclarationName ( ) { int index ; if ( ( index = indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { super . consumeTypeImportOnDemandDeclarationName ( ) ; return ; } int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; char [ ] [ ] subset = identifierSubSet ( index + <NUM_LIT:1> ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; ImportReference reference = createAssistImportReference ( subset , positions , ClassFileConstants . AccDefault ) ; reference . bits |= ASTNode . OnDemand ; reference . trailingStarPosition = this . intStack [ this . intPtr -- ] ; this . assistNode = reference ; this . lastCheckPoint = reference . sourceEnd + <NUM_LIT:1> ; pushOnAstStack ( reference ) ; if ( this . currentToken == TokenNameSEMICOLON ) { reference . declarationSourceEnd = this . scanner . currentPosition - <NUM_LIT:1> ; } else { reference . declarationSourceEnd = ( int ) positions [ length - <NUM_LIT:1> ] ; } reference . declarationSourceStart = this . intStack [ this . intPtr -- ] ; reference . declarationSourceEnd = flushCommentsDefinedPriorTo ( reference . declarationSourceEnd ) ; if ( this . currentElement != null ) { this . lastCheckPoint = reference . declarationSourceEnd + <NUM_LIT:1> ; this . currentElement = this . currentElement . add ( reference , <NUM_LIT:0> ) ; this . lastIgnoredToken = - <NUM_LIT:1> ; this . restartRecovery = true ; } } public abstract ImportReference createAssistImportReference ( char [ ] [ ] tokens , long [ ] positions , int mod ) ; public abstract ImportReference createAssistPackageReference ( char [ ] [ ] tokens , long [ ] positions ) ; public abstract NameReference createQualifiedAssistNameReference ( char [ ] [ ] previousIdentifiers , char [ ] assistName , long [ ] positions ) ; public abstract TypeReference createQualifiedAssistTypeReference ( char [ ] [ ] previousIdentifiers , char [ ] assistName , long [ ] positions ) ; public abstract TypeReference createParameterizedQualifiedAssistTypeReference ( char [ ] [ ] previousIdentifiers , TypeReference [ ] [ ] typeArguments , char [ ] asistIdentifier , TypeReference [ ] assistTypeArguments , long [ ] positions ) ; public abstract NameReference createSingleAssistNameReference ( char [ ] assistName , long position ) ; public abstract TypeReference createSingleAssistTypeReference ( char [ ] assistName , long position ) ; public abstract TypeReference createParameterizedSingleAssistTypeReference ( TypeReference [ ] typeArguments , char [ ] assistName , long position ) ; public void flushAssistState ( ) { this . assistNode = null ; this . isOrphanCompletionNode = false ; setAssistIdentifier ( null ) ; } protected void flushElementStack ( ) { for ( int j = <NUM_LIT:0> ; j <= this . elementPtr ; j ++ ) { this . elementObjectInfoStack [ j ] = null ; } this . elementPtr = - <NUM_LIT:1> ; this . previousKind = <NUM_LIT:0> ; this . previousInfo = <NUM_LIT:0> ; this . previousObjectInfo = null ; } protected TypeReference getTypeReference ( int dim ) { int index ; if ( ( index = indexOfAssistIdentifier ( true ) ) < <NUM_LIT:0> ) { return super . getTypeReference ( dim ) ; } int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; TypeReference reference ; int numberOfIdentifiers = this . genericsIdentifiersLengthStack [ this . genericsIdentifiersLengthPtr -- ] ; if ( length != numberOfIdentifiers || this . genericsLengthStack [ this . genericsLengthPtr ] != <NUM_LIT:0> ) { this . identifierLengthPtr -- ; reference = getAssistTypeReferenceForGenericType ( dim , length , numberOfIdentifiers ) ; } else { char [ ] [ ] subset = identifierSubSet ( index ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; if ( index == <NUM_LIT:0> ) { this . genericsLengthPtr -- ; reference = createSingleAssistTypeReference ( assistIdentifier ( ) , positions [ <NUM_LIT:0> ] ) ; } else { this . genericsLengthPtr -- ; reference = createQualifiedAssistTypeReference ( subset , assistIdentifier ( ) , positions ) ; } this . assistNode = reference ; this . lastCheckPoint = reference . sourceEnd + <NUM_LIT:1> ; } return reference ; } protected TypeReference getAssistTypeReferenceForGenericType ( int dim , int identifierLength , int numberOfIdentifiers ) { if ( ( identifierLength == <NUM_LIT:1> && numberOfIdentifiers == <NUM_LIT:1> ) ) { int currentTypeArgumentsLength = this . genericsLengthStack [ this . genericsLengthPtr -- ] ; TypeReference [ ] typeArguments ; if ( currentTypeArgumentsLength > - <NUM_LIT:1> ) { typeArguments = new TypeReference [ currentTypeArgumentsLength ] ; this . genericsPtr -= currentTypeArgumentsLength ; System . arraycopy ( this . genericsStack , this . genericsPtr + <NUM_LIT:1> , typeArguments , <NUM_LIT:0> , currentTypeArgumentsLength ) ; } else { typeArguments = TypeReference . NO_TYPE_ARGUMENTS ; } long [ ] positions = new long [ identifierLength ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr , positions , <NUM_LIT:0> , identifierLength ) ; this . identifierPtr -- ; TypeReference reference = createParameterizedSingleAssistTypeReference ( typeArguments , assistIdentifier ( ) , positions [ <NUM_LIT:0> ] ) ; this . assistNode = reference ; this . lastCheckPoint = reference . sourceEnd + <NUM_LIT:1> ; return reference ; } TypeReference [ ] [ ] typeArguments = new TypeReference [ numberOfIdentifiers ] [ ] ; char [ ] [ ] tokens = new char [ numberOfIdentifiers ] [ ] ; long [ ] positions = new long [ numberOfIdentifiers ] ; int index = numberOfIdentifiers ; int currentIdentifiersLength = identifierLength ; while ( index > <NUM_LIT:0> ) { int currentTypeArgumentsLength = this . genericsLengthStack [ this . genericsLengthPtr -- ] ; if ( currentTypeArgumentsLength > <NUM_LIT:0> ) { this . genericsPtr -= currentTypeArgumentsLength ; System . arraycopy ( this . genericsStack , this . genericsPtr + <NUM_LIT:1> , typeArguments [ index - <NUM_LIT:1> ] = new TypeReference [ currentTypeArgumentsLength ] , <NUM_LIT:0> , currentTypeArgumentsLength ) ; } switch ( currentIdentifiersLength ) { case <NUM_LIT:1> : tokens [ index - <NUM_LIT:1> ] = this . identifierStack [ this . identifierPtr ] ; positions [ index - <NUM_LIT:1> ] = this . identifierPositionStack [ this . identifierPtr -- ] ; break ; default : this . identifierPtr -= currentIdentifiersLength ; System . arraycopy ( this . identifierStack , this . identifierPtr + <NUM_LIT:1> , tokens , index - currentIdentifiersLength , currentIdentifiersLength ) ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , index - currentIdentifiersLength , currentIdentifiersLength ) ; } index -= currentIdentifiersLength ; if ( index > <NUM_LIT:0> ) { currentIdentifiersLength = this . identifierLengthStack [ this . identifierLengthPtr -- ] ; } } int realLength = numberOfIdentifiers ; for ( int i = <NUM_LIT:0> ; i < numberOfIdentifiers ; i ++ ) { if ( tokens [ i ] == assistIdentifier ( ) ) { realLength = i ; } } TypeReference reference ; if ( realLength == <NUM_LIT:0> ) { if ( typeArguments [ <NUM_LIT:0> ] != null && typeArguments [ <NUM_LIT:0> ] . length > <NUM_LIT:0> ) { reference = createParameterizedSingleAssistTypeReference ( typeArguments [ <NUM_LIT:0> ] , assistIdentifier ( ) , positions [ <NUM_LIT:0> ] ) ; } else { reference = createSingleAssistTypeReference ( assistIdentifier ( ) , positions [ <NUM_LIT:0> ] ) ; } } else { TypeReference [ ] assistTypeArguments = typeArguments [ realLength ] ; System . arraycopy ( tokens , <NUM_LIT:0> , tokens = new char [ realLength ] [ ] , <NUM_LIT:0> , realLength ) ; System . arraycopy ( typeArguments , <NUM_LIT:0> , typeArguments = new TypeReference [ realLength ] [ ] , <NUM_LIT:0> , realLength ) ; boolean isParameterized = false ; for ( int i = <NUM_LIT:0> ; i < typeArguments . length ; i ++ ) { if ( typeArguments [ i ] != null ) { isParameterized = true ; } } if ( isParameterized || ( assistTypeArguments != null && assistTypeArguments . length > <NUM_LIT:0> ) ) { reference = createParameterizedQualifiedAssistTypeReference ( tokens , typeArguments , assistIdentifier ( ) , assistTypeArguments , positions ) ; } else { reference = createQualifiedAssistTypeReference ( tokens , assistIdentifier ( ) , positions ) ; } } this . assistNode = reference ; this . lastCheckPoint = reference . sourceEnd + <NUM_LIT:1> ; return reference ; } protected NameReference getUnspecifiedReferenceOptimized ( ) { int completionIndex ; if ( ( completionIndex = indexOfAssistIdentifier ( ) ) < <NUM_LIT:0> ) { return super . getUnspecifiedReferenceOptimized ( ) ; } int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; char [ ] [ ] subset = identifierSubSet ( completionIndex ) ; this . identifierLengthPtr -- ; this . identifierPtr -= length ; long [ ] positions = new long [ length ] ; System . arraycopy ( this . identifierPositionStack , this . identifierPtr + <NUM_LIT:1> , positions , <NUM_LIT:0> , length ) ; NameReference reference ; if ( completionIndex == <NUM_LIT:0> ) { reference = createSingleAssistNameReference ( assistIdentifier ( ) , positions [ <NUM_LIT:0> ] ) ; } else { reference = createQualifiedAssistNameReference ( subset , assistIdentifier ( ) , positions ) ; } reference . bits &= ~ ASTNode . RestrictiveFlagMASK ; reference . bits |= Binding . LOCAL | Binding . FIELD ; this . assistNode = reference ; this . lastCheckPoint = reference . sourceEnd + <NUM_LIT:1> ; return reference ; } public void goForBlockStatementsopt ( ) { super . goForBlockStatementsopt ( ) ; this . isFirst = true ; } public void goForHeaders ( ) { super . goForHeaders ( ) ; this . isFirst = true ; } public void goForCompilationUnit ( ) { super . goForCompilationUnit ( ) ; this . isFirst = true ; } public void goForBlockStatementsOrCatchHeader ( ) { super . goForBlockStatementsOrCatchHeader ( ) ; this . isFirst = true ; } protected char [ ] [ ] identifierSubSet ( int subsetLength ) { if ( subsetLength == <NUM_LIT:0> ) return null ; char [ ] [ ] subset ; System . arraycopy ( this . identifierStack , this . identifierPtr - this . identifierLengthStack [ this . identifierLengthPtr ] + <NUM_LIT:1> , ( subset = new char [ subsetLength ] [ ] ) , <NUM_LIT:0> , subsetLength ) ; return subset ; } protected int indexOfAssistIdentifier ( ) { return this . indexOfAssistIdentifier ( false ) ; } protected int indexOfAssistIdentifier ( boolean useGenericsStack ) { if ( this . identifierLengthPtr < <NUM_LIT:0> ) { return - <NUM_LIT:1> ; } char [ ] assistIdentifier ; if ( ( assistIdentifier = assistIdentifier ( ) ) == null ) { return - <NUM_LIT:1> ; } int length = this . identifierLengthStack [ this . identifierLengthPtr ] ; if ( useGenericsStack && length > <NUM_LIT:0> && this . genericsIdentifiersLengthPtr > - <NUM_LIT:1> ) { length = this . genericsIdentifiersLengthStack [ this . genericsIdentifiersLengthPtr ] ; } for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( this . identifierStack [ this . identifierPtr - i ] == assistIdentifier ) { return length - i - <NUM_LIT:1> ; } } return - <NUM_LIT:1> ; } public void initialize ( ) { super . initialize ( ) ; flushAssistState ( ) ; flushElementStack ( ) ; this . previousIdentifierPtr = - <NUM_LIT:1> ; this . bracketDepth = <NUM_LIT:0> ; } public void initialize ( boolean initializeNLS ) { super . initialize ( initializeNLS ) ; flushAssistState ( ) ; flushElementStack ( ) ; this . previousIdentifierPtr = - <NUM_LIT:1> ; this . bracketDepth = <NUM_LIT:0> ; } public abstract void initializeScanner ( ) ; protected boolean isIndirectlyInsideFieldInitialization ( ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { if ( this . elementKindStack [ i ] == K_FIELD_INITIALIZER_DELIMITER ) return true ; i -- ; } return false ; } protected boolean isIndirectlyInsideMethod ( ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { if ( this . elementKindStack [ i ] == K_METHOD_DELIMITER ) return true ; i -- ; } return false ; } protected boolean isIndirectlyInsideType ( ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { if ( this . elementKindStack [ i ] == K_TYPE_DELIMITER ) return true ; i -- ; } return false ; } protected boolean isInsideAttributeValue ( ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { switch ( this . elementKindStack [ i ] ) { case K_TYPE_DELIMITER : return false ; case K_METHOD_DELIMITER : return false ; case K_FIELD_INITIALIZER_DELIMITER : return false ; case K_ATTRIBUTE_VALUE_DELIMITER : return true ; } i -- ; } return false ; } protected boolean isInsideFieldInitialization ( ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { switch ( this . elementKindStack [ i ] ) { case K_TYPE_DELIMITER : return false ; case K_METHOD_DELIMITER : return false ; case K_FIELD_INITIALIZER_DELIMITER : return true ; } i -- ; } return false ; } protected boolean isInsideMethod ( ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { switch ( this . elementKindStack [ i ] ) { case K_TYPE_DELIMITER : return false ; case K_METHOD_DELIMITER : return true ; case K_FIELD_INITIALIZER_DELIMITER : return false ; } i -- ; } return false ; } protected boolean isInsideType ( ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { switch ( this . elementKindStack [ i ] ) { case K_TYPE_DELIMITER : return true ; case K_METHOD_DELIMITER : return false ; case K_FIELD_INITIALIZER_DELIMITER : return false ; } i -- ; } return false ; } protected int lastIndexOfElement ( int kind ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { if ( this . elementKindStack [ i ] == kind ) return i ; i -- ; } return - <NUM_LIT:1> ; } public void parseBlockStatements ( AbstractMethodDeclaration md , CompilationUnitDeclaration unit ) { if ( md instanceof MethodDeclaration ) { parseBlockStatements ( ( MethodDeclaration ) md , unit ) ; } else if ( md instanceof ConstructorDeclaration ) { parseBlockStatements ( ( ConstructorDeclaration ) md , unit ) ; } } public void parseBlockStatements ( ConstructorDeclaration cd , CompilationUnitDeclaration unit ) { initialize ( ) ; this . lastModifiers = cd . modifiers ; this . lastModifiersStart = cd . modifiersSourceStart ; goForBlockStatementsopt ( ) ; this . referenceContext = cd ; this . compilationUnit = unit ; this . scanner . resetTo ( cd . bodyStart , bodyEnd ( cd ) ) ; consumeNestedMethod ( ) ; try { parse ( ) ; } catch ( AbortCompilation ex ) { this . lastAct = ERROR_ACTION ; } if ( this . lastAct == ERROR_ACTION ) { cd . bits |= ASTNode . HasSyntaxErrors ; return ; } cd . explicitDeclarations = this . realBlockStack [ this . realBlockPtr -- ] ; int length ; if ( ( length = this . astLengthStack [ this . astLengthPtr -- ] ) != <NUM_LIT:0> ) { this . astPtr -= length ; if ( this . astStack [ this . astPtr + <NUM_LIT:1> ] instanceof ExplicitConstructorCall ) { System . arraycopy ( this . astStack , this . astPtr + <NUM_LIT:2> , cd . statements = new Statement [ length - <NUM_LIT:1> ] , <NUM_LIT:0> , length - <NUM_LIT:1> ) ; cd . constructorCall = ( ExplicitConstructorCall ) this . astStack [ this . astPtr + <NUM_LIT:1> ] ; } else { System . arraycopy ( this . astStack , this . astPtr + <NUM_LIT:1> , cd . statements = new Statement [ length ] , <NUM_LIT:0> , length ) ; cd . constructorCall = SuperReference . implicitSuperConstructorCall ( ) ; } } else { cd . constructorCall = SuperReference . implicitSuperConstructorCall ( ) ; if ( ! containsComment ( cd . bodyStart , cd . bodyEnd ) ) { cd . bits |= ASTNode . UndocumentedEmptyBlock ; } } if ( cd . constructorCall . sourceEnd == <NUM_LIT:0> ) { cd . constructorCall . sourceEnd = cd . sourceEnd ; cd . constructorCall . sourceStart = cd . sourceStart ; } } public void parseBlockStatements ( Initializer initializer , TypeDeclaration type , CompilationUnitDeclaration unit ) { initialize ( ) ; this . lastModifiers = initializer . modifiers ; this . lastModifiersStart = initializer . modifiersSourceStart ; goForBlockStatementsopt ( ) ; this . referenceContext = type ; this . compilationUnit = unit ; this . scanner . resetTo ( initializer . sourceStart , bodyEnd ( initializer ) ) ; consumeNestedMethod ( ) ; try { parse ( ) ; } catch ( AbortCompilation ex ) { this . lastAct = ERROR_ACTION ; } finally { this . nestedMethod [ this . nestedType ] -- ; } if ( this . lastAct == ERROR_ACTION ) { initializer . bits |= ASTNode . HasSyntaxErrors ; return ; } initializer . block . explicitDeclarations = this . realBlockStack [ this . realBlockPtr -- ] ; int length ; if ( ( length = this . astLengthStack [ this . astLengthPtr -- ] ) > <NUM_LIT:0> ) { System . arraycopy ( this . astStack , ( this . astPtr -= length ) + <NUM_LIT:1> , initializer . block . statements = new Statement [ length ] , <NUM_LIT:0> , length ) ; } else { if ( ! containsComment ( initializer . block . sourceStart , initializer . block . sourceEnd ) ) { initializer . block . bits |= ASTNode . UndocumentedEmptyBlock ; } } if ( ( type . bits & ASTNode . HasLocalType ) != <NUM_LIT:0> ) { initializer . bits |= ASTNode . HasLocalType ; } } public void parseBlockStatements ( MethodDeclaration md , CompilationUnitDeclaration unit ) { if ( md . isAbstract ( ) ) return ; if ( md . isNative ( ) ) return ; if ( ( md . modifiers & ExtraCompilerModifiers . AccSemicolonBody ) != <NUM_LIT:0> ) return ; initialize ( ) ; this . lastModifiers = md . modifiers ; this . lastModifiersStart = md . modifiersSourceStart ; goForBlockStatementsopt ( ) ; this . referenceContext = md ; this . compilationUnit = unit ; this . scanner . resetTo ( md . bodyStart , bodyEnd ( md ) ) ; consumeNestedMethod ( ) ; try { parse ( ) ; } catch ( AbortCompilation ex ) { this . lastAct = ERROR_ACTION ; } finally { this . nestedMethod [ this . nestedType ] -- ; } if ( this . lastAct == ERROR_ACTION ) { md . bits |= ASTNode . HasSyntaxErrors ; return ; } md . explicitDeclarations = this . realBlockStack [ this . realBlockPtr -- ] ; int length ; if ( ( length = this . astLengthStack [ this . astLengthPtr -- ] ) != <NUM_LIT:0> ) { System . arraycopy ( this . astStack , ( this . astPtr -= length ) + <NUM_LIT:1> , md . statements = new Statement [ length ] , <NUM_LIT:0> , length ) ; } else { if ( ! containsComment ( md . bodyStart , md . bodyEnd ) ) { md . bits |= ASTNode . UndocumentedEmptyBlock ; } } } protected void popElement ( int kind ) { if ( this . elementPtr < <NUM_LIT:0> || this . elementKindStack [ this . elementPtr ] != kind ) return ; this . previousKind = this . elementKindStack [ this . elementPtr ] ; this . previousInfo = this . elementInfoStack [ this . elementPtr ] ; this . previousObjectInfo = this . elementObjectInfoStack [ this . elementPtr ] ; this . elementObjectInfoStack [ this . elementPtr ] = null ; switch ( kind ) { default : this . elementPtr -- ; break ; } } protected void popUntilElement ( int kind ) { if ( this . elementPtr < <NUM_LIT:0> ) return ; int i = this . elementPtr ; while ( i >= <NUM_LIT:0> && this . elementKindStack [ i ] != kind ) { i -- ; } if ( i >= <NUM_LIT:0> ) { if ( i < this . elementPtr ) { this . previousKind = this . elementKindStack [ i + <NUM_LIT:1> ] ; this . previousInfo = this . elementInfoStack [ i + <NUM_LIT:1> ] ; this . previousObjectInfo = this . elementObjectInfoStack [ i + <NUM_LIT:1> ] ; for ( int j = i + <NUM_LIT:1> ; j <= this . elementPtr ; j ++ ) { this . elementObjectInfoStack [ j ] = null ; } } this . elementPtr = i ; } } protected void prepareForBlockStatements ( ) { this . nestedMethod [ this . nestedType = <NUM_LIT:0> ] = <NUM_LIT:1> ; this . variablesCounter [ this . nestedType ] = <NUM_LIT:0> ; this . realBlockStack [ this . realBlockPtr = <NUM_LIT:1> ] = <NUM_LIT:0> ; int fieldInitializerIndex = lastIndexOfElement ( K_FIELD_INITIALIZER_DELIMITER ) ; int methodIndex = lastIndexOfElement ( K_METHOD_DELIMITER ) ; if ( methodIndex == fieldInitializerIndex ) { flushElementStack ( ) ; } else if ( methodIndex > fieldInitializerIndex ) { popUntilElement ( K_METHOD_DELIMITER ) ; } else { popUntilElement ( K_FIELD_INITIALIZER_DELIMITER ) ; } } protected void prepareForHeaders ( ) { this . nestedMethod [ this . nestedType = <NUM_LIT:0> ] = <NUM_LIT:0> ; this . variablesCounter [ this . nestedType ] = <NUM_LIT:0> ; this . realBlockStack [ this . realBlockPtr = <NUM_LIT:0> ] = <NUM_LIT:0> ; popUntilElement ( K_TYPE_DELIMITER ) ; if ( this . topKnownElementKind ( ASSIST_PARSER ) != K_TYPE_DELIMITER ) { flushElementStack ( ) ; } } protected void pushOnElementStack ( int kind ) { this . pushOnElementStack ( kind , <NUM_LIT:0> , null ) ; } protected void pushOnElementStack ( int kind , int info ) { this . pushOnElementStack ( kind , info , null ) ; } protected void pushOnElementStack ( int kind , int info , Object objectInfo ) { if ( this . elementPtr < - <NUM_LIT:1> ) return ; this . previousKind = <NUM_LIT:0> ; this . previousInfo = <NUM_LIT:0> ; this . previousObjectInfo = null ; int stackLength = this . elementKindStack . length ; if ( ++ this . elementPtr >= stackLength ) { System . arraycopy ( this . elementKindStack , <NUM_LIT:0> , this . elementKindStack = new int [ stackLength + StackIncrement ] , <NUM_LIT:0> , stackLength ) ; System . arraycopy ( this . elementInfoStack , <NUM_LIT:0> , this . elementInfoStack = new int [ stackLength + StackIncrement ] , <NUM_LIT:0> , stackLength ) ; System . arraycopy ( this . elementObjectInfoStack , <NUM_LIT:0> , this . elementObjectInfoStack = new Object [ stackLength + StackIncrement ] , <NUM_LIT:0> , stackLength ) ; } this . elementKindStack [ this . elementPtr ] = kind ; this . elementInfoStack [ this . elementPtr ] = info ; this . elementObjectInfoStack [ this . elementPtr ] = objectInfo ; } public void recoveryExitFromVariable ( ) { if ( this . currentElement != null && this . currentElement instanceof RecoveredField && ! ( this . currentElement instanceof RecoveredInitializer ) ) { RecoveredElement oldElement = this . currentElement ; super . recoveryExitFromVariable ( ) ; if ( oldElement != this . currentElement ) { popElement ( K_FIELD_INITIALIZER_DELIMITER ) ; } } else { super . recoveryExitFromVariable ( ) ; } } public void recoveryTokenCheck ( ) { RecoveredElement oldElement = this . currentElement ; switch ( this . currentToken ) { case TokenNameLBRACE : super . recoveryTokenCheck ( ) ; if ( this . currentElement instanceof RecoveredInitializer ) { if ( oldElement instanceof RecoveredField ) { popUntilElement ( K_FIELD_INITIALIZER_DELIMITER ) ; popElement ( K_FIELD_INITIALIZER_DELIMITER ) ; } if ( this . currentElement != oldElement && topKnownElementKind ( ASSIST_PARSER ) != K_METHOD_DELIMITER ) { pushOnElementStack ( K_METHOD_DELIMITER ) ; } } break ; case TokenNameRBRACE : super . recoveryTokenCheck ( ) ; if ( this . currentElement != oldElement && ! isInsideAttributeValue ( ) ) { if ( oldElement instanceof RecoveredInitializer || oldElement instanceof RecoveredMethod || ( oldElement instanceof RecoveredBlock && oldElement . parent instanceof RecoveredInitializer ) || ( oldElement instanceof RecoveredBlock && oldElement . parent instanceof RecoveredMethod ) ) { popUntilElement ( K_METHOD_DELIMITER ) ; popElement ( K_METHOD_DELIMITER ) ; } else if ( oldElement instanceof RecoveredType ) { popUntilElement ( K_TYPE_DELIMITER ) ; if ( ! ( this . referenceContext instanceof CompilationUnitDeclaration ) || isIndirectlyInsideFieldInitialization ( ) || this . currentElement instanceof RecoveredUnit ) { popElement ( K_TYPE_DELIMITER ) ; } } } break ; default : super . recoveryTokenCheck ( ) ; break ; } } public void reset ( ) { flushAssistState ( ) ; } protected boolean resumeAfterRecovery ( ) { this . astPtr = - <NUM_LIT:1> ; this . astLengthPtr = - <NUM_LIT:1> ; this . expressionPtr = - <NUM_LIT:1> ; this . expressionLengthPtr = - <NUM_LIT:1> ; this . identifierPtr = - <NUM_LIT:1> ; this . identifierLengthPtr = - <NUM_LIT:1> ; this . intPtr = - <NUM_LIT:1> ; this . dimensions = <NUM_LIT:0> ; this . recoveredStaticInitializerStart = <NUM_LIT:0> ; this . genericsIdentifiersLengthPtr = - <NUM_LIT:1> ; this . genericsLengthPtr = - <NUM_LIT:1> ; this . genericsPtr = - <NUM_LIT:1> ; this . modifiers = ClassFileConstants . AccDefault ; this . modifiersSourceStart = - <NUM_LIT:1> ; if ( this . diet ) this . dietInt = <NUM_LIT:0> ; if ( ! moveRecoveryCheckpoint ( ) ) return false ; if ( this . referenceContext instanceof CompilationUnitDeclaration || this . assistNode != null ) { if ( isInsideMethod ( ) && isIndirectlyInsideFieldInitialization ( ) && this . assistNode == null ) { prepareForBlockStatements ( ) ; goForBlockStatementsOrCatchHeader ( ) ; } else if ( ( isInsideArrayInitializer ( ) ) && isIndirectlyInsideFieldInitialization ( ) && this . assistNode == null ) { prepareForBlockStatements ( ) ; goForBlockStatementsopt ( ) ; } else { prepareForHeaders ( ) ; goForHeaders ( ) ; this . diet = true ; } return true ; } if ( this . referenceContext instanceof AbstractMethodDeclaration || this . referenceContext instanceof TypeDeclaration ) { if ( this . currentElement instanceof RecoveredType ) { prepareForHeaders ( ) ; goForHeaders ( ) ; } else { prepareForBlockStatements ( ) ; goForBlockStatementsOrCatchHeader ( ) ; } return true ; } return false ; } protected boolean isInsideArrayInitializer ( ) { return false ; } public abstract void setAssistIdentifier ( char [ ] assistIdent ) ; protected int topKnownElementInfo ( int owner ) { return topKnownElementInfo ( owner , <NUM_LIT:0> ) ; } protected int topKnownElementInfo ( int owner , int offSet ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { if ( ( this . elementKindStack [ i ] & owner ) != <NUM_LIT:0> ) { if ( offSet <= <NUM_LIT:0> ) return this . elementInfoStack [ i ] ; offSet -- ; } i -- ; } return <NUM_LIT:0> ; } protected int topKnownElementKind ( int owner ) { return topKnownElementKind ( owner , <NUM_LIT:0> ) ; } protected int topKnownElementKind ( int owner , int offSet ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { if ( ( this . elementKindStack [ i ] & owner ) != <NUM_LIT:0> ) { if ( offSet <= <NUM_LIT:0> ) return this . elementKindStack [ i ] ; offSet -- ; } i -- ; } return <NUM_LIT:0> ; } protected Object topKnownElementObjectInfo ( int owner , int offSet ) { int i = this . elementPtr ; while ( i > - <NUM_LIT:1> ) { if ( ( this . elementKindStack [ i ] & owner ) != <NUM_LIT:0> ) { if ( offSet <= <NUM_LIT:0> ) return this . elementObjectInfoStack [ i ] ; offSet -- ; } i -- ; } return null ; } protected Object topKnownElementObjectInfo ( int owner ) { return topKnownElementObjectInfo ( owner , <NUM_LIT:0> ) ; } protected ASTNode wrapWithExplicitConstructorCallIfNeeded ( ASTNode ast ) { int selector ; if ( ast != null && topKnownElementKind ( ASSIST_PARSER ) == K_SELECTOR && ast instanceof Expression && ( ( ( selector = topKnownElementInfo ( ASSIST_PARSER ) ) == THIS_CONSTRUCTOR ) || ( selector == SUPER_CONSTRUCTOR ) ) ) { ExplicitConstructorCall call = new ExplicitConstructorCall ( ( selector == THIS_CONSTRUCTOR ) ? ExplicitConstructorCall . This : ExplicitConstructorCall . Super ) ; call . arguments = new Expression [ ] { ( Expression ) ast } ; call . sourceStart = ast . sourceStart ; call . sourceEnd = ast . sourceEnd ; return call ; } else { return ast ; } } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; import java . util . Map ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . JavaElement ; import org . eclipse . jdt . internal . core . TypeParameter ; public class AssistTypeParameter extends TypeParameter { private Map infoCache ; public AssistTypeParameter ( JavaElement parent , String name , Map infoCache ) { super ( parent , name ) ; this . infoCache = infoCache ; } public Object getElementInfo ( IProgressMonitor monitor ) throws JavaModelException { return this . infoCache . get ( this ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; import java . util . Map ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IImportContainer ; import org . eclipse . jdt . core . IPackageDeclaration ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . internal . core . CompilationUnit ; import org . eclipse . jdt . internal . core . JavaElementInfo ; import org . eclipse . jdt . internal . core . PackageFragment ; public class AssistCompilationUnit extends CompilationUnit { private Map infoCache ; private Map bindingCache ; public AssistCompilationUnit ( ICompilationUnit compilationUnit , WorkingCopyOwner owner , Map bindingCache , Map infoCache ) { super ( ( PackageFragment ) compilationUnit . getParent ( ) , compilationUnit . getElementName ( ) , owner ) ; this . bindingCache = bindingCache ; this . infoCache = infoCache ; } public Object getElementInfo ( IProgressMonitor monitor ) throws JavaModelException { return this . infoCache . get ( this ) ; } public IImportContainer getImportContainer ( ) { return new AssistImportContainer ( this , this . infoCache ) ; } public IPackageDeclaration getPackageDeclaration ( String pkg ) { return new AssistPackageDeclaration ( this , pkg , this . infoCache ) ; } public IType getType ( String typeName ) { return new AssistSourceType ( this , typeName , this . bindingCache , this . infoCache ) ; } public boolean hasChildren ( ) throws JavaModelException { JavaElementInfo info = ( JavaElementInfo ) this . infoCache . get ( this ) ; return info . getChildren ( ) . length > <NUM_LIT:0> ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; import java . util . Map ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . ITypeParameter ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . core . JavaElement ; import org . eclipse . jdt . internal . core . ResolvedSourceMethod ; public class AssistSourceMethod extends ResolvedSourceMethod { private Map bindingCache ; private Map infoCache ; private String uniqueKey ; private boolean isResolved ; public AssistSourceMethod ( JavaElement parent , String name , String [ ] parameterTypes , Map bindingCache , Map infoCache ) { super ( parent , name , parameterTypes , null ) ; this . bindingCache = bindingCache ; this . infoCache = infoCache ; } public Object getElementInfo ( IProgressMonitor monitor ) throws JavaModelException { return this . infoCache . get ( this ) ; } public String getKey ( ) { if ( this . uniqueKey == null ) { Binding binding = ( Binding ) this . bindingCache . get ( this ) ; if ( binding != null ) { this . isResolved = true ; this . uniqueKey = new String ( binding . computeUniqueKey ( ) ) ; } else { this . isResolved = false ; try { this . uniqueKey = getKey ( this , false ) ; } catch ( JavaModelException e ) { return null ; } } } return this . uniqueKey ; } public boolean isResolved ( ) { getKey ( ) ; return this . isResolved ; } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { super . toStringInfo ( tab , buffer , info , showResolvedInfo && isResolved ( ) ) ; } public IAnnotation getAnnotation ( String annotationName ) { return new AssistAnnotation ( this , annotationName , this . infoCache ) ; } public IType getType ( String typeName , int count ) { AssistSourceType type = new AssistSourceType ( this , typeName , this . bindingCache , this . infoCache ) ; type . occurrenceCount = count ; return type ; } public ITypeParameter getTypeParameter ( String typeParameterName ) { return new AssistTypeParameter ( this , typeParameterName , this . infoCache ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; import java . util . Map ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . ImportContainer ; import org . eclipse . jdt . internal . core . ImportDeclaration ; public class AssistImportDeclaration extends ImportDeclaration { private Map infoCache ; public AssistImportDeclaration ( ImportContainer parent , String name , boolean isOnDemand , Map infoCache ) { super ( parent , name , isOnDemand ) ; this . infoCache = infoCache ; } public Object getElementInfo ( IProgressMonitor monitor ) throws JavaModelException { return this . infoCache . get ( this ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; import java . util . Map ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . IImportDeclaration ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . CompilationUnit ; import org . eclipse . jdt . internal . core . ImportContainer ; public class AssistImportContainer extends ImportContainer { private Map infoCache ; public AssistImportContainer ( CompilationUnit parent , Map infoCache ) { super ( parent ) ; this . infoCache = infoCache ; } public Object getElementInfo ( IProgressMonitor monitor ) throws JavaModelException { return this . infoCache . get ( this ) ; } protected IImportDeclaration getImport ( String importName , boolean isOnDemand ) { return new AssistImportDeclaration ( this , importName , isOnDemand , this . infoCache ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; import java . util . Map ; import org . eclipse . jdt . core . compiler . CharOperation ; public class AssistOptions { public static final String OPTION_PerformVisibilityCheck = "<STR_LIT>" ; public static final String OPTION_PerformDeprecationCheck = "<STR_LIT>" ; public static final String OPTION_ForceImplicitQualification = "<STR_LIT>" ; public static final String OPTION_FieldPrefixes = "<STR_LIT>" ; public static final String OPTION_StaticFieldPrefixes = "<STR_LIT>" ; public static final String OPTION_StaticFinalFieldPrefixes = "<STR_LIT>" ; public static final String OPTION_LocalPrefixes = "<STR_LIT>" ; public static final String OPTION_ArgumentPrefixes = "<STR_LIT>" ; public static final String OPTION_FieldSuffixes = "<STR_LIT>" ; public static final String OPTION_StaticFieldSuffixes = "<STR_LIT>" ; public static final String OPTION_StaticFinalFieldSuffixes = "<STR_LIT>" ; public static final String OPTION_LocalSuffixes = "<STR_LIT>" ; public static final String OPTION_ArgumentSuffixes = "<STR_LIT>" ; public static final String OPTION_PerformForbiddenReferenceCheck = "<STR_LIT>" ; public static final String OPTION_PerformDiscouragedReferenceCheck = "<STR_LIT>" ; public static final String OPTION_CamelCaseMatch = "<STR_LIT>" ; public static final String OPTION_SuggestStaticImports = "<STR_LIT>" ; public static final String ENABLED = "<STR_LIT>" ; public static final String DISABLED = "<STR_LIT>" ; public boolean checkVisibility = false ; public boolean checkDeprecation = false ; public boolean checkForbiddenReference = false ; public boolean checkDiscouragedReference = false ; public boolean forceImplicitQualification = false ; public boolean camelCaseMatch = true ; public boolean suggestStaticImport = true ; public char [ ] [ ] fieldPrefixes = null ; public char [ ] [ ] staticFieldPrefixes = null ; public char [ ] [ ] staticFinalFieldPrefixes = null ; public char [ ] [ ] localPrefixes = null ; public char [ ] [ ] argumentPrefixes = null ; public char [ ] [ ] fieldSuffixes = null ; public char [ ] [ ] staticFieldSuffixes = null ; public char [ ] [ ] staticFinalFieldSuffixes = null ; public char [ ] [ ] localSuffixes = null ; public char [ ] [ ] argumentSuffixes = null ; public AssistOptions ( ) { } public AssistOptions ( Map settings ) { if ( settings == null ) return ; set ( settings ) ; } public void set ( Map optionsMap ) { Object optionValue ; if ( ( optionValue = optionsMap . get ( OPTION_PerformVisibilityCheck ) ) != null ) { if ( ENABLED . equals ( optionValue ) ) { this . checkVisibility = true ; } else if ( DISABLED . equals ( optionValue ) ) { this . checkVisibility = false ; } } if ( ( optionValue = optionsMap . get ( OPTION_ForceImplicitQualification ) ) != null ) { if ( ENABLED . equals ( optionValue ) ) { this . forceImplicitQualification = true ; } else if ( DISABLED . equals ( optionValue ) ) { this . forceImplicitQualification = false ; } } if ( ( optionValue = optionsMap . get ( OPTION_FieldPrefixes ) ) != null ) { if ( optionValue instanceof String ) { String stringValue = ( String ) optionValue ; if ( stringValue . length ( ) > <NUM_LIT:0> ) { this . fieldPrefixes = splitAndTrimOn ( '<CHAR_LIT:U+002C>' , stringValue . toCharArray ( ) ) ; } else { this . fieldPrefixes = null ; } } } if ( ( optionValue = optionsMap . get ( OPTION_StaticFieldPrefixes ) ) != null ) { if ( optionValue instanceof String ) { String stringValue = ( String ) optionValue ; if ( stringValue . length ( ) > <NUM_LIT:0> ) { this . staticFieldPrefixes = splitAndTrimOn ( '<CHAR_LIT:U+002C>' , stringValue . toCharArray ( ) ) ; } else { this . staticFieldPrefixes = null ; } } } if ( ( optionValue = optionsMap . get ( OPTION_StaticFinalFieldPrefixes ) ) != null ) { if ( optionValue instanceof String ) { String stringValue = ( String ) optionValue ; if ( stringValue . length ( ) > <NUM_LIT:0> ) { this . staticFinalFieldPrefixes = splitAndTrimOn ( '<CHAR_LIT:U+002C>' , stringValue . toCharArray ( ) ) ; } else { this . staticFinalFieldPrefixes = null ; } } } if ( ( optionValue = optionsMap . get ( OPTION_LocalPrefixes ) ) != null ) { if ( optionValue instanceof String ) { String stringValue = ( String ) optionValue ; if ( stringValue . length ( ) > <NUM_LIT:0> ) { this . localPrefixes = splitAndTrimOn ( '<CHAR_LIT:U+002C>' , stringValue . toCharArray ( ) ) ; } else { this . localPrefixes = null ; } } } if ( ( optionValue = optionsMap . get ( OPTION_ArgumentPrefixes ) ) != null ) { if ( optionValue instanceof String ) { String stringValue = ( String ) optionValue ; if ( stringValue . length ( ) > <NUM_LIT:0> ) { this . argumentPrefixes = splitAndTrimOn ( '<CHAR_LIT:U+002C>' , stringValue . toCharArray ( ) ) ; } else { this . argumentPrefixes = null ; } } } if ( ( optionValue = optionsMap . get ( OPTION_FieldSuffixes ) ) != null ) { if ( optionValue instanceof String ) { String stringValue = ( String ) optionValue ; if ( stringValue . length ( ) > <NUM_LIT:0> ) { this . fieldSuffixes = splitAndTrimOn ( '<CHAR_LIT:U+002C>' , stringValue . toCharArray ( ) ) ; } else { this . fieldSuffixes = null ; } } } if ( ( optionValue = optionsMap . get ( OPTION_StaticFieldSuffixes ) ) != null ) { if ( optionValue instanceof String ) { String stringValue = ( String ) optionValue ; if ( stringValue . length ( ) > <NUM_LIT:0> ) { this . staticFieldSuffixes = splitAndTrimOn ( '<CHAR_LIT:U+002C>' , stringValue . toCharArray ( ) ) ; } else { this . staticFieldSuffixes = null ; } } } if ( ( optionValue = optionsMap . get ( OPTION_StaticFinalFieldSuffixes ) ) != null ) { if ( optionValue instanceof String ) { String stringValue = ( String ) optionValue ; if ( stringValue . length ( ) > <NUM_LIT:0> ) { this . staticFinalFieldSuffixes = splitAndTrimOn ( '<CHAR_LIT:U+002C>' , stringValue . toCharArray ( ) ) ; } else { this . staticFinalFieldSuffixes = null ; } } } if ( ( optionValue = optionsMap . get ( OPTION_LocalSuffixes ) ) != null ) { if ( optionValue instanceof String ) { String stringValue = ( String ) optionValue ; if ( stringValue . length ( ) > <NUM_LIT:0> ) { this . localSuffixes = splitAndTrimOn ( '<CHAR_LIT:U+002C>' , stringValue . toCharArray ( ) ) ; } else { this . localSuffixes = null ; } } } if ( ( optionValue = optionsMap . get ( OPTION_ArgumentSuffixes ) ) != null ) { if ( optionValue instanceof String ) { String stringValue = ( String ) optionValue ; if ( stringValue . length ( ) > <NUM_LIT:0> ) { this . argumentSuffixes = splitAndTrimOn ( '<CHAR_LIT:U+002C>' , stringValue . toCharArray ( ) ) ; } else { this . argumentSuffixes = null ; } } } if ( ( optionValue = optionsMap . get ( OPTION_PerformForbiddenReferenceCheck ) ) != null ) { if ( ENABLED . equals ( optionValue ) ) { this . checkForbiddenReference = true ; } else if ( DISABLED . equals ( optionValue ) ) { this . checkForbiddenReference = false ; } } if ( ( optionValue = optionsMap . get ( OPTION_PerformDiscouragedReferenceCheck ) ) != null ) { if ( ENABLED . equals ( optionValue ) ) { this . checkDiscouragedReference = true ; } else if ( DISABLED . equals ( optionValue ) ) { this . checkDiscouragedReference = false ; } } if ( ( optionValue = optionsMap . get ( OPTION_CamelCaseMatch ) ) != null ) { if ( ENABLED . equals ( optionValue ) ) { this . camelCaseMatch = true ; } else if ( DISABLED . equals ( optionValue ) ) { this . camelCaseMatch = false ; } } if ( ( optionValue = optionsMap . get ( OPTION_PerformDeprecationCheck ) ) != null ) { if ( ENABLED . equals ( optionValue ) ) { this . checkDeprecation = true ; } else if ( DISABLED . equals ( optionValue ) ) { this . checkDeprecation = false ; } } if ( ( optionValue = optionsMap . get ( OPTION_SuggestStaticImports ) ) != null ) { if ( ENABLED . equals ( optionValue ) ) { this . suggestStaticImport = true ; } else if ( DISABLED . equals ( optionValue ) ) { this . suggestStaticImport = false ; } } } private char [ ] [ ] splitAndTrimOn ( char divider , char [ ] arrayToSplit ) { char [ ] [ ] result = CharOperation . splitAndTrimOn ( '<CHAR_LIT:U+002C>' , arrayToSplit ) ; int length = result . length ; int resultCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( result [ i ] . length != <NUM_LIT:0> ) { result [ resultCount ++ ] = result [ i ] ; } } if ( resultCount != length ) { System . arraycopy ( result , <NUM_LIT:0> , result = new char [ resultCount ] [ ] , <NUM_LIT:0> , resultCount ) ; } return result ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; import java . util . Map ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . Initializer ; import org . eclipse . jdt . internal . core . JavaElement ; public class AssistInitializer extends Initializer { private Map bindingCache ; private Map infoCache ; public AssistInitializer ( JavaElement parent , int count , Map bindingCache , Map infoCache ) { super ( parent , count ) ; this . bindingCache = bindingCache ; this . infoCache = infoCache ; } public Object getElementInfo ( IProgressMonitor monitor ) throws JavaModelException { return this . infoCache . get ( this ) ; } public IType getType ( String typeName , int count ) { AssistSourceType type = new AssistSourceType ( this , typeName , this . bindingCache , this . infoCache ) ; type . occurrenceCount = count ; return type ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; import java . util . Map ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . IField ; import org . eclipse . jdt . core . IInitializer ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . ITypeParameter ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . core . JavaElement ; import org . eclipse . jdt . internal . core . ResolvedSourceType ; public class AssistSourceType extends ResolvedSourceType { private Map bindingCache ; private Map infoCache ; private String uniqueKey ; private boolean isResolved ; public AssistSourceType ( JavaElement parent , String name , Map bindingCache , Map infoCache ) { super ( parent , name , null ) ; this . bindingCache = bindingCache ; this . infoCache = infoCache ; } public Object getElementInfo ( IProgressMonitor monitor ) throws JavaModelException { return this . infoCache . get ( this ) ; } public String getFullyQualifiedParameterizedName ( ) throws JavaModelException { if ( isResolved ( ) ) { return getFullyQualifiedParameterizedName ( getFullyQualifiedName ( '<CHAR_LIT:.>' ) , this . getKey ( ) ) ; } return getFullyQualifiedName ( '<CHAR_LIT:.>' , true ) ; } public String getKey ( ) { if ( this . uniqueKey == null ) { Binding binding = ( Binding ) this . bindingCache . get ( this ) ; if ( binding != null ) { this . isResolved = true ; this . uniqueKey = new String ( binding . computeUniqueKey ( ) ) ; } else { this . isResolved = false ; try { this . uniqueKey = getKey ( this , false ) ; } catch ( JavaModelException e ) { return null ; } } } return this . uniqueKey ; } public boolean isResolved ( ) { getKey ( ) ; return this . isResolved ; } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { super . toStringInfo ( tab , buffer , info , showResolvedInfo && isResolved ( ) ) ; } public IAnnotation getAnnotation ( String annotationName ) { return new AssistAnnotation ( this , annotationName , this . infoCache ) ; } public IField getField ( String fieldName ) { return new AssistSourceField ( this , fieldName , this . bindingCache , this . infoCache ) ; } public IInitializer getInitializer ( int count ) { return new AssistInitializer ( this , count , this . bindingCache , this . infoCache ) ; } public IMethod getMethod ( String selector , String [ ] parameterTypeSignatures ) { return new AssistSourceMethod ( this , selector , parameterTypeSignatures , this . bindingCache , this . infoCache ) ; } public IType getType ( String typeName ) { return new AssistSourceType ( this , typeName , this . bindingCache , this . infoCache ) ; } public IType getType ( String typeName , int count ) { AssistSourceType type = new AssistSourceType ( this , typeName , this . bindingCache , this . infoCache ) ; type . occurrenceCount = count ; return type ; } public ITypeParameter getTypeParameter ( String typeParameterName ) { return new AssistTypeParameter ( this , typeParameterName , this . infoCache ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; import java . util . Map ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . core . JavaElement ; import org . eclipse . jdt . internal . core . ResolvedSourceField ; public class AssistSourceField extends ResolvedSourceField { private Map bindingCache ; private Map infoCache ; private String uniqueKey ; private boolean isResolved ; public AssistSourceField ( JavaElement parent , String name , Map bindingCache , Map infoCache ) { super ( parent , name , null ) ; this . bindingCache = bindingCache ; this . infoCache = infoCache ; } public Object getElementInfo ( IProgressMonitor monitor ) throws JavaModelException { return this . infoCache . get ( this ) ; } public String getKey ( ) { if ( this . uniqueKey == null ) { Binding binding = ( Binding ) this . bindingCache . get ( this ) ; if ( binding != null ) { this . isResolved = true ; this . uniqueKey = new String ( binding . computeUniqueKey ( ) ) ; } else { this . isResolved = false ; try { this . uniqueKey = getKey ( this , false ) ; } catch ( JavaModelException e ) { return null ; } } } return this . uniqueKey ; } public boolean isResolved ( ) { getKey ( ) ; return this . isResolved ; } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { super . toStringInfo ( tab , buffer , info , showResolvedInfo && isResolved ( ) ) ; } public IAnnotation getAnnotation ( String annotationName ) { return new AssistAnnotation ( this , annotationName , this . infoCache ) ; } public IType getType ( String typeName , int count ) { AssistSourceType type = new AssistSourceType ( this , typeName , this . bindingCache , this . infoCache ) ; type . occurrenceCount = count ; return type ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; import java . util . Map ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . Annotation ; import org . eclipse . jdt . internal . core . JavaElement ; public class AssistAnnotation extends Annotation { private Map infoCache ; public AssistAnnotation ( JavaElement parent , String name , Map infoCache ) { super ( parent , name ) ; this . infoCache = infoCache ; } public Object getElementInfo ( IProgressMonitor monitor ) throws JavaModelException { return this . infoCache . get ( this ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist . impl ; import java . util . Map ; import org . eclipse . jdt . core . compiler . CharOperation ; import 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 . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; import org . eclipse . jdt . internal . compiler . parser . * ; import org . eclipse . jdt . internal . compiler . problem . ProblemSeverities ; import org . eclipse . jdt . internal . compiler . impl . * ; import org . eclipse . jdt . internal . core . NameLookup ; import org . eclipse . jdt . internal . core . SearchableEnvironment ; public abstract class Engine implements ITypeRequestor { public LookupEnvironment lookupEnvironment ; protected CompilationUnitScope unitScope ; public SearchableEnvironment nameEnvironment ; public AssistOptions options ; public CompilerOptions compilerOptions ; public boolean forbiddenReferenceIsError ; public boolean discouragedReferenceIsError ; public boolean importCachesInitialized = false ; public char [ ] [ ] [ ] importsCache ; public ImportBinding [ ] onDemandImportsCache ; public int importCacheCount = <NUM_LIT:0> ; public int onDemandImportCacheCount = <NUM_LIT:0> ; public char [ ] currentPackageName = null ; public Engine ( Map settings ) { this . options = new AssistOptions ( settings ) ; this . compilerOptions = new CompilerOptions ( settings ) ; this . forbiddenReferenceIsError = ( this . compilerOptions . getSeverity ( CompilerOptions . ForbiddenReference ) & ProblemSeverities . Error ) != <NUM_LIT:0> ; this . discouragedReferenceIsError = ( this . compilerOptions . getSeverity ( CompilerOptions . DiscouragedReference ) & ProblemSeverities . Error ) != <NUM_LIT:0> ; } public void accept ( IBinaryType binaryType , PackageBinding packageBinding , AccessRestriction accessRestriction ) { this . lookupEnvironment . createBinaryTypeFrom ( binaryType , packageBinding , accessRestriction ) ; } public void accept ( ICompilationUnit sourceUnit , AccessRestriction accessRestriction ) { CompilationResult result = new CompilationResult ( sourceUnit , <NUM_LIT:1> , <NUM_LIT:1> , this . compilerOptions . maxProblemsPerUnit ) ; AssistParser assistParser = getParser ( ) ; Object parserState = assistParser . becomeSimpleParser ( ) ; CompilationUnitDeclaration parsedUnit = assistParser . dietParse ( sourceUnit , result ) ; assistParser . restoreAssistParser ( parserState ) ; this . lookupEnvironment . buildTypeBindings ( parsedUnit , accessRestriction ) ; this . lookupEnvironment . completeTypeBindings ( parsedUnit , true ) ; } public void accept ( ISourceType [ ] sourceTypes , PackageBinding packageBinding , AccessRestriction accessRestriction ) { CompilationResult result = new CompilationResult ( sourceTypes [ <NUM_LIT:0> ] . getFileName ( ) , <NUM_LIT:1> , <NUM_LIT:1> , this . compilerOptions . maxProblemsPerUnit ) ; CompilationUnitDeclaration unit = SourceTypeConverter . buildCompilationUnit ( sourceTypes , SourceTypeConverter . FIELD_AND_METHOD | SourceTypeConverter . MEMBER_TYPE , this . lookupEnvironment . problemReporter , result ) ; if ( unit != null ) { this . lookupEnvironment . buildTypeBindings ( unit , accessRestriction ) ; this . lookupEnvironment . completeTypeBindings ( unit , true ) ; } } public abstract AssistParser getParser ( ) ; public void initializeImportCaches ( ) { if ( this . currentPackageName == null ) { initializePackageCache ( ) ; } ImportBinding [ ] importBindings = this . unitScope . imports ; int length = importBindings == null ? <NUM_LIT:0> : importBindings . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ImportBinding importBinding = importBindings [ i ] ; if ( importBinding . onDemand ) { if ( this . onDemandImportsCache == null ) { this . onDemandImportsCache = new ImportBinding [ length - i ] ; } this . onDemandImportsCache [ this . onDemandImportCacheCount ++ ] = importBinding ; } else { if ( ! ( importBinding . resolvedImport instanceof MethodBinding ) || importBinding instanceof ImportConflictBinding ) { if ( this . importsCache == null ) { this . importsCache = new char [ length - i ] [ ] [ ] ; } this . importsCache [ this . importCacheCount ++ ] = new char [ ] [ ] { importBinding . compoundName [ importBinding . compoundName . length - <NUM_LIT:1> ] , CharOperation . concatWith ( importBinding . compoundName , '<CHAR_LIT:.>' ) } ; } } } this . importCachesInitialized = true ; } public void initializePackageCache ( ) { if ( this . unitScope . fPackage != null ) { this . currentPackageName = CharOperation . concatWith ( this . unitScope . fPackage . compoundName , '<CHAR_LIT:.>' ) ; } else if ( this . unitScope . referenceContext != null && this . unitScope . referenceContext . currentPackage != null ) { this . currentPackageName = CharOperation . concatWith ( this . unitScope . referenceContext . currentPackage . tokens , '<CHAR_LIT:.>' ) ; } else { this . currentPackageName = CharOperation . NO_CHAR ; } } protected boolean mustQualifyType ( char [ ] packageName , char [ ] typeName , char [ ] enclosingTypeNames , int modifiers ) { if ( this . unitScope == null ) return true ; if ( ! this . importCachesInitialized ) { initializeImportCaches ( ) ; } for ( int i = <NUM_LIT:0> ; i < this . importCacheCount ; i ++ ) { char [ ] [ ] importName = this . importsCache [ i ] ; if ( CharOperation . equals ( typeName , importName [ <NUM_LIT:0> ] ) ) { char [ ] fullyQualifiedTypeName = enclosingTypeNames == null || enclosingTypeNames . length == <NUM_LIT:0> ? CharOperation . concat ( packageName , typeName , '<CHAR_LIT:.>' ) : CharOperation . concat ( CharOperation . concat ( packageName , enclosingTypeNames , '<CHAR_LIT:.>' ) , typeName , '<CHAR_LIT:.>' ) ; return ! CharOperation . equals ( fullyQualifiedTypeName , importName [ <NUM_LIT:1> ] ) ; } } if ( ( enclosingTypeNames == null || enclosingTypeNames . length == <NUM_LIT:0> ) && CharOperation . equals ( this . currentPackageName , packageName ) ) return false ; char [ ] fullyQualifiedEnclosingTypeName = null ; for ( int i = <NUM_LIT:0> ; i < this . onDemandImportCacheCount ; i ++ ) { ImportBinding importBinding = this . onDemandImportsCache [ i ] ; Binding resolvedImport = importBinding . resolvedImport ; char [ ] [ ] importName = importBinding . compoundName ; char [ ] importFlatName = CharOperation . concatWith ( importName , '<CHAR_LIT:.>' ) ; boolean isFound = false ; if ( resolvedImport instanceof ReferenceBinding ) { if ( enclosingTypeNames != null && enclosingTypeNames . length != <NUM_LIT:0> ) { if ( fullyQualifiedEnclosingTypeName == null ) { fullyQualifiedEnclosingTypeName = CharOperation . concat ( packageName , enclosingTypeNames , '<CHAR_LIT:.>' ) ; } if ( CharOperation . equals ( fullyQualifiedEnclosingTypeName , importFlatName ) ) { if ( importBinding . isStatic ( ) ) { isFound = ( modifiers & ClassFileConstants . AccStatic ) != <NUM_LIT:0> ; } else { isFound = true ; } } } } else { if ( enclosingTypeNames == null || enclosingTypeNames . length == <NUM_LIT:0> ) { if ( CharOperation . equals ( packageName , importFlatName ) ) { if ( importBinding . isStatic ( ) ) { isFound = ( modifiers & ClassFileConstants . AccStatic ) != <NUM_LIT:0> ; } else { isFound = true ; } } } } if ( isFound ) { for ( int j = <NUM_LIT:0> ; j < this . onDemandImportCacheCount ; j ++ ) { if ( i != j ) { ImportBinding conflictingImportBinding = this . onDemandImportsCache [ j ] ; if ( conflictingImportBinding . resolvedImport instanceof ReferenceBinding ) { ReferenceBinding refBinding = ( ReferenceBinding ) conflictingImportBinding . resolvedImport ; if ( refBinding . getMemberType ( typeName ) != null ) { return true ; } } else { char [ ] conflictingImportName = CharOperation . concatWith ( conflictingImportBinding . compoundName , '<CHAR_LIT:.>' ) ; if ( this . nameEnvironment . nameLookup . findType ( String . valueOf ( typeName ) , String . valueOf ( conflictingImportName ) , false , NameLookup . ACCEPT_ALL , false ) != null ) { return true ; } } } } return false ; } } return true ; } protected ASTNode parseBlockStatements ( CompilationUnitDeclaration unit , int position ) { int length = unit . types . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { TypeDeclaration type = unit . types [ i ] ; if ( type . declarationSourceStart < position && type . declarationSourceEnd >= position ) { getParser ( ) . scanner . setSource ( unit . compilationResult ) ; return parseBlockStatements ( type , unit , position ) ; } } return null ; } private ASTNode parseBlockStatements ( TypeDeclaration type , CompilationUnitDeclaration unit , int position ) { TypeDeclaration [ ] memberTypes = type . memberTypes ; if ( memberTypes != null ) { int length = memberTypes . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { TypeDeclaration memberType = memberTypes [ i ] ; if ( memberType . bodyStart > position ) continue ; if ( memberType . declarationSourceEnd >= position ) { return parseBlockStatements ( memberType , unit , position ) ; } } } AbstractMethodDeclaration [ ] methods = type . methods ; if ( methods != null ) { int length = methods . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { AbstractMethodDeclaration method = methods [ i ] ; if ( method . bodyStart > position + <NUM_LIT:1> ) continue ; if ( method . isDefaultConstructor ( ) ) continue ; if ( method . declarationSourceEnd >= position ) { getParser ( ) . parseBlockStatements ( method , unit ) ; return method ; } } } FieldDeclaration [ ] fields = type . fields ; if ( fields != null ) { int length = fields . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { FieldDeclaration field = fields [ i ] ; if ( field . sourceStart > position ) continue ; if ( field . declarationSourceEnd >= position ) { if ( field instanceof Initializer ) { getParser ( ) . parseBlockStatements ( ( Initializer ) field , type , unit ) ; } return field ; } } } return null ; } protected void reset ( boolean resetLookupEnvironment ) { if ( resetLookupEnvironment ) this . lookupEnvironment . reset ( ) ; } public static char [ ] getTypeSignature ( TypeBinding typeBinding ) { char [ ] result = typeBinding . signature ( ) ; if ( result != null ) { result = CharOperation . replaceOnCopy ( result , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; } return result ; } public static char [ ] getSignature ( MethodBinding methodBinding ) { char [ ] result = null ; int oldMod = methodBinding . modifiers ; methodBinding . modifiers |= ExtraCompilerModifiers . AccGenericSignature ; result = methodBinding . genericSignature ( ) ; if ( result == null ) { result = methodBinding . signature ( ) ; } methodBinding . modifiers = oldMod ; if ( result != null ) { result = CharOperation . replaceOnCopy ( result , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; } return result ; } public static char [ ] getSignature ( TypeBinding typeBinding ) { char [ ] result = null ; result = typeBinding . genericTypeSignature ( ) ; if ( result != null ) { result = CharOperation . replaceOnCopy ( result , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; } return result ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . ITypeRoot ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . codeassist . complete . CompletionNodeDetector ; import org . eclipse . jdt . internal . codeassist . complete . CompletionParser ; import org . eclipse . jdt . internal . codeassist . impl . AssistCompilationUnit ; 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 . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Initializer ; import org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ; import org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . SingleTypeReference ; 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 . impl . ReferenceContext ; import org . eclipse . jdt . internal . compiler . lookup . BinaryTypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . ImportBinding ; import org . eclipse . jdt . internal . compiler . lookup . InvocationSite ; import org . eclipse . jdt . internal . compiler . lookup . LocalVariableBinding ; import org . eclipse . jdt . internal . compiler . lookup . LookupEnvironment ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . MethodScope ; import org . eclipse . jdt . internal . compiler . lookup . ParameterizedTypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . Scope ; import org . eclipse . jdt . internal . compiler . lookup . SignatureWrapper ; import org . eclipse . jdt . internal . compiler . lookup . SourceTypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeVariableBinding ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . compiler . util . ObjectVector ; import org . eclipse . jdt . internal . core . CompilationUnitElementInfo ; import org . eclipse . jdt . internal . core . JavaElement ; import org . eclipse . jdt . internal . core . LocalVariable ; import org . eclipse . jdt . internal . core . util . Util ; public class InternalExtendedCompletionContext { private static Util . BindingsToNodesMap EmptyNodeMap = new Util . BindingsToNodesMap ( ) { public ASTNode get ( Binding binding ) { return null ; } } ; private InternalCompletionContext completionContext ; private ITypeRoot typeRoot ; private CompilationUnitDeclaration compilationUnitDeclaration ; private LookupEnvironment lookupEnvironment ; private Scope assistScope ; private ASTNode assistNode ; private ASTNode assistNodeParent ; private WorkingCopyOwner owner ; private CompletionParser parser ; private boolean hasComputedVisibleElementBindings ; private ObjectVector visibleLocalVariables ; private ObjectVector visibleFields ; private ObjectVector visibleMethods ; private boolean hasComputedEnclosingJavaElements ; private Map bindingsToHandles ; private Map nodesWithProblemsToHandles ; private ICompilationUnit compilationUnit ; public InternalExtendedCompletionContext ( InternalCompletionContext completionContext , ITypeRoot typeRoot , CompilationUnitDeclaration compilationUnitDeclaration , LookupEnvironment lookupEnvironment , Scope assistScope , ASTNode assistNode , ASTNode assistNodeParent , WorkingCopyOwner owner , CompletionParser parser ) { this . completionContext = completionContext ; this . typeRoot = typeRoot ; this . compilationUnitDeclaration = compilationUnitDeclaration ; this . lookupEnvironment = lookupEnvironment ; this . assistScope = assistScope ; this . assistNode = assistNode ; this . assistNodeParent = assistNodeParent ; this . owner = owner ; this . parser = parser ; } private void computeEnclosingJavaElements ( ) { this . hasComputedEnclosingJavaElements = true ; if ( this . typeRoot == null ) return ; if ( this . typeRoot . getElementType ( ) == IJavaElement . COMPILATION_UNIT ) { ICompilationUnit original = ( org . eclipse . jdt . core . ICompilationUnit ) this . typeRoot ; HashMap handleToBinding = new HashMap ( ) ; HashMap bindingToHandle = new HashMap ( ) ; HashMap nodeWithProblemToHandle = new HashMap ( ) ; HashMap handleToInfo = new HashMap ( ) ; org . eclipse . jdt . core . ICompilationUnit handle = new AssistCompilationUnit ( original , this . owner , handleToBinding , handleToInfo ) ; CompilationUnitElementInfo info = new CompilationUnitElementInfo ( ) ; handleToInfo . put ( handle , info ) ; CompletionUnitStructureRequestor structureRequestor = new CompletionUnitStructureRequestor ( handle , info , this . parser , this . assistNode , handleToBinding , bindingToHandle , nodeWithProblemToHandle , handleToInfo ) ; CompletionElementNotifier notifier = new CompletionElementNotifier ( structureRequestor , true , this . assistNode ) ; notifier . notifySourceElementRequestor ( this . compilationUnitDeclaration , this . compilationUnitDeclaration . sourceStart , this . compilationUnitDeclaration . sourceEnd , false , this . parser . sourceEnds , new HashMap ( ) ) ; this . bindingsToHandles = bindingToHandle ; this . nodesWithProblemsToHandles = nodeWithProblemToHandle ; this . compilationUnit = handle ; } } private void computeVisibleElementBindings ( ) { CompilationUnitDeclaration previousUnitBeingCompleted = this . lookupEnvironment . unitBeingCompleted ; this . lookupEnvironment . unitBeingCompleted = this . compilationUnitDeclaration ; try { this . hasComputedVisibleElementBindings = true ; Scope scope = this . assistScope ; ASTNode astNode = this . assistNode ; boolean notInJavadoc = this . completionContext . javadoc == <NUM_LIT:0> ; this . visibleLocalVariables = new ObjectVector ( ) ; this . visibleFields = new ObjectVector ( ) ; this . visibleMethods = new ObjectVector ( ) ; ReferenceContext referenceContext = scope . referenceContext ( ) ; if ( referenceContext instanceof AbstractMethodDeclaration ) { searchVisibleVariablesAndMethods ( scope , this . visibleLocalVariables , this . visibleFields , this . visibleMethods , notInJavadoc ) ; } else if ( referenceContext instanceof TypeDeclaration ) { TypeDeclaration typeDeclaration = ( TypeDeclaration ) referenceContext ; FieldDeclaration [ ] fields = typeDeclaration . fields ; if ( fields != null ) { done : for ( int i = <NUM_LIT:0> ; i < fields . length ; i ++ ) { if ( fields [ i ] instanceof Initializer ) { Initializer initializer = ( Initializer ) fields [ i ] ; if ( initializer . block . sourceStart <= astNode . sourceStart && astNode . sourceStart < initializer . bodyEnd ) { searchVisibleVariablesAndMethods ( scope , this . visibleLocalVariables , this . visibleFields , this . visibleMethods , notInJavadoc ) ; break done ; } } else { FieldDeclaration fieldDeclaration = fields [ i ] ; if ( fieldDeclaration . initialization != null ) { boolean isInsideInitializer = false ; if ( fieldDeclaration . initialization . sourceEnd > <NUM_LIT:0> ) { if ( fieldDeclaration . initialization . sourceStart <= astNode . sourceStart && astNode . sourceEnd <= fieldDeclaration . initialization . sourceEnd ) { isInsideInitializer = true ; } } else { CompletionNodeDetector detector = new CompletionNodeDetector ( this . assistNode , fieldDeclaration . initialization ) ; if ( detector . containsCompletionNode ( ) ) { isInsideInitializer = true ; } } if ( isInsideInitializer ) { searchVisibleVariablesAndMethods ( scope , this . visibleLocalVariables , this . visibleFields , this . visibleMethods , notInJavadoc ) ; if ( this . visibleFields . size > <NUM_LIT:0> && this . visibleFields . contains ( fieldDeclaration . binding ) ) { this . visibleFields . remove ( fieldDeclaration . binding ) ; } int count = <NUM_LIT:0> ; while ( count < this . visibleFields . size ) { FieldBinding visibleField = ( FieldBinding ) this . visibleFields . elementAt ( count ) ; if ( visibleField . id > fieldDeclaration . binding . id ) { this . visibleFields . remove ( visibleField ) ; continue ; } count ++ ; } break done ; } } } } } } } finally { this . lookupEnvironment . unitBeingCompleted = previousUnitBeingCompleted ; } } public IJavaElement getEnclosingElement ( ) { try { if ( ! this . hasComputedEnclosingJavaElements ) { computeEnclosingJavaElements ( ) ; } if ( this . compilationUnit == null ) return null ; IJavaElement enclosingElement = this . compilationUnit . getElementAt ( this . completionContext . offset ) ; return enclosingElement == null ? this . compilationUnit : enclosingElement ; } catch ( JavaModelException e ) { Util . log ( e , "<STR_LIT>" ) ; return null ; } } private JavaElement getJavaElement ( LocalVariableBinding binding ) { LocalDeclaration local = binding . declaration ; JavaElement parent = null ; ReferenceContext referenceContext = binding . declaringScope . referenceContext ( ) ; if ( referenceContext instanceof AbstractMethodDeclaration ) { AbstractMethodDeclaration methodDeclaration = ( AbstractMethodDeclaration ) referenceContext ; parent = this . getJavaElementOfCompilationUnit ( methodDeclaration , methodDeclaration . binding ) ; } else if ( referenceContext instanceof TypeDeclaration ) { TypeDeclaration typeDeclaration = ( TypeDeclaration ) referenceContext ; JavaElement type = this . getJavaElementOfCompilationUnit ( typeDeclaration , typeDeclaration . binding ) ; parent = Util . getUnresolvedJavaElement ( local . sourceStart , local . sourceEnd , type ) ; } if ( parent == null ) return null ; return new LocalVariable ( parent , new String ( local . name ) , local . declarationSourceStart , local . declarationSourceEnd , local . sourceStart , local . sourceEnd , Util . typeSignature ( local . type ) , binding . declaration . annotations , local . modifiers , local . getKind ( ) == AbstractVariableDeclaration . PARAMETER ) ; } private JavaElement getJavaElementOfCompilationUnit ( Binding binding ) { if ( ! this . hasComputedEnclosingJavaElements ) { computeEnclosingJavaElements ( ) ; } if ( this . bindingsToHandles == null ) return null ; return ( JavaElement ) this . bindingsToHandles . get ( binding ) ; } private JavaElement getJavaElementOfCompilationUnit ( ASTNode node , Binding binding ) { if ( ! this . hasComputedEnclosingJavaElements ) { computeEnclosingJavaElements ( ) ; } if ( binding != null ) { if ( this . bindingsToHandles == null ) return null ; return ( JavaElement ) this . bindingsToHandles . get ( binding ) ; } else { if ( this . nodesWithProblemsToHandles == null ) return null ; return ( JavaElement ) this . nodesWithProblemsToHandles . get ( node ) ; } } private TypeBinding getTypeFromSignature ( String typeSignature , Scope scope ) { TypeBinding assignableTypeBinding = null ; TypeVariableBinding [ ] typeVariables = Binding . NO_TYPE_VARIABLES ; ReferenceContext referenceContext = scope . referenceContext ( ) ; if ( referenceContext instanceof AbstractMethodDeclaration ) { AbstractMethodDeclaration methodDeclaration = ( AbstractMethodDeclaration ) referenceContext ; TypeParameter [ ] typeParameters = methodDeclaration . typeParameters ( ) ; if ( typeParameters != null && typeParameters . length > <NUM_LIT:0> ) { int length = typeParameters . length ; int count = <NUM_LIT:0> ; typeVariables = new TypeVariableBinding [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( typeParameters [ i ] . binding != null ) { typeVariables [ count ++ ] = typeParameters [ i ] . binding ; } } if ( count != length ) { System . arraycopy ( typeVariables , <NUM_LIT:0> , typeVariables = new TypeVariableBinding [ count ] , <NUM_LIT:0> , count ) ; } } } CompilationUnitDeclaration previousUnitBeingCompleted = this . lookupEnvironment . unitBeingCompleted ; this . lookupEnvironment . unitBeingCompleted = this . compilationUnitDeclaration ; try { SignatureWrapper wrapper = new SignatureWrapper ( replacePackagesDot ( typeSignature . toCharArray ( ) ) ) ; assignableTypeBinding = this . lookupEnvironment . getTypeFromTypeSignature ( wrapper , typeVariables , this . assistScope . enclosingClassScope ( ) . referenceContext . binding , null ) ; assignableTypeBinding = BinaryTypeBinding . resolveType ( assignableTypeBinding , this . lookupEnvironment , true ) ; } catch ( AbortCompilation e ) { assignableTypeBinding = null ; } finally { this . lookupEnvironment . unitBeingCompleted = previousUnitBeingCompleted ; } return assignableTypeBinding ; } private char [ ] replacePackagesDot ( char [ ] signature ) { boolean replace = true ; int length = signature . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { switch ( signature [ i ] ) { case '<CHAR_LIT:.>' : if ( replace ) signature [ i ] = '<CHAR_LIT:/>' ; break ; case '<CHAR_LIT>' : replace = true ; break ; case '<CHAR_LIT:>>' : replace = false ; break ; } } return signature ; } public IJavaElement [ ] getVisibleElements ( String typeSignature ) { if ( this . assistScope == null ) return new IJavaElement [ <NUM_LIT:0> ] ; if ( ! this . hasComputedVisibleElementBindings ) { computeVisibleElementBindings ( ) ; } TypeBinding assignableTypeBinding = null ; if ( typeSignature != null ) { assignableTypeBinding = getTypeFromSignature ( typeSignature , this . assistScope ) ; if ( assignableTypeBinding == null ) return new IJavaElement [ <NUM_LIT:0> ] ; } int length = this . visibleLocalVariables . size ( ) + this . visibleFields . size ( ) + this . visibleMethods . size ( ) ; if ( length == <NUM_LIT:0> ) return new IJavaElement [ <NUM_LIT:0> ] ; IJavaElement [ ] result = new IJavaElement [ length ] ; int elementCount = <NUM_LIT:0> ; int size = this . visibleLocalVariables . size ( ) ; if ( size > <NUM_LIT:0> ) { next : for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { try { LocalVariableBinding binding = ( LocalVariableBinding ) this . visibleLocalVariables . elementAt ( i ) ; if ( binding . type == null || ( assignableTypeBinding != null && ! binding . type . isCompatibleWith ( assignableTypeBinding ) ) ) continue next ; JavaElement localVariable = getJavaElement ( binding ) ; if ( localVariable != null ) result [ elementCount ++ ] = localVariable ; } catch ( AbortCompilation e ) { Util . logRepeatedMessage ( e . getKey ( ) , e ) ; } } } size = this . visibleFields . size ( ) ; if ( size > <NUM_LIT:0> ) { next : for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { try { FieldBinding binding = ( FieldBinding ) this . visibleFields . elementAt ( i ) ; if ( assignableTypeBinding != null && ! binding . type . isCompatibleWith ( assignableTypeBinding ) ) continue next ; if ( this . assistScope . isDefinedInSameUnit ( binding . declaringClass ) ) { JavaElement field = getJavaElementOfCompilationUnit ( binding ) ; if ( field != null ) result [ elementCount ++ ] = field ; } else { JavaElement field = Util . getUnresolvedJavaElement ( binding , this . owner , EmptyNodeMap ) ; if ( field != null ) result [ elementCount ++ ] = field . resolved ( binding ) ; } } catch ( AbortCompilation e ) { Util . logRepeatedMessage ( e . getKey ( ) , e ) ; } } } size = this . visibleMethods . size ( ) ; if ( size > <NUM_LIT:0> ) { next : for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { try { MethodBinding binding = ( MethodBinding ) this . visibleMethods . elementAt ( i ) ; if ( assignableTypeBinding != null && ! binding . returnType . isCompatibleWith ( assignableTypeBinding ) ) continue next ; if ( this . assistScope . isDefinedInSameUnit ( binding . declaringClass ) ) { JavaElement method = getJavaElementOfCompilationUnit ( binding ) ; if ( method != null ) result [ elementCount ++ ] = method ; } else { JavaElement method = Util . getUnresolvedJavaElement ( binding , this . owner , EmptyNodeMap ) ; if ( method != null ) result [ elementCount ++ ] = method . resolved ( binding ) ; } } catch ( AbortCompilation e ) { Util . logRepeatedMessage ( e . getKey ( ) , e ) ; } } } if ( elementCount != result . length ) { System . arraycopy ( result , <NUM_LIT:0> , result = new IJavaElement [ elementCount ] , <NUM_LIT:0> , elementCount ) ; } return result ; } private void searchVisibleFields ( FieldBinding [ ] fields , ReferenceBinding receiverType , Scope scope , InvocationSite invocationSite , Scope invocationScope , boolean onlyStaticFields , ObjectVector localsFound , ObjectVector fieldsFound ) { ObjectVector newFieldsFound = new ObjectVector ( ) ; next : for ( int f = fields . length ; -- f >= <NUM_LIT:0> ; ) { FieldBinding field = fields [ f ] ; if ( field . isSynthetic ( ) ) continue next ; if ( onlyStaticFields && ! field . isStatic ( ) ) continue next ; if ( ! field . canBeSeenBy ( receiverType , invocationSite , scope ) ) continue next ; for ( int i = fieldsFound . size ; -- i >= <NUM_LIT:0> ; ) { FieldBinding otherField = ( FieldBinding ) fieldsFound . elementAt ( i ) ; if ( CharOperation . equals ( field . name , otherField . name , true ) ) { continue next ; } } for ( int l = localsFound . size ; -- l >= <NUM_LIT:0> ; ) { LocalVariableBinding local = ( LocalVariableBinding ) localsFound . elementAt ( l ) ; if ( CharOperation . equals ( field . name , local . name , true ) ) { continue next ; } } newFieldsFound . add ( field ) ; } fieldsFound . addAll ( newFieldsFound ) ; } private void searchVisibleFields ( ReferenceBinding receiverType , Scope scope , InvocationSite invocationSite , Scope invocationScope , boolean onlyStaticFields , boolean notInJavadoc , ObjectVector localsFound , ObjectVector fieldsFound ) { ReferenceBinding currentType = receiverType ; ReferenceBinding [ ] interfacesToVisit = null ; int nextPosition = <NUM_LIT:0> ; do { ReferenceBinding [ ] itsInterfaces = currentType . superInterfaces ( ) ; if ( notInJavadoc && itsInterfaces != Binding . NO_SUPERINTERFACES ) { if ( interfacesToVisit == null ) { interfacesToVisit = itsInterfaces ; nextPosition = interfacesToVisit . length ; } else { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + <NUM_LIT:5> ] , <NUM_LIT:0> , nextPosition ) ; nextInterface : for ( int a = <NUM_LIT:0> ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = <NUM_LIT:0> ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } FieldBinding [ ] fields = currentType . availableFields ( ) ; if ( fields != null && fields . length > <NUM_LIT:0> ) { searchVisibleFields ( fields , receiverType , scope , invocationSite , invocationScope , onlyStaticFields , localsFound , fieldsFound ) ; } currentType = currentType . superclass ( ) ; } while ( notInJavadoc && currentType != null ) ; if ( notInJavadoc && interfacesToVisit != null ) { for ( int i = <NUM_LIT:0> ; i < nextPosition ; i ++ ) { ReferenceBinding anInterface = interfacesToVisit [ i ] ; FieldBinding [ ] fields = anInterface . availableFields ( ) ; if ( fields != null ) { searchVisibleFields ( fields , receiverType , scope , invocationSite , invocationScope , onlyStaticFields , localsFound , fieldsFound ) ; } ReferenceBinding [ ] itsInterfaces = anInterface . superInterfaces ( ) ; if ( itsInterfaces != Binding . NO_SUPERINTERFACES ) { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + <NUM_LIT:5> ] , <NUM_LIT:0> , nextPosition ) ; nextInterface : for ( int a = <NUM_LIT:0> ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = <NUM_LIT:0> ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } } } private void searchVisibleInterfaceMethods ( ReferenceBinding [ ] itsInterfaces , ReferenceBinding receiverType , Scope scope , InvocationSite invocationSite , Scope invocationScope , boolean onlyStaticMethods , ObjectVector methodsFound ) { if ( itsInterfaces != Binding . NO_SUPERINTERFACES ) { ReferenceBinding [ ] interfacesToVisit = itsInterfaces ; int nextPosition = interfacesToVisit . length ; for ( int i = <NUM_LIT:0> ; i < nextPosition ; i ++ ) { ReferenceBinding currentType = interfacesToVisit [ i ] ; MethodBinding [ ] methods = currentType . availableMethods ( ) ; if ( methods != null ) { searchVisibleLocalMethods ( methods , receiverType , scope , invocationSite , invocationScope , onlyStaticMethods , methodsFound ) ; } itsInterfaces = currentType . superInterfaces ( ) ; if ( itsInterfaces != null && itsInterfaces != Binding . NO_SUPERINTERFACES ) { int itsLength = itsInterfaces . length ; if ( nextPosition + itsLength >= interfacesToVisit . length ) System . arraycopy ( interfacesToVisit , <NUM_LIT:0> , interfacesToVisit = new ReferenceBinding [ nextPosition + itsLength + <NUM_LIT:5> ] , <NUM_LIT:0> , nextPosition ) ; nextInterface : for ( int a = <NUM_LIT:0> ; a < itsLength ; a ++ ) { ReferenceBinding next = itsInterfaces [ a ] ; for ( int b = <NUM_LIT:0> ; b < nextPosition ; b ++ ) if ( next == interfacesToVisit [ b ] ) continue nextInterface ; interfacesToVisit [ nextPosition ++ ] = next ; } } } } } private void searchVisibleLocalMethods ( MethodBinding [ ] methods , ReferenceBinding receiverType , Scope scope , InvocationSite invocationSite , Scope invocationScope , boolean onlyStaticMethods , ObjectVector methodsFound ) { ObjectVector newMethodsFound = new ObjectVector ( ) ; next : for ( int f = methods . length ; -- f >= <NUM_LIT:0> ; ) { MethodBinding method = methods [ f ] ; if ( method . isSynthetic ( ) ) continue next ; if ( method . isDefaultAbstract ( ) ) continue next ; if ( method . isConstructor ( ) ) continue next ; if ( onlyStaticMethods && ! method . isStatic ( ) ) continue next ; if ( ! method . canBeSeenBy ( receiverType , invocationSite , scope ) ) continue next ; for ( int i = methodsFound . size ; -- i >= <NUM_LIT:0> ; ) { MethodBinding otherMethod = ( MethodBinding ) methodsFound . elementAt ( i ) ; if ( method == otherMethod ) continue next ; if ( CharOperation . equals ( method . selector , otherMethod . selector , true ) ) { if ( this . lookupEnvironment . methodVerifier ( ) . isMethodSubsignature ( otherMethod , method ) ) { continue next ; } } } newMethodsFound . add ( method ) ; } methodsFound . addAll ( newMethodsFound ) ; } private void searchVisibleMethods ( ReferenceBinding receiverType , Scope scope , InvocationSite invocationSite , Scope invocationScope , boolean onlyStaticMethods , boolean notInJavadoc , ObjectVector methodsFound ) { ReferenceBinding currentType = receiverType ; if ( notInJavadoc ) { if ( receiverType . isInterface ( ) ) { searchVisibleInterfaceMethods ( new ReferenceBinding [ ] { currentType } , receiverType , scope , invocationSite , invocationScope , onlyStaticMethods , methodsFound ) ; currentType = scope . getJavaLangObject ( ) ; } } boolean hasPotentialDefaultAbstractMethods = true ; while ( currentType != null ) { MethodBinding [ ] methods = currentType . availableMethods ( ) ; if ( methods != null ) { searchVisibleLocalMethods ( methods , receiverType , scope , invocationSite , invocationScope , onlyStaticMethods , methodsFound ) ; } if ( notInJavadoc && hasPotentialDefaultAbstractMethods && ( currentType . isAbstract ( ) || currentType . isTypeVariable ( ) || currentType . isIntersectionType ( ) || currentType . isEnum ( ) ) ) { ReferenceBinding [ ] superInterfaces = currentType . superInterfaces ( ) ; if ( superInterfaces != null && currentType . isIntersectionType ( ) ) { for ( int i = <NUM_LIT:0> ; i < superInterfaces . length ; i ++ ) { superInterfaces [ i ] = ( ReferenceBinding ) superInterfaces [ i ] . capture ( invocationScope , invocationSite . sourceEnd ( ) ) ; } } searchVisibleInterfaceMethods ( superInterfaces , receiverType , scope , invocationSite , invocationScope , onlyStaticMethods , methodsFound ) ; } else { hasPotentialDefaultAbstractMethods = false ; } if ( currentType . isParameterizedType ( ) ) { currentType = ( ( ParameterizedTypeBinding ) currentType ) . genericType ( ) . superclass ( ) ; } else { currentType = currentType . superclass ( ) ; } } } private void searchVisibleVariablesAndMethods ( Scope scope , ObjectVector localsFound , ObjectVector fieldsFound , ObjectVector methodsFound , boolean notInJavadoc ) { InvocationSite invocationSite = CompletionEngine . FakeInvocationSite ; boolean staticsOnly = false ; Scope currentScope = scope ; done1 : while ( true ) { switch ( currentScope . kind ) { case Scope . METHOD_SCOPE : MethodScope methodScope = ( MethodScope ) currentScope ; staticsOnly |= methodScope . isStatic | methodScope . isConstructorCall ; case Scope . BLOCK_SCOPE : BlockScope blockScope = ( BlockScope ) currentScope ; next : for ( int i = <NUM_LIT:0> , length = blockScope . locals . length ; i < length ; i ++ ) { LocalVariableBinding local = blockScope . locals [ i ] ; if ( local == null ) break next ; if ( local . isSecret ( ) ) continue next ; if ( local . declaration . initialization != null ) { continue next ; } for ( int f = <NUM_LIT:0> ; f < localsFound . size ; f ++ ) { LocalVariableBinding otherLocal = ( LocalVariableBinding ) localsFound . elementAt ( f ) ; if ( CharOperation . equals ( otherLocal . name , local . name , true ) ) continue next ; } localsFound . add ( local ) ; } break ; case Scope . COMPILATION_UNIT_SCOPE : break done1 ; } currentScope = currentScope . parent ; } staticsOnly = false ; currentScope = scope ; done2 : while ( true ) { switch ( currentScope . kind ) { case Scope . METHOD_SCOPE : MethodScope methodScope = ( MethodScope ) currentScope ; staticsOnly |= methodScope . isStatic | methodScope . isConstructorCall ; break ; case Scope . CLASS_SCOPE : ClassScope classScope = ( ClassScope ) currentScope ; SourceTypeBinding enclosingType = classScope . referenceContext . binding ; searchVisibleFields ( enclosingType , classScope , invocationSite , scope , staticsOnly , notInJavadoc , localsFound , fieldsFound ) ; searchVisibleMethods ( enclosingType , classScope , invocationSite , scope , staticsOnly , notInJavadoc , methodsFound ) ; staticsOnly |= enclosingType . isStatic ( ) ; break ; case Scope . COMPILATION_UNIT_SCOPE : break done2 ; } currentScope = currentScope . parent ; } ImportBinding [ ] importBindings = scope . compilationUnitScope ( ) . imports ; for ( int i = <NUM_LIT:0> ; i < importBindings . length ; i ++ ) { ImportBinding importBinding = importBindings [ i ] ; if ( importBinding . isValidBinding ( ) && importBinding . isStatic ( ) ) { Binding binding = importBinding . resolvedImport ; if ( binding != null && binding . isValidBinding ( ) ) { if ( importBinding . onDemand ) { if ( ( binding . kind ( ) & Binding . TYPE ) != <NUM_LIT:0> ) { searchVisibleFields ( ( ReferenceBinding ) binding , scope , invocationSite , scope , staticsOnly , notInJavadoc , localsFound , fieldsFound ) ; searchVisibleMethods ( ( ReferenceBinding ) binding , scope , invocationSite , scope , staticsOnly , notInJavadoc , methodsFound ) ; } } else { if ( ( binding . kind ( ) & Binding . FIELD ) != <NUM_LIT:0> ) { searchVisibleFields ( new FieldBinding [ ] { ( FieldBinding ) binding } , ( ( FieldBinding ) binding ) . declaringClass , scope , invocationSite , scope , staticsOnly , localsFound , fieldsFound ) ; } else if ( ( binding . kind ( ) & Binding . METHOD ) != <NUM_LIT:0> ) { MethodBinding methodBinding = ( MethodBinding ) binding ; searchVisibleLocalMethods ( methodBinding . declaringClass . getMethods ( methodBinding . selector ) , methodBinding . declaringClass , scope , invocationSite , scope , true , methodsFound ) ; } } } } } } public boolean canUseDiamond ( String [ ] parameterTypes , char [ ] fullyQualifiedTypeName ) { TypeBinding guessedType = null ; char [ ] [ ] cn = CharOperation . splitOn ( '<CHAR_LIT:.>' , fullyQualifiedTypeName ) ; Scope scope = this . assistScope ; if ( scope . compilerOptions ( ) . sourceLevel < ClassFileConstants . JDK1_7 ) return false ; char [ ] [ ] expectedTypekeys = this . completionContext . getExpectedTypesKeys ( ) ; if ( expectedTypekeys == null || expectedTypekeys . length == <NUM_LIT:0> ) return true ; TypeReference ref ; if ( cn . length == <NUM_LIT:1> ) { ref = new SingleTypeReference ( cn [ <NUM_LIT:0> ] , <NUM_LIT:0> ) ; } else { ref = new QualifiedTypeReference ( cn , new long [ cn . length ] ) ; } switch ( scope . kind ) { case Scope . METHOD_SCOPE : case Scope . BLOCK_SCOPE : guessedType = ref . resolveType ( ( BlockScope ) scope ) ; break ; case Scope . CLASS_SCOPE : guessedType = ref . resolveType ( ( ClassScope ) scope ) ; break ; } if ( guessedType != null && guessedType . isValidBinding ( ) ) { guessedType = guessedType . erasure ( ) ; TypeVariableBinding [ ] typeVars = guessedType . typeVariables ( ) ; for ( int i = <NUM_LIT:0> ; i < parameterTypes . length ; i ++ ) { for ( int j = <NUM_LIT:0> ; j < typeVars . length ; j ++ ) { if ( CharOperation . equals ( parameterTypes [ i ] . toCharArray ( ) , typeVars [ j ] . sourceName ) ) return false ; } } return true ; } return false ; } public ASTNode getCompletionNode ( ) { return this . assistNode ; } public ASTNode getCompletionNodeParent ( ) { return this . assistNodeParent ; } public ObjectVector getVisibleLocalVariables ( ) { if ( ! this . hasComputedVisibleElementBindings ) { computeVisibleElementBindings ( ) ; } return this . visibleLocalVariables ; } public ObjectVector getVisibleFields ( ) { if ( ! this . hasComputedVisibleElementBindings ) { computeVisibleElementBindings ( ) ; } return this . visibleFields ; } public ObjectVector getVisibleMethods ( ) { if ( ! this . hasComputedVisibleElementBindings ) { computeVisibleElementBindings ( ) ; } return this . visibleMethods ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist ; public interface RelevanceConstants { int R_DEFAULT = <NUM_LIT:5> ; int R_INTERESTING = <NUM_LIT:5> ; int R_CASE = <NUM_LIT:10> ; int R_CAMEL_CASE = <NUM_LIT:5> ; int R_EXACT_NAME = <NUM_LIT:4> ; int R_VOID = - <NUM_LIT:5> ; int R_EXPECTED_TYPE = <NUM_LIT:20> ; int R_EXACT_EXPECTED_TYPE = <NUM_LIT:30> ; int R_INTERFACE = <NUM_LIT:20> ; int R_CLASS = <NUM_LIT:20> ; int R_ENUM = <NUM_LIT:20> ; int R_ANNOTATION = <NUM_LIT:20> ; int R_EXCEPTION = <NUM_LIT:20> ; int R_ENUM_CONSTANT = <NUM_LIT:5> ; int R_ABSTRACT_METHOD = <NUM_LIT:20> ; int R_NON_STATIC = <NUM_LIT:11> ; int R_UNQUALIFIED = <NUM_LIT:3> ; int R_QUALIFIED = <NUM_LIT:2> ; int R_NAME_FIRST_PREFIX = <NUM_LIT:6> ; int R_NAME_PREFIX = <NUM_LIT:5> ; int R_NAME_FIRST_SUFFIX = <NUM_LIT:4> ; int R_NAME_SUFFIX = <NUM_LIT:3> ; int R_NAME_LESS_NEW_CHARACTERS = <NUM_LIT:15> ; int R_METHOD_OVERIDE = <NUM_LIT:3> ; int R_NON_RESTRICTED = <NUM_LIT:3> ; int R_TRUE_OR_FALSE = <NUM_LIT:1> ; int R_INLINE_TAG = <NUM_LIT:31> ; int R_VALUE_TAG = <NUM_LIT:31> ; int R_NON_INHERITED = <NUM_LIT:2> ; int R_NO_PROBLEMS = <NUM_LIT:1> ; int R_RESOLVED = <NUM_LIT:1> ; int R_TARGET = <NUM_LIT:5> ; int R_FINAL = <NUM_LIT:3> ; int R_CONSTRUCTOR = <NUM_LIT:3> ; } </s>
|
<s> package org . eclipse . jdt . internal . codeassist ; import java . util . Map ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnAnnotationOfType ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnArgumentName ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnFieldName ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnFieldType ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnImportReference ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnKeyword ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnKeyword2 ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnMethodName ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnMethodReturnType ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnMethodTypeParameter ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnPackageReference ; import org . eclipse . jdt . internal . compiler . SourceElementNotifier ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . QualifiedAllocationExpression ; 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 . util . HashtableOfObjectToInt ; public class CompletionElementNotifier extends SourceElementNotifier { private ASTNode assistNode ; public CompletionElementNotifier ( CompletionUnitStructureRequestor requestor , boolean reportLocalDeclarations , ASTNode assistNode ) { super ( requestor , reportLocalDeclarations ) ; this . assistNode = assistNode ; } protected char [ ] [ ] [ ] getArguments ( Argument [ ] arguments ) { int argumentLength = arguments . length ; char [ ] [ ] argumentTypes = new char [ argumentLength ] [ ] ; char [ ] [ ] argumentNames = new char [ argumentLength ] [ ] ; int argumentCount = <NUM_LIT:0> ; next : for ( int i = <NUM_LIT:0> ; i < argumentLength ; i ++ ) { Argument argument = arguments [ i ] ; if ( argument instanceof CompletionOnArgumentName && argument . name . length == <NUM_LIT:0> ) continue next ; argumentTypes [ argumentCount ] = CharOperation . concatWith ( argument . type . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; argumentNames [ argumentCount ++ ] = argument . name ; } if ( argumentCount < argumentLength ) { System . arraycopy ( argumentTypes , <NUM_LIT:0> , argumentTypes = new char [ argumentCount ] [ ] , <NUM_LIT:0> , argumentCount ) ; System . arraycopy ( argumentNames , <NUM_LIT:0> , argumentNames = new char [ argumentCount ] [ ] , <NUM_LIT:0> , argumentCount ) ; } return 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 ) { int superInterfaceCount = <NUM_LIT:0> ; next : for ( int i = <NUM_LIT:0> ; i < superInterfacesLength ; i ++ ) { TypeReference superInterface = superInterfaces [ i ] ; if ( superInterface instanceof CompletionOnKeyword ) continue next ; if ( CompletionUnitStructureRequestor . hasEmptyName ( superInterface , this . assistNode ) ) continue next ; interfaceNames [ superInterfaceCount ++ ] = CharOperation . concatWith ( superInterface . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; } if ( superInterfaceCount == <NUM_LIT:0> ) return null ; if ( superInterfaceCount < superInterfacesLength ) { System . arraycopy ( interfaceNames , <NUM_LIT:0> , interfaceNames = new char [ superInterfaceCount ] [ ] , <NUM_LIT:0> , superInterfaceCount ) ; } } return interfaceNames ; } protected char [ ] getSuperclassName ( TypeDeclaration typeDeclaration ) { TypeReference superclass = typeDeclaration . superclass ; if ( superclass instanceof CompletionOnKeyword ) return null ; if ( CompletionUnitStructureRequestor . hasEmptyName ( superclass , this . assistNode ) ) return null ; 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 ; int thrownExceptionCount = <NUM_LIT:0> ; thrownExceptionTypes = new char [ thrownExceptionLength ] [ ] ; next : for ( int i = <NUM_LIT:0> ; i < thrownExceptionLength ; i ++ ) { TypeReference thrownException = thrownExceptions [ i ] ; if ( thrownException instanceof CompletionOnKeyword ) continue next ; if ( CompletionUnitStructureRequestor . hasEmptyName ( thrownException , this . assistNode ) ) continue next ; thrownExceptionTypes [ thrownExceptionCount ++ ] = CharOperation . concatWith ( thrownException . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; } if ( thrownExceptionCount == <NUM_LIT:0> ) return null ; if ( thrownExceptionCount < thrownExceptionLength ) { System . arraycopy ( thrownExceptionTypes , <NUM_LIT:0> , thrownExceptionTypes = new char [ thrownExceptionCount ] [ ] , <NUM_LIT:0> , thrownExceptionCount ) ; } } 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> ] [ ] ; int boundCount = <NUM_LIT:0> ; if ( ! CompletionUnitStructureRequestor . hasEmptyName ( firstBound , this . assistNode ) ) { boundNames [ boundCount ++ ] = CharOperation . concatWith ( firstBound . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; } for ( int j = <NUM_LIT:0> ; j < otherBoundsLength ; j ++ ) { TypeReference otherBound = otherBounds [ j ] ; if ( ! CompletionUnitStructureRequestor . hasEmptyName ( otherBound , this . assistNode ) ) { boundNames [ boundCount ++ ] = CharOperation . concatWith ( otherBound . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) ; } } if ( boundCount == <NUM_LIT:0> ) { boundNames = CharOperation . NO_CHAR_CHAR ; } else if ( boundCount < otherBoundsLength + <NUM_LIT:1> ) { System . arraycopy ( boundNames , <NUM_LIT:0> , boundNames = new char [ boundCount ] [ ] , <NUM_LIT:0> , boundCount ) ; } typeParameterBounds = boundNames ; } else { if ( ! CompletionUnitStructureRequestor . hasEmptyName ( firstBound , this . assistNode ) ) { typeParameterBounds = new char [ ] [ ] { CharOperation . concatWith ( firstBound . getParameterizedTypeName ( ) , '<CHAR_LIT:.>' ) } ; } else { typeParameterBounds = CharOperation . NO_CHAR_CHAR ; } } } else { typeParameterBounds = CharOperation . NO_CHAR_CHAR ; } return typeParameterBounds ; } protected void notifySourceElementRequestor ( AbstractMethodDeclaration methodDeclaration , TypeDeclaration declaringType , ImportReference currentPackage ) { if ( methodDeclaration instanceof CompletionOnMethodReturnType ) return ; if ( methodDeclaration instanceof CompletionOnMethodTypeParameter ) return ; if ( methodDeclaration instanceof CompletionOnMethodName ) return ; super . notifySourceElementRequestor ( methodDeclaration , declaringType , currentPackage ) ; } public void notifySourceElementRequestor ( CompilationUnitDeclaration parsedUnit , int sourceStart , int sourceEnd , boolean reportReference , HashtableOfObjectToInt sourceEndsMap , Map nodesToCategoriesMap ) { super . notifySourceElementRequestor ( parsedUnit , sourceStart , sourceEnd , reportReference , sourceEndsMap , nodesToCategoriesMap ) ; } protected void notifySourceElementRequestor ( FieldDeclaration fieldDeclaration , TypeDeclaration declaringType ) { if ( fieldDeclaration instanceof CompletionOnFieldType ) return ; if ( fieldDeclaration instanceof CompletionOnFieldName ) return ; super . notifySourceElementRequestor ( fieldDeclaration , declaringType ) ; } protected void notifySourceElementRequestor ( ImportReference importReference , boolean isPackage ) { if ( importReference instanceof CompletionOnKeyword2 ) return ; if ( importReference instanceof CompletionOnImportReference || importReference instanceof CompletionOnPackageReference ) { if ( importReference . tokens [ importReference . tokens . length - <NUM_LIT:1> ] . length == <NUM_LIT:0> ) return ; } super . notifySourceElementRequestor ( importReference , isPackage ) ; } protected void notifySourceElementRequestor ( TypeDeclaration typeDeclaration , boolean notifyTypePresence , TypeDeclaration declaringType , ImportReference currentPackage ) { if ( typeDeclaration instanceof CompletionOnAnnotationOfType ) return ; super . notifySourceElementRequestor ( typeDeclaration , notifyTypePresence , declaringType , currentPackage ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist ; import java . util . Stack ; import org . eclipse . jdt . internal . compiler . ASTVisitor ; import org . eclipse . jdt . internal . compiler . ast . AllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . Block ; import org . eclipse . jdt . internal . compiler . ast . MessageSend ; import org . eclipse . jdt . internal . compiler . ast . ThrowStatement ; import org . eclipse . jdt . internal . compiler . ast . TryStatement ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . ast . UnionTypeReference ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . CompilationUnitScope ; 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 . util . SimpleSet ; public class ThrownExceptionFinder extends ASTVisitor { private SimpleSet thrownExceptions ; private Stack exceptionsStack ; private SimpleSet caughtExceptions ; private SimpleSet discouragedExceptions ; public void processThrownExceptions ( TryStatement tryStatement , BlockScope scope ) { this . thrownExceptions = new SimpleSet ( ) ; this . exceptionsStack = new Stack ( ) ; this . caughtExceptions = new SimpleSet ( ) ; this . discouragedExceptions = new SimpleSet ( ) ; tryStatement . traverse ( this , scope ) ; removeCaughtExceptions ( tryStatement , true ) ; } private void acceptException ( ReferenceBinding binding ) { if ( binding != null && binding . isValidBinding ( ) ) { this . thrownExceptions . add ( binding ) ; } } public void endVisit ( MessageSend messageSend , BlockScope scope ) { if ( messageSend . binding != null ) { endVisitMethodInvocation ( messageSend . binding ) ; } super . endVisit ( messageSend , scope ) ; } public void endVisit ( AllocationExpression allocationExpression , BlockScope scope ) { if ( allocationExpression . binding != null ) { endVisitMethodInvocation ( allocationExpression . binding ) ; } super . endVisit ( allocationExpression , scope ) ; } public void endVisit ( ThrowStatement throwStatement , BlockScope scope ) { acceptException ( ( ReferenceBinding ) throwStatement . exception . resolvedType ) ; super . endVisit ( throwStatement , scope ) ; } private void endVisitMethodInvocation ( MethodBinding methodBinding ) { ReferenceBinding [ ] thrownExceptionBindings = methodBinding . thrownExceptions ; int length = thrownExceptionBindings == null ? <NUM_LIT:0> : thrownExceptionBindings . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { acceptException ( thrownExceptionBindings [ i ] ) ; } } public ReferenceBinding [ ] getAlreadyCaughtExceptions ( ) { ReferenceBinding [ ] allCaughtExceptions = new ReferenceBinding [ this . caughtExceptions . elementSize ] ; this . caughtExceptions . asArray ( allCaughtExceptions ) ; return allCaughtExceptions ; } public ReferenceBinding [ ] getThrownUncaughtExceptions ( ) { ReferenceBinding [ ] result = new ReferenceBinding [ this . thrownExceptions . elementSize ] ; this . thrownExceptions . asArray ( result ) ; return result ; } public ReferenceBinding [ ] getDiscouragedExceptions ( ) { ReferenceBinding [ ] allDiscouragedExceptions = new ReferenceBinding [ this . discouragedExceptions . elementSize ] ; this . discouragedExceptions . asArray ( allDiscouragedExceptions ) ; return allDiscouragedExceptions ; } public boolean visit ( TypeDeclaration typeDeclaration , CompilationUnitScope scope ) { return visitType ( typeDeclaration ) ; } public boolean visit ( TypeDeclaration memberTypeDeclaration , ClassScope scope ) { return visitType ( memberTypeDeclaration ) ; } public boolean visit ( TypeDeclaration localTypeDeclaration , BlockScope scope ) { return visitType ( localTypeDeclaration ) ; } private boolean visitType ( TypeDeclaration typeDeclaration ) { return false ; } public boolean visit ( TryStatement tryStatement , BlockScope scope ) { this . exceptionsStack . push ( this . thrownExceptions ) ; SimpleSet exceptionSet = new SimpleSet ( ) ; this . thrownExceptions = exceptionSet ; tryStatement . tryBlock . traverse ( this , scope ) ; removeCaughtExceptions ( tryStatement , false ) ; this . thrownExceptions = ( SimpleSet ) this . exceptionsStack . pop ( ) ; Object [ ] values = exceptionSet . values ; for ( int i = <NUM_LIT:0> ; i < values . length ; i ++ ) { if ( values [ i ] != null ) { this . thrownExceptions . add ( values [ i ] ) ; } } Block [ ] catchBlocks = tryStatement . catchBlocks ; int length = catchBlocks == null ? <NUM_LIT:0> : catchBlocks . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { catchBlocks [ i ] . traverse ( this , scope ) ; } return false ; } private void removeCaughtExceptions ( TryStatement tryStatement , boolean recordUncheckedCaughtExceptions ) { Argument [ ] catchArguments = tryStatement . catchArguments ; int length = catchArguments == null ? <NUM_LIT:0> : catchArguments . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( catchArguments [ i ] . type instanceof UnionTypeReference ) { UnionTypeReference unionTypeReference = ( UnionTypeReference ) catchArguments [ i ] . type ; TypeBinding caughtException ; for ( int j = <NUM_LIT:0> ; j < unionTypeReference . typeReferences . length ; j ++ ) { caughtException = unionTypeReference . typeReferences [ j ] . resolvedType ; if ( ( caughtException instanceof ReferenceBinding ) && caughtException . isValidBinding ( ) ) { if ( recordUncheckedCaughtExceptions ) { removeCaughtException ( ( ReferenceBinding ) caughtException ) ; this . caughtExceptions . add ( caughtException ) ; } else { if ( ! caughtException . isUncheckedException ( true ) ) { this . discouragedExceptions . add ( caughtException ) ; } } } } } else { TypeBinding exception = catchArguments [ i ] . type . resolvedType ; if ( ( exception instanceof ReferenceBinding ) && exception . isValidBinding ( ) ) { if ( recordUncheckedCaughtExceptions ) { removeCaughtException ( ( ReferenceBinding ) exception ) ; this . caughtExceptions . add ( exception ) ; } else { if ( ! exception . isUncheckedException ( true ) ) { this . discouragedExceptions . add ( exception ) ; } } } } } } private void removeCaughtException ( ReferenceBinding caughtException ) { Object [ ] exceptions = this . thrownExceptions . values ; for ( int i = <NUM_LIT:0> ; i < exceptions . length ; i ++ ) { ReferenceBinding exception = ( ReferenceBinding ) exceptions [ i ] ; if ( exception != null ) { if ( exception == caughtException ) { this . thrownExceptions . remove ( exception ) ; } else if ( caughtException . isSuperclassOf ( exception ) ) { this . thrownExceptions . remove ( exception ) ; this . discouragedExceptions . add ( exception ) ; } } } } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist ; import java . util . Map ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IMemberValuePair ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnMarkerAnnotationName ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnMemberValueName ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnParameterizedQualifiedTypeReference ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnQualifiedNameReference ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnQualifiedTypeReference ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnSingleNameReference ; import org . eclipse . jdt . internal . codeassist . complete . CompletionOnSingleTypeReference ; import org . eclipse . jdt . internal . codeassist . impl . AssistAnnotation ; import org . eclipse . jdt . internal . codeassist . impl . AssistImportContainer ; import org . eclipse . jdt . internal . codeassist . impl . AssistImportDeclaration ; import org . eclipse . jdt . internal . codeassist . impl . AssistInitializer ; import org . eclipse . jdt . internal . codeassist . impl . AssistPackageDeclaration ; import org . eclipse . jdt . internal . codeassist . impl . AssistSourceField ; import org . eclipse . jdt . internal . codeassist . impl . AssistSourceMethod ; import org . eclipse . jdt . internal . codeassist . impl . AssistSourceType ; import org . eclipse . jdt . internal . codeassist . impl . AssistTypeParameter ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . MemberValuePair ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedSingleTypeReference ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . core . AnnotatableInfo ; import org . eclipse . jdt . internal . core . Annotation ; import org . eclipse . jdt . internal . core . CompilationUnit ; import org . eclipse . jdt . internal . core . CompilationUnitElementInfo ; import org . eclipse . jdt . internal . core . CompilationUnitStructureRequestor ; import org . eclipse . jdt . internal . core . ImportContainer ; import org . eclipse . jdt . internal . core . ImportDeclaration ; import org . eclipse . jdt . internal . core . Initializer ; import org . eclipse . jdt . internal . core . JavaElement ; import org . eclipse . jdt . internal . core . JavaModelManager ; import org . eclipse . jdt . internal . core . PackageDeclaration ; import org . eclipse . jdt . internal . core . SourceField ; import org . eclipse . jdt . internal . core . SourceMethod ; import org . eclipse . jdt . internal . core . SourceType ; import org . eclipse . jdt . internal . core . TypeParameter ; public class CompletionUnitStructureRequestor extends CompilationUnitStructureRequestor { private ASTNode assistNode ; private Map bindingCache ; private Map elementCache ; private Map elementWithProblemCache ; public CompletionUnitStructureRequestor ( ICompilationUnit unit , CompilationUnitElementInfo unitInfo , Parser parser , ASTNode assistNode , Map bindingCache , Map elementCache , Map elementWithProblemCache , Map newElements ) { super ( unit , unitInfo , newElements ) ; this . parser = parser ; this . assistNode = assistNode ; this . bindingCache = bindingCache ; this . elementCache = elementCache ; this . elementWithProblemCache = elementWithProblemCache ; } protected Annotation createAnnotation ( JavaElement parent , String name ) { return new AssistAnnotation ( parent , name , this . newElements ) ; } protected SourceField createField ( JavaElement parent , FieldInfo fieldInfo ) { String fieldName = JavaModelManager . getJavaModelManager ( ) . intern ( new String ( fieldInfo . name ) ) ; AssistSourceField field = new AssistSourceField ( parent , fieldName , this . bindingCache , this . newElements ) ; if ( fieldInfo . node . binding != null ) { this . bindingCache . put ( field , fieldInfo . node . binding ) ; this . elementCache . put ( fieldInfo . node . binding , field ) ; } else { this . elementWithProblemCache . put ( fieldInfo . node , field ) ; } return field ; } protected ImportContainer createImportContainer ( ICompilationUnit parent ) { return new AssistImportContainer ( ( CompilationUnit ) parent , this . newElements ) ; } protected ImportDeclaration createImportDeclaration ( ImportContainer parent , String name , boolean onDemand ) { return new AssistImportDeclaration ( parent , name , onDemand , this . newElements ) ; } protected Initializer createInitializer ( JavaElement parent ) { return new AssistInitializer ( parent , <NUM_LIT:1> , this . bindingCache , this . newElements ) ; } protected SourceMethod createMethodHandle ( JavaElement parent , MethodInfo methodInfo ) { String selector = JavaModelManager . getJavaModelManager ( ) . intern ( new String ( methodInfo . name ) ) ; String [ ] parameterTypeSigs = convertTypeNamesToSigs ( methodInfo . parameterTypes ) ; AssistSourceMethod method = new AssistSourceMethod ( parent , selector , parameterTypeSigs , this . bindingCache , this . newElements ) ; if ( methodInfo . node . binding != null ) { this . bindingCache . put ( method , methodInfo . node . binding ) ; this . elementCache . put ( methodInfo . node . binding , method ) ; } else { this . elementWithProblemCache . put ( methodInfo . node , method ) ; } return method ; } protected PackageDeclaration createPackageDeclaration ( JavaElement parent , String name ) { return new AssistPackageDeclaration ( ( CompilationUnit ) parent , name , this . newElements ) ; } protected SourceType createTypeHandle ( JavaElement parent , TypeInfo typeInfo ) { String nameString = new String ( typeInfo . name ) ; AssistSourceType type = new AssistSourceType ( parent , nameString , this . bindingCache , this . newElements ) ; if ( typeInfo . node . binding != null ) { this . bindingCache . put ( type , typeInfo . node . binding ) ; this . elementCache . put ( typeInfo . node . binding , type ) ; } else { this . elementWithProblemCache . put ( typeInfo . node , type ) ; } return type ; } protected TypeParameter createTypeParameter ( JavaElement parent , String name ) { return new AssistTypeParameter ( parent , name , this . newElements ) ; } protected IAnnotation acceptAnnotation ( org . eclipse . jdt . internal . compiler . ast . Annotation annotation , AnnotatableInfo parentInfo , JavaElement parentHandle ) { if ( annotation instanceof CompletionOnMarkerAnnotationName ) { if ( hasEmptyName ( annotation . type , this . assistNode ) ) { super . acceptAnnotation ( annotation , null , parentHandle ) ; return null ; } } return super . acceptAnnotation ( annotation , parentInfo , parentHandle ) ; } protected Object getMemberValue ( org . eclipse . jdt . internal . core . MemberValuePair memberValuePair , Expression expression ) { if ( expression instanceof CompletionOnSingleNameReference ) { CompletionOnSingleNameReference reference = ( CompletionOnSingleNameReference ) expression ; if ( reference . token . length == <NUM_LIT:0> ) return null ; } else if ( expression instanceof CompletionOnQualifiedNameReference ) { CompletionOnQualifiedNameReference reference = ( CompletionOnQualifiedNameReference ) expression ; if ( reference . tokens [ reference . tokens . length - <NUM_LIT:1> ] . length == <NUM_LIT:0> ) return null ; } return super . getMemberValue ( memberValuePair , expression ) ; } protected IMemberValuePair [ ] getMemberValuePairs ( MemberValuePair [ ] memberValuePairs ) { int membersLength = memberValuePairs . length ; int membersCount = <NUM_LIT:0> ; IMemberValuePair [ ] members = new IMemberValuePair [ membersLength ] ; next : for ( int j = <NUM_LIT:0> ; j < membersLength ; j ++ ) { if ( memberValuePairs [ j ] instanceof CompletionOnMemberValueName ) continue next ; members [ membersCount ++ ] = getMemberValuePair ( memberValuePairs [ j ] ) ; } if ( membersCount > membersLength ) { System . arraycopy ( members , <NUM_LIT:0> , members , <NUM_LIT:0> , membersCount ) ; } return members ; } protected static boolean hasEmptyName ( TypeReference reference , ASTNode assistNode ) { if ( reference == null ) return false ; if ( reference . sourceStart <= assistNode . sourceStart && assistNode . sourceEnd <= reference . sourceEnd ) return false ; if ( reference instanceof CompletionOnSingleTypeReference || reference instanceof CompletionOnQualifiedTypeReference || reference instanceof CompletionOnParameterizedQualifiedTypeReference ) { char [ ] [ ] typeName = reference . getTypeName ( ) ; if ( typeName [ typeName . length - <NUM_LIT:1> ] . length == <NUM_LIT:0> ) return true ; } if ( reference instanceof ParameterizedSingleTypeReference ) { ParameterizedSingleTypeReference parameterizedReference = ( ParameterizedSingleTypeReference ) reference ; TypeReference [ ] typeArguments = parameterizedReference . typeArguments ; if ( typeArguments != null ) { for ( int i = <NUM_LIT:0> ; i < typeArguments . length ; i ++ ) { if ( hasEmptyName ( typeArguments [ i ] , assistNode ) ) return true ; } } } else if ( reference instanceof ParameterizedQualifiedTypeReference ) { ParameterizedQualifiedTypeReference parameterizedReference = ( ParameterizedQualifiedTypeReference ) reference ; TypeReference [ ] [ ] typeArguments = parameterizedReference . typeArguments ; if ( typeArguments != null ) { for ( int i = <NUM_LIT:0> ; i < typeArguments . length ; i ++ ) { if ( typeArguments [ i ] != null ) { for ( int j = <NUM_LIT:0> ; j < typeArguments [ i ] . length ; j ++ ) { if ( hasEmptyName ( typeArguments [ i ] [ j ] , assistNode ) ) return true ; } } } } } return false ; } } </s>
|
<s> package org . eclipse . jdt . internal . codeassist ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . codeassist . complete . CompletionParser ; import org . eclipse . jdt . internal . codeassist . complete . CompletionScanner ; import org . eclipse . jdt . internal . compiler . ASTVisitor ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . Block ; import org . eclipse . jdt . internal . compiler . ast . ConstructorDeclaration ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Initializer ; import org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ; import org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Statement ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; 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 . compiler . util . SimpleSetOfCharArray ; import org . eclipse . jdt . internal . compiler . util . Util ; public class UnresolvedReferenceNameFinder extends ASTVisitor { private static final int MAX_LINE_COUNT = <NUM_LIT:100> ; private static final int FAKE_BLOCKS_COUNT = <NUM_LIT:20> ; public static interface UnresolvedReferenceNameRequestor { public void acceptName ( char [ ] name ) ; } private UnresolvedReferenceNameRequestor requestor ; private CompletionEngine completionEngine ; private CompletionParser parser ; private CompletionScanner completionScanner ; private int parentsPtr ; private ASTNode [ ] parents ; private int potentialVariableNamesPtr ; private char [ ] [ ] potentialVariableNames ; private int [ ] potentialVariableNameStarts ; private SimpleSetOfCharArray acceptedNames = new SimpleSetOfCharArray ( ) ; public UnresolvedReferenceNameFinder ( CompletionEngine completionEngine ) { this . completionEngine = completionEngine ; this . parser = completionEngine . parser ; this . completionScanner = ( CompletionScanner ) this . parser . scanner ; } private void acceptName ( char [ ] name ) { if ( name == null ) return ; if ( ! CharOperation . prefixEquals ( this . completionEngine . completionToken , name , false ) && ! ( this . completionEngine . options . camelCaseMatch && CharOperation . camelCaseMatch ( this . completionEngine . completionToken , name ) ) ) return ; if ( this . acceptedNames . includes ( name ) ) return ; this . acceptedNames . add ( name ) ; this . requestor . acceptName ( name ) ; } public void find ( char [ ] startWith , Initializer initializer , ClassScope scope , int from , char [ ] [ ] discouragedNames , UnresolvedReferenceNameRequestor nameRequestor ) { MethodDeclaration fakeMethod = this . findAfter ( startWith , scope , from , initializer . bodyEnd , MAX_LINE_COUNT , false , discouragedNames , nameRequestor ) ; if ( fakeMethod != null ) fakeMethod . traverse ( this , scope ) ; } public void find ( char [ ] startWith , AbstractMethodDeclaration methodDeclaration , int from , char [ ] [ ] discouragedNames , UnresolvedReferenceNameRequestor nameRequestor ) { MethodDeclaration fakeMethod = this . findAfter ( startWith , methodDeclaration . scope , from , methodDeclaration . bodyEnd , MAX_LINE_COUNT , false , discouragedNames , nameRequestor ) ; if ( fakeMethod != null ) fakeMethod . traverse ( this , methodDeclaration . scope . classScope ( ) ) ; } public void findAfter ( char [ ] startWith , Scope scope , ClassScope classScope , int from , int to , char [ ] [ ] discouragedNames , UnresolvedReferenceNameRequestor nameRequestor ) { MethodDeclaration fakeMethod = this . findAfter ( startWith , scope , from , to , MAX_LINE_COUNT / <NUM_LIT:2> , true , discouragedNames , nameRequestor ) ; if ( fakeMethod != null ) fakeMethod . traverse ( this , classScope ) ; } private MethodDeclaration findAfter ( char [ ] startWith , Scope s , int from , int to , int maxLineCount , boolean outsideEnclosingBlock , char [ ] [ ] discouragedNames , UnresolvedReferenceNameRequestor nameRequestor ) { this . requestor = nameRequestor ; this . completionScanner . cursorLocation = <NUM_LIT:0> ; if ( ! outsideEnclosingBlock ) { this . completionScanner . resetTo ( from + <NUM_LIT:1> , to ) ; this . completionScanner . jumpOverBlock ( ) ; to = this . completionScanner . startPosition - <NUM_LIT:1> ; } int maxEnd = this . completionScanner . getLineEnd ( Util . getLineNumber ( from , this . completionScanner . lineEnds , <NUM_LIT:0> , this . completionScanner . linePtr ) + maxLineCount ) ; int end ; if ( maxEnd < <NUM_LIT:0> ) { end = to ; } else { end = maxEnd < to ? maxEnd : to ; } this . parser . startRecordingIdentifiers ( from , end ) ; MethodDeclaration fakeMethod = this . parser . parseSomeStatements ( from , end , outsideEnclosingBlock ? FAKE_BLOCKS_COUNT : <NUM_LIT:0> , s . compilationUnitScope ( ) . referenceContext ) ; this . parser . stopRecordingIdentifiers ( ) ; if ( ! initPotentialNamesTables ( discouragedNames ) ) return null ; this . parentsPtr = - <NUM_LIT:1> ; this . parents = new ASTNode [ <NUM_LIT:10> ] ; return fakeMethod ; } public void findBefore ( char [ ] startWith , Scope scope , ClassScope classScope , int from , int recordTo , int parseTo , char [ ] [ ] discouragedNames , UnresolvedReferenceNameRequestor nameRequestor ) { MethodDeclaration fakeMethod = this . findBefore ( startWith , scope , from , recordTo , parseTo , MAX_LINE_COUNT / <NUM_LIT:2> , discouragedNames , nameRequestor ) ; if ( fakeMethod != null ) fakeMethod . traverse ( this , classScope ) ; } private MethodDeclaration findBefore ( char [ ] startWith , Scope s , int from , int recordTo , int parseTo , int maxLineCount , char [ ] [ ] discouragedNames , UnresolvedReferenceNameRequestor nameRequestor ) { this . requestor = nameRequestor ; this . completionScanner . cursorLocation = <NUM_LIT:0> ; int minStart = this . completionScanner . getLineStart ( Util . getLineNumber ( recordTo , this . completionScanner . lineEnds , <NUM_LIT:0> , this . completionScanner . linePtr ) - maxLineCount ) ; int start ; int fakeBlocksCount ; if ( minStart <= from ) { start = from ; fakeBlocksCount = <NUM_LIT:0> ; } else { start = minStart ; fakeBlocksCount = FAKE_BLOCKS_COUNT ; } this . parser . startRecordingIdentifiers ( start , recordTo ) ; MethodDeclaration fakeMethod = this . parser . parseSomeStatements ( start , parseTo , fakeBlocksCount , s . compilationUnitScope ( ) . referenceContext ) ; this . parser . stopRecordingIdentifiers ( ) ; if ( ! initPotentialNamesTables ( discouragedNames ) ) return null ; this . parentsPtr = - <NUM_LIT:1> ; this . parents = new ASTNode [ <NUM_LIT:10> ] ; return fakeMethod ; } private boolean initPotentialNamesTables ( char [ ] [ ] discouragedNames ) { char [ ] [ ] pvns = this . parser . potentialVariableNames ; int [ ] pvnss = this . parser . potentialVariableNameStarts ; int pvnsPtr = this . parser . potentialVariableNamesPtr ; if ( pvnsPtr < <NUM_LIT:0> ) return false ; int discouragedNamesCount = discouragedNames == null ? <NUM_LIT:0> : discouragedNames . length ; int j = - <NUM_LIT:1> ; next : for ( int i = <NUM_LIT:0> ; i <= pvnsPtr ; i ++ ) { char [ ] temp = pvns [ i ] ; if ( temp == null ) continue next ; for ( int k = <NUM_LIT:0> ; k < discouragedNamesCount ; k ++ ) { if ( CharOperation . equals ( temp , discouragedNames [ k ] , false ) ) { continue next ; } } pvns [ i ] = null ; pvns [ ++ j ] = temp ; pvnss [ j ] = pvnss [ i ] ; } pvnsPtr = j ; if ( pvnsPtr < <NUM_LIT:0> ) return false ; this . potentialVariableNames = pvns ; this . potentialVariableNameStarts = pvnss ; this . potentialVariableNamesPtr = pvnsPtr ; return true ; } private void popParent ( ) { this . parentsPtr -- ; } private void pushParent ( ASTNode parent ) { int length = this . parents . length ; if ( this . parentsPtr >= length - <NUM_LIT:1> ) { System . arraycopy ( this . parents , <NUM_LIT:0> , this . parents = new ASTNode [ length * <NUM_LIT:2> ] , <NUM_LIT:0> , length ) ; } this . parents [ ++ this . parentsPtr ] = parent ; } private ASTNode getEnclosingDeclaration ( ) { int i = this . parentsPtr ; while ( i > - <NUM_LIT:1> ) { ASTNode parent = this . parents [ i ] ; if ( parent instanceof AbstractMethodDeclaration ) { return parent ; } else if ( parent instanceof Initializer ) { return parent ; } else if ( parent instanceof FieldDeclaration ) { return parent ; } else if ( parent instanceof TypeDeclaration ) { return parent ; } i -- ; } return null ; } public boolean visit ( Block block , BlockScope blockScope ) { ASTNode enclosingDeclaration = getEnclosingDeclaration ( ) ; removeLocals ( block . statements , enclosingDeclaration . sourceStart , block . sourceEnd ) ; pushParent ( block ) ; return true ; } public boolean visit ( ConstructorDeclaration constructorDeclaration , ClassScope classScope ) { if ( ( ( constructorDeclaration . bits & ASTNode . IsDefaultConstructor ) == <NUM_LIT:0> ) && ! constructorDeclaration . isClinit ( ) ) { removeLocals ( constructorDeclaration . arguments , constructorDeclaration . declarationSourceStart , constructorDeclaration . declarationSourceEnd ) ; removeLocals ( constructorDeclaration . statements , constructorDeclaration . declarationSourceStart , constructorDeclaration . declarationSourceEnd ) ; } pushParent ( constructorDeclaration ) ; return true ; } public boolean visit ( FieldDeclaration fieldDeclaration , MethodScope methodScope ) { pushParent ( fieldDeclaration ) ; return true ; } public boolean visit ( Initializer initializer , MethodScope methodScope ) { pushParent ( initializer ) ; return true ; } public boolean visit ( MethodDeclaration methodDeclaration , ClassScope classScope ) { removeLocals ( methodDeclaration . arguments , methodDeclaration . declarationSourceStart , methodDeclaration . declarationSourceEnd ) ; removeLocals ( methodDeclaration . statements , methodDeclaration . declarationSourceStart , methodDeclaration . declarationSourceEnd ) ; pushParent ( methodDeclaration ) ; return true ; } public boolean visit ( TypeDeclaration localTypeDeclaration , BlockScope blockScope ) { removeFields ( localTypeDeclaration ) ; pushParent ( localTypeDeclaration ) ; return true ; } public boolean visit ( TypeDeclaration memberTypeDeclaration , ClassScope classScope ) { removeFields ( memberTypeDeclaration ) ; pushParent ( memberTypeDeclaration ) ; return true ; } public void endVisit ( Block block , BlockScope blockScope ) { popParent ( ) ; } public void endVisit ( Argument argument , BlockScope blockScope ) { endVisitRemoved ( argument . declarationSourceStart , argument . sourceEnd ) ; } public void endVisit ( Argument argument , ClassScope classScope ) { endVisitRemoved ( argument . declarationSourceStart , argument . sourceEnd ) ; } public void endVisit ( ConstructorDeclaration constructorDeclaration , ClassScope classScope ) { if ( ( ( constructorDeclaration . bits & ASTNode . IsDefaultConstructor ) == <NUM_LIT:0> ) && ! constructorDeclaration . isClinit ( ) ) { endVisitPreserved ( constructorDeclaration . bodyStart , constructorDeclaration . bodyEnd ) ; } popParent ( ) ; } public void endVisit ( FieldDeclaration fieldDeclaration , MethodScope methodScope ) { endVisitRemoved ( fieldDeclaration . declarationSourceStart , fieldDeclaration . sourceEnd ) ; endVisitPreserved ( fieldDeclaration . sourceEnd , fieldDeclaration . declarationEnd ) ; popParent ( ) ; } public void endVisit ( Initializer initializer , MethodScope methodScope ) { endVisitPreserved ( initializer . bodyStart , initializer . bodyEnd ) ; popParent ( ) ; } public void endVisit ( LocalDeclaration localDeclaration , BlockScope blockScope ) { endVisitRemoved ( localDeclaration . declarationSourceStart , localDeclaration . sourceEnd ) ; } public void endVisit ( MethodDeclaration methodDeclaration , ClassScope classScope ) { endVisitPreserved ( methodDeclaration . bodyStart , methodDeclaration . bodyEnd ) ; popParent ( ) ; } public void endVisit ( TypeDeclaration typeDeclaration , BlockScope blockScope ) { endVisitRemoved ( typeDeclaration . sourceStart , typeDeclaration . declarationSourceEnd ) ; popParent ( ) ; } public void endVisit ( TypeDeclaration typeDeclaration , ClassScope classScope ) { endVisitRemoved ( typeDeclaration . sourceStart , typeDeclaration . declarationSourceEnd ) ; popParent ( ) ; } private int indexOfFisrtNameAfter ( int position ) { int left = <NUM_LIT:0> ; int right = this . potentialVariableNamesPtr ; next : while ( true ) { if ( right < left ) return - <NUM_LIT:1> ; int mid = left + ( right - left ) / <NUM_LIT:2> ; int midPosition = this . potentialVariableNameStarts [ mid ] ; if ( midPosition < <NUM_LIT:0> ) { int nextMid = indexOfNextName ( mid ) ; if ( nextMid < <NUM_LIT:0> || right < nextMid ) { right = mid - <NUM_LIT:1> ; continue next ; } mid = nextMid ; midPosition = this . potentialVariableNameStarts [ nextMid ] ; if ( mid == right ) { int leftPosition = this . potentialVariableNameStarts [ left ] ; if ( leftPosition < <NUM_LIT:0> || leftPosition < position ) { int nextLeft = indexOfNextName ( left ) ; if ( nextLeft < <NUM_LIT:0> ) return - <NUM_LIT:1> ; left = nextLeft ; continue next ; } return left ; } } if ( left != right ) { if ( midPosition < position ) { left = mid + <NUM_LIT:1> ; } else { right = mid ; } } else { if ( midPosition < position ) { return - <NUM_LIT:1> ; } return mid ; } } } private int indexOfNextName ( int index ) { int nextIndex = index + <NUM_LIT:1> ; while ( nextIndex <= this . potentialVariableNamesPtr && this . potentialVariableNames [ nextIndex ] == null ) { int jumpIndex = - this . potentialVariableNameStarts [ nextIndex ] ; if ( jumpIndex > <NUM_LIT:0> ) { nextIndex = jumpIndex ; } else { nextIndex ++ ; } } if ( this . potentialVariableNamesPtr < nextIndex ) { if ( index < this . potentialVariableNamesPtr ) { this . potentialVariableNamesPtr = index ; } return - <NUM_LIT:1> ; } if ( index + <NUM_LIT:1> < nextIndex ) { this . potentialVariableNameStarts [ index + <NUM_LIT:1> ] = - nextIndex ; } return nextIndex ; } private void removeNameAt ( int index ) { this . potentialVariableNames [ index ] = null ; int nextIndex = indexOfNextName ( index ) ; if ( nextIndex != - <NUM_LIT:1> ) { this . potentialVariableNameStarts [ index ] = - nextIndex ; } else { this . potentialVariableNamesPtr = index - <NUM_LIT:1> ; } } private void endVisitPreserved ( int start , int end ) { int i = indexOfFisrtNameAfter ( start ) ; done : while ( i != - <NUM_LIT:1> ) { int nameStart = this . potentialVariableNameStarts [ i ] ; if ( start < nameStart && nameStart < end ) { acceptName ( this . potentialVariableNames [ i ] ) ; removeNameAt ( i ) ; } if ( end < nameStart ) break done ; i = indexOfNextName ( i ) ; } } private void endVisitRemoved ( int start , int end ) { int i = indexOfFisrtNameAfter ( start ) ; done : while ( i != - <NUM_LIT:1> ) { int nameStart = this . potentialVariableNameStarts [ i ] ; if ( start < nameStart && nameStart < end ) { removeNameAt ( i ) ; } if ( end < nameStart ) break done ; i = indexOfNextName ( i ) ; } } private void removeLocals ( Statement [ ] statements , int start , int end ) { if ( statements != null ) { for ( int i = <NUM_LIT:0> ; i < statements . length ; i ++ ) { if ( statements [ i ] instanceof LocalDeclaration ) { LocalDeclaration localDeclaration = ( LocalDeclaration ) statements [ i ] ; int j = indexOfFisrtNameAfter ( start ) ; done : while ( j != - <NUM_LIT:1> ) { int nameStart = this . potentialVariableNameStarts [ j ] ; if ( start <= nameStart && nameStart <= end ) { if ( CharOperation . equals ( this . potentialVariableNames [ j ] , localDeclaration . name , false ) ) { removeNameAt ( j ) ; } } if ( end < nameStart ) break done ; j = indexOfNextName ( j ) ; } } } } } private void removeFields ( TypeDeclaration typeDeclaration ) { int start = typeDeclaration . declarationSourceStart ; int end = typeDeclaration . declarationSourceEnd ; FieldDeclaration [ ] fieldDeclarations = typeDeclaration . fields ; if ( fieldDeclarations != null ) { for ( int i = <NUM_LIT:0> ; i < fieldDeclarations . length ; i ++ ) { int j = indexOfFisrtNameAfter ( start ) ; done : while ( j != - <NUM_LIT:1> ) { int nameStart = this . potentialVariableNameStarts [ j ] ; if ( start <= nameStart && nameStart <= end ) { if ( CharOperation . equals ( this . potentialVariableNames [ j ] , fieldDeclarations [ i ] . name , false ) ) { removeNameAt ( j ) ; } } if ( end < nameStart ) break done ; j = indexOfNextName ( j ) ; } } } } } </s>
|
<s> package org . codehaus . jdt . groovy . internal ; import org . eclipse . jdt . internal . codeassist . InternalExtendedCompletionContext ; public class SimplifiedExtendedCompletionContext extends InternalExtendedCompletionContext { public SimplifiedExtendedCompletionContext ( ) { super ( null , null , null , null , null , null , null , null , null ) ; } } </s>
|
<s> package org . codehaus . jdt . groovy . integration ; import org . eclipse . jdt . internal . core . JavaProject ; public interface EventHandler { void handle ( JavaProject javaProject , String string ) ; } </s>
|
<s> package org . codehaus . jdt . groovy . integration ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . runtime . Platform ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . core . search . SearchPattern ; import org . eclipse . jdt . core . search . SearchRequestor ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . IProblemFactory ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor ; import org . eclipse . jdt . internal . compiler . SourceElementParser ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . core . BinaryType ; import org . eclipse . jdt . internal . core . CompilationUnit ; import org . eclipse . jdt . internal . core . PackageFragment ; import org . eclipse . jdt . internal . core . search . indexing . IndexingParser ; import org . eclipse . jdt . internal . core . search . matching . ImportMatchLocatorParser ; import org . eclipse . jdt . internal . core . search . matching . MatchLocator ; import org . eclipse . jdt . internal . core . search . matching . MatchLocatorParser ; import org . eclipse . jdt . internal . core . search . matching . PossibleMatch ; import org . eclipse . jdt . internal . core . util . Util ; import org . osgi . framework . Bundle ; public class LanguageSupportFactory { private static LanguageSupport languageSupport ; public static final int CommentRecorderParserVariant = <NUM_LIT:2> ; public static Parser getParser ( Object requestor , CompilerOptions compilerOptions , ProblemReporter problemReporter , boolean parseLiteralExpressionsAsConstants , int variant ) { return getLanguageSupport ( ) . getParser ( requestor , compilerOptions , problemReporter , parseLiteralExpressionsAsConstants , variant ) ; } public static IndexingParser getIndexingParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) { return getLanguageSupport ( ) . getIndexingParser ( requestor , problemFactory , options , reportLocalDeclarations , optimizeStringLiterals , useSourceJavadocParser ) ; } public static SourceElementParser getSourceElementParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) { return getLanguageSupport ( ) . getSourceElementParser ( requestor , problemFactory , options , reportLocalDeclarations , optimizeStringLiterals , useSourceJavadocParser ) ; } public static MatchLocatorParser getMatchLocatorParser ( ProblemReporter problemReporter , MatchLocator locator ) { return getLanguageSupport ( ) . getMatchLocatorParserParser ( problemReporter , locator ) ; } public static ImportMatchLocatorParser getImportMatchLocatorParser ( ProblemReporter problemReporter , MatchLocator locator ) { return getLanguageSupport ( ) . getImportMatchLocatorParserParser ( problemReporter , locator ) ; } public static CompilationUnit newCompilationUnit ( PackageFragment parent , String name , WorkingCopyOwner owner ) { return getLanguageSupport ( ) . newCompilationUnit ( parent , name , owner ) ; } public static CompilationUnitDeclaration newCompilationUnitDeclaration ( ICompilationUnit unit , ProblemReporter problemReporter , CompilationResult compilationResult , int sourceLength ) { return getLanguageSupport ( ) . newCompilationUnitDeclaration ( unit , problemReporter , compilationResult , sourceLength ) ; } public static boolean isInterestingProject ( IProject project ) { return getLanguageSupport ( ) . isInterestingProject ( project ) ; } public static boolean isSourceFile ( String fileName , boolean isInterestingProject ) { return getLanguageSupport ( ) . isSourceFile ( fileName , isInterestingProject ) ; } public static boolean isInterestingSourceFile ( String fileName ) { return getLanguageSupport ( ) . isInterestingSourceFile ( fileName ) ; } public static boolean maybePerformDelegatedSearch ( PossibleMatch possibleMatch , SearchPattern pattern , SearchRequestor requestor ) { return getLanguageSupport ( ) . maybePerformDelegatedSearch ( possibleMatch , pattern , requestor ) ; } public static void filterNonSourceMembers ( BinaryType binaryType ) { getLanguageSupport ( ) . filterNonSourceMembers ( binaryType ) ; } private static LanguageSupport getLanguageSupport ( ) { if ( languageSupport == null ) { languageSupport = tryInstantiate ( "<STR_LIT>" ) ; if ( languageSupport == null ) { languageSupport = new DefaultLanguageSupport ( ) ; } } return languageSupport ; } private static LanguageSupport tryInstantiate ( String className ) { LanguageSupport instance = null ; if ( className != null && className . length ( ) > <NUM_LIT:0> ) { try { int separator = className . indexOf ( '<CHAR_LIT::>' ) ; Bundle bundle = null ; if ( separator == - <NUM_LIT:1> ) { JavaCore javaCore = JavaCore . getJavaCore ( ) ; if ( javaCore == null ) { Class clazz = Class . forName ( className ) ; return ( LanguageSupport ) clazz . newInstance ( ) ; } else { bundle = javaCore . getBundle ( ) ; } } else { String bundleName = className . substring ( <NUM_LIT:0> , separator ) ; className = className . substring ( separator + <NUM_LIT:1> ) ; bundle = Platform . getBundle ( bundleName ) ; } Class c = bundle . loadClass ( className ) ; instance = ( LanguageSupport ) c . newInstance ( ) ; } catch ( ClassNotFoundException e ) { log ( e ) ; } catch ( InstantiationException e ) { log ( e ) ; } catch ( IllegalAccessException e ) { log ( e ) ; } catch ( ClassCastException e ) { log ( e ) ; } } return instance ; } private static void log ( Exception e ) { if ( JavaCore . getPlugin ( ) == null || JavaCore . getPlugin ( ) . getLog ( ) == null ) { System . err . println ( "<STR_LIT>" ) ; e . printStackTrace ( System . err ) ; } else { Util . log ( e , "<STR_LIT>" ) ; } } public static EventHandler getEventHandler ( ) { return getLanguageSupport ( ) . getEventHandler ( ) ; } public static IJavaSearchScope expandSearchScope ( IJavaSearchScope scope , SearchPattern pattern , SearchRequestor requestor ) { return getLanguageSupport ( ) . expandSearchScope ( scope , pattern , requestor ) ; } public static boolean isGroovyLanguageSupportInstalled ( ) { return getLanguageSupport ( ) . getClass ( ) . getName ( ) . endsWith ( "<STR_LIT>" ) ; } } </s>
|
<s> package org . codehaus . jdt . groovy . integration ; import org . eclipse . core . resources . IProject ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . core . search . SearchPattern ; import org . eclipse . jdt . core . search . SearchRequestor ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . IProblemFactory ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor ; import org . eclipse . jdt . internal . compiler . SourceElementParser ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . core . BinaryType ; import org . eclipse . jdt . internal . core . CompilationUnit ; import org . eclipse . jdt . internal . core . JavaProject ; import org . eclipse . jdt . internal . core . PackageFragment ; import org . eclipse . jdt . internal . core . search . indexing . IndexingParser ; import org . eclipse . jdt . internal . core . search . matching . ImportMatchLocatorParser ; import org . eclipse . jdt . internal . core . search . matching . MatchLocator ; import org . eclipse . jdt . internal . core . search . matching . MatchLocatorParser ; import org . eclipse . jdt . internal . core . search . matching . PossibleMatch ; import org . eclipse . jdt . internal . core . util . CommentRecorderParser ; import org . eclipse . jdt . internal . core . util . Util ; class DefaultLanguageSupport implements LanguageSupport { public Parser getParser ( Object requestor , CompilerOptions compilerOptions , ProblemReporter problemReporter , boolean parseLiteralExpressionsAsConstants , int variant ) { if ( variant == <NUM_LIT:1> ) { return new Parser ( problemReporter , parseLiteralExpressionsAsConstants ) ; } else { return new CommentRecorderParser ( problemReporter , parseLiteralExpressionsAsConstants ) ; } } public IndexingParser getIndexingParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) { return new IndexingParser ( requestor , problemFactory , options , reportLocalDeclarations , optimizeStringLiterals , useSourceJavadocParser ) ; } public ImportMatchLocatorParser getImportMatchLocatorParserParser ( ProblemReporter problemReporter , MatchLocator locator ) { return new ImportMatchLocatorParser ( problemReporter , locator ) ; } public SourceElementParser getSourceElementParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) { return new SourceElementParser ( requestor , problemFactory , options , reportLocalDeclarations , optimizeStringLiterals , useSourceJavadocParser ) ; } public MatchLocatorParser getMatchLocatorParserParser ( ProblemReporter problemReporter , MatchLocator locator ) { return new MatchLocatorParser ( problemReporter , locator ) ; } public CompilationUnit newCompilationUnit ( PackageFragment parent , String name , WorkingCopyOwner owner ) { return new CompilationUnit ( parent , name , owner ) ; } public CompilationUnitDeclaration newCompilationUnitDeclaration ( ICompilationUnit unit , ProblemReporter problemReporter , CompilationResult compilationResult , int sourceLength ) { return new CompilationUnitDeclaration ( problemReporter , compilationResult , sourceLength ) ; } public boolean isInterestingProject ( IProject project ) { return true ; } public boolean isSourceFile ( String fileName , boolean isInterestingProject ) { return Util . isJavaLikeFileName ( fileName ) ; } public boolean isInterestingSourceFile ( String fileName ) { return false ; } public boolean maybePerformDelegatedSearch ( PossibleMatch possibleMatch , SearchPattern pattern , SearchRequestor requestor ) { return false ; } public EventHandler getEventHandler ( ) { return DefaultEventHandler . instance ; } static class DefaultEventHandler implements EventHandler { static DefaultEventHandler instance = new DefaultEventHandler ( ) ; private DefaultEventHandler ( ) { } public void handle ( JavaProject javaProject , String string ) { } } public void filterNonSourceMembers ( BinaryType binaryType ) { } public IJavaSearchScope expandSearchScope ( IJavaSearchScope scope , SearchPattern pattern , SearchRequestor requestor ) { return scope ; } } </s>
|
<s> package org . codehaus . jdt . groovy . integration ; import org . eclipse . core . resources . IProject ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . core . search . SearchPattern ; import org . eclipse . jdt . core . search . SearchRequestor ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . IProblemFactory ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor ; import org . eclipse . jdt . internal . compiler . SourceElementParser ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . env . ICompilationUnit ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . core . BinaryType ; import org . eclipse . jdt . internal . core . CompilationUnit ; import org . eclipse . jdt . internal . core . PackageFragment ; import org . eclipse . jdt . internal . core . search . indexing . IndexingParser ; import org . eclipse . jdt . internal . core . search . matching . ImportMatchLocatorParser ; import org . eclipse . jdt . internal . core . search . matching . MatchLocator ; import org . eclipse . jdt . internal . core . search . matching . MatchLocatorParser ; import org . eclipse . jdt . internal . core . search . matching . PossibleMatch ; public interface LanguageSupport { Parser getParser ( Object requestor , CompilerOptions compilerOptions , ProblemReporter problemReporter , boolean parseLiteralExpressionsAsConstants , int variant ) ; IndexingParser getIndexingParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) ; MatchLocatorParser getMatchLocatorParserParser ( ProblemReporter problemReporter , MatchLocator locator ) ; SourceElementParser getSourceElementParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) ; ImportMatchLocatorParser getImportMatchLocatorParserParser ( ProblemReporter problemReporter , MatchLocator locator ) ; CompilationUnit newCompilationUnit ( PackageFragment parent , String name , WorkingCopyOwner owner ) ; CompilationUnitDeclaration newCompilationUnitDeclaration ( ICompilationUnit unit , ProblemReporter problemReporter , CompilationResult compilationResult , int sourceLength ) ; boolean isInterestingProject ( IProject project ) ; boolean isSourceFile ( String fileName , boolean isInterestingProject ) ; boolean isInterestingSourceFile ( String fileName ) ; boolean maybePerformDelegatedSearch ( PossibleMatch possibleMatch , SearchPattern pattern , SearchRequestor requestor ) ; EventHandler getEventHandler ( ) ; void filterNonSourceMembers ( BinaryType binaryType ) ; IJavaSearchScope expandSearchScope ( IJavaSearchScope scope , SearchPattern pattern , SearchRequestor requestor ) ; } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . util . HashMap ; import java . util . Iterator ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaModel ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . core . util . Util ; public class SetVariablesOperation extends ChangeClasspathOperation { String [ ] variableNames ; IPath [ ] variablePaths ; boolean updatePreferences ; public SetVariablesOperation ( String [ ] variableNames , IPath [ ] variablePaths , boolean updatePreferences ) { super ( new IJavaElement [ ] { JavaModelManager . getJavaModelManager ( ) . getJavaModel ( ) } , ! ResourcesPlugin . getWorkspace ( ) . isTreeLocked ( ) ) ; this . variableNames = variableNames ; this . variablePaths = variablePaths ; this . updatePreferences = updatePreferences ; } protected void executeOperation ( ) throws JavaModelException { checkCanceled ( ) ; try { beginTask ( "<STR_LIT>" , <NUM_LIT:1> ) ; if ( JavaModelManager . CP_RESOLVE_VERBOSE ) verbose_set_variables ( ) ; JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; if ( manager . variablePutIfInitializingWithSameValue ( this . variableNames , this . variablePaths ) ) return ; int varLength = this . variableNames . length ; final HashMap affectedProjectClasspaths = new HashMap ( <NUM_LIT:5> ) ; IJavaModel model = getJavaModel ( ) ; int discardCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < varLength ; i ++ ) { String variableName = this . variableNames [ i ] ; IPath oldPath = manager . variableGet ( variableName ) ; if ( oldPath == JavaModelManager . VARIABLE_INITIALIZATION_IN_PROGRESS ) { oldPath = null ; } if ( oldPath != null && oldPath . equals ( this . variablePaths [ i ] ) ) { this . variableNames [ i ] = null ; discardCount ++ ; } } if ( discardCount > <NUM_LIT:0> ) { if ( discardCount == varLength ) return ; int changedLength = varLength - discardCount ; String [ ] changedVariableNames = new String [ changedLength ] ; IPath [ ] changedVariablePaths = new IPath [ changedLength ] ; for ( int i = <NUM_LIT:0> , index = <NUM_LIT:0> ; i < varLength ; i ++ ) { if ( this . variableNames [ i ] != null ) { changedVariableNames [ index ] = this . variableNames [ i ] ; changedVariablePaths [ index ] = this . variablePaths [ i ] ; index ++ ; } } this . variableNames = changedVariableNames ; this . variablePaths = changedVariablePaths ; varLength = changedLength ; } if ( isCanceled ( ) ) return ; IJavaProject [ ] projects = model . getJavaProjects ( ) ; nextProject : for ( int i = <NUM_LIT:0> , projectLength = projects . length ; i < projectLength ; i ++ ) { JavaProject project = ( JavaProject ) projects [ i ] ; IClasspathEntry [ ] classpath = project . getRawClasspath ( ) ; for ( int j = <NUM_LIT:0> , cpLength = classpath . length ; j < cpLength ; j ++ ) { IClasspathEntry entry = classpath [ j ] ; for ( int k = <NUM_LIT:0> ; k < varLength ; k ++ ) { String variableName = this . variableNames [ k ] ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_VARIABLE ) { if ( variableName . equals ( entry . getPath ( ) . segment ( <NUM_LIT:0> ) ) ) { affectedProjectClasspaths . put ( project , project . getResolvedClasspath ( ) ) ; continue nextProject ; } IPath sourcePath , sourceRootPath ; if ( ( ( sourcePath = entry . getSourceAttachmentPath ( ) ) != null && variableName . equals ( sourcePath . segment ( <NUM_LIT:0> ) ) ) || ( ( sourceRootPath = entry . getSourceAttachmentRootPath ( ) ) != null && variableName . equals ( sourceRootPath . segment ( <NUM_LIT:0> ) ) ) ) { affectedProjectClasspaths . put ( project , project . getResolvedClasspath ( ) ) ; continue nextProject ; } } } } } for ( int i = <NUM_LIT:0> ; i < varLength ; i ++ ) { manager . variablePut ( this . variableNames [ i ] , this . variablePaths [ i ] ) ; if ( this . updatePreferences ) manager . variablePreferencesPut ( this . variableNames [ i ] , this . variablePaths [ i ] ) ; } if ( ! affectedProjectClasspaths . isEmpty ( ) ) { String [ ] dbgVariableNames = this . variableNames ; try { Iterator projectsToUpdate = affectedProjectClasspaths . keySet ( ) . iterator ( ) ; while ( projectsToUpdate . hasNext ( ) ) { if ( this . progressMonitor != null && this . progressMonitor . isCanceled ( ) ) return ; JavaProject affectedProject = ( JavaProject ) projectsToUpdate . next ( ) ; if ( JavaModelManager . CP_RESOLVE_VERBOSE_ADVANCED ) verbose_update_project ( dbgVariableNames , affectedProject ) ; ClasspathChange classpathChange = affectedProject . getPerProjectInfo ( ) . resetResolvedClasspath ( ) ; classpathChanged ( classpathChange , true ) ; if ( this . canChangeResources ) { affectedProject . getProject ( ) . touch ( this . progressMonitor ) ; } } } catch ( CoreException e ) { if ( JavaModelManager . CP_RESOLVE_VERBOSE || JavaModelManager . CP_RESOLVE_VERBOSE_FAILURE ) { verbose_failure ( dbgVariableNames ) ; e . printStackTrace ( ) ; } if ( e instanceof JavaModelException ) { throw ( JavaModelException ) e ; } else { throw new JavaModelException ( e ) ; } } } } finally { done ( ) ; } } private void verbose_failure ( String [ ] dbgVariableNames ) { Util . verbose ( "<STR_LIT>" + "<STR_LIT>" + org . eclipse . jdt . internal . compiler . util . Util . toString ( dbgVariableNames ) , System . err ) ; } private void verbose_update_project ( String [ ] dbgVariableNames , JavaProject affectedProject ) { Util . verbose ( "<STR_LIT>" + "<STR_LIT>" + affectedProject . getElementName ( ) + '<STR_LIT:\n>' + "<STR_LIT>" + org . eclipse . jdt . internal . compiler . util . Util . toString ( dbgVariableNames ) ) ; } private void verbose_set_variables ( ) { Util . verbose ( "<STR_LIT>" + "<STR_LIT>" + org . eclipse . jdt . internal . compiler . util . Util . toString ( this . variableNames ) + '<STR_LIT:\n>' + "<STR_LIT>" + org . eclipse . jdt . internal . compiler . util . Util . toString ( this . variablePaths ) ) ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . Flags ; import org . eclipse . jdt . core . IField ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . ITypeParameter ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . AnnotationMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ConstructorDeclaration ; import org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . lookup . ExtraCompilerModifiers ; import org . eclipse . jdt . internal . compiler . parser . TypeConverter ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . core . util . HashSetOfCharArrayArray ; import org . eclipse . jdt . internal . core . util . Util ; public class BinaryTypeConverter extends TypeConverter { private CompilationResult compilationResult ; private HashSetOfCharArrayArray typeNames ; public BinaryTypeConverter ( ProblemReporter problemReporter , CompilationResult compilationResult , HashSetOfCharArrayArray typeNames ) { super ( problemReporter , Signature . C_DOLLAR ) ; this . compilationResult = compilationResult ; this . typeNames = typeNames ; } public ImportReference [ ] buildImports ( ClassFileReader reader ) { int [ ] constantPoolOffsets = reader . getConstantPoolOffsets ( ) ; int constantPoolCount = constantPoolOffsets . length ; for ( int i = <NUM_LIT:0> ; i < constantPoolCount ; i ++ ) { int tag = reader . u1At ( constantPoolOffsets [ i ] ) ; char [ ] name = null ; switch ( tag ) { case ClassFileConstants . MethodRefTag : case ClassFileConstants . InterfaceMethodRefTag : int constantPoolIndex = reader . u2At ( constantPoolOffsets [ i ] + <NUM_LIT:3> ) ; int utf8Offset = constantPoolOffsets [ reader . u2At ( constantPoolOffsets [ constantPoolIndex ] + <NUM_LIT:3> ) ] ; name = reader . utf8At ( utf8Offset + <NUM_LIT:3> , reader . u2At ( utf8Offset + <NUM_LIT:1> ) ) ; break ; case ClassFileConstants . ClassTag : utf8Offset = constantPoolOffsets [ reader . u2At ( constantPoolOffsets [ i ] + <NUM_LIT:1> ) ] ; name = reader . utf8At ( utf8Offset + <NUM_LIT:3> , reader . u2At ( utf8Offset + <NUM_LIT:1> ) ) ; break ; } if ( name == null || ( name . length > <NUM_LIT:0> && name [ <NUM_LIT:0> ] == '<CHAR_LIT:[>' ) ) break ; this . typeNames . add ( CharOperation . splitOn ( '<CHAR_LIT:/>' , name ) ) ; } int typeNamesLength = this . typeNames . size ( ) ; ImportReference [ ] imports = new ImportReference [ typeNamesLength ] ; char [ ] [ ] [ ] set = this . typeNames . set ; int index = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , length = set . length ; i < length ; i ++ ) { char [ ] [ ] typeName = set [ i ] ; if ( typeName != null ) { imports [ index ++ ] = new ImportReference ( typeName , new long [ typeName . length ] , false , <NUM_LIT:0> ) ; } } return imports ; } public TypeDeclaration buildTypeDeclaration ( IType type , CompilationUnitDeclaration compilationUnit ) throws JavaModelException { PackageFragment pkg = ( PackageFragment ) type . getPackageFragment ( ) ; char [ ] [ ] packageName = Util . toCharArrays ( pkg . names ) ; if ( packageName . length > <NUM_LIT:0> ) { compilationUnit . currentPackage = new ImportReference ( packageName , new long [ ] { <NUM_LIT:0> } , false , ClassFileConstants . AccDefault ) ; } TypeDeclaration typeDeclaration = convert ( type , null , null ) ; IType alreadyComputedMember = type ; IType parent = type . getDeclaringType ( ) ; TypeDeclaration previousDeclaration = typeDeclaration ; while ( parent != null ) { TypeDeclaration declaration = convert ( parent , alreadyComputedMember , previousDeclaration ) ; alreadyComputedMember = parent ; previousDeclaration = declaration ; parent = parent . getDeclaringType ( ) ; } compilationUnit . types = new TypeDeclaration [ ] { previousDeclaration } ; return typeDeclaration ; } private FieldDeclaration convert ( IField field , IType type ) throws JavaModelException { TypeReference typeReference = createTypeReference ( field . getTypeSignature ( ) ) ; if ( typeReference == null ) return null ; FieldDeclaration fieldDeclaration = new FieldDeclaration ( ) ; fieldDeclaration . name = field . getElementName ( ) . toCharArray ( ) ; fieldDeclaration . type = typeReference ; fieldDeclaration . modifiers = field . getFlags ( ) ; return fieldDeclaration ; } private AbstractMethodDeclaration convert ( IMethod method , IType type ) throws JavaModelException { AbstractMethodDeclaration methodDeclaration ; org . eclipse . jdt . internal . compiler . ast . TypeParameter [ ] typeParams = null ; if ( this . has1_5Compliance ) { ITypeParameter [ ] typeParameters = method . getTypeParameters ( ) ; if ( typeParameters != null && typeParameters . length > <NUM_LIT:0> ) { int parameterCount = typeParameters . length ; typeParams = new org . eclipse . jdt . internal . compiler . ast . TypeParameter [ parameterCount ] ; for ( int i = <NUM_LIT:0> ; i < parameterCount ; i ++ ) { ITypeParameter typeParameter = typeParameters [ i ] ; typeParams [ i ] = createTypeParameter ( typeParameter . getElementName ( ) . toCharArray ( ) , stringArrayToCharArray ( typeParameter . getBounds ( ) ) , <NUM_LIT:0> , <NUM_LIT:0> ) ; } } } if ( method . isConstructor ( ) ) { ConstructorDeclaration decl = new ConstructorDeclaration ( this . compilationResult ) ; decl . bits &= ~ ASTNode . IsDefaultConstructor ; decl . typeParameters = typeParams ; methodDeclaration = decl ; } else { MethodDeclaration decl = type . isAnnotation ( ) ? new AnnotationMethodDeclaration ( this . compilationResult ) : new MethodDeclaration ( this . compilationResult ) ; TypeReference typeReference = createTypeReference ( method . getReturnType ( ) ) ; if ( typeReference == null ) return null ; decl . returnType = typeReference ; decl . typeParameters = typeParams ; methodDeclaration = decl ; } methodDeclaration . selector = method . getElementName ( ) . toCharArray ( ) ; int flags = method . getFlags ( ) ; boolean isVarargs = Flags . isVarargs ( flags ) ; methodDeclaration . modifiers = flags & ~ Flags . AccVarargs ; String [ ] argumentTypeNames = method . getParameterTypes ( ) ; String [ ] argumentNames = method . getParameterNames ( ) ; int argumentCount = argumentTypeNames == null ? <NUM_LIT:0> : argumentTypeNames . length ; int startIndex = ( method . isConstructor ( ) && type . isMember ( ) && ! Flags . isStatic ( type . getFlags ( ) ) ) ? <NUM_LIT:1> : <NUM_LIT:0> ; argumentCount -= startIndex ; methodDeclaration . arguments = new Argument [ argumentCount ] ; for ( int i = <NUM_LIT:0> ; i < argumentCount ; i ++ ) { String argumentTypeName = argumentTypeNames [ startIndex + i ] ; TypeReference typeReference = createTypeReference ( argumentTypeName ) ; if ( typeReference == null ) return null ; if ( isVarargs && i == argumentCount - <NUM_LIT:1> ) { typeReference . bits |= ASTNode . IsVarArgs ; } methodDeclaration . arguments [ i ] = new Argument ( argumentNames [ i ] . toCharArray ( ) , <NUM_LIT:0> , typeReference , ClassFileConstants . AccDefault ) ; } String [ ] exceptionTypeNames = method . getExceptionTypes ( ) ; int exceptionCount = exceptionTypeNames == null ? <NUM_LIT:0> : exceptionTypeNames . length ; if ( exceptionCount > <NUM_LIT:0> ) { methodDeclaration . thrownExceptions = new TypeReference [ exceptionCount ] ; for ( int i = <NUM_LIT:0> ; i < exceptionCount ; i ++ ) { TypeReference typeReference = createTypeReference ( exceptionTypeNames [ i ] ) ; if ( typeReference == null ) return null ; methodDeclaration . thrownExceptions [ i ] = typeReference ; } } return methodDeclaration ; } private TypeDeclaration convert ( IType type , IType alreadyComputedMember , TypeDeclaration alreadyComputedMemberDeclaration ) throws JavaModelException { TypeDeclaration typeDeclaration = new TypeDeclaration ( this . compilationResult ) ; if ( type . getDeclaringType ( ) != null ) { typeDeclaration . bits |= ASTNode . IsMemberType ; } typeDeclaration . name = type . getElementName ( ) . toCharArray ( ) ; typeDeclaration . modifiers = type . getFlags ( ) ; if ( type . getSuperclassName ( ) != null ) { TypeReference typeReference = createTypeReference ( type . getSuperclassTypeSignature ( ) ) ; if ( typeReference != null ) { typeDeclaration . superclass = typeReference ; typeDeclaration . superclass . bits |= ASTNode . IsSuperType ; } } String [ ] interfaceTypes = type . getSuperInterfaceTypeSignatures ( ) ; int interfaceCount = interfaceTypes == null ? <NUM_LIT:0> : interfaceTypes . length ; typeDeclaration . superInterfaces = new TypeReference [ interfaceCount ] ; int count = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < interfaceCount ; i ++ ) { TypeReference typeReference = createTypeReference ( interfaceTypes [ i ] ) ; if ( typeReference != null ) { typeDeclaration . superInterfaces [ count ] = typeReference ; typeDeclaration . superInterfaces [ count ++ ] . bits |= ASTNode . IsSuperType ; } } if ( count != interfaceCount ) { System . arraycopy ( typeDeclaration . fields , <NUM_LIT:0> , typeDeclaration . superInterfaces = new TypeReference [ interfaceCount ] , <NUM_LIT:0> , interfaceCount ) ; } if ( this . has1_5Compliance ) { ITypeParameter [ ] typeParameters = type . getTypeParameters ( ) ; if ( typeParameters != null && typeParameters . length > <NUM_LIT:0> ) { int parameterCount = typeParameters . length ; org . eclipse . jdt . internal . compiler . ast . TypeParameter [ ] typeParams = new org . eclipse . jdt . internal . compiler . ast . TypeParameter [ parameterCount ] ; for ( int i = <NUM_LIT:0> ; i < parameterCount ; i ++ ) { ITypeParameter typeParameter = typeParameters [ i ] ; typeParams [ i ] = createTypeParameter ( typeParameter . getElementName ( ) . toCharArray ( ) , stringArrayToCharArray ( typeParameter . getBounds ( ) ) , <NUM_LIT:0> , <NUM_LIT:0> ) ; } typeDeclaration . typeParameters = typeParams ; } } IType [ ] memberTypes = type . getTypes ( ) ; int memberTypeCount = memberTypes == null ? <NUM_LIT:0> : memberTypes . length ; typeDeclaration . memberTypes = new TypeDeclaration [ memberTypeCount ] ; for ( int i = <NUM_LIT:0> ; i < memberTypeCount ; i ++ ) { if ( alreadyComputedMember != null && alreadyComputedMember . getFullyQualifiedName ( ) . equals ( memberTypes [ i ] . getFullyQualifiedName ( ) ) ) { typeDeclaration . memberTypes [ i ] = alreadyComputedMemberDeclaration ; } else { typeDeclaration . memberTypes [ i ] = convert ( memberTypes [ i ] , null , null ) ; } typeDeclaration . memberTypes [ i ] . enclosingType = typeDeclaration ; } IField [ ] fields = type . getFields ( ) ; int fieldCount = fields == null ? <NUM_LIT:0> : fields . length ; typeDeclaration . fields = new FieldDeclaration [ fieldCount ] ; count = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < fieldCount ; i ++ ) { FieldDeclaration fieldDeclaration = convert ( fields [ i ] , type ) ; if ( fieldDeclaration != null ) { typeDeclaration . fields [ count ++ ] = fieldDeclaration ; } } if ( count != fieldCount ) { System . arraycopy ( typeDeclaration . fields , <NUM_LIT:0> , typeDeclaration . fields = new FieldDeclaration [ count ] , <NUM_LIT:0> , count ) ; } IMethod [ ] methods = type . getMethods ( ) ; int methodCount = methods == null ? <NUM_LIT:0> : methods . length ; int neededCount = <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < methodCount ; i ++ ) { if ( methods [ i ] . isConstructor ( ) ) { neededCount = <NUM_LIT:0> ; break ; } } boolean isInterface = type . isInterface ( ) ; neededCount = isInterface ? <NUM_LIT:0> : neededCount ; typeDeclaration . methods = new AbstractMethodDeclaration [ methodCount + neededCount ] ; if ( neededCount != <NUM_LIT:0> ) { typeDeclaration . methods [ <NUM_LIT:0> ] = typeDeclaration . createDefaultConstructor ( false , false ) ; } boolean hasAbstractMethods = false ; count = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < methodCount ; i ++ ) { AbstractMethodDeclaration method = convert ( methods [ i ] , type ) ; if ( method != null ) { boolean isAbstract ; if ( ( isAbstract = method . isAbstract ( ) ) || isInterface ) { method . modifiers |= ExtraCompilerModifiers . AccSemicolonBody ; } if ( isAbstract ) { hasAbstractMethods = true ; } typeDeclaration . methods [ neededCount + ( count ++ ) ] = method ; } } if ( count != methodCount ) { System . arraycopy ( typeDeclaration . methods , <NUM_LIT:0> , typeDeclaration . methods = new AbstractMethodDeclaration [ count + neededCount ] , <NUM_LIT:0> , count + neededCount ) ; } if ( hasAbstractMethods ) { typeDeclaration . bits |= ASTNode . HasAbstractMethods ; } return typeDeclaration ; } private static char [ ] [ ] stringArrayToCharArray ( String [ ] strings ) { if ( strings == null ) return null ; int length = strings . length ; if ( length == <NUM_LIT:0> ) return CharOperation . NO_CHAR_CHAR ; char [ ] [ ] result = new char [ length ] [ ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { result [ i ] = strings [ i ] . toCharArray ( ) ; } return result ; } private TypeReference createTypeReference ( String typeSignature ) { TypeReference result = createTypeReference ( typeSignature , <NUM_LIT:0> , <NUM_LIT:0> ) ; if ( this . typeNames != null && result instanceof QualifiedTypeReference ) { this . typeNames . add ( ( ( QualifiedTypeReference ) result ) . tokens ) ; } return result ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . IContainer ; import org . eclipse . core . resources . IResource ; import org . eclipse . jdt . core . JavaModelException ; class PackageFragmentInfo extends OpenableElementInfo { protected Object [ ] nonJavaResources ; public PackageFragmentInfo ( ) { this . nonJavaResources = null ; } boolean containsJavaResources ( ) { return this . children . length != <NUM_LIT:0> ; } Object [ ] getNonJavaResources ( IResource underlyingResource , PackageFragmentRoot rootHandle ) { if ( this . nonJavaResources == null ) { try { this . nonJavaResources = PackageFragmentRootInfo . computeFolderNonJavaResources ( rootHandle , ( IContainer ) underlyingResource , rootHandle . fullInclusionPatternChars ( ) , rootHandle . fullExclusionPatternChars ( ) ) ; } catch ( JavaModelException e ) { this . nonJavaResources = NO_NON_JAVA_RESOURCES ; } } return this . nonJavaResources ; } void setNonJavaResources ( Object [ ] resources ) { this . nonJavaResources = resources ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import java . io . ByteArrayInputStream ; import java . io . InputStream ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . jdt . core . IJarEntryResource ; public class JarEntryDirectory extends JarEntryResource { private IJarEntryResource [ ] children ; public JarEntryDirectory ( String simpleName ) { super ( simpleName ) ; } public JarEntryResource clone ( Object newParent ) { JarEntryDirectory dir = new JarEntryDirectory ( this . simpleName ) ; dir . setParent ( newParent ) ; int length = this . children . length ; if ( length > <NUM_LIT:0> ) { IJarEntryResource [ ] newChildren = new IJarEntryResource [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { JarEntryResource child = ( JarEntryResource ) this . children [ i ] ; newChildren [ i ] = child . clone ( dir ) ; } dir . setChildren ( newChildren ) ; } return dir ; } public IJarEntryResource [ ] getChildren ( ) { return this . children ; } public InputStream getContents ( ) throws CoreException { return new ByteArrayInputStream ( new byte [ <NUM_LIT:0> ] ) ; } public boolean isFile ( ) { return false ; } public void setChildren ( IJarEntryResource [ ] children ) { this . children = children ; } public String toString ( ) { return "<STR_LIT>" + getEntryName ( ) + "<STR_LIT:]>" ; } } </s>
|
<s> package org . eclipse . jdt . internal . core ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . internal . core . util . Messages ; public class CopyPackageFragmentRootOperation extends JavaModelOperation { IPath destination ; int updateResourceFlags ; int updateModelFlags ; IClasspathEntry sibling ; public CopyPackageFragmentRootOperation ( IPackageFragmentRoot root , IPath destination , int updateResourceFlags , int updateModelFlags , IClasspathEntry sibling ) { super ( root ) ; this . destination = destination ; this . updateResourceFlags = updateResourceFlags ; this . updateModelFlags = updateModelFlags ; this . sibling = sibling ; } protected void executeOperation ( ) throws JavaModelException { IPackageFragmentRoot root = ( IPackageFragmentRoot ) getElementToProcess ( ) ; IClasspathEntry rootEntry = root . getRawClasspathEntry ( ) ; IWorkspaceRoot workspaceRoot = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ; if ( ! root . isExternal ( ) && ( this . updateModelFlags & IPackageFragmentRoot . NO_RESOURCE_MODIFICATION ) == <NUM_LIT:0> ) { copyResource ( root , rootEntry , workspaceRoot ) ; } if ( ( this . updateModelFlags & IPackageFragmentRoot . DESTINATION_PROJECT_CLASSPATH ) != <NUM_LIT:0> ) { addEntryToClasspath ( rootEntry , workspaceRoot ) ; } } protected void copyResource ( IPackageFragmentRoot root , IClasspathEntry rootEntry , final IWorkspaceRoot workspaceRoot ) throws JavaModelException { final char [ ] [ ] exclusionPatterns = ( ( ClasspathEntry ) rootEntry ) . fullExclusionPatternChars ( ) ; IResource rootResource = ( ( JavaElement ) root ) . resource ( ) ; if ( root . getKind ( ) == IPackageFragmentRoot . K_BINARY || exclusionPatterns == null ) { try { IResource destRes ; if ( ( this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> ) { if ( rootEntry . getPath ( ) . equals ( this . destination ) ) return ; if ( ( destRes = workspaceRoot . findMember ( this . destination ) ) != null ) { destRes . delete ( this . updateResourceFlags , this . progressMonitor ) ; } } rootResource . copy ( this . destination , this . updateResourceFlags , this . progressMonitor ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } else { final int sourceSegmentCount = rootEntry . getPath ( ) . segmentCount ( ) ; final IFolder destFolder = workspaceRoot . getFolder ( this . destination ) ; final IPath [ ] nestedFolders = getNestedFolders ( root ) ; IResourceProxyVisitor visitor = new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) throws CoreException { if ( proxy . getType ( ) == IResource . FOLDER ) { IPath path = proxy . requestFullPath ( ) ; if ( prefixesOneOf ( path , nestedFolders ) ) { if ( equalsOneOf ( path , nestedFolders ) ) { return false ; } else { IFolder folder = destFolder . getFolder ( path . removeFirstSegments ( sourceSegmentCount ) ) ; if ( ( CopyPackageFragmentRootOperation . this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> && folder . exists ( ) ) { return true ; } folder . create ( CopyPackageFragmentRootOperation . this . updateResourceFlags , true , CopyPackageFragmentRootOperation . this . progressMonitor ) ; return true ; } } else { IPath destPath = CopyPackageFragmentRootOperation . this . destination . append ( path . removeFirstSegments ( sourceSegmentCount ) ) ; IResource destRes ; if ( ( CopyPackageFragmentRootOperation . this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> && ( destRes = workspaceRoot . findMember ( destPath ) ) != null ) { destRes . delete ( CopyPackageFragmentRootOperation . this . updateResourceFlags , CopyPackageFragmentRootOperation . this . progressMonitor ) ; } proxy . requestResource ( ) . copy ( destPath , CopyPackageFragmentRootOperation . this . updateResourceFlags , CopyPackageFragmentRootOperation . this . progressMonitor ) ; return false ; } } else { IPath path = proxy . requestFullPath ( ) ; IPath destPath = CopyPackageFragmentRootOperation . this . destination . append ( path . removeFirstSegments ( sourceSegmentCount ) ) ; IResource destRes ; if ( ( CopyPackageFragmentRootOperation . this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> && ( destRes = workspaceRoot . findMember ( destPath ) ) != null ) { destRes . delete ( CopyPackageFragmentRootOperation . this . updateResourceFlags , CopyPackageFragmentRootOperation . this . progressMonitor ) ; } proxy . requestResource ( ) . copy ( destPath , CopyPackageFragmentRootOperation . this . updateResourceFlags , CopyPackageFragmentRootOperation . this . progressMonitor ) ; return false ; } } } ; try { rootResource . accept ( visitor , IResource . NONE ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } setAttribute ( HAS_MODIFIED_RESOURCE_ATTR , TRUE ) ; } protected void addEntryToClasspath ( IClasspathEntry rootEntry , IWorkspaceRoot workspaceRoot ) throws JavaModelException { IProject destProject = workspaceRoot . getProject ( this . destination . segment ( <NUM_LIT:0> ) ) ; IJavaProject jProject = JavaCore . create ( destProject ) ; IClasspathEntry [ ] classpath = jProject . getRawClasspath ( ) ; int length = classpath . length ; IClasspathEntry [ ] newClasspath ; if ( ( this . updateModelFlags & IPackageFragmentRoot . REPLACE ) != <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( this . destination . equals ( classpath [ i ] . getPath ( ) ) ) { newClasspath = new IClasspathEntry [ length ] ; System . arraycopy ( classpath , <NUM_LIT:0> , newClasspath , <NUM_LIT:0> , length ) ; newClasspath [ i ] = copy ( rootEntry ) ; jProject . setRawClasspath ( newClasspath , this . progressMonitor ) ; return ; } } } int position ; if ( this . sibling == null ) { position = length ; } else { position = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( this . sibling . equals ( classpath [ i ] ) ) { position = i ; break ; } } } if ( position == - <NUM_LIT:1> ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INVALID_SIBLING , this . sibling . toString ( ) ) ) ; } newClasspath = new IClasspathEntry [ length + <NUM_LIT:1> ] ; if ( position != <NUM_LIT:0> ) { System . arraycopy ( classpath , <NUM_LIT:0> , newClasspath , <NUM_LIT:0> , position ) ; } if ( position != length ) { System . arraycopy ( classpath , position , newClasspath , position + <NUM_LIT:1> , length - position ) ; } IClasspathEntry newEntry = copy ( rootEntry ) ; newClasspath [ position ] = newEntry ; jProject . setRawClasspath ( newClasspath , this . progressMonitor ) ; } protected IClasspathEntry copy ( IClasspathEntry entry ) throws JavaModelException { switch ( entry . getEntryKind ( ) ) { case IClasspathEntry . CPE_CONTAINER : return JavaCore . newContainerEntry ( entry . getPath ( ) , entry . getAccessRules ( ) , entry . getExtraAttributes ( ) , entry . isExported ( ) ) ; case IClasspathEntry . CPE_LIBRARY : try { return JavaCore . newLibraryEntry ( this . destination , entry . getSourceAttachmentPath ( ) , entry . getSourceAttachmentRootPath ( ) , entry . getAccessRules ( ) , entry . getExtraAttributes ( ) , entry . isExported ( ) ) ; } catch ( ClasspathEntry . AssertionFailedException e ) { IJavaModelStatus status = new JavaModelStatus ( IJavaModelStatusConstants . INVALID_PATH , e . getMessage ( ) ) ; throw new JavaModelException ( status ) ; } case IClasspathEntry . CPE_PROJECT : return JavaCore . newProjectEntry ( entry . getPath ( ) , entry . getAccessRules ( ) , entry . combineAccessRules ( ) , entry . getExtraAttributes ( ) , entry . isExported ( ) ) ; case IClasspathEntry . CPE_SOURCE : return JavaCore . newSourceEntry ( this . destination , entry . getInclusionPatterns ( ) , entry . getExclusionPatterns ( ) , entry . getOutputLocation ( ) , entry . getExtraAttributes ( ) ) ; case IClasspathEntry . CPE_VARIABLE : try { return JavaCore . newVariableEntry ( entry . getPath ( ) , entry . getSourceAttachmentPath ( ) , entry . getSourceAttachmentRootPath ( ) , entry . getAccessRules ( ) , entry . getExtraAttributes ( ) , entry . isExported ( ) ) ; } catch ( ClasspathEntry . AssertionFailedException e ) { IJavaModelStatus status = new JavaModelStatus ( IJavaModelStatusConstants . INVALID_PATH , e . getMessage ( ) ) ; throw new JavaModelException ( status ) ; } default : throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST , getElementToProcess ( ) ) ) ; } } public IJavaModelStatus verify ( ) { IJavaModelStatus status = super . verify ( ) ; if ( ! status . isOK ( ) ) { return status ; } PackageFragmentRoot root = ( PackageFragmentRoot ) getElementToProcess ( ) ; if ( root == null || ! root . exists ( ) ) { return new JavaModelStatus ( IJavaModelStatusConstants . ELEMENT_DOES_NOT_EXIST , root ) ; } IResource resource = root . resource ( ) ; if ( resource instanceof IFolder ) { if ( resource . isLinked ( ) ) { return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_RESOURCE , root ) ; } } if ( ( this . updateModelFlags & IPackageFragmentRoot . DESTINATION_PROJECT_CLASSPATH ) != <NUM_LIT:0> ) { String destProjectName = this . destination . segment ( <NUM_LIT:0> ) ; IProject project = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getProject ( destProjectName ) ; if ( JavaProject . hasJavaNature ( project ) ) { try { IJavaProject destProject = JavaCore . create ( project ) ; IClasspathEntry [ ] destClasspath = destProject . getRawClasspath ( ) ; boolean foundSibling = false ; boolean foundExistingEntry = false ; for ( int i = <NUM_LIT:0> , length = destClasspath . length ; i < length ; i ++ ) { IClasspathEntry entry = destClasspath [ i ] ; if ( entry . equals ( this . sibling ) ) { foundSibling = true ; break ; } if ( entry . getPath ( ) . equals ( this . destination ) ) { foundExistingEntry = true ; } } if ( this . sibling != null && ! foundSibling ) { return new JavaModelStatus ( IJavaModelStatusConstants . INVALID_SIBLING , this . sibling . toString ( ) ) ; } if ( foundExistingEntry && ( this . updateModelFlags & IPackageFragmentRoot . REPLACE ) == <NUM_LIT:0> ) { return new JavaModelStatus ( IJavaModelStatusConstants . NAME_COLLISION , Messages . bind ( Messages . status_nameCollision , new String [ ] { this . destination . toString ( ) } ) ) ; } } catch ( JavaModelException e ) { return e . getJavaModelStatus ( ) ; } } } return JavaModelStatus . VERIFIED_OK ; } } </s>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.