Class PsiBuilderAdapter

java.lang.Object
com.intellij.lang.impl.PsiBuilderAdapter
All Implemented Interfaces:
PsiBuilder, SyntaxTreeBuilder, com.intellij.openapi.util.UserDataHolder
Direct Known Subclasses:
GeneratedParserUtilBase.Builder, IndentPsiBuilder

public class PsiBuilderAdapter extends Object implements PsiBuilder
  • Field Details

    • myDelegate

      protected final PsiBuilder myDelegate
  • Constructor Details

    • PsiBuilderAdapter

      public PsiBuilderAdapter(@NotNull @NotNull PsiBuilder delegate)
  • Method Details

    • getDelegate

      @NotNull public @NotNull PsiBuilder getDelegate()
    • 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
    • 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
    • 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.
    • 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
    • isWhitespaceOrComment

      public boolean isWhitespaceOrComment(@NotNull @NotNull IElementType elementType)
      Specified by:
      isWhitespaceOrComment in interface SyntaxTreeBuilder
    • 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

      public 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
    • getTokenText

      @Nullable @NonNls public @Nullable @NonNls 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.
    • 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.
    • 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.
    • 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.
    • eof

      public 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.
    • 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.
    • enforceCommentTokens

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

      @Nullable public @Nullable LighterASTNode getLatestDoneMarker()
      Specified by:
      getLatestDoneMarker in interface SyntaxTreeBuilder
      Returns:
      latest left done node for context dependent parsing.
    • getUserData

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

      public <T> void putUserData(@NotNull @NotNull com.intellij.openapi.util.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 com.intellij.openapi.util.UserDataHolder