Interface TokenFactory

All Superinterfaces:
AutoCloseable

public interface TokenFactory extends AutoCloseable
Proxy to record tokens from within CpdLexer.tokenize(TextDocument, TokenFactory).
  • Method Details

    • recordToken

      void recordToken(@NonNull String image, int startLine, int startCol, int endLine, int endCol)
      Record a token given its coordinates. Coordinates must match the requirements of FileLocation, ie, be 1-based and ordered properly.
      Parameters:
      image - Image of the token. This will be taken into account to determine the hash value of the token.
      startLine - Start line of the token
      startCol - Start column of the token
      endLine - End line of the token
      endCol - End column of the token
    • recordToken

      default void recordToken(@NonNull String image, @NonNull FileLocation location)
      Record a token given its coordinates. Coordinates must match the requirements of FileLocation, ie, be 1-based and ordered properly.
      Parameters:
      image - Image of the token. This will be taken into account to determine the hash value of the token.
      location - Location of the token.
    • makeLexException

      LexException makeLexException(int line, int column, String message, @Nullable Throwable cause)
    • setImage

      void setImage(TokenEntry entry, @NonNull String newImage)
      Sets the image of an existing token entry.
    • peekLastToken

      @Nullable TokenEntry peekLastToken()
      Returns the last token that has been recorded in this file.
    • close

      void close()
      This adds the EOF token, it must be called when CpdLexer.tokenize(TextDocument, TokenFactory) is done.
      Specified by:
      close in interface AutoCloseable