package psi
Type Members
- class ANTLRPsiLeafNode extends LeafPsiElement
A leaf node you can use as a superclass for your PSI trees.
A leaf node you can use as a superclass for your PSI trees. You don't have to use it of course, but it gives you basic simple scoping behavior via getContext().
I recommends creating a subclass for identifiers, such as MyLanguageIDNode. To enable rename, find usages, etc... that node will need to implement PsiNamedElement.
- class ANTLRPsiNode extends ASTWrapperPsiElement
This class represents an internal, non-leaf "composite" PSI node.
This class represents an internal, non-leaf "composite" PSI node. The term "ANTLRPsiNode" is somewhat of a misnomer as it's really just a PSI node but make sure that getChildren() acts as I would expect, returning all children.
The IElementType of the associated ASTNode's will be
RuleIElementType
and the ASTNode's associated with LeafElement's areTokenIElementType
. The only exception is when parsing snippets of code. In that case, Intellij calls ParserDefinition.createElement() with a TokenIElementType (usually identifier) as the root of the generated PSI tree. So, when looking for an ID, you might get a tree like (ID (expr (primary ID))). Weird but whatever. The root ID is an ANTLRPsiNode and the leaf ID is an ANTLRPsiLeafNode.I've come to the conclusion that it's much easier to build plug-ins when you have PSI trees with heterogeneous types. I typically make subclasses of ANTLRPsiNode for each kind of declaration for use with renaming, find usages, and jump to declaration.
- abstract class IdentifierDefSubtree extends ANTLRPsiNode with PsiNameIdentifierOwner
The superclass of nodes in your PSI tree that come from ANTLR subtree roots and that represent phrases that define/declare variables, functions, ...
The superclass of nodes in your PSI tree that come from ANTLR subtree roots and that represent phrases that define/declare variables, functions, ... Typical subclasses include FunctionSubtree, VardefSubtree, ... To integrate such subclasses, this class implements PsiNameIdentifierOwner.
PsiNameIdentifierOwner points at the root of an entire definition statement rather than the individual ID node within that subtree. I then have getNameIdentifier() return that ID child. See forum thread for more details.
- trait ScopeNode extends PsiElement
This interface acts as a tag so that we can identify nodes in the PSI tree that represent symbol scopes.
This interface acts as a tag so that we can identify nodes in the PSI tree that represent symbol scopes. For example, in a simple language like C with globals, functions, arguments, and local blocks you could create a PSI tree with heterogeneous node types such as FileSubtree, FunctionSubtree, BlockSubtree, etc... Each of those should implement this interface. If you use this mechanism, then the default getContext() mechanism will work; given a node, it looks upward in the PSI tree for a node that implements ScopeNode.
- class Trees extends AnyRef