Class LayeredLexer

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

public class LayeredLexer extends DelegateLexer
  • Field Details

  • Constructor Details

    • LayeredLexer

      public LayeredLexer(Lexer baseLexer)
  • Method Details

    • registerSelfStoppingLayer

      public void registerSelfStoppingLayer(Lexer lexer, IElementType[] startTokens, IElementType[] stopTokens)
    • registerLayer

      public void registerLayer(Lexer lexer, IElementType... startTokens)
    • findLayerLexer

      @Nullable protected @Nullable Lexer findLayerLexer(IElementType baseTokenType)
    • 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
      Overrides:
      start in class DelegateLexer
      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.
    • getState

      public int getState()
      Description copied from interface: Lexer
      Returns the current state of the lexer.
      Specified by:
      getState in interface Lexer
      Overrides:
      getState in class DelegateLexer
      Returns:
      the lexer state.
    • 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
      Overrides:
      getTokenType in class DelegateLexer
      Returns:
      the current token.
    • getTokenStart

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

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

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

      @NotNull public @NotNull LexerPosition getCurrentPosition()
      Description copied from interface: Lexer
      Returns the current position and state of the lexer.
      Returns:
      the lexer position and state.
    • restore

      public void restore(@NotNull @NotNull LexerPosition position)
      Description copied from interface: Lexer
      Restores the lexer to the specified state and position.
      Parameters:
      position - the state and position to restore to.
    • isLayerActive

      protected boolean isLayerActive()