java.lang.Object
com.intellij.lexer.Lexer
- Direct Known Subclasses:
LexerBase
Interface for breaking a file into a sequence of tokens.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidadvance()Advances the lexer to the next token.abstract intReturns the offset at which the lexer will stop lexing.abstract @NotNull CharSequenceReturns the buffer sequence over which the lexer is running.abstract @NotNull LexerPositionReturns the current position and state of the lexer.abstract intgetState()Returns the current state of the lexer.abstract intReturns the end offset of the current token.@NotNull CharSequenceabstract intReturns the start offset of the current token.@NotNull Stringabstract @Nullable IElementTypeReturns the token at the current position of the lexer ornullif lexing is finished.abstract voidrestore(@NotNull LexerPosition position) Restores the lexer to the specified state and position.final voidstart(@NotNull CharSequence buf) final voidstart(@NotNull CharSequence buf, int start, int end) abstract voidstart(@NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) Prepare for lexing character data frombufferpassed.
-
Constructor Details
-
Lexer
public Lexer()
-
-
Method Details
-
start
public abstract void start(@NotNull @NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) Prepare for lexing character data frombufferpassed. Internal lexer state is supposed to beinitialState. It is guaranteed that the value of initialState is the same as returned bygetState()method of this lexer at conditionstartOffset=getTokenStart(). This method is used to incrementally re-lex changed characters using lexing data acquired from this particular lexer sometime in the past.- Parameters:
buffer- character data for lexing.startOffset- offset to start lexing fromendOffset- offset to stop lexing atinitialState- the initial state of the lexer.
-
start
-
start
-
getTokenSequence
-
getTokenText
-
getState
public abstract int getState()Returns the current state of the lexer.- Returns:
- the lexer state.
-
getTokenType
Returns the token at the current position of the lexer ornullif lexing is finished.- Returns:
- the current token.
-
getTokenStart
public abstract int getTokenStart()Returns the start offset of the current token.- Returns:
- the current token start offset.
-
getTokenEnd
public abstract int getTokenEnd()Returns the end offset of the current token.- Returns:
- the current token end offset.
-
advance
public abstract void advance()Advances the lexer to the next token. -
getCurrentPosition
Returns the current position and state of the lexer.- Returns:
- the lexer position and state.
-
restore
Restores the lexer to the specified state and position.- Parameters:
position- the state and position to restore to.
-
getBufferSequence
Returns the buffer sequence over which the lexer is running. This method should return the same buffer instance which was passed to thestart()method.- Returns:
- the lexer buffer.
-
getBufferEnd
public abstract int getBufferEnd()Returns the offset at which the lexer will stop lexing. This method should return the length of the buffer or the value passed in theendOffsetparameter to thestart()method.- Returns:
- the lexing end offset
-