- All Known Subinterfaces:
PsiBuilder
- All Known Implementing Classes:
FleetPsiBuilder,GeneratedParserUtilBase.Builder,IndentPsiBuilder,MarkerPsiBuilder,PsiBuilderAdapter,SyntaxTreeBuilderAdapter
public interface SyntaxTreeBuilder
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA marker defines a range in the document text which becomes a node in the AST tree. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdvances the lexer to the next token, skipping whitespace and comment tokens.voidenforceCommentTokens(@NotNull TokenSet tokens) booleaneof()Checks if the lexer has reached the end of file.voidAdds an error marker with the specified message text at the current position in the tree.intReturns the start offset of the current token, or the file length when the token stream is over.@Nullable LighterASTNode@NotNull CharSequenceReturns the complete text being parsed.@NonNls @Nullable StringReturns the text of the current token from the lexer.@Nullable IElementTypeReturns the type of current token from the lexer.default booleanisWhitespaceOrComment(@NotNull IElementType elementType) @Nullable IElementTypelookAhead(int steps) See what token type is instepsahead.@NotNull SyntaxTreeBuilder.Markermark()Creates a marker at the current parsing position.@Nullable IElementTyperawLookup(int steps) See what token type is instepsahead/behind.intReturns the index of the current token in the original sequence.intrawTokenTypeStart(int steps) See what token type is instepsahead/behind current position.voidSlightly easier way to whatITokenTypeRemapperdoes (i.e.voidsetDebugMode(boolean dbgMode) Enables or disables the builder debug mode.voidsetTokenTypeRemapper(@Nullable ITokenTypeRemapper remapper) Sets optional remapper that can change the type of tokens.voidsetWhitespaceSkippedCallback(@Nullable WhitespaceSkippedCallback callback) Subscribe for notification on default whitespace and comments skipped events.
-
Method Details
-
getOriginalText
Returns the complete text being parsed.- Returns:
- the text being parsed
-
advanceLexer
void advanceLexer()Advances the lexer to the next token, skipping whitespace and comment tokens. -
getTokenType
Returns the type of current token from the lexer.- Returns:
- the token type, or
nullwhen the token stream is over.
-
setTokenTypeRemapper
Sets optional remapper that can change the type of tokens. Output ofgetTokenType()is affected by it.- Parameters:
remapper- the remapper object, ornull.
-
remapCurrentToken
Slightly easier way to whatITokenTypeRemapperdoes (i.e. it just remaps current token to a given type).- Parameters:
type- new type for the current token.
-
setWhitespaceSkippedCallback
Subscribe for notification on default whitespace and comments skipped events.- Parameters:
callback- an implementation for the callback
-
lookAhead
See what token type is instepsahead.- Parameters:
steps- 0 is current token (i.e. the samegetTokenType()returns)- Returns:
- type element which
getTokenType()will return if we call advancestepstimes in a row
-
rawLookup
See what token type is instepsahead/behind.- Parameters:
steps- 0 is current token (i.e. the samegetTokenType()returns)- Returns:
- type element ahead or behind, including whitespace/comment tokens
-
rawTokenTypeStart
int rawTokenTypeStart(int steps) See what token type is instepsahead/behind current position.- Parameters:
steps- 0 is current token (i.e. the samegetTokenType()returns)- Returns:
- offset type element ahead or behind, including whitespace/comment tokens, -1 if first token,
getOriginalText().getLength()at end
-
rawTokenIndex
int rawTokenIndex()Returns the index of the current token in the original sequence.- Returns:
- token index
-
getTokenText
Returns the text of the current token from the lexer.- Returns:
- the token text, or
nullwhen the token stream is over.
-
getCurrentOffset
int getCurrentOffset()Returns the start offset of the current token, or the file length when the token stream is over.- Returns:
- the token offset.
-
mark
Creates a marker at the current parsing position.- Returns:
- the new marker instance.
-
error
Adds an error marker with the specified message text at the current position in the tree.
Note: from series of subsequent errors messages only first will be part of resulting tree.- Parameters:
messageText- the text of the error message displayed to the user.
-
eof
boolean eof()Checks if the lexer has reached the end of file.- Returns:
trueif the lexer is at end of file,falseotherwise.
-
setDebugMode
void setDebugMode(boolean dbgMode) Enables or disables the builder debug mode. In debug mode, the builder will print stack trace to marker allocation position if one is not done when calling#getTreeBuilt().- Parameters:
dbgMode- the debug mode value.
-
enforceCommentTokens
-
getLatestDoneMarker
- Returns:
- latest left done node for context dependent parsing.
-
isWhitespaceOrComment
-