Class PublicScanner

java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.util.PublicScanner
All Implemented Interfaces:
IScanner, ITerminalSymbols

public class PublicScanner extends Object implements 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.

  • 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 interface IScanner
      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 answer abc.
      Specified by:
      getCurrentTokenSource in interface IScanner
      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 interface IScanner
      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 interface IScanner
      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 interface IScanner
      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 interface IScanner
      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 interface IScanner
      Parameters:
      lineNumber - int
      Returns:
      int
    • getNextToken

      public int getNextToken() throws InvalidInputException
      Description copied from interface: IScanner
      Read the next token in the source, and answers its ID as specified by ITerminalSymbols. 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 interface IScanner
      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).
      Specified by:
      getSource in interface IScanner
      Returns:
      the original source being processed
    • 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).
      Specified by:
      resetTo in interface IScanner
      Parameters:
      begin - the given start position
      end - the given end position
    • getLineNumber

      public final int getLineNumber(int position)
      Search the line number corresponding to a specific position
      Specified by:
      getLineNumber in interface IScanner
      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 is null, this clears the source.
      Specified by:
      setSource in interface IScanner
      Parameters:
      sourceString - the given source
    • toString

      public String toString()
      Overrides:
      toString in class Object