Class LookAheadLexer

java.lang.Object
com.intellij.lexer.LookAheadLexer
All Implemented Interfaces:
Lexer, LexerBase

public abstract class LookAheadLexer extends Object implements LexerBase
  • Constructor Details

    • LookAheadLexer

      public LookAheadLexer(@NotNull @NotNull Lexer baseLexer, int capacity)
    • LookAheadLexer

      public LookAheadLexer(@NotNull @NotNull Lexer baseLexer)
  • Method Details

    • addToken

      protected void addToken(IElementType type)
    • addToken

      protected void addToken(int endOffset, IElementType type)
    • lookAhead

      protected void lookAhead(@NotNull @NotNull Lexer baseLexer)
    • advance

      public void advance()
      Description copied from interface: Lexer
      Advances the lexer to the next token.
      Specified by:
      advance in interface Lexer
    • getBufferSequence

      @NotNull public @NotNull CharSequence getBufferSequence()
      Description copied from interface: Lexer
      Returns the buffer sequence over which the lexer is running. This method should return the same buffer instance which was passed to the start() method.
      Specified by:
      getBufferSequence in interface Lexer
      Returns:
      the lexer buffer.
    • getBufferEnd

      public int getBufferEnd()
      Description copied from interface: Lexer
      Returns the offset at which the lexer will stop lexing. This method should return the length of the buffer or the value passed in the endOffset parameter to the start() method.
      Specified by:
      getBufferEnd in interface Lexer
      Returns:
      the lexing end offset
    • getCacheSize

      protected int getCacheSize()
    • resetCacheSize

      protected void resetCacheSize(int size)
    • replaceCachedType

      public IElementType replaceCachedType(int index, IElementType token)
    • getCachedType

      protected final IElementType getCachedType(int index)
    • getCachedOffset

      protected final int getCachedOffset(int index)
    • getState

      public int getState()
      Description copied from interface: Lexer
      Returns the current state of the lexer.
      Specified by:
      getState in interface Lexer
      Returns:
      the lexer state.
    • getTokenEnd

      public int getTokenEnd()
      Description copied from interface: Lexer
      Returns the end offset of the current token.
      Specified by:
      getTokenEnd in interface Lexer
      Returns:
      the current token end offset.
    • getTokenStart

      public int getTokenStart()
      Description copied from interface: Lexer
      Returns the start offset of the current token.
      Specified by:
      getTokenStart in interface Lexer
      Returns:
      the current token start offset.
    • getCurrentPosition

      @NotNull public @NotNull LookAheadLexer.LookAheadLexerPosition getCurrentPosition()
      Description copied from interface: Lexer
      Returns the current position and state of the lexer.
      Specified by:
      getCurrentPosition in interface Lexer
      Specified by:
      getCurrentPosition in interface LexerBase
      Returns:
      the lexer position and state.
    • restore

      public final void restore(@NotNull @NotNull LexerPosition _position)
      Description copied from interface: Lexer
      Restores the lexer to the specified state and position.
      Specified by:
      restore in interface Lexer
      Specified by:
      restore in interface LexerBase
      Parameters:
      _position - the state and position to restore to.
    • restore

      protected void restore(@NotNull @NotNull LookAheadLexer.LookAheadLexerPosition position)
    • getTokenType

      public IElementType getTokenType()
      Description copied from interface: Lexer
      Returns the token at the current position of the lexer or null if lexing is finished.
      Specified by:
      getTokenType in interface Lexer
      Returns:
      the current token.
    • start

      public void start(@NotNull @NotNull CharSequence buffer, int startOffset, int endOffset, int initialState)
      Description copied from interface: Lexer
      Prepare for lexing character data from buffer passed. Internal lexer state is supposed to be initialState. It is guaranteed that the value of initialState is the same as returned by Lexer.getState() method of this lexer at condition startOffset=getTokenStart(). This method is used to incrementally re-lex changed characters using lexing data acquired from this particular lexer sometime in the past.
      Specified by:
      start in interface Lexer
      Parameters:
      buffer - character data for lexing.
      startOffset - offset to start lexing from
      endOffset - offset to stop lexing at
      initialState - the initial state of the lexer.
    • advanceLexer

      protected final void advanceLexer(@NotNull @NotNull Lexer lexer)
    • advanceAs

      protected final void advanceAs(@NotNull @NotNull Lexer lexer, IElementType type)