com.intellij.lang
Interface PsiBuilder


public interface PsiBuilder

The IDEA side of a custom language parser. Provides lexing results to the plugin and allows the plugin to build the AST tree.

See Also:
PsiParser, ASTNode

Nested Class Summary
static interface PsiBuilder.Marker
          A marker defines a range in the document text which becomes a node in the AST tree.
 
Method Summary
 void advanceLexer()
          Advances the lexer to the next token, skipping whitespace and comment tokens.
 boolean eof()
          Checks if the lexer has reached the end of file.
 void error(java.lang.String messageText)
          Adds an error marker with the specified message text at the current position in the tree.
 int getCurrentOffset()
          Returns the start offset of the current token, or the file length when the lexing is over.
 java.lang.CharSequence getOriginalText()
          Returns the complete text being parsed.
 java.lang.String getTokenText()
          Returns the text of the current token from the lexer.
 IElementType getTokenType()
          Returns the type of current token from the lexer.
 ASTNode getTreeBuilt()
          Returns the result of the parsing.
 PsiBuilder.Marker mark()
          Creates a marker at the current parsing position.
 void setDebugMode(boolean dbgMode)
          Enables or disables the builder debug mode.
 

Method Detail

getOriginalText

java.lang.CharSequence 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

@Nullable
IElementType getTokenType()
Returns the type of current token from the lexer.

Returns:
the token type, or null when lexing is over.

getTokenText

@Nullable
java.lang.String getTokenText()
Returns the text of the current token from the lexer.

Returns:
the token text, or null when the lexing is over.

getCurrentOffset

int getCurrentOffset()
Returns the start offset of the current token, or the file length when the lexing is over.

Returns:
the token offset.

mark

PsiBuilder.Marker mark()
Creates a marker at the current parsing position.

Returns:
the new marker instance.

error

void error(java.lang.String messageText)
Adds an error marker with the specified message text at the current position in the 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:
true if the lexer is at end of file, false otherwise.

getTreeBuilt

ASTNode getTreeBuilt()
Returns the result of the parsing. All markers must be completed or dropped before this method is called.

Returns:
the built tree.

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.