java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner

public class TokenScanner extends Object
Wraps a scanner and offers convenient methods for finding tokens
  • Feldübersicht

    Felder
    Modifizierer und Typ
    Feld
    Beschreibung
    static final int
     
    static final int
     
    static final int
     
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
    Creates a TokenScanner
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    static org.eclipse.core.runtime.IStatus
    createError(int code, String message, Throwable throwable)
     
    int
     
    int
     
    int
     
    int
    getNextEndOffset(int offset, boolean ignoreComments)
    Reads the next token from the given offset and returns the offset after the token.
    int
    getNextStartOffset(int offset, boolean ignoreComments)
    Reads the next token from the given offset and returns the start offset of the token.
    int
    getPreviousTokenEndOffset(int token, int startOffset)
    Reads from the given offset until a token is reached and returns the offset after the previous token.
    Returns the wrapped scanner
    int
    getTokenEndOffset(int token, int startOffset)
    Reads from the given offset until a token is reached and returns the offset after the token.
    int
    getTokenStartOffset(int token, int startOffset)
    Reads from the given offset until a token is reached and returns the start offset of the token.
    static boolean
    isComment(int token)
     
    static boolean
    isModifier(int token)
     
    int
    readNext(boolean ignoreComments)
    Reads the next token.
    int
    readNext(int offset, boolean ignoreComments)
    Reads the next token from the given offset.
    void
    readToToken(int tok)
    Reads until a token is reached.
    void
    readToToken(int tok, int offset)
    Reads until a token is reached, starting from the given offset.
    void
    setOffset(int offset)
    Sets the scanner offset to the given offset.

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Felddetails

  • Konstruktordetails

    • TokenScanner

      public TokenScanner(Scanner scanner)
      Creates a TokenScanner
      Parameter:
      scanner - The scanner to be wrapped
  • Methodendetails

    • getScanner

      public Scanner getScanner()
      Returns the wrapped scanner
      Gibt zurück:
      IScanner
    • setOffset

      public void setOffset(int offset)
      Sets the scanner offset to the given offset.
      Parameter:
      offset - The offset to set
    • getCurrentEndOffset

      public int getCurrentEndOffset()
      Gibt zurück:
      Returns the offset after the current token
    • getCurrentStartOffset

      public int getCurrentStartOffset()
      Gibt zurück:
      Returns the start offset of the current token
    • getCurrentLength

      public int getCurrentLength()
      Gibt zurück:
      Returns the length of the current token
    • readNext

      public int readNext(boolean ignoreComments) throws org.eclipse.core.runtime.CoreException
      Reads the next token.
      Parameter:
      ignoreComments - If set, comments will be overread
      Gibt zurück:
      Return the token id.
      Löst aus:
      org.eclipse.core.runtime.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE) or a lexical error was detected while scanning (code LEXICAL_ERROR)
    • readNext

      public int readNext(int offset, boolean ignoreComments) throws org.eclipse.core.runtime.CoreException
      Reads the next token from the given offset.
      Parameter:
      offset - The offset to start reading from.
      ignoreComments - If set, comments will be overread.
      Gibt zurück:
      Returns the token id.
      Löst aus:
      org.eclipse.core.runtime.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE) or a lexical error was detected while scanning (code LEXICAL_ERROR)
    • getNextStartOffset

      public int getNextStartOffset(int offset, boolean ignoreComments) throws org.eclipse.core.runtime.CoreException
      Reads the next token from the given offset and returns the start offset of the token.
      Parameter:
      offset - The offset to start reading from.
      ignoreComments - If set, comments will be overread
      Gibt zurück:
      Returns the start position of the next token.
      Löst aus:
      org.eclipse.core.runtime.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE) or a lexical error was detected while scanning (code LEXICAL_ERROR)
    • getNextEndOffset

      public int getNextEndOffset(int offset, boolean ignoreComments) throws org.eclipse.core.runtime.CoreException
      Reads the next token from the given offset and returns the offset after the token.
      Parameter:
      offset - The offset to start reading from.
      ignoreComments - If set, comments will be overread
      Gibt zurück:
      Returns the start position of the next token.
      Löst aus:
      org.eclipse.core.runtime.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE) or a lexical error was detected while scanning (code LEXICAL_ERROR)
    • readToToken

      public void readToToken(int tok) throws org.eclipse.core.runtime.CoreException
      Reads until a token is reached.
      Parameter:
      tok - The token to read to.
      Löst aus:
      org.eclipse.core.runtime.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE) or a lexical error was detected while scanning (code LEXICAL_ERROR)
    • readToToken

      public void readToToken(int tok, int offset) throws org.eclipse.core.runtime.CoreException
      Reads until a token is reached, starting from the given offset.
      Parameter:
      tok - The token to read to.
      offset - The offset to start reading from.
      Löst aus:
      org.eclipse.core.runtime.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE) or a lexical error was detected while scanning (code LEXICAL_ERROR)
    • getTokenStartOffset

      public int getTokenStartOffset(int token, int startOffset) throws org.eclipse.core.runtime.CoreException
      Reads from the given offset until a token is reached and returns the start offset of the token.
      Parameter:
      token - The token to be found.
      startOffset - The offset to start reading from.
      Gibt zurück:
      Returns the start position of the found token.
      Löst aus:
      org.eclipse.core.runtime.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE) or a lexical error was detected while scanning (code LEXICAL_ERROR)
    • getTokenEndOffset

      public int getTokenEndOffset(int token, int startOffset) throws org.eclipse.core.runtime.CoreException
      Reads from the given offset until a token is reached and returns the offset after the token.
      Parameter:
      token - The token to be found.
      startOffset - Offset to start reading from
      Gibt zurück:
      Returns the end position of the found token.
      Löst aus:
      org.eclipse.core.runtime.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE) or a lexical error was detected while scanning (code LEXICAL_ERROR)
    • getPreviousTokenEndOffset

      public int getPreviousTokenEndOffset(int token, int startOffset) throws org.eclipse.core.runtime.CoreException
      Reads from the given offset until a token is reached and returns the offset after the previous token.
      Parameter:
      token - The token to be found.
      startOffset - The offset to start scanning from.
      Gibt zurück:
      Returns the end offset of the token previous to the given token.
      Löst aus:
      org.eclipse.core.runtime.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE) or a lexical error was detected while scanning (code LEXICAL_ERROR)
    • isComment

      public static boolean isComment(int token)
    • isModifier

      public static boolean isModifier(int token)
    • createError

      public static org.eclipse.core.runtime.IStatus createError(int code, String message, Throwable throwable)