Class Scanner
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.compiler.parser.Scanner
- Direct Known Subclasses:
CompletionScanner,JavadocScanner,RecoveryScanner,SelectionScanner
IMPORTANT NOTE: Internal Scanner implementation. It is mirrored in
org.eclipse.jdt.core.compiler public package where it is API.
The mirror implementation is using the backward compatible ITerminalSymbols constant
definitions (stable with 2.0), whereas the internal implementation uses TerminalToken
which constant values reflect the latest parser generation state.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final intbooleanbooleanstatic intboolean[]intint[]int[]int[]longbooleanstatic final intcharintbooleanstatic final Stringintbooleanintchar[][]int[][]char[][]char[][]static final intstatic final intstatic final char[]static final Stringintprotected booleanbooleanstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringbooleanintprotected intint[]intstatic final intstatic final intprotected TerminalTokenprotected intstatic final Stringbooleanprotected intbooleanbooleanstatic final intprotected org.aspectj.org.eclipse.jdt.internal.compiler.parser.Scanner.ScanContextbooleanbooleanbooleanchar[]longstatic final intintstatic final charstatic final intstatic final char[]static final intchar[][]char[][]booleanbooleanstatic final Stringbooleanstatic final Stringstatic final Stringstatic final Stringbooleanbooleanboolean[]booleanchar[]int -
Constructor Summary
ConstructorsConstructorDescriptionScanner()Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals, long sourceLevel, char[][] taskTags, char[][] taskPriorities, boolean isTaskCaseSensitive) Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals, long sourceLevel, char[][] taskTags, char[][] taskPriorities, boolean isTaskCaseSensitive, boolean isPreviewEnabled) Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals, long sourceLevel, long complianceLevel, char[][] taskTags, char[][] taskPriorities, boolean isTaskCaseSensitive, boolean isPreviewEnabled) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanfinal booleanatEnd()booleanprotected final booleanvoidcheckTaskTag(int commentStart, int commentEnd) voidcopyAllCommentInfo(int from, int to, int length) voidcopyCommentInfo(int to, int from) fastForward(Statement unused) protected intchar[]final Stringchar[]intchar[]char[]intfinal Stringboolean[]final intgetLineEnd(int lineNumber) final int[]final intgetLineNumber(int position) Search the line number corresponding to a specific positionfinal intgetLineStart(int lineNumber) Search the source position corresponding to the beginning of a given line number Line numbers are 1-based, and relative to the scanner initialPosition.final intfinal booleangetNextChar(char testedChar) final intgetNextChar(char testedChar1, char testedChar2) final booleanfinal booleangetNextCharAsDigit(int radix) booleanbooleanfinal intprotected TerminalTokenOverridable hook, to allow CompletionScanner to hide a faked identifier token.protected TerminalTokenvoidNLSTag[]final char[]final char[]char[]protected voidgrowCommentInfoArrays(int length, int newLength) protected static InvalidInputExceptionprotected static InvalidInputExceptionprotected static InvalidInputExceptionprotected static InvalidInputExceptionprotected static InvalidInputExceptionprotected static InvalidInputExceptionprotected static InvalidInputExceptionprotected static InvalidInputExceptionprotected static InvalidInputExceptionprotected static InvalidInputExceptionstatic InvalidInputExceptionprotected static InvalidInputExceptionstatic InvalidInputExceptioninvalidToken(TerminalToken token) protected static InvalidInputExceptionprotected static InvalidInputExceptionprotected static InvalidInputExceptionprotected booleanprotected booleanstatic booleanisIdentifier(TerminalToken token) booleanstatic booleanisKeyword(TerminalToken token) static booleanisLiteral(TerminalToken token) static booleanisRestrictedKeyword(TerminalToken token) final voidfinal booleanprotected final booleanprotected final booleanmayBeAtCasePattern(TerminalToken token) protected final booleanprotected final booleanprotected TerminalTokenprocessSingleQuotes(boolean checkIfUnicode) final voidfinal voidvoidrecordComment(TerminalToken token) voidresetTo(int begin, int end) Reposition the scanner on some portion of the original source.voidresetTo(int begin, int end, boolean isModuleInfo) voidresetTo(int begin, int end, boolean isModuleInfo, org.aspectj.org.eclipse.jdt.internal.compiler.parser.Scanner.ScanContext context) Reposition the scanner on some portion of the original source.protected final voidprotected TerminalTokenprotected TerminalTokenprotected final booleanprotected final booleanscanNumber(boolean dotPrefix) voidsetActiveParser(ConflictedParser parser) final voidsetSource(char[] sourceString) final voidsetSource(char[] contents, CompilationResult compilationResult) final voidsetSource(CompilationResult compilationResult) toString()voidungetToken(TerminalToken unambiguousToken) voidunicodeInitializeBuffer(int length) voidvoidunicodeStore(char character) protected static InvalidInputExceptionprotected static InvalidInputExceptionprotected static InvalidInputException
-
Field Details
-
sourceLevel
public long sourceLevel -
complianceLevel
public long complianceLevel -
useAssertAsAnIndentifier
public boolean useAssertAsAnIndentifier -
containsAssertKeyword
public boolean containsAssertKeyword -
previewEnabled
public boolean previewEnabled -
useEnumAsAnIndentifier
public boolean useEnumAsAnIndentifier -
recordLineSeparator
public boolean recordLineSeparator -
currentCharacter
public char currentCharacter -
startPosition
public int startPosition -
currentPosition
public int currentPosition -
initialPosition
public int initialPosition -
eofPosition
public int eofPosition -
skipComments
public boolean skipComments -
tokenizeComments
public boolean tokenizeComments -
tokenizeWhiteSpace
public boolean tokenizeWhiteSpace -
source
public char[] source -
withoutUnicodeBuffer
public char[] withoutUnicodeBuffer -
withoutUnicodePtr
public int withoutUnicodePtr -
unicodeAsBackSlash
public boolean unicodeAsBackSlash -
scanningFloatLiteral
public boolean scanningFloatLiteral -
COMMENT_ARRAYS_SIZE
public static int COMMENT_ARRAYS_SIZE -
commentStops
public int[] commentStops -
commentStarts
public int[] commentStarts -
commentIsMarkdown
public boolean[] commentIsMarkdown -
commentTagStarts
public int[] commentTagStarts -
commentPtr
public int commentPtr -
lastCommentLinePosition
public int lastCommentLinePosition -
foundTaskTags
public char[][] foundTaskTags -
foundTaskMessages
public char[][] foundTaskMessages -
foundTaskPriorities
public char[][] foundTaskPriorities -
foundTaskPositions
public int[][] foundTaskPositions -
foundTaskCount
public int foundTaskCount -
taskTags
public char[][] taskTags -
taskPriorities
public char[][] taskPriorities -
isTaskCaseSensitive
public boolean isTaskCaseSensitive -
diet
public boolean diet -
lineEnds
public int[] lineEnds -
linePtr
public int linePtr -
wasAcr
public boolean wasAcr -
fakeInModule
public boolean fakeInModule -
scanContext
protected org.aspectj.org.eclipse.jdt.internal.compiler.parser.Scanner.ScanContext scanContext -
insideModuleInfo
protected boolean insideModuleInfo -
END_OF_SOURCE
- See Also:
-
INVALID_HEXA
- See Also:
-
INVALID_OCTAL
- See Also:
-
INVALID_CHARACTER_CONSTANT
- See Also:
-
INVALID_ESCAPE
- See Also:
-
INVALID_INPUT
- See Also:
-
INVALID_TEXTBLOCK
- See Also:
-
INVALID_UNICODE_ESCAPE
- See Also:
-
INVALID_FLOAT
- See Also:
-
INVALID_LOW_SURROGATE
- See Also:
-
INVALID_HIGH_SURROGATE
- See Also:
-
NULL_SOURCE_STRING
- See Also:
-
UNTERMINATED_STRING
- See Also:
-
UNTERMINATED_TEXT_BLOCK
- See Also:
-
UNTERMINATED_COMMENT
- See Also:
-
INVALID_CHAR_IN_STRING
- See Also:
-
INVALID_DIGIT
- See Also:
-
INVALID_BINARY
- See Also:
-
BINARY_LITERAL_NOT_BELOW_17
- See Also:
-
ILLEGAL_HEXA_LITERAL
- See Also:
-
INVALID_UNDERSCORE
- See Also:
-
UNDERSCORES_IN_LITERALS_NOT_BELOW_17
- See Also:
-
TAG_PREFIX
public static final char[] TAG_PREFIX -
TAG_PREFIX_LENGTH
public static final int TAG_PREFIX_LENGTH -
TAG_POSTFIX
public static final char TAG_POSTFIX- See Also:
-
TAG_POSTFIX_LENGTH
public static final int TAG_POSTFIX_LENGTH- See Also:
-
IDENTITY_COMPARISON_TAG
public static final char[] IDENTITY_COMPARISON_TAG -
validIdentityComparisonLines
public boolean[] validIdentityComparisonLines -
checkUninternedIdentityComparison
public boolean checkUninternedIdentityComparison -
nlsTagsPtr
protected int nlsTagsPtr -
checkNonExternalizedStringLiterals
public boolean checkNonExternalizedStringLiterals -
lastPosition
protected int lastPosition -
returnOnlyGreater
public boolean returnOnlyGreater -
insideRecovery
public boolean insideRecovery -
nextToken
-
scanningSwitchLabel
public boolean scanningSwitchLabel -
RoundBracket
public static final int RoundBracket- See Also:
-
SquareBracket
public static final int SquareBracket- See Also:
-
CurlyBracket
public static final int CurlyBracket- See Also:
-
BracketKinds
public static final int BracketKinds- See Also:
-
LOW_SURROGATE_MIN_VALUE
public static final int LOW_SURROGATE_MIN_VALUE- See Also:
-
HIGH_SURROGATE_MIN_VALUE
public static final int HIGH_SURROGATE_MIN_VALUE- See Also:
-
HIGH_SURROGATE_MAX_VALUE
public static final int HIGH_SURROGATE_MAX_VALUE- See Also:
-
LOW_SURROGATE_MAX_VALUE
public static final int LOW_SURROGATE_MAX_VALUE- See Also:
-
rawStart
protected int rawStart
-
-
Constructor Details
-
Scanner
public Scanner() -
Scanner
public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals, long sourceLevel, long complianceLevel, char[][] taskTags, char[][] taskPriorities, boolean isTaskCaseSensitive, boolean isPreviewEnabled) -
Scanner
public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals, long sourceLevel, char[][] taskTags, char[][] taskPriorities, boolean isTaskCaseSensitive, boolean isPreviewEnabled) -
Scanner
public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals, long sourceLevel, char[][] taskTags, char[][] taskPriorities, boolean isTaskCaseSensitive)
-
-
Method Details
-
atEnd
public final boolean atEnd() -
checkTaskTag
- Throws:
InvalidInputException
-
getCurrentIdentifierSource
public char[] getCurrentIdentifierSource() -
getCurrentTokenEndPosition
public int getCurrentTokenEndPosition() -
getCurrentTokenSource
public char[] getCurrentTokenSource() -
getCurrentTokenString
-
getCurrentTokenSourceString
public char[] getCurrentTokenSourceString() -
scanForTextBlockBeginning
protected final boolean scanForTextBlockBeginning() -
lineBeginsWithMarkdown
- Throws:
InvalidInputException
-
scanForTextBlockClose
- Throws:
InvalidInputException
-
getCurrentTextBlock
public char[] getCurrentTextBlock() -
getCurrentStringLiteral
-
getRawTokenSource
public final char[] getRawTokenSource() -
getRawTokenSourceEnd
public final char[] getRawTokenSourceEnd() -
getCurrentTokenStartPosition
public int getCurrentTokenStartPosition() -
getLineEnd
public final int getLineEnd(int lineNumber) -
getLineEnds
public final int[] getLineEnds() -
getLineStart
public final int getLineStart(int lineNumber) Search the source position corresponding to the beginning of a given line number Line numbers are 1-based, and relative to the scanner initialPosition. Character positions are 0-based. e.g. getLineStart(1) --> 0 indicates that the first line starts at character 0. In case the given line number is inconsistent, answers -1.- Parameters:
lineNumber- int- Returns:
- int
-
getNextChar
public final int getNextChar() -
getNextCharWithBoundChecks
public final int getNextCharWithBoundChecks() -
getNextChar
public final boolean getNextChar(char testedChar) -
getNextChar
public final int getNextChar(char testedChar1, char testedChar2) -
getNextCharAsDigit
- Throws:
InvalidInputException
-
getNextCharAsDigit
public final boolean getNextCharAsDigit(int radix) -
getNextCharAsJavaIdentifierPartWithBoundCheck
public boolean getNextCharAsJavaIdentifierPartWithBoundCheck() -
getNextCharAsJavaIdentifierPart
public boolean getNextCharAsJavaIdentifierPart() -
scanIdentifier
- Throws:
InvalidInputException
-
ungetToken
-
getNextToken
- Throws:
InvalidInputException
-
findCommentType
protected int findCommentType() -
getNextToken0
- Throws:
InvalidInputException
-
processSingleQuotes
- Throws:
InvalidInputException
-
scanForStringLiteral
- Throws:
InvalidInputException
-
scanForTextBlock
- Throws:
InvalidInputException
-
getNextUnicodeChar
- Throws:
InvalidInputException
-
getNLSTags
-
getIdentityComparisonLines
public boolean[] getIdentityComparisonLines() -
getSource
public char[] getSource() -
isFirstTag
protected boolean isFirstTag() -
jumpOverMethodBody
public final void jumpOverMethodBody() -
jumpOverUnicodeWhiteSpace
- Throws:
InvalidInputException
-
isInModuleDeclaration
public boolean isInModuleDeclaration() -
areRestrictedModuleKeywordsActive
protected boolean areRestrictedModuleKeywordsActive() -
pushLineSeparator
public final void pushLineSeparator() -
pushUnicodeLineSeparator
public final void pushUnicodeLineSeparator() -
recordComment
-
resetTo
public void resetTo(int begin, int end) Reposition the scanner on some portion of the original source. The given endPosition is the last valid position. Beyond this position, the scanner will answer EOF tokens (ITerminalSymbols.TokenNameEOF).- Parameters:
begin- the given start positionend- the given end position
-
resetTo
public void resetTo(int begin, int end, boolean isModuleInfo) -
resetTo
public void resetTo(int begin, int end, boolean isModuleInfo, org.aspectj.org.eclipse.jdt.internal.compiler.parser.Scanner.ScanContext context) Reposition the scanner on some portion of the original source. The given endPosition is the last valid position. Beyond this position, the scanner will answer EOF tokens (ITerminalSymbols.TokenNameEOF).- Parameters:
begin- the given start positionend- the given end positionisModuleInfo- if true apply rules for restricted keywords even without a connection to a properly configured parsercontext- The scan context to use for restricted keyword support, use null to compute
-
scanEscapeCharacter
- Throws:
InvalidInputException
-
scanIdentifierOrKeywordWithBoundCheck
-
scanIdentifierOrKeyword
-
scanIdentifierOrKeywordAj
-
scanNumber
- Throws:
InvalidInputException
-
getLineNumber
public final int getLineNumber(int position) Search the line number corresponding to a specific position- Parameters:
position- int- Returns:
- int
-
setSource
public final void setSource(char[] sourceString) -
setSource
-
setSource
-
toString
-
toStringAction
-
unicodeInitializeBuffer
public void unicodeInitializeBuffer(int length) -
unicodeStore
public void unicodeStore() -
unicodeStore
public void unicodeStore(char character) -
isIdentifier
-
isLiteral
-
isKeyword
-
maybeAtLambdaOrCast
protected final boolean maybeAtLambdaOrCast() -
maybeAtReferenceExpression
protected final boolean maybeAtReferenceExpression() -
atTypeAnnotation
protected final boolean atTypeAnnotation() -
setActiveParser
-
isRestrictedKeyword
-
atMultiCaseComma
public boolean atMultiCaseComma() -
mayBeAtCasePattern
-
isAtAssistIdentifier
protected boolean isAtAssistIdentifier() -
fastForward
-
getNextNotFakedToken
Overridable hook, to allow CompletionScanner to hide a faked identifier token.- Throws:
InvalidInputException
-
invalidCharacter
-
invalidCharInString
-
unterminatedString
-
invalidUnicodeEscape
-
invalidLowSurrogate
-
invalidHighSurrogate
-
unterminatedComment
-
unterminatedTextBlock
-
invalidEof
-
invalidUnderscore
-
invalidUnderscoresInLiterals
-
invalidEscape
-
invalidHexa
-
illegalHexaLiteral
-
invalidFloat
-
invalidBinaryLiteral
-
invalidBinary
-
invalidToken
-
invalidInput
-
copyCommentInfo
public void copyCommentInfo(int to, int from) -
copyAllCommentInfo
public void copyAllCommentInfo(int from, int to, int length) -
growCommentInfoArrays
protected void growCommentInfoArrays(int length, int newLength)
-