public abstract class NodeBase extends SourceLocation implements IASNode
Modifier and Type | Field and Description |
---|---|
protected static IASNode[] |
emptyNodeArray
Used in calls to CheapArray functions.
|
protected IASNode |
parent
Parent node.
|
UNKNOWN
Constructor and Description |
---|
NodeBase()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
analyze(EnumSet<PostProcessStep> set,
ASScope scope,
Collection<ICompilerProblem> problems) |
protected boolean |
buildInnerString(StringBuilder sb)
For debugging only.
|
void |
buildStringRecursive(StringBuilder sb,
int level,
boolean skipSrcPath)
For debugging only.
|
protected boolean |
canContinueContainmentSearch(IASNode containingNode,
IASNode currentNode,
int childOffset,
boolean offsetsStillValid) |
void |
collectImportNodes(Collection<IImportNode> importNodes)
Collects the import nodes that are descendants of this node
but which are not contained within a scoped node.
|
static String[] |
combineAttributes(String[] superAttributes,
String[] myAttributes)
Combine the attributes from the base class with the attributes specific
to this class
|
protected void |
connectedToProjectScope()
Allow various subclasses to do special kludgy things like identify
mx.core.Application.application
|
boolean |
contains(int offset)
Determine whether the offset fits within this node.
|
void |
endAfter(ISourceLocation location)
Set the end offset of the node to fall just after the token.
|
void |
endAfter(antlr.Token token)
Set the end offset of the node to fall just after the token.
|
void |
endBefore(ISourceLocation location)
Set the end offset of the node to fall just before the token.
|
void |
endBefore(antlr.Token token)
Set the end offset of the node to fall just before the token.
|
protected void |
fillInOffsets()
If the start and end offsets haven't been set explicitly, fill them in
based on the offsets of the children.
|
int |
getAbsoluteEnd()
Gets the absolute starting offset.
|
int |
getAbsoluteStart()
Gets the absolute starting offset.
|
IASNode |
getAncestorOfType(Class<? extends IASNode> nodeType)
Get the nearest ancestor of this node that has the specified type.
|
ASScope |
getASScope()
Get the scope this Node uses for name resolution as an ASScope.
|
IASNode |
getChild(int i)
Get a particular child of this node
|
int |
getChildCount()
Get the number of children
|
String |
getContainingFilePath()
Get the path of the file in which this parse tree node resides.
|
IASNode |
getContainingNode(int offset)
Gets the child node that contains the offset
|
IScopedNode |
getContainingScope()
Gets the containing scope for this node
|
int |
getEnd()
Get the node's local end offset.
|
ASFileScope |
getFileScope() |
IFileSpecification |
getFileSpecification()
Get the
IFileSpecification that produced this node |
String |
getInnerString()
For debugging only.
|
String |
getNodeKind()
Get the node type as a string.
|
String |
getPackageName()
Get package name that applies to this node.
|
IASNode |
getParent()
Get the parent of this node
|
IScopedNode |
getScopeNode()
Get the nearest containing scope for this node.
|
int |
getSpanningStart()
Gets the local offset where the node starts, including any extra items that may
change the appearance of the node's start.
|
int |
getStart()
Get the node's local start offset.
|
IASNode |
getSucceedingNode(int offset)
Get the first node that succeeds the offset (i.e. which starts after the
offset).
|
IWorkspace |
getWorkspace()
Get's the
IWorkspace in which this NodeBase lives. |
boolean |
isTerminal()
Determines if this node is a terminal node, meaning it cannot have
children
|
boolean |
isTransparent()
Determine whether this node is transparent.
|
boolean |
looselyContains(int offset)
Determine whether the offset "loosely" fits within this node.
|
void |
normalize(boolean fillInOffsets)
Normalize the tree.
|
protected void |
replaceChild(NodeBase child,
NodeBase target)
Replaces the child with the given target.
|
Collection<ICompilerProblem> |
runPostProcess(EnumSet<PostProcessStep> set,
ASScope containingScope) |
protected void |
setChildren(boolean fillInOffsets)
If this node has custom children (names, arguments, etc), shove them into
the list of children.
|
void |
setParent(NodeBase parent)
Set the parent node.
|
void |
span(int start,
int end,
int line,
int column)
Set the start and end offsets of the node.
|
void |
span(antlr.Token token)
Set the start and end offsets of the node to coincide with the token's
offsets.
|
void |
span(antlr.Token firstToken,
antlr.Token lastToken)
Set the start and end offsets of the node to coincide with the tokens'
offsets.
|
void |
startAfter(ISourceLocation location)
Set the start offset of the node to fall just after the token.
|
void |
startAfter(antlr.Token token)
Set the start offset of the node to fall just after the token.
|
void |
startBefore(ISourceLocation location)
Set the start offset of the node to fall just before the token.
|
void |
startBefore(antlr.Token token)
Set the start offset of the node to fall just before the token.
|
protected void |
swapChildren(NodeBase child,
NodeBase target)
Changes the position of two children in our tree.
|
String |
toString()
For debugging only.
|
protected OffsetLookup |
tryGetOffsetLookup() |
boolean |
verify()
Used only in asserts.
|
getColumn, getEndColumn, getEndLine, getLine, getLineColumnString, getOffsetsString, getSourcePath, getSourcePathString, setColumn, setEnd, setEndColumn, setEndLine, setLine, setSourceLocation, setSourcePath, setStart, span, span
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getColumn, getEndColumn, getEndLine, getLine, getSourcePath
protected static final IASNode[] emptyNodeArray
protected IASNode parent
Methods (even in NodeBase itself) should use getParent() instead of accessing this member directly. getParent() is overridden in FileNode to do something special when the FileNode represents a shared file.
public static String[] combineAttributes(String[] superAttributes, String[] myAttributes)
superAttributes
- The attributes of the base class.myAttributes
- The attributes of this class.public IASNode getParent()
IASNode
public int getChildCount()
IASNode
getChildCount
in interface IASNode
public IASNode getChild(int i)
IASNode
public IFileSpecification getFileSpecification()
IASNode
IFileSpecification
that produced this nodegetFileSpecification
in interface IASNode
public int getSpanningStart()
IASNode
getSpanningStart
in interface IASNode
public String getNodeKind()
public boolean contains(int offset)
IASNode
public boolean looselyContains(int offset)
offset
- the offset to testpublic IASNode getSucceedingNode(int offset)
IASNode
getSucceedingNode
in interface IASNode
offset
- the offset for which to searchpublic boolean isTransparent()
public IASNode getContainingNode(int offset)
IASNode
getContainingNode
in interface IASNode
offset
- an offestpublic boolean isTerminal()
IASNode
isTerminal
in interface IASNode
public IScopedNode getContainingScope()
IASNode
getContainingScope
in interface IASNode
IScopedNode
protected boolean canContinueContainmentSearch(IASNode containingNode, IASNode currentNode, int childOffset, boolean offsetsStillValid)
public IASNode getAncestorOfType(Class<? extends IASNode> nodeType)
IASNode
getAncestorOfType
in interface IASNode
nodeType
- the node type for which to searchpublic String getPackageName()
IASNode
getPackageName
in interface IASNode
public void startAfter(antlr.Token token)
token
- start this node after this tokenpublic final void startAfter(ISourceLocation location)
location
- start this node after this tokenpublic final void startBefore(antlr.Token token)
token
- start this node before this tokenpublic final void startBefore(ISourceLocation location)
location
- start this node before this tokenpublic final void endAfter(antlr.Token token)
token
- end this node after this tokenpublic final void endAfter(ISourceLocation location)
location
- end this node after this tokenpublic final void endBefore(antlr.Token token)
token
- start this node before this tokenpublic final void endBefore(ISourceLocation location)
location
- start this node before this tokenpublic final void span(antlr.Token token)
token
- the token to take the offsets frompublic final void span(antlr.Token firstToken, antlr.Token lastToken)
firstToken
- the token to take the start offset and line number fromlastToken
- the token to take the end offset frompublic final void span(int start, int end, int line, int column)
start
- start offset for the nodeend
- end offset for the nodeline
- line number for the nodepublic Collection<ICompilerProblem> runPostProcess(EnumSet<PostProcessStep> set, ASScope containingScope)
protected void analyze(EnumSet<PostProcessStep> set, ASScope scope, Collection<ICompilerProblem> problems)
protected void swapChildren(NodeBase child, NodeBase target)
child
- the child to replace targettarget
- the child to replace childprotected void replaceChild(NodeBase child, NodeBase target)
public void normalize(boolean fillInOffsets)
protected void connectedToProjectScope()
protected void setChildren(boolean fillInOffsets)
protected void fillInOffsets()
public void setParent(NodeBase parent)
parent
- parent nodepublic IScopedNode getScopeNode()
public String getContainingFilePath()
The tree builder can set a node's origin source file using
SourceLocation.setSourcePath(String)
. If the source path was set, return the
source path; Otherwise, use root FileNode
's path.
public final String toString()
FileNode "D:\tests\UIComponent.as" 0:0 0-467464 D:\tests\UIComponent.as PackageNode "mx.core" 12:1 436-465667 D:\tests\UIComponent.as FullNameNode "mx.core" 0:0 444-451 null IdentifierNode "mx" 12:9 444-446 D:\tests\UIComponent.as IdentifierNode "core" 12:12 447-451 D:\tests\UIComponent.as ScopedBlockNode 13:1 454-465667 D:\tests\UIComponent.as ImportNode "flash.accessibility.Accessibility" 14:1 457-497 D:\tests\UIComponent.as FullNameNode "flash.accessibility.Accessibility" 0:0 464-497 null FullNameNode "flash.accessibility" 0:0 464-483 null IdentifierNode "flash" 14:8 464-469 D:\tests\UIComponent.as IdentifierNode "accessibility" 14:14 470-483 D:\tests\UIComponent.as IdentifierNode "Accessibility" 14:28 484-497 D:\tests\UIComponent.as ...
Subclasses may not override this, because we want to maintain regularity for how all nodes display.
toString
in class SourceLocation
public void buildStringRecursive(StringBuilder sb, int level, boolean skipSrcPath)
toString()
, and recursively by
itself, to display this node on one line and each descendant node on
subsequent indented lines.
*protected boolean buildInnerString(StringBuilder sb)
buildOuterString()
.
It is overridden by subclasses to display optional node-specific
information in the middle of the string, between the node type and the
location information.public String getInnerString()
public ASFileScope getFileScope()
protected final OffsetLookup tryGetOffsetLookup()
OffsetLookup
object for the current tree or null.public IWorkspace getWorkspace()
IWorkspace
in which this NodeBase
lives.IWorkspace
in which this NodeBase
lives.public ASScope getASScope()
public int getStart()
getStart
in interface ISourceLocation
getStart
in class SourceLocation
public int getEnd()
getEnd
in interface ISourceLocation
getEnd
in class SourceLocation
public int getAbsoluteStart()
ISourceLocation
getAbsoluteStart
in interface ISourceLocation
getAbsoluteStart
in class SourceLocation
public int getAbsoluteEnd()
ISourceLocation
getAbsoluteEnd
in interface ISourceLocation
getAbsoluteEnd
in class SourceLocation
public void collectImportNodes(Collection<IImportNode> importNodes)
This is a helper method for IScopedNode.getAllImportNodes(java.util.Collection<org.apache.flex.compiler.tree.as.IImportNode>)
().
Since that method walks up the chain of scoped nodes, we don't want
to look inside scoped nodes that were already processed.
importNodes
- The collection of import nodes being built.public boolean verify()
Copyright © 2016 The Apache Software Foundation. All rights reserved.