class ANTLRParseTreeToPSIConverter extends ParseTreeListener
This is how we build an intellij PSI tree from an ANTLR parse tree. We let the ANTLR parser build its kind of ParseTree and then we convert to a PSI tree in one go using a standard ANTLR ParseTreeListener.
The list of SyntaxError objects are pulled from the parser and used for error message highlighting (error nodes don't have the info).
- Alphabetic
- By Inheritance
- ANTLRParseTreeToPSIConverter
- ParseTreeListener
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new ANTLRParseTreeToPSIConverter(language: Language, parser: Parser, builder: PsiBuilder)
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- def enterEveryRule(ctx: ParserRuleContext): Unit
- Definition Classes
- ANTLRParseTreeToPSIConverter → ParseTreeListener
- Annotations
- @Override()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def exitEveryRule(ctx: ParserRuleContext): Unit
- Definition Classes
- ANTLRParseTreeToPSIConverter → ParseTreeListener
- Annotations
- @Override()
- final def getBuilder(): PsiBuilder
- Attributes
- protected[parser]
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- final def getLanguage(): Language
- Attributes
- protected[parser]
- final def getMarkers(): Deque[Marker]
- Attributes
- protected[parser]
- final def getRuleElementTypes(): List[RuleIElementType]
- Attributes
- protected[parser]
- final def getTokenElementTypes(): List[TokenIElementType]
- Attributes
- protected[parser]
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def visitErrorNode(node: ErrorNode): Unit
Summary.
Summary. For any syntax error thrown by the parser, there will be an ErrorNode in the parse tree and this method will process it. All errors correspond to actual tokens in the input except for missing token errors.
There are there are multiple error situations to consider:
- Extraneous token. The parse tree will have an ErrorNode for token.
2. Token mismatch. The parse tree will have an ErrorNode for token.
3. Missing token. The parse tree will have an ErrorNode but it does not correspond to any bit of the input. We underline the current token.
4. NoViableAlt (input inconsistent with any rule alt). The parse tree will have an ErrorNode for token.
5. Tokens consumed to resync the parser during recovery. The parse tree will have an ErrorNode for each token.
This is complicated by errors that occur at EOF but I have modified error strategy to add error nodes for EOF if needed.
Another complication. During prediction, we might match n tokens and then fail on the n+1 token, leading to NoViableAltException. But, it's offending token is at n+1 not current token where prediction started (which we use to find syntax errors). So, SyntaxError objects return start not offending token in this case.
- Definition Classes
- ANTLRParseTreeToPSIConverter → ParseTreeListener
- Annotations
- @Override()
- def visitTerminal(node: TerminalNode): Unit
- Definition Classes
- ANTLRParseTreeToPSIConverter → ParseTreeListener
- Annotations
- @Override()
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)