public abstract class MXMLNodeBase extends NodeBase implements IMXMLNode
MXMLNodeBase
is the abstract base class for all MXML nodes in an AST.
Although the MXML node interfaces (i.e., IMXMLNode
and its
subinterfaces) support only read-only operations on the MXML AST, the MXML
node class contain the logic for building the tree node-by-node from the MXML
DOM.
For example, the processing of the <Script> tag is handled by the
MXMLScriptNode
class, which encapsulates the logic that a
<Script> tag can only have namespace attributes and a
source
attribute, and that it cannot have any child tags.
This base class handles some analysis that must be done on every kind of MXML tag:
Problems at the level of incorrect XML are noticed before tree construction, during MXML parsing. Such problems include:
The default behavior implemented in this base class reports a problem for every attribute (except for namespace and private ones) and every non-whitespace text unit. In other words, by default it implements "you can't put that here". It is the responsibility then of subclasses to allow particular attributes and content units rather than disallow them.
Modifier and Type | Class and Description |
---|---|
protected static class |
MXMLNodeBase.MXMLNodeInfo
MXML node classes can choose to create this object in
createNodeInfo() . |
emptyNodeArray, parent
UNKNOWN
Modifier and Type | Method and Description |
---|---|
protected void |
accumulateTextFragments(MXMLTreeBuilder builder,
IMXMLTextData text,
MXMLNodeBase.MXMLNodeInfo info)
Accumulates source fragments that are produced by a text unit for later
processing.
|
void |
adjustOffsets(MXMLTreeBuilder builder)
Translates the node's start and end offset from local to absolute
offsets.
|
protected MXMLNodeBase.MXMLNodeInfo |
createNodeInfo(MXMLTreeBuilder builder) |
IASNode |
getChild(int i)
Get a particular child of this node
|
int |
getChildCount()
Get the number of children
|
IMXMLClassDefinitionNode |
getClassDefinitionNode()
Gets the closest ancestor node that defines a class.
|
IMXMLDocumentNode |
getDocumentNode()
Gets the closest ancestor node that is the root node of the MXML file.
|
IMXMLFileNode |
getFileNode()
Gets the root file node.
|
protected void |
initializationComplete(MXMLTreeBuilder builder,
IMXMLTagData tag,
MXMLNodeBase.MXMLNodeInfo info)
This method gives subclasses a chance to do final processing after
considering each attribute and content unit.
|
protected void |
initializeFromTag(MXMLTreeBuilder builder,
IMXMLTagData tag)
Initializes this MXML node from an MXML tag by processing the attribute
and content units of the tag.
|
protected static boolean |
isValidASIdentifier(String identifier)
Determines whether the specified String is a single valid ActionScript
identifier, by tokenizing it.
|
boolean |
isValidForCodeGen()
Indicates whether code should be generated for this node.
|
protected static boolean |
isValidXMLTagName(String tagName)
Determines whether the specified String is a valid XML tag name
by appending it to "<" and tokenizing it.
|
protected void |
processChildNonWhitespaceUnit(MXMLTreeBuilder builder,
IMXMLTagData tag,
IMXMLTextData text,
MXMLNodeBase.MXMLNodeInfo info)
Processes a single child text unit which is not all whitespace.
|
protected void |
processChildTag(MXMLTreeBuilder builder,
IMXMLTagData tag,
IMXMLTagData childTag,
MXMLNodeBase.MXMLNodeInfo info)
Processes a single child tag.
|
protected void |
processChildWhitespaceUnit(MXMLTreeBuilder builder,
IMXMLTagData tag,
IMXMLTextData text,
MXMLNodeBase.MXMLNodeInfo info)
Processes a single child text unit which is all whitespace.
|
protected String[] |
processIncludeInOrExcludeFromAttribute(MXMLTreeBuilder builder,
IMXMLTagAttributeData attribute)
Processes an
includeIn="..." |
protected void |
processTagSpecificAttribute(MXMLTreeBuilder builder,
IMXMLTagData tag,
IMXMLTagAttributeData attribute,
MXMLNodeBase.MXMLNodeInfo info)
Processes a single tag-specific attribute (i.e., one that isn't allowed
on every tag, unlike a namespace attribute or a private attribute).
|
static List<ScopedBlockNode> |
processUnitAsAS(MXMLTreeBuilder builder,
IMXMLTagData tag,
String sourcePath,
ASScope containingScope,
PostProcessStep buildOrReconnect,
IMXMLFileNode ancestorFileNode)
Processes all the children of the given
IMXMLTagData unit that are
IMXMLTextData nodes. |
static String |
resolveSourceAttributePath(MXMLTreeBuilder builder,
IMXMLTagAttributeData attribute,
MXMLNodeBase.MXMLNodeInfo info)
Resolves the path specified in an MXML tag's
source
attribute. |
protected void |
setLocation(IMXMLTagAttributeData attribute)
Sets the start/end/line/column location information for this node.
|
protected void |
setLocation(IMXMLUnitData unit)
Sets the start/end/line/column location information for this node.
|
void |
setLocation(ISourceLocation location)
Sets the start/end/line/column location information for this node.
|
protected void |
setLocation(MXMLTreeBuilder builder,
List<IMXMLUnitData> units)
Sets the start/end/line/column location information for this node so that
it spans a list of MXML content units.
|
void |
setLocation(String sourcePath,
int start,
int end,
int line,
int column)
Sets the start/end/line/column location information for this node.
|
analyze, buildInnerString, buildStringRecursive, canContinueContainmentSearch, collectImportNodes, combineAttributes, connectedToProjectScope, contains, endAfter, endAfter, endBefore, endBefore, fillInOffsets, getAbsoluteEnd, getAbsoluteStart, getAncestorOfType, getASScope, getContainingFilePath, getContainingNode, getContainingScope, getEnd, getFileScope, getFileSpecification, getInnerString, getNodeKind, getPackageName, getParent, getScopeNode, getSpanningStart, getStart, getSucceedingNode, getWorkspace, isTerminal, isTransparent, looselyContains, normalize, replaceChild, runPostProcess, setChildren, setParent, span, span, span, startAfter, startAfter, startBefore, startBefore, swapChildren, toString, tryGetOffsetLookup, verify
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
contains, getAncestorOfType, getContainingNode, getContainingScope, getFileSpecification, getNodeID, getPackageName, getParent, getSpanningStart, getSucceedingNode, isTerminal
getAbsoluteEnd, getAbsoluteStart, getColumn, getEnd, getEndColumn, getEndLine, getLine, getSourcePath, getStart
public static String resolveSourceAttributePath(MXMLTreeBuilder builder, IMXMLTagAttributeData attribute, MXMLNodeBase.MXMLNodeInfo info)
source
attribute.builder
- The MXMLTreeBuilder
object which is building this
MXML tree.attribute
- The source
attribute.protected static boolean isValidASIdentifier(String identifier)
identifier
- A String to be tokenized.true
if the String tokenizes to a single identifier
token.protected static boolean isValidXMLTagName(String tagName)
tagName
- A String proposed as a tag name.true
if the String is a valid tag name.public boolean isValidForCodeGen()
IMXMLNode
If this method returns false
, there is something invalid
about this node, or one of its descendants, that prevents code
generation.
isValidForCodeGen
in interface IMXMLNode
protected void initializeFromTag(MXMLTreeBuilder builder, IMXMLTagData tag)
builder
- The MXMLTreeBuilder
object which is building this
MXML tree.tag
- The MXML tag from which this MXML node is being created.protected MXMLNodeBase.MXMLNodeInfo createNodeInfo(MXMLTreeBuilder builder)
protected void initializationComplete(MXMLTreeBuilder builder, IMXMLTagData tag, MXMLNodeBase.MXMLNodeInfo info)
The base class version calls adjustOffset
to translate the
node start and end offset from local to absolute offsets.
public void adjustOffsets(MXMLTreeBuilder builder)
public IASNode getChild(int i)
IASNode
public int getChildCount()
IASNode
getChildCount
in interface IASNode
getChildCount
in class NodeBase
public IMXMLClassDefinitionNode getClassDefinitionNode()
IMXMLNode
getClassDefinitionNode
in interface IMXMLNode
IMXMLClassDefinitionNode
object.public IMXMLDocumentNode getDocumentNode()
IMXMLNode
getDocumentNode
in interface IMXMLNode
IMXMLDocumentNode
object.public IMXMLFileNode getFileNode()
IMXMLNode
getFileNode
in interface IMXMLNode
IOldMXMLFileNode
object.protected void processTagSpecificAttribute(MXMLTreeBuilder builder, IMXMLTagData tag, IMXMLTagAttributeData attribute, MXMLNodeBase.MXMLNodeInfo info)
The attribute might be specifying a property, event, or style; or it might be a special compile-time attribute such as 'id', 'includeIn', 'excludeFrom', 'source', etc. A property/event/style attribute will cause a child node to be added to this node; a compile-time attribute typically will simply set a property of the node.
The default behavior implemented in this base class is to report each tag-specific attribute as a problem.
Subclasses must override this method in order to allow tag-specific attributes.
attribute
- An MXMLTagAttributeData
object representing the
attribute.protected void processChildTag(MXMLTreeBuilder builder, IMXMLTagData tag, IMXMLTagData childTag, MXMLNodeBase.MXMLNodeInfo info)
tag
- An MXMLTagData
object representing the child tag.
The default behavior implemented in this base class is to report each child tag as a problem.
Subclasses must override this method in order to allow the child tags that they recognize.
protected void processChildWhitespaceUnit(MXMLTreeBuilder builder, IMXMLTagData tag, IMXMLTextData text, MXMLNodeBase.MXMLNodeInfo info)
The default behavior implemented in this base class is to ignore whitespace.
Subclasses must override this method in order to disallow whitespace text units.
text
- An MXMLTextData
object representing the child text
unit.protected void processChildNonWhitespaceUnit(MXMLTreeBuilder builder, IMXMLTagData tag, IMXMLTextData text, MXMLNodeBase.MXMLNodeInfo info)
The default behavior implemented in this base class is to report each unit of non-whitespace as a problem.
Subclasses must override this method in order to allow the non-whitespace text unit.
text
- An MXMLTextData
object representing the child text
unit.public static List<ScopedBlockNode> processUnitAsAS(MXMLTreeBuilder builder, IMXMLTagData tag, String sourcePath, ASScope containingScope, PostProcessStep buildOrReconnect, IMXMLFileNode ancestorFileNode)
IMXMLTagData
unit that are
IMXMLTextData
nodes. Each node will be processes separately, in
the order in which the appear in the document.
This method is only used by MXML AST building. To parse an ActionScript
block for scope building, see MXMLScopeBuilder.processScriptTag(org.apache.flex.compiler.mxml.IMXMLTagData)
.
tag
- the IMXMLTagData
to processList
of ScopedBlockNode
s for each
IMXMLTextData
we encountered.public void setLocation(String sourcePath, int start, int end, int line, int column)
start
- The starting offset of this node.end
- The ending offset of this node.line
- The number of the line on which this node starts.column
- This number of the column at which this node starts.public void setLocation(ISourceLocation location)
location
- A SourceLocation
object.protected void setLocation(IMXMLUnitData unit)
unit
- The MXML unit from which this node was created.protected void setLocation(IMXMLTagAttributeData attribute)
attribute
- The MXML attribute from which this node was created.protected void setLocation(MXMLTreeBuilder builder, List<IMXMLUnitData> units)
units
- A list of MXML content units.protected void accumulateTextFragments(MXMLTreeBuilder builder, IMXMLTextData text, MXMLNodeBase.MXMLNodeInfo info)
protected String[] processIncludeInOrExcludeFromAttribute(MXMLTreeBuilder builder, IMXMLTagAttributeData attribute)
includeIn="..."
or
excludeFrom"..."
attribute on an instance tag or a
<Reparent>
tag.Copyright © 2016 The Apache Software Foundation. All rights reserved.