Class BaseToken

All Implemented Interfaces:
Direct Known Subclasses:

public class BaseToken extends Object implements Comparable<BaseToken>
A supertype for our generated token class. This is cleaner than us maintaining a complete copy of Token
  • Field Details

    • startIndex

      public int startIndex
    • endIndex

      public int endIndex
    • tokenBegin

      public int tokenBegin
    • detached

      public boolean detached
  • Constructor Details

    • BaseToken

      public BaseToken()
  • Method Details

    • addBackLinks

      public Token addBackLinks()
    • addBackLinks

      public Token addBackLinks(Token until)
    • prev

      public Token prev()
    • compareTo

      public int compareTo(BaseToken o)
      Specified by:
      compareTo in interface Comparable<BaseToken>
    • containsIndex

      public boolean containsIndex(int desired)
    • getEndIndex

      public int getEndIndex()
    • getStartIndex

      public int getStartIndex()
    • specialTokenLength

      public int specialTokenLength()
    • copyToken

      public void copyToken(Token token)
    • next

      public Token next()
    • special

      public Token special()
    • getNextNonWhitespace

      public Token getNextNonWhitespace()
    • dump

      public String dump()
    • positionStart

      public Position.Builder positionStart()
      Converts our 1-indexed javacc start token to a 0-indexed LSP Position
    • positionEnd

      public Position.Builder positionEnd()
      Converts our 1-indexed javacc end token to a 0-indexed LSP Position. Does not consider javacc's weird EOF handling specially; the final end position will land outside the document's actual range, which is perfectly acceptable to Monaco when telling it what chars to replace (it's actually required when the cursor is at the end of the document; a common occurrence).
    • positionEnd

      public Position.Builder positionEnd(boolean considerEof)
      Converts our 1-indexed javacc end token to a 0-indexed LSP Position.
      considerEof - Whether or not to normalize javacc's weird EOF token handling. Normally false, which allows the position to exceed the document's size. This is acceptable to Monaco. EOF is only considered during internal operations when we are looking up tokens from cursor positions (and can likely be refactored / deleted when we stop using absolute cursor positions).
      A 0-indexed Position describing the end of this token.
    • toReverse

      public MappedIterable<Token> toReverse(Token end)
      Returns an iterable which runs backwards from this token. If you specify an end token, the iterator will include that token and stop. If an end token is not specified, the iterable will run backwards until the start token.
      end - optional end token, if specified, will be the last token returned by iterator.
    • to

      public MappedIterable<Token> to(Token end)
    • containsPosition

      public boolean containsPosition(PositionOrBuilder pos)
    • contains

      public boolean contains(DocumentRangeOrBuilder replaceRange)