-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CharSequenceprotected intprotected intprotected final IElementTypeprotected final charprotected intstatic final charFields inherited from interface com.intellij.lexer.Lexer
LEXER_START_THRESHOLD -
Constructor Summary
ConstructorsConstructorDescriptionStringLiteralLexer(char quoteChar, IElementType originalLiteralToken) StringLiteralLexer(char quoteChar, IElementType originalLiteralToken, boolean canEscapeEolOrFramingSpaces, String additionalValidEscapes) StringLiteralLexer(char quoteChar, IElementType originalLiteralToken, boolean canEscapeEolOrFramingSpaces, String additionalValidEscapes, boolean allowOctal, boolean allowHex) -
Method Summary
Modifier and TypeMethodDescriptionvoidadvance()Advances the lexer to the next token.intReturns the offset at which the lexer will stop lexing.@NotNull CharSequenceReturns the buffer sequence over which the lexer is running.protected IElementTypeprotected @NotNull IElementTypegetStandardLimitedHexCodedEscapeSeq(int offsetLimit) intgetState()Returns the current state of the lexer.intReturns the end offset of the current token.intReturns the start offset of the current token.Returns the token at the current position of the lexer ornullif lexing is finished.protected @NotNull IElementTypeprotected @NotNull IElementTypeprotected booleanhighlightAsOriginalLiteral(char escapedChar) protected intlocateAdditionalEscapeSequence(int start, int indexOfCharAfterSlash) Locates the end of an additional (non-standard) escape sequence.protected intlocateHexEscapeSequence(int start, int i) protected intlocateUnicodeEscapeSequence(int start, int i) protected booleanvoidstart(@NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) Prepare for lexing character data frombufferpassed.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.intellij.lexer.Lexer
getTokenSequence, getTokenText, start, startMethods inherited from interface com.intellij.lexer.LexerBase
getCurrentPosition, restore
-
Field Details
-
NO_QUOTE_CHAR
public static final char NO_QUOTE_CHAR- See Also:
-
myBuffer
-
myStart
protected int myStart -
myEnd
protected int myEnd -
myBufferEnd
protected int myBufferEnd -
myQuoteChar
protected final char myQuoteChar -
myOriginalLiteralToken
-
-
Constructor Details
-
StringLiteralLexer
-
StringLiteralLexer
public StringLiteralLexer(char quoteChar, IElementType originalLiteralToken, boolean canEscapeEolOrFramingSpaces, String additionalValidEscapes) -
StringLiteralLexer
public StringLiteralLexer(char quoteChar, IElementType originalLiteralToken, boolean canEscapeEolOrFramingSpaces, String additionalValidEscapes, boolean allowOctal, boolean allowHex) - Parameters:
canEscapeEolOrFramingSpaces-trueif following sequences are acceptable:
*'\'at the end of the buffer (meaning escaped end of line)
*'\ '(escaped space) at the beginning and ath the end of the buffer (meaning escaped space, to avoid auto trimming on load)
-
-
Method Details
-
start
public void start(@NotNull @NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) Description copied from interface:LexerPrepare 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 byLexer.getState()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. -
getState
public int getState()Description copied from interface:LexerReturns the current state of the lexer. -
getTokenType
Description copied from interface:LexerReturns the token at the current position of the lexer ornullif lexing is finished.- Specified by:
getTokenTypein interfaceLexer- Returns:
- the current token.
-
highlightAsOriginalLiteral
protected boolean highlightAsOriginalLiteral(char escapedChar) -
shouldAllowSlashZero
protected boolean shouldAllowSlashZero() -
handleSingleSlashEscapeSequence
-
getHexCodedEscapeSeq
-
getUnicodeEscapeSequenceType
-
getStandardLimitedHexCodedEscapeSeq
-
getTokenStart
public int getTokenStart()Description copied from interface:LexerReturns the start offset of the current token.- Specified by:
getTokenStartin interfaceLexer- Returns:
- the current token start offset.
-
getTokenEnd
public int getTokenEnd()Description copied from interface:LexerReturns the end offset of the current token.- Specified by:
getTokenEndin interfaceLexer- Returns:
- the current token end offset.
-
locateHexEscapeSequence
protected int locateHexEscapeSequence(int start, int i) -
locateUnicodeEscapeSequence
protected int locateUnicodeEscapeSequence(int start, int i) -
locateAdditionalEscapeSequence
protected int locateAdditionalEscapeSequence(int start, int indexOfCharAfterSlash) Locates the end of an additional (non-standard) escape sequence. The sequence is considered to begin with a backslash symbol located at the
startindex of the lexer's buffer.Override this method if your language supports non-standard escape sequences. For example, in Go language Unicode escapes look like '\U12345678'. To locate this escape sequence, the implementation should check that
indexOfCharAfterSlashpoints to the 'U' symbol in the buffer and returnstart + 8(or the end index of the buffer if it is too short). Otherwise, the implementations should return -1 to indicate that the current buffer starting at the indexstartdoesn't represent an additional escape sequence.When overriding this method, you most likely will need to also override
getTokenType()to return proper type for the sequences located here. -
advance
public void advance()Description copied from interface:LexerAdvances the lexer to the next token. -
getBufferSequence
Description copied from interface:LexerReturns the buffer sequence over which the lexer is running. This method should return the same buffer instance which was passed to thestart()method.- Specified by:
getBufferSequencein interfaceLexer- Returns:
- the lexer buffer.
-
getBufferEnd
public int getBufferEnd()Description copied from interface:LexerReturns 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.- Specified by:
getBufferEndin interfaceLexer- Returns:
- the lexing end offset
-
toString
-