public class MXMLTreeBuilder extends Object
MXMLTreeBuilder
is used by MXMLCompilationUnit
to build
abstract syntax trees (ASTs) for MXML files.
The input for MXML tree-building is an MXMLData
object, a DOM-like
representing of an MXML file, and the MXMLFileScope
already
constructed from that MXMLData
. The output is an
IOldMXMLFileNode
object, the root of a MXML AST.
MXMLTreeBuilder
is the only public class in this package.
An instance of this class is passed to each tree-building method in MXML node classes. It provides quick access to various useful objects while building an MXML AST.
Constructor and Description |
---|
MXMLTreeBuilder(MXMLCompilationUnit compilationUnit,
IFileSpecificationGetter fileSpecGetter,
String qname,
IMXMLData mxmlData,
MXMLFileScope fileScope,
Collection<ICompilerProblem> problems)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addDependency(String qname,
DependencyType type)
Adds a dependency from the current compilation unit to the compilation
unit for the specified qualified name.
|
void |
addExpressionDependency(String qname)
Adds an expression dependency from the current compilation unit to the
compilation unit for the specified qualified name.
|
void |
addProblem(ICompilerProblem problem) |
IMXMLFileNode |
build()
Builds an MXML tree.
|
NodeBase |
createExpressionNode(IMXMLNode propertyNode,
ITypeDefinition type,
ISourceFragment[] fragments,
ISourceLocation location,
EnumSet<MXMLDialect.TextParsingFlags> flags,
Object defaultValue,
MXMLClassDefinitionNode classNode)
Creates a databinding node, a class directive node, or a literal node.
|
org.apache.flex.compiler.internal.tree.mxml.MXMLInstanceNode |
createInstanceNode(NodeBase parent,
ITypeDefinition type,
ISourceFragment[] fragments,
ISourceLocation location,
EnumSet<MXMLDialect.TextParsingFlags> flags,
MXMLClassDefinitionNode classNode)
Parses the specified source fragments as a databinding, or a compiler
directive, or a textual value of the specified type and returns an MXML
instance node representing the result.
|
ITypeDefinition |
getBuiltinType(String name) |
MXMLCompilationUnit |
getCompilationUnit()
Gets the compilation unit which is building the MXML tree.
|
IMXMLData |
getExternalMXMLData(IMXMLTagAttributeData sourceAttribute,
String resolvedSourcePath)
Gets the
IMXMLData representation of an external file specified by
a source attribute. |
MXMLFileNode |
getFileNode() |
MXMLFileScope |
getFileScope()
Gets the file scope previously built for thsi compilation unit.
|
IFileSpecification |
getFileSpecification()
Gets the file specification of the MXML file.
|
IFileSpecificationGetter |
getFileSpecificationGetter() |
IMXMLData |
getMXMLData()
Gets the DOM representation of the MXML file.
|
MXMLDialect |
getMXMLDialect()
Gets the version of MXML used by the MXML file.
|
String |
getPath()
Gets the path of the MXML file.
|
IVariableDefinition |
getPercentProxyDefinition() |
Collection<ICompilerProblem> |
getProblems() |
FlexProject |
getProject()
Gets the project which is building the MXML tree.
|
ASProjectScope |
getProjectScope()
Gets the project scope for building the MXML tree.
|
String |
getQName()
Gets the fully-qualified classname for the MXML file.
|
Workspace |
getWorkspace()
Gets the workspace which is building the MXML tree.
|
NodeBase |
parseExpressionNode(ITypeDefinition type,
ISourceFragment[] fragments,
ISourceLocation location,
EnumSet<MXMLDialect.TextParsingFlags> flags,
Object defaultValue,
MXMLClassDefinitionNode classNode,
boolean postProcess) |
String |
readExternalFile(IMXMLTagAttributeData sourceAttribute,
String resolvedSourcePath)
Reads an external file specified by a
source attribute. |
String |
toString()
For debugging only.
|
public MXMLTreeBuilder(MXMLCompilationUnit compilationUnit, IFileSpecificationGetter fileSpecGetter, String qname, IMXMLData mxmlData, MXMLFileScope fileScope, Collection<ICompilerProblem> problems)
fileSpecGetter
- The IFileSpecificationGetter
that will be
used to open included files.compilationUnit
- The compilation unit which is compiling the MXML
file.qname
- The fully-qualified classname corresponding to the MXML
file.mxmlData
- The DOM representation of the MXML file.fileScope
- The file scope already built for the MXML file.problems
- An existing collection of ICompilerProblem
objects to which the tree-building code adds the problems it finds.public MXMLCompilationUnit getCompilationUnit()
MXMLCompilationUnit
object.public FlexProject getProject()
FlexProject
object.public ASProjectScope getProjectScope()
ASProjectScope
object.public Workspace getWorkspace()
Workspace
object.public IFileSpecification getFileSpecification()
IFileSpecification
object.public String getPath()
public IMXMLData getMXMLData()
MXMLData
object.public MXMLDialect getMXMLDialect()
MXMLDialect
object.public String getQName()
public MXMLFileScope getFileScope()
MXMLFileScope
object.public Collection<ICompilerProblem> getProblems()
public void addProblem(ICompilerProblem problem)
public MXMLFileNode getFileNode()
public IVariableDefinition getPercentProxyDefinition()
public ITypeDefinition getBuiltinType(String name)
public IMXMLFileNode build()
IOldMXMLFileNode
that is the root of the MXML tree.public NodeBase parseExpressionNode(ITypeDefinition type, ISourceFragment[] fragments, ISourceLocation location, EnumSet<MXMLDialect.TextParsingFlags> flags, Object defaultValue, MXMLClassDefinitionNode classNode, boolean postProcess)
public NodeBase createExpressionNode(IMXMLNode propertyNode, ITypeDefinition type, ISourceFragment[] fragments, ISourceLocation location, EnumSet<MXMLDialect.TextParsingFlags> flags, Object defaultValue, MXMLClassDefinitionNode classNode)
public org.apache.flex.compiler.internal.tree.mxml.MXMLInstanceNode createInstanceNode(NodeBase parent, ITypeDefinition type, ISourceFragment[] fragments, ISourceLocation location, EnumSet<MXMLDialect.TextParsingFlags> flags, MXMLClassDefinitionNode classNode)
parent
- The parent node for the instance node.type
- The type of the value, as a String. This should be one of the
builtin types "Boolean"
, "int"
,
"uint"
, "Number"
, "String"
,
"Class"
, "Function"
, "RegExp"
,
"Array"
, "Object"
, or "*"
.flags
- Flags determining the details of the parsing algorithms.IMXMLInstanceNode
representing the value. It will be
one of the following:
public String readExternalFile(IMXMLTagAttributeData sourceAttribute, String resolvedSourcePath)
source
attribute.sourceAttribute
- The IMXMLTagAttributeData
representing the
source
attribute.resolvedSourcePath
- The path to the file specified by the attribute,
resolved and normalized.null
if the file does not exist or cannot be read.public IMXMLData getExternalMXMLData(IMXMLTagAttributeData sourceAttribute, String resolvedSourcePath)
IMXMLData
representation of an external file specified by
a source
attribute.sourceAttribute
- The IMXMLTagAttributeData
representing the
source
attribute.resolvedSourcePath
- The path to the file specified by the attribute,
resolved and normalized.IMXMLData
object representing the contents of the file,
or null
if the file does not exist or cannot be read.public void addDependency(String qname, DependencyType type)
qname
- A fully-qualified name.type
- The type of dependency to add.public void addExpressionDependency(String qname)
qname
- A fully-qualified name.public final IFileSpecificationGetter getFileSpecificationGetter()
Copyright © 2016 The Apache Software Foundation. All rights reserved.