Class PublicScanner
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.util.PublicScanner
- All Implemented Interfaces:
IScanner
,ITerminalSymbols
This class acts as a facade to the internal Scanner implementation and delegates
all the work to the internal Scanner instance.
Note for maintainers
No additional logic should be added here except adopting NON-API constants
returned by getNextToken()
from TerminalTokens
to ITerminalSymbols
.
-
Field Summary
Fields inherited from interface org.aspectj.org.eclipse.jdt.core.compiler.ITerminalSymbols
TokenNameabstract, TokenNameAND, TokenNameAND_AND, TokenNameAND_EQUAL, TokenNameARROW, TokenNameassert, TokenNameAT, TokenNameboolean, TokenNamebreak, TokenNamebyte, TokenNamecase, TokenNamecatch, TokenNamechar, TokenNameCharacterLiteral, TokenNameclass, TokenNameCOLON, TokenNameCOLON_COLON, TokenNameCOMMA, TokenNameCOMMENT_BLOCK, TokenNameCOMMENT_JAVADOC, TokenNameCOMMENT_LINE, TokenNameconst, TokenNamecontinue, TokenNamedefault, TokenNameDIVIDE, TokenNameDIVIDE_EQUAL, TokenNamedo, TokenNameDOT, TokenNamedouble, TokenNameDoubleLiteral, TokenNameELLIPSIS, TokenNameelse, TokenNameenum, TokenNameEOF, TokenNameEQUAL, TokenNameEQUAL_EQUAL, TokenNameERROR, TokenNameextends, TokenNamefalse, TokenNamefinal, TokenNamefinally, TokenNamefloat, TokenNameFloatingPointLiteral, TokenNamefor, TokenNamegoto, TokenNameGREATER, TokenNameGREATER_EQUAL, TokenNameIdentifier, TokenNameif, TokenNameimplements, TokenNameimport, TokenNameinstanceof, TokenNameint, TokenNameIntegerLiteral, TokenNameinterface, TokenNameLBRACE, TokenNameLBRACKET, TokenNameLEFT_SHIFT, TokenNameLEFT_SHIFT_EQUAL, TokenNameLESS, TokenNameLESS_EQUAL, TokenNamelong, TokenNameLongLiteral, TokenNameLPAREN, TokenNameMINUS, TokenNameMINUS_EQUAL, TokenNameMINUS_MINUS, TokenNameMULTIPLY, TokenNameMULTIPLY_EQUAL, TokenNamenative, TokenNamenew, TokenNamenon_sealed, TokenNameNOT, TokenNameNOT_EQUAL, TokenNameNotAToken, TokenNamenull, TokenNameOR, TokenNameOR_EQUAL, TokenNameOR_OR, TokenNamepackage, TokenNamePLUS, TokenNamePLUS_EQUAL, TokenNamePLUS_PLUS, TokenNameprivate, TokenNameprotected, TokenNamepublic, TokenNameQUESTION, TokenNameRBRACE, TokenNameRBRACKET, TokenNameREMAINDER, TokenNameREMAINDER_EQUAL, TokenNameRestrictedIdentifierpermits, TokenNameRestrictedIdentifierrecord, TokenNameRestrictedIdentifiersealed, TokenNameRestrictedIdentifierWhen, TokenNameRestrictedIdentifierYield, TokenNamereturn, TokenNameRIGHT_SHIFT, TokenNameRIGHT_SHIFT_EQUAL, TokenNameRPAREN, TokenNameSEMICOLON, TokenNameshort, TokenNameSingleQuoteStringLiteral, TokenNamestatic, TokenNamestrictfp, TokenNameStringLiteral, TokenNameStringTemplate, TokenNamesuper, TokenNameswitch, TokenNamesynchronized, TokenNameTextBlock, TokenNameTextBlockTemplate, TokenNamethis, TokenNamethrow, TokenNamethrows, TokenNametransient, TokenNametrue, TokenNametry, TokenNameTWIDDLE, TokenNameUNDERSCORE, TokenNameUNSIGNED_RIGHT_SHIFT, TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL, TokenNamevoid, TokenNamevolatile, TokenNamewhile, TokenNameWHITESPACE, TokenNameXOR, TokenNameXOR_EQUAL
-
Constructor Summary
ConstructorDescriptionPublicScanner
(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals, long sourceLevel, long complianceLevel, char[][] taskTags, char[][] taskPriorities, boolean isTaskCaseSensitive, boolean isPreviewEnabled, boolean recordLineSeparator) -
Method Summary
Modifier and TypeMethodDescriptionprotected Scanner
createScanner
(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals, long sourceLevel, long complianceLevel, char[][] taskTags, char[][] taskPriorities, boolean isTaskCaseSensitive, boolean isPreviewEnabled) int
Answers the ending position of the current token inside the original source.char[]
Answers the current identifier source, after unicode escape sequences have been translated into unicode characters.int
Answers the starting position of the current token inside the original source.final int
getLineEnd
(int lineNumber) Answers the ending position of a given line number.final int[]
Answers an array of the ending positions of the lines encountered so far.final int
getLineNumber
(int position) Search the line number corresponding to a specific positionfinal 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.int
Read the next token in the source, and answers its ID as specified byITerminalSymbols
.final char[]
Answers the current identifier source, before unicode escape sequences have been translated into unicode characters.char[]
Answers the original source being processed (not a copy of it).void
resetTo
(int begin, int end) Reposition the scanner on some portion of the original source.final void
setSource
(char[] sourceString) Set the scanner source to process.toString()
-
Constructor Details
-
PublicScanner
public PublicScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals, long sourceLevel, long complianceLevel, char[][] taskTags, char[][] taskPriorities, boolean isTaskCaseSensitive, boolean isPreviewEnabled, boolean recordLineSeparator)
-
-
Method Details
-
createScanner
protected Scanner createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals, long sourceLevel, long complianceLevel, char[][] taskTags, char[][] taskPriorities, boolean isTaskCaseSensitive, boolean isPreviewEnabled) -
getCurrentTokenEndPosition
public int getCurrentTokenEndPosition()Description copied from interface:IScanner
Answers the ending position of the current token inside the original source. This position is zero-based and inclusive. It corresponds to the position of the last character which is part of this token. If this character was a unicode escape sequence, it points at the last character of this sequence.- Specified by:
getCurrentTokenEndPosition
in interfaceIScanner
- Returns:
- the ending position of the current token inside the original source
-
getCurrentTokenSource
public char[] getCurrentTokenSource()Description copied from interface:IScanner
Answers the current identifier source, after unicode escape sequences have been translated into unicode characters. For example, if original source was\\u0061bc
then it will answerabc
.- Specified by:
getCurrentTokenSource
in interfaceIScanner
- Returns:
- the current identifier source, after unicode escape sequences have been translated into unicode characters
-
getRawTokenSource
public final char[] getRawTokenSource()Description copied from interface:IScanner
Answers the current identifier source, before unicode escape sequences have been translated into unicode characters. For example, if original source was\\u0061bc
then it will answer\\u0061bc
.- Specified by:
getRawTokenSource
in interfaceIScanner
- Returns:
- the current identifier source, before unicode escape sequences have been translated into unicode characters
-
getCurrentTokenStartPosition
public int getCurrentTokenStartPosition()Description copied from interface:IScanner
Answers the starting position of the current token inside the original source. This position is zero-based and inclusive. It corresponds to the position of the first character which is part of this token. If this character was a unicode escape sequence, it points at the first character of this sequence.- Specified by:
getCurrentTokenStartPosition
in interfaceIScanner
- Returns:
- the starting position of the current token inside the original source
-
getLineEnd
public final int getLineEnd(int lineNumber) Description copied from interface:IScanner
Answers the ending position of a given line number. This line has to have been encountered already in the tokenization process (in other words, it cannot be used to compute positions of lines beyond current token). Once the entire source has been processed, it can be used without any limit. Line ending positions are zero-based, and correspond to the last character of the line separator (in case multi-character line separators).- Specified by:
getLineEnd
in interfaceIScanner
- Parameters:
lineNumber
- the given line number- Returns:
- the ending position of a given line number
-
getLineEnds
public final int[] getLineEnds()Description copied from interface:IScanner
Answers an array of the ending positions of the lines encountered so far. Line ending positions are zero-based, and correspond to the last character of the line separator (in case multi-character line separators).- Specified by:
getLineEnds
in interfaceIScanner
- Returns:
- an array of the ending positions of the lines encountered so far
-
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.- Specified by:
getLineStart
in interfaceIScanner
- Parameters:
lineNumber
- int- Returns:
- int
-
getNextToken
Description copied from interface:IScanner
Read the next token in the source, and answers its ID as specified byITerminalSymbols
. Note that the actual token ID values are subject to change if new keywords were added to the language (for instance, 'assert' is a keyword in 1.4).- Specified by:
getNextToken
in interfaceIScanner
- Returns:
- the next token
- Throws:
InvalidInputException
- in case a lexical error was detected while reading the current token
-
getSource
public char[] getSource()Description copied from interface:IScanner
Answers the original source being processed (not a copy of it). -
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
). -
getLineNumber
public final int getLineNumber(int position) Search the line number corresponding to a specific position- Specified by:
getLineNumber
in interfaceIScanner
- Parameters:
position
- int- Returns:
- int
-
setSource
public final void setSource(char[] sourceString) Description copied from interface:IScanner
Set the scanner source to process. By default, the scanner will consider starting at the beginning of the source until it reaches its end. If the given source isnull
, this clears the source. -
toString
-