public abstract class CompilationUnitBase extends Object implements ICompilationUnit
This class converts calls to the getXXXRequest methods to calls into handleXXXRequest methods. Subclasses can just implement the handleXXXRequest methods without having to worry about creating an IRequest implementation.
ICompilationUnit.Operation, ICompilationUnit.UnitType
Modifier and Type | Field and Description |
---|---|
protected AtomicReference<IRequest<IABCBytesRequestResult,ICompilationUnit>> |
abc |
protected static String |
DEFAULT_DO_ABC_TAG_NAME |
protected AtomicReference<IRequest<IFileScopeRequestResult,ICompilationUnit>> |
fileScopeRequest |
protected AtomicReference<IRequest<IOutgoingDependenciesRequestResult,ICompilationUnit>> |
problems |
protected AtomicReference<IRequest<ISyntaxTreeRequestResult,ICompilationUnit>> |
syntaxTreeRequest |
Modifier | Constructor and Description |
---|---|
protected |
CompilationUnitBase(CompilerProject project,
String path,
DefinitionPriority.BasePriority basePriority,
boolean scopeBuiltFromSytaxTree)
Use this constructor if derived class has no definition promises
|
protected |
CompilationUnitBase(CompilerProject project,
String path,
DefinitionPriority.BasePriority basePriority,
Collection<String> qnamesOfDefinitions)
This is the most generic constructor
|
protected |
CompilationUnitBase(CompilerProject project,
String path,
DefinitionPriority.BasePriority basePriority,
String qnameOfDefinition)
Use this constructor if the derived class has at most one definition promise
|
Modifier and Type | Method and Description |
---|---|
protected void |
addScopeToProjectScope(ASFileScope[] scopes) |
boolean |
clean(Map<ICompilerProject,Set<File>> invalidatedSWCFiles,
Map<ICompilerProject,Set<ICompilationUnit>> cusToUpdate,
boolean clearFileScope)
Removes all data created during a compile Clients should not call this
method directly, as it can potentially leave the ICompilationUnit in an
invalid state.
|
void |
clearIncludedFilesFromWorkspace()
This method is used to update the Workspace
includeFilesToIncludingCompilationUnitMapping map when a file get's cleaned.
|
void |
clearProject()
Called by
ICompilerProject 's when an ICompilationUnit
is removed from a project. |
IRequest<IABCBytesRequestResult,ICompilationUnit> |
getABCBytesRequest()
Gets the request object from which the caller can extract the abc bytes
generated for this ICompilationUnit.
|
String |
getAbsoluteFilename()
Gets the path to the compilation unit instance.
|
IDefinitionPriority |
getDefinitionPriority()
Gets the definition priority for definitions defined by the compilation
unit.
|
List<IDefinition> |
getDefinitionPromises() |
Collection<String> |
getEmbeddedFilenames() |
protected Map<String,String> |
getEncodedDebugFiles() |
protected String |
getFilenameNoPath() |
IRequest<IFileScopeRequestResult,ICompilationUnit> |
getFileScopeRequest()
Gets the request object from which the caller can extract the root scope,
AST, and any parsing ICompilerProblems, for the CompilationUnit.
|
protected IFileSpecificationGetter |
getFileSpecificationGetter() |
String |
getName()
Gets a string that is unique to the compilation unit instance and can be
used to produce an ordering of compilation units that is stable across
different compilation runs.
|
IRequest<IOutgoingDependenciesRequestResult,ICompilationUnit> |
getOutgoingDependenciesRequest()
Gets the request object from which the caller cause the dependency graph to be updated
with all the dependencies from this compilation unit.
|
CompilerProject |
getProject() |
List<String> |
getQualifiedNames() |
protected IFileSpecification |
getRootFileSpecification() |
List<String> |
getShortNames() |
IRequest<ISWFTagsRequestResult,ICompilationUnit> |
getSWFTagsRequest()
Gets the request object with which the caller can add the SWF tags
generated for this ICompilationUnit to a ISWF.
|
IRequest<ISyntaxTreeRequestResult,ICompilationUnit> |
getSyntaxTreeRequest()
Gets the request object from which the caller can extract the syntax tree
and any source file parsing
ICompilerProblem 's
for this ICompilationUnit . |
protected abstract IABCBytesRequestResult |
handleABCBytesRequest()
Builds a IABCBytesRequestResult.
|
protected void |
handleClean(boolean clearFileScope,
Map<ICompilerProject,Set<File>> invalidatedSWCFiles)
This method is overriden by base classes to
clean additional processing results not cleaned by
the clean method above.
|
protected abstract IFileScopeRequestResult |
handleFileScopeRequest()
Builds a
IFileScopeRequestResult . |
protected abstract IOutgoingDependenciesRequestResult |
handleOutgoingDependenciesRequest()
Builds a IOutgoingDependenciesRequestResult.
|
protected abstract ISWFTagsRequestResult |
handleSWFTagsRequest()
Builds a ISWFTagsRequestResult.
|
protected abstract ISyntaxTreeRequestResult |
handleSyntaxTreeRequest()
Builds a
ISyntaxTreeRequestResult . |
boolean |
isInvisible() |
void |
makeInvisible(InvisibleCompilationUnit invisibleCU)
Marks this
ICompilationUnit as the delegate of an
IInvisibleCompilationUnit , which will prevent this
ICompilationUnit from contributing any symbols to the containing
ICompilerProject 's ASProjectScope . |
protected boolean |
operationsCompleted(EnumSet<ICompilationUnit.Operation> operations)
Atomically checks the state of this compilation unit to determine
if all the specified operations are complete.
|
protected void |
removeAST() |
void |
setFileSpecificationGetter(IFileSpecificationGetter getter) |
void |
startBuildAsync(ITarget.TargetType targetType)
This method starts to build the compilation unit asynchronously.
|
protected void |
startParsingImports(IFileNodeAccumulator fna)
Iterate through all imports within a IFileNodeAccumulator and start parsing any
non-wildcard imports.
|
protected void |
startProfile(ICompilationUnit.Operation operation) |
protected void |
stopProfile(ICompilationUnit.Operation operation) |
String |
toString() |
protected void |
updateEmbedCompilationUnitDependencies(List<IEmbedResolver> embedNodes,
Collection<ICompilerProblem> problems)
Iterate through all specified embeds, adding the
EmbedCompilationUnit dependencies, and removing any EmbedCompilationUnits
which no longer exist
This function adds an empty definition dependency to the
DependencyGraph ,
so it will not be printed to the link-report |
protected void |
updateStyleCompilationUnitDependencies(CSSCompilationSession cssCompilationSession,
IXMLNameResolver xmlNameResolver,
Iterable<ICSSDocument> cssDocuments,
Collection<ICompilerProblem> problems)
Semantic analyze a collection of CSS model objects, and return a
CSSCompilationSession that contains the resolved symbols. |
protected void |
verifyAST(IASNode ast) |
void |
waitForBuildFinish(Collection<ICompilerProblem> problems,
ITarget.TargetType targetType)
Wait till the compilation unit finishes building, and collect compiler
problems.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCompilationUnitType
protected static final String DEFAULT_DO_ABC_TAG_NAME
protected final AtomicReference<IRequest<ISyntaxTreeRequestResult,ICompilationUnit>> syntaxTreeRequest
protected final AtomicReference<IRequest<IFileScopeRequestResult,ICompilationUnit>> fileScopeRequest
protected final AtomicReference<IRequest<IABCBytesRequestResult,ICompilationUnit>> abc
protected final AtomicReference<IRequest<IOutgoingDependenciesRequestResult,ICompilationUnit>> problems
protected CompilationUnitBase(CompilerProject project, String path, DefinitionPriority.BasePriority basePriority, Collection<String> qnamesOfDefinitions)
project
- path
- basePriority
- qnamesOfDefinitions
- is a collection with all the definition promises for the compilation unitprotected CompilationUnitBase(CompilerProject project, String path, DefinitionPriority.BasePriority basePriority, boolean scopeBuiltFromSytaxTree)
protected CompilationUnitBase(CompilerProject project, String path, DefinitionPriority.BasePriority basePriority, String qnameOfDefinition)
project
- path
- basePriority
- qnameOfDefinition
- is the definition promise, or nullprotected void updateStyleCompilationUnitDependencies(CSSCompilationSession cssCompilationSession, IXMLNameResolver xmlNameResolver, Iterable<ICSSDocument> cssDocuments, Collection<ICompilerProblem> problems)
CSSCompilationSession
that contains the resolved symbols.
IClassDefinition
definitions.ClassReference()
and
Embed()
property values.cssCompilationSession
- A CSSCompilationSession
object that
contains resolved symbols from all the CSS models in cssDocuments
collection.xmlNameResolver
- Resolve type selectors to definitions.cssDocuments
- A list of CSS model objects.problems
- Compiler problem collection.protected final boolean operationsCompleted(EnumSet<ICompilationUnit.Operation> operations)
operations
- The set of operation to check.public List<IDefinition> getDefinitionPromises()
getDefinitionPromises
in interface ICompilationUnit
public CompilerProject getProject()
getProject
in interface ICompilationUnit
protected abstract ISyntaxTreeRequestResult handleSyntaxTreeRequest() throws InterruptedException
ISyntaxTreeRequestResult
. In many cases the ISyntaxTreeRequestResult
is built by parsing a source file into a syntax tree.
Called by this class from potentially any thread. This class guarantees that this method will only be entered from one thread at a time for a given instance of this class, so implementations do not need to make this a synchronized method.
ISyntaxTreeRequestResult
for this compilation unit.InterruptedException
protected abstract IFileScopeRequestResult handleFileScopeRequest() throws InterruptedException
IFileScopeRequestResult
. In many cases the
IFileScopeRequestResult
is built by walking an AST produced by a parser.
Called by this class from potentially any thread. This class guarantees that this method will only be entered from one thread at a time for a given instance of this class, so implementations do not need to make this a synchronized method.
IFileScopeRequestResult
for this compilation unit.InterruptedException
protected abstract IABCBytesRequestResult handleABCBytesRequest() throws InterruptedException
Called by this class from potentially any thread. This class guarantees that this method will only be entered from one thread at a time for a given instance of this class, so implementations do not need to make this a synchronized method.
InterruptedException
protected abstract ISWFTagsRequestResult handleSWFTagsRequest() throws InterruptedException
Called by this class from potentially any thread. This class guarantees that this method will only be entered from one thread at a time for a given instance of this class, so implementations do not need to make this a synchronized method.
InterruptedException
protected abstract IOutgoingDependenciesRequestResult handleOutgoingDependenciesRequest() throws InterruptedException
Called by this class from potentially any thread. This class guarantees that this method will only be entered from one thread at a time for a given instance of this class, so implementations do not need to make this a synchronized method.
InterruptedException
public IRequest<ISyntaxTreeRequestResult,ICompilationUnit> getSyntaxTreeRequest()
ICompilationUnit
ICompilerProblem
's
for this ICompilationUnit
. Implementations may update the dependency
graph in the project as a side
affect of this operation.getSyntaxTreeRequest
in interface ICompilationUnit
public IRequest<IFileScopeRequestResult,ICompilationUnit> getFileScopeRequest()
ICompilationUnit
getFileScopeRequest
in interface ICompilationUnit
public IRequest<IABCBytesRequestResult,ICompilationUnit> getABCBytesRequest()
ICompilationUnit
getABCBytesRequest
in interface ICompilationUnit
public IRequest<ISWFTagsRequestResult,ICompilationUnit> getSWFTagsRequest()
ICompilationUnit
getSWFTagsRequest
in interface ICompilationUnit
public IRequest<IOutgoingDependenciesRequestResult,ICompilationUnit> getOutgoingDependenciesRequest()
ICompilationUnit
getOutgoingDependenciesRequest
in interface ICompilationUnit
public List<String> getShortNames() throws InterruptedException
getShortNames
in interface ICompilationUnit
InterruptedException
public List<String> getQualifiedNames() throws InterruptedException
getQualifiedNames
in interface ICompilationUnit
InterruptedException
public final String getAbsoluteFilename()
ICompilationUnit
getAbsoluteFilename
in interface ICompilationUnit
protected final String getFilenameNoPath()
protected IFileSpecification getRootFileSpecification()
protected IFileSpecificationGetter getFileSpecificationGetter()
public boolean clean(Map<ICompilerProject,Set<File>> invalidatedSWCFiles, Map<ICompilerProject,Set<ICompilationUnit>> cusToUpdate, boolean clearFileScope)
ICompilationUnit
clean
in interface ICompilationUnit
invalidatedSWCFiles
- Map of SWC filenames and depending projects
which have been invalidated by this callcusToUpdate
- Map
from ICompilerProject
to
Set
of ICompilationUnit
s in the project whose externally
visible symbols need to be re-registered with the symbol table of the
containing ICompilerProject
when cleaning is complete.clearFileScope
- Whether to clear the file scopepublic void clearIncludedFilesFromWorkspace()
protected void handleClean(boolean clearFileScope, Map<ICompilerProject,Set<File>> invalidatedSWCFiles)
invalidatedSWCFiles
- protected final void startProfile(ICompilationUnit.Operation operation)
protected final void stopProfile(ICompilationUnit.Operation operation)
protected void verifyAST(IASNode ast)
protected final void addScopeToProjectScope(ASFileScope[] scopes)
protected void startParsingImports(IFileNodeAccumulator fna)
fna
- IFileNodeAccumulatorprotected void updateEmbedCompilationUnitDependencies(List<IEmbedResolver> embedNodes, Collection<ICompilerProblem> problems) throws InterruptedException
This function adds an empty definition dependency to the DependencyGraph
,
so it will not be printed to the link-report
InterruptedException
public Collection<String> getEmbeddedFilenames()
getEmbeddedFilenames
in interface ICompilationUnit
ICompilationUnit
through Embed metadata. This
will never return null.protected void removeAST()
public String getName()
ICompilationUnit
getName
in interface ICompilationUnit
public String toString()
public IDefinitionPriority getDefinitionPriority()
ICompilationUnit
getDefinitionPriority
in interface ICompilationUnit
public void clearProject()
ICompilationUnit
ICompilerProject
's when an ICompilationUnit
is removed from a project. Implementations should clear an references
to the containing project when this method is called. After this
method is called ICompilationUnit.getProject()
should return null.clearProject
in interface ICompilationUnit
public void waitForBuildFinish(Collection<ICompilerProblem> problems, ITarget.TargetType targetType) throws InterruptedException
ICompilationUnit
waitForBuildFinish
in interface ICompilationUnit
problems
- Problems from executing the requests.targetType
- type of the active Target
InterruptedException
- Concurrency error.ICompilationUnit.startBuildAsync(org.apache.flex.compiler.targets.ITarget.TargetType)
public void startBuildAsync(ITarget.TargetType targetType)
ICompilationUnit
startBuildAsync
in interface ICompilationUnit
targetType
- type of the active Target
public void setFileSpecificationGetter(IFileSpecificationGetter getter)
public void makeInvisible(InvisibleCompilationUnit invisibleCU)
ICompilationUnit
as the delegate of an
IInvisibleCompilationUnit
, which will prevent this
ICompilationUnit
from contributing any symbols to the containing
ICompilerProject
's ASProjectScope
.
This method should be called very shortly after the constructor and
before any other methods on this class or its sub-classes are called (
except setFileSpecificationGetter(IFileSpecificationGetter)
).
This method must only be called zero or one time on each
ICompilationUnit
.
public final boolean isInvisible()
isInvisible
in interface ICompilationUnit
ICompilationUnit
does *not*
put its global definitions in the ICompilerProject
's
symbol table, false otherwise.protected Map<String,String> getEncodedDebugFiles() throws InterruptedException
InterruptedException
Copyright © 2016 The Apache Software Foundation. All rights reserved.