Class FleetPsiBuilder<N>

java.lang.Object
com.intellij.psi.builder.FleetPsiBuilder<N>
All Implemented Interfaces:
PsiBuilder, SyntaxTreeBuilder, UserDataHolder
Direct Known Subclasses:
MarkerPsiBuilder

public abstract class FleetPsiBuilder<N> extends Object implements PsiBuilder
  • 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

      @NotNull public abstract N getRoot()
    • isWhitespaceOrComment

      public boolean isWhitespaceOrComment(@NotNull @NotNull IElementType elementType)
      Specified by:
      isWhitespaceOrComment in interface SyntaxTreeBuilder
    • enforceCommentTokens

      public void enforceCommentTokens(@NotNull @NotNull TokenSet tokens)
      Specified by:
      enforceCommentTokens in interface SyntaxTreeBuilder
    • getLatestDoneMarker

      @Nullable public @Nullable com.intellij.psi.builder.FleetPsiBuilder.StartMarker getLatestDoneMarker()
      Specified by:
      getLatestDoneMarker in interface SyntaxTreeBuilder
      Returns:
      latest left done node for context dependent parsing.
    • getUserData

      @Nullable public <T> T getUserData(@NotNull @NotNull Key<T> key)
      Specified by:
      getUserData in interface PsiBuilder
      Specified by:
      getUserData in interface UserDataHolder
      Returns:
      a user data value associated with this object. Doesn't require read action.
    • putUserData

      public <T> void putUserData(@NotNull @NotNull Key<T> key, @Nullable T value)
      Description copied from interface: PsiBuilder
      Add a new user data value to this object. Doesn't require write action.
      Specified by:
      putUserData in interface PsiBuilder
      Specified by:
      putUserData in interface UserDataHolder
    • getOriginalText

      @NotNull public @NotNull CharSequence getOriginalText()
      Description copied from interface: SyntaxTreeBuilder
      Returns the complete text being parsed.
      Specified by:
      getOriginalText in interface SyntaxTreeBuilder
      Returns:
      the text being parsed
    • getTokenType

      @Nullable public @Nullable IElementType getTokenType()
      Description copied from interface: SyntaxTreeBuilder
      Returns the type of current token from the lexer.
      Specified by:
      getTokenType in interface SyntaxTreeBuilder
      Returns:
      the token type, or null when the token stream is over.
    • setTokenTypeRemapper

      public void setTokenTypeRemapper(ITokenTypeRemapper remapper)
      Description copied from interface: SyntaxTreeBuilder
      Sets optional remapper that can change the type of tokens. Output of SyntaxTreeBuilder.getTokenType() is affected by it.
      Specified by:
      setTokenTypeRemapper in interface SyntaxTreeBuilder
      Parameters:
      remapper - the remapper object, or null.
    • remapCurrentToken

      public void remapCurrentToken(IElementType type)
      Description copied from interface: SyntaxTreeBuilder
      Slightly easier way to what ITokenTypeRemapper does (i.e. it just remaps current token to a given type).
      Specified by:
      remapCurrentToken in interface SyntaxTreeBuilder
      Parameters:
      type - new type for the current token.
    • lookAhead

      @Nullable public @Nullable IElementType lookAhead(int steps)
      Description copied from interface: SyntaxTreeBuilder
      See what token type is in steps ahead.
      Specified by:
      lookAhead in interface SyntaxTreeBuilder
      Parameters:
      steps - 0 is current token (i.e. the same SyntaxTreeBuilder.getTokenType() returns)
      Returns:
      type element which SyntaxTreeBuilder.getTokenType() will return if we call advance steps times in a row
    • rawLookup

      public IElementType rawLookup(int steps)
      Description copied from interface: SyntaxTreeBuilder
      See what token type is in steps ahead/behind.
      Specified by:
      rawLookup in interface SyntaxTreeBuilder
      Parameters:
      steps - 0 is current token (i.e. the same SyntaxTreeBuilder.getTokenType() returns)
      Returns:
      type element ahead or behind, including whitespace/comment tokens
    • rawTokenTypeStart

      public int rawTokenTypeStart(int steps)
      Description copied from interface: SyntaxTreeBuilder
      See what token type is in steps ahead/behind current position.
      Specified by:
      rawTokenTypeStart in interface SyntaxTreeBuilder
      Parameters:
      steps - 0 is current token (i.e. the same SyntaxTreeBuilder.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: SyntaxTreeBuilder
      Returns the index of the current token in the original sequence.
      Specified by:
      rawTokenIndex in interface SyntaxTreeBuilder
      Returns:
      token index
    • setWhitespaceSkippedCallback

      public void setWhitespaceSkippedCallback(@Nullable @Nullable WhitespaceSkippedCallback callback)
      Description copied from interface: SyntaxTreeBuilder
      Subscribe for notification on default whitespace and comments skipped events.
      Specified by:
      setWhitespaceSkippedCallback in interface SyntaxTreeBuilder
      Parameters:
      callback - an implementation for the callback
    • advanceLexer

      public void advanceLexer()
      Description copied from interface: SyntaxTreeBuilder
      Advances the lexer to the next token, skipping whitespace and comment tokens.
      Specified by:
      advanceLexer in interface SyntaxTreeBuilder
    • getCurrentOffset

      public int getCurrentOffset()
      Description copied from interface: SyntaxTreeBuilder
      Returns the start offset of the current token, or the file length when the token stream is over.
      Specified by:
      getCurrentOffset in interface SyntaxTreeBuilder
      Returns:
      the token offset.
    • getTokenText

      @Nullable public @Nullable String getTokenText()
      Description copied from interface: SyntaxTreeBuilder
      Returns the text of the current token from the lexer.
      Specified by:
      getTokenText in interface SyntaxTreeBuilder
      Returns:
      the token text, or null when the token stream is over.
    • whitespaceOrComment

      public boolean whitespaceOrComment(IElementType token)
    • mark

      @NotNull public @NotNull PsiBuilder.Marker mark()
      Description copied from interface: SyntaxTreeBuilder
      Creates a marker at the current parsing position.
      Specified by:
      mark in interface PsiBuilder
      Specified by:
      mark in interface SyntaxTreeBuilder
      Returns:
      the new marker instance.
    • eof

      public final boolean eof()
      Description copied from interface: SyntaxTreeBuilder
      Checks if the lexer has reached the end of file.
      Specified by:
      eof in interface SyntaxTreeBuilder
      Returns:
      true if the lexer is at end of file, false otherwise.
    • error

      public void error(@NotNull @NotNull String messageText)
      Description copied from interface: SyntaxTreeBuilder
      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.
      Specified by:
      error in interface SyntaxTreeBuilder
      Parameters:
      messageText - the text of the error message displayed to the user.
    • getErrorMessage

      @Nullable public static @Nullable String getErrorMessage(@NotNull @NotNull LighterASTNode node)
    • setDebugMode

      public void setDebugMode(boolean dbgMode)
      Description copied from interface: SyntaxTreeBuilder
      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().
      Specified by:
      setDebugMode in interface SyntaxTreeBuilder
      Parameters:
      dbgMode - the debug mode value.
    • getProductions

      @Nullable public @Nullable List<FleetPsiBuilder.ProductionMarker> getProductions()