java.lang.Object
com.intellij.openapi.util.UserDataHolderBase
com.intellij.psi.builder.FleetPsiBuilder<N>
- All Implemented Interfaces:
PsiBuilder,SyntaxTreeBuilder,com.intellij.openapi.util.UserDataHolder
- Direct Known Subclasses:
MarkerPsiBuilder
public abstract class FleetPsiBuilder<N>
extends com.intellij.openapi.util.UserDataHolderBase
implements PsiBuilder
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classNested classes/interfaces inherited from interface com.intellij.lang.PsiBuilder
PsiBuilder.Marker -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFleetPsiBuilder(@NotNull CharSequence text, @NotNull ITokenSequence tokens, @NotNull TokenSet whitespaceTokens, @NotNull TokenSet commentTokens, int startLexeme, int lexemeCount) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdvances the lexer to the next token, skipping whitespace and comment tokens.voidenforceCommentTokens(@NotNull TokenSet tokens) final 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.static @Nullable StringgetErrorMessage(@NotNull LighterASTNode node) @Nullable FleetPsiBuilder.StartMarker@NotNull CharSequenceReturns the complete text being parsed.@Nullable List<FleetPsiBuilder.ProductionMarker>abstract NgetRoot()@Nullable StringReturns the text of the current token from the lexer.@Nullable IElementTypeReturns the type of current token from the lexer.booleanisWhitespaceOrComment(@NotNull IElementType elementType) @Nullable IElementTypelookAhead(int steps) See what token type is instepsahead.@NotNull PsiBuilder.Markermark()Creates a marker at the current parsing position.rawLookup(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(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.booleanwhitespaceOrComment(IElementType token) Methods inherited from class com.intellij.openapi.util.UserDataHolderBase
getUserData, putUserDataMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.intellij.lang.PsiBuilder
getTreeBuilt, getUserData, putUserData
-
Field Details
-
myTokens
-
-
Constructor Details
-
FleetPsiBuilder
public FleetPsiBuilder(@NotNull @NotNull CharSequence text, @NotNull @NotNull ITokenSequence tokens, @NotNull @NotNull TokenSet whitespaceTokens, @NotNull @NotNull TokenSet commentTokens, int startLexeme, int lexemeCount)
-
-
Method Details
-
getRoot
-
isWhitespaceOrComment
- Specified by:
isWhitespaceOrCommentin interfaceSyntaxTreeBuilder
-
enforceCommentTokens
- Specified by:
enforceCommentTokensin interfaceSyntaxTreeBuilder
-
getLatestDoneMarker
- Specified by:
getLatestDoneMarkerin interfaceSyntaxTreeBuilder- Returns:
- latest left done node for context dependent parsing.
-
getOriginalText
Description copied from interface:SyntaxTreeBuilderReturns the complete text being parsed.- Specified by:
getOriginalTextin interfaceSyntaxTreeBuilder- Returns:
- the text being parsed
-
getTokenType
Description copied from interface:SyntaxTreeBuilderReturns the type of current token from the lexer.- Specified by:
getTokenTypein interfaceSyntaxTreeBuilder- Returns:
- the token type, or
nullwhen the token stream is over.
-
setTokenTypeRemapper
Description copied from interface:SyntaxTreeBuilderSets optional remapper that can change the type of tokens. Output ofSyntaxTreeBuilder.getTokenType()is affected by it.- Specified by:
setTokenTypeRemapperin interfaceSyntaxTreeBuilder- Parameters:
remapper- the remapper object, ornull.
-
remapCurrentToken
Description copied from interface:SyntaxTreeBuilderSlightly easier way to whatITokenTypeRemapperdoes (i.e. it just remaps current token to a given type).- Specified by:
remapCurrentTokenin interfaceSyntaxTreeBuilder- Parameters:
type- new type for the current token.
-
lookAhead
Description copied from interface:SyntaxTreeBuilderSee what token type is instepsahead.- Specified by:
lookAheadin interfaceSyntaxTreeBuilder- Parameters:
steps- 0 is current token (i.e. the sameSyntaxTreeBuilder.getTokenType()returns)- Returns:
- type element which
SyntaxTreeBuilder.getTokenType()will return if we call advancestepstimes in a row
-
rawLookup
Description copied from interface:SyntaxTreeBuilderSee what token type is instepsahead/behind.- Specified by:
rawLookupin interfaceSyntaxTreeBuilder- Parameters:
steps- 0 is current token (i.e. the sameSyntaxTreeBuilder.getTokenType()returns)- Returns:
- type element ahead or behind, including whitespace/comment tokens
-
rawTokenTypeStart
public int rawTokenTypeStart(int steps) Description copied from interface:SyntaxTreeBuilderSee what token type is instepsahead/behind current position.- Specified by:
rawTokenTypeStartin interfaceSyntaxTreeBuilder- Parameters:
steps- 0 is current token (i.e. the sameSyntaxTreeBuilder.getTokenType()returns)- Returns:
- offset type element ahead or behind, including whitespace/comment tokens, -1 if first token,
getOriginalText().getLength()at end
-
rawTokenIndex
public int rawTokenIndex()Description copied from interface:SyntaxTreeBuilderReturns the index of the current token in the original sequence.- Specified by:
rawTokenIndexin interfaceSyntaxTreeBuilder- Returns:
- token index
-
setWhitespaceSkippedCallback
Description copied from interface:SyntaxTreeBuilderSubscribe for notification on default whitespace and comments skipped events.- Specified by:
setWhitespaceSkippedCallbackin interfaceSyntaxTreeBuilder- Parameters:
callback- an implementation for the callback
-
advanceLexer
public void advanceLexer()Description copied from interface:SyntaxTreeBuilderAdvances the lexer to the next token, skipping whitespace and comment tokens.- Specified by:
advanceLexerin interfaceSyntaxTreeBuilder
-
getCurrentOffset
public int getCurrentOffset()Description copied from interface:SyntaxTreeBuilderReturns the start offset of the current token, or the file length when the token stream is over.- Specified by:
getCurrentOffsetin interfaceSyntaxTreeBuilder- Returns:
- the token offset.
-
getTokenText
Description copied from interface:SyntaxTreeBuilderReturns the text of the current token from the lexer.- Specified by:
getTokenTextin interfaceSyntaxTreeBuilder- Returns:
- the token text, or
nullwhen the token stream is over.
-
whitespaceOrComment
-
mark
Description copied from interface:SyntaxTreeBuilderCreates a marker at the current parsing position.- Specified by:
markin interfacePsiBuilder- Specified by:
markin interfaceSyntaxTreeBuilder- Returns:
- the new marker instance.
-
eof
public final boolean eof()Description copied from interface:SyntaxTreeBuilderChecks if the lexer has reached the end of file.- Specified by:
eofin interfaceSyntaxTreeBuilder- Returns:
trueif the lexer is at end of file,falseotherwise.
-
error
Description copied from interface:SyntaxTreeBuilderAdds 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.- Specified by:
errorin interfaceSyntaxTreeBuilder- Parameters:
messageText- the text of the error message displayed to the user.
-
getErrorMessage
-
setDebugMode
public void setDebugMode(boolean dbgMode) Description copied from interface:SyntaxTreeBuilderEnables 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().- Specified by:
setDebugModein interfaceSyntaxTreeBuilder- Parameters:
dbgMode- the debug mode value.
-
getProductions
-