public final class Workspace extends Object implements IWorkspace
Modifier and Type | Field and Description |
---|---|
ReadWriteLock |
embedLock |
protected Map<CompilerProject,Object> |
projects |
NIL_COMPILATIONUNITS_TO_UPDATE
Constructor and Description |
---|
Workspace()
Constructor
|
Workspace(ExecutorService es)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addCompilationUnit(ICompilationUnit compilationUnit)
Maintain a mapping between filenames and compilation units.
|
void |
addIncludedFilesToCompilationUnit(ICompilationUnit includingCompilationUnit,
Collection<String> includedFiles)
Specifies that the specified compilation unit includes the specified list
of files.
|
void |
addInvalidationListener(IInvalidationListener invalidationListner)
Adds a
IInvalidationListener on the workspace. |
void |
addProject(CompilerProject project) |
void |
close()
Close the workspace.
|
void |
deleteProject(ICompilerProject compilerProject)
Delete the reference of compiler project from the workspace
|
void |
doneBuilding()
Allows the workspace to enter the idle state once all pending operations
are completed.
|
void |
endIdleState(Map<ICompilerProject,Set<ICompilationUnit>> cusToUpdate)
Updates symbol table entries for all the
ICompilationUnit s in the
specified map and unlocks the lock acquired by calling
IWorkspace.startIdleState() . |
void |
endRequest()
Called by code in
RequestMaker when a request has completed execution. |
void |
fileAdded(IFileSpecification addedFile)
Called by clients of the driver object model when a file add has been
detected.
|
void |
fileChanged(IFileSpecification changedFile)
Called by clients of the driver object model when a file change has been
detected.
|
void |
fileRemoved(IFileSpecification removedFile)
Called by clients of the driver object model when a file remove has been
detected.
|
IASDocDelegate |
getASDocDelegate()
Gets the
IASDocDelegate that instances of
ASParser will use to record information about ASDoc comments. |
EmbedData |
getCanonicalEmbedData(EmbedData data)
If there is an existing EmbedData which is equivalent to the data
EmbedData, return the equiv. otherwise return the entered EmbedData
|
Collection<WeakReference<ICompilationUnit>> |
getCompilationUnits(String path)
Get all compilation units from the filename across all projects
|
Collection<ICompilationUnit> |
getCompilationUnits(String path,
ICompilerProject project)
Get all compilation units in the specified project related to the
specified file name.
|
Map<EmbedData,EmbedData> |
getEmbedDatas()
Returns all EmbedDatas
|
ExecutorService |
getExecutorService()
Gets the
ExecutorService to use in this workspace. |
IFileSpecification |
getFileSpecification(String path)
Returns the most recent
IFileSpecification given to the workspace
for a specified path. |
IFileSpecification |
getFileSpecificationForCompilationUnit(ICompilationUnit compilationUnit)
Gets the
IFileSpecification for the root source file of the
specified ICompilationUnit . |
Collection<ICompilationUnit> |
getIncludingCompilationUnits(String path,
ICompilerProject project)
Get all compilation units from which the filename is included related to the specified
project
|
Iterable<ICompilationUnit> |
getInvisibleAndVisibleCompilationUnits(String path,
ICompilerProject project)
Gets an iterator that iterates first over all invisible
ICompilationUnit 's for the specified file path in the specified
ICompilerProject and then over all visible
ICompilationUnit 's for the specified file path in the specified
ICompilerProject . |
com.google.common.base.FinalizableReferenceQueue |
getInvisibleCompilationUnitReferenceQueue()
Returns the invisibleCompilationUnitReferenceQueue which is used to remove
the backing Compilation Units when invisible compilation units get gc'd
|
Collection<WeakReference<ICompilationUnit>> |
getInvisibleCompilationUnits(String path)
Get all invisible compilation units from the filename across all projects
|
IBinaryFileSpecification |
getLatestBinaryFileSpecification(String path)
Returns the most recent
IBinaryFileSpecification given to the workspace
for a specified path. |
IMXMLDataManager |
getMXMLDataManager()
Gets the singleton that manages DOM-like
MXMLData objects for
MXML files in the workspace. |
PackageNamespaceDefinitionCache |
getPackageNamespaceDefinitionCache() |
IWorkspaceProfilingDelegate |
getProfilingDelegate()
Gets the
IWorkspaceProfilingDelegate from the workspace. |
ReferenceCache |
getReferenceCache()
Get the ReferenceCache used by this workspace.
|
ISWCManager |
getSWCManager()
Get the SWC manager.
|
IWorkspace |
getWorkspace()
Returns the
IWorkspace associated with the implementation, must
never be null. |
boolean |
isBuilding()
Determines if there is any currently running build activity in the
workspace.
|
void |
removeCompilationUnit(ICompilationUnit compilationUnit)
Remove a compilation unit from the filename to compilation unit map
|
void |
removeIncludedFilesToCompilationUnit(ICompilationUnit includingCompilationUnit,
Collection<String> includedFiles)
Remove any references to the compilation unit to the collection of include files it includes.
|
void |
removeInvalidationListener(IInvalidationListener invalidationListner)
Removes a
IInvalidationListener on the workspace. |
void |
setASDocDelegate(IASDocDelegate asDocDelegate)
Sets the
IASDocDelegate that instances of
ASParser will use to record information about ASDoc comments. |
void |
setProfilingDelegate(IWorkspaceProfilingDelegate profilingDelegate)
Sets the
IWorkspaceProfilingDelegate on the workspace. |
void |
startBuilding()
Waits for the workspace to leave the idle state and prevents all threads
from putting the workspace into the idle state.
|
void |
startIdleState()
Waits for all pending operation on all
ICompilationUnit 's in all
ICompilerProject s in this IWorkspace to complete. |
void |
startRequest(boolean requestNeededForFileScope)
Called by code in
RequestMaker when a request is about to be
submitted for execution. |
void |
swcChanged(Collection<ICompilationUnit> unitsRemoved,
Collection<ICompilationUnit> unitsAdded,
Runnable runWhileIdle)
When an ISWC has changed in memory, invalidate any compilation units which depend on the
units which depend on the SWC
|
protected final Map<CompilerProject,Object> projects
public final ReadWriteLock embedLock
public Workspace()
public Workspace(ExecutorService es)
es
- ExecutorService
to use to do background work in this
workspace.public ExecutorService getExecutorService()
ExecutorService
to use in this workspace.ExecutorService
to use in this workspace.public void startIdleState()
IWorkspace
ICompilationUnit
's in all
ICompilerProject
s in this IWorkspace
to complete. The
activity lock will also be acquired in this call, so once this method has
been called, no new work can be submitted until after the lock has been
released by calling IWorkspace.endIdleState(Map)
.
This method must never be called from an ICompilationUnit
operation
as that would result in dead lock.
startIdleState
in interface IWorkspace
public void endIdleState(Map<ICompilerProject,Set<ICompilationUnit>> cusToUpdate)
IWorkspace
ICompilationUnit
s in the
specified map and unlocks the lock acquired by calling
IWorkspace.startIdleState()
.endIdleState
in interface IWorkspace
cusToUpdate
- 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
.public void startBuilding()
IWorkspace
IWorkspace.doneBuilding()
.startBuilding
in interface IWorkspace
public void doneBuilding()
IWorkspace
IWorkspace.startBuilding()
.doneBuilding
in interface IWorkspace
public void startRequest(boolean requestNeededForFileScope)
RequestMaker
when a request is about to be
submitted for execution. Blocks until the workspace has left the idle
state.requestNeededForFileScope
- true if the request that is about to be
submitted for execution is needed to build an IFileScope
.public void endRequest()
RequestMaker
when a request has completed execution.public boolean isBuilding()
public void setProfilingDelegate(IWorkspaceProfilingDelegate profilingDelegate)
IWorkspace
IWorkspaceProfilingDelegate
on the workspace.setProfilingDelegate
in interface IWorkspace
profilingDelegate
- IWorkspaceProfilingDelegate
that will receive
profiling information. Can be null, in which case no profiling
information is collected.public IWorkspaceProfilingDelegate getProfilingDelegate()
IWorkspace
IWorkspaceProfilingDelegate
from the workspace.getProfilingDelegate
in interface IWorkspace
IWorkspaceProfilingDelegate
for this IWorkspace. Can be null.public void addInvalidationListener(IInvalidationListener invalidationListner)
IWorkspace
IInvalidationListener
on the workspace.addInvalidationListener
in interface IWorkspace
invalidationListner
- IInvalidationListener
that will receive
invalidation notifications.public void removeInvalidationListener(IInvalidationListener invalidationListner)
IWorkspace
IInvalidationListener
on the workspace.removeInvalidationListener
in interface IWorkspace
invalidationListner
- IInvalidationListener
that will be removed.public ISWCManager getSWCManager()
IWorkspace
getSWCManager
in interface IWorkspace
public PackageNamespaceDefinitionCache getPackageNamespaceDefinitionCache()
public void close()
public void swcChanged(Collection<ICompilationUnit> unitsRemoved, Collection<ICompilationUnit> unitsAdded, Runnable runWhileIdle)
unitsRemoved
- The collection of compilation units to be removed.unitsAdded
- The collection compilation units to be added.public void fileChanged(IFileSpecification changedFile)
IWorkspace
fileChanged
in interface IWorkspace
changedFile
- An IFileSpecification
that can be used to get
the change filename.public void fileRemoved(IFileSpecification removedFile)
IWorkspace
fileRemoved
in interface IWorkspace
removedFile
- An IFileSpecification
that can be used to get
the new contents of the removed file.public void fileAdded(IFileSpecification addedFile)
IWorkspace
fileAdded
in interface IWorkspace
addedFile
- An IFileSpecification
that can be used to get the
name and contents of the added file.public IFileSpecification getFileSpecificationForCompilationUnit(ICompilationUnit compilationUnit)
IFileSpecification
for the root source file of the
specified ICompilationUnit
.compilationUnit
- A compilation unit.IFileSpecification
for the root source file of the
specified ICompilationUnit
public void addCompilationUnit(ICompilationUnit compilationUnit)
public void addIncludedFilesToCompilationUnit(ICompilationUnit includingCompilationUnit, Collection<String> includedFiles)
ICompilationUnit
's when they discover
included files.includingCompilationUnit
- ICompilationUnit
that contains
include statements that reference the specified list of files.includedFiles
- The included files.public void removeIncludedFilesToCompilationUnit(ICompilationUnit includingCompilationUnit, Collection<String> includedFiles)
includingCompilationUnit
- ICompilationUnit
that contains
include statements that reference the specified list of files.includedFiles
- The included files.public void removeCompilationUnit(ICompilationUnit compilationUnit)
compilationUnit
- The compilation unit to be removed.public Collection<WeakReference<ICompilationUnit>> getCompilationUnits(String path)
path
- String to source filenamepublic Collection<WeakReference<ICompilationUnit>> getInvisibleCompilationUnits(String path)
path
- String to source filenamepublic Collection<ICompilationUnit> getCompilationUnits(String path, ICompilerProject project)
IWorkspace
getCompilationUnits
in interface IWorkspace
path
- String to source filenameproject
- containing projectpublic Iterable<ICompilationUnit> getInvisibleAndVisibleCompilationUnits(String path, ICompilerProject project)
IWorkspace
ICompilationUnit
's for the specified file path in the specified
ICompilerProject
and then over all visible
ICompilationUnit
's for the specified file path in the specified
ICompilerProject
.getInvisibleAndVisibleCompilationUnits
in interface IWorkspace
path
- Normalized absolute file name.project
- ICompilerProject
that will contains all the
ICompilationUnit
in the returned Iterable
.ICompilationUnit
's for the specified file path in the specified
ICompilerProject
and then over all visible
ICompilationUnit
's for the specified file path in the specified
ICompilerProject
public Collection<ICompilationUnit> getIncludingCompilationUnits(String path, ICompilerProject project)
path
- String to source filenameproject
- containing projectpublic EmbedData getCanonicalEmbedData(EmbedData data)
data
- The embedding data.public Map<EmbedData,EmbedData> getEmbedDatas()
public com.google.common.base.FinalizableReferenceQueue getInvisibleCompilationUnitReferenceQueue()
public IMXMLDataManager getMXMLDataManager()
IWorkspace
MXMLData
objects for
MXML files in the workspace.getMXMLDataManager
in interface IWorkspace
IMXMLDataManager
objectpublic IFileSpecification getFileSpecification(String path)
IFileSpecification
given to the workspace
for a specified path. If the workspace has not seen the specified path
before a new FileSpecification
is returned.getFileSpecification
in interface IFileSpecificationGetter
path
- Path for which a IFileSpecification
should be returned.IFileSpecification
given to the workspace
for a specified path.public IWorkspace getWorkspace()
IFileSpecificationGetter
IWorkspace
associated with the implementation, must
never be null.getWorkspace
in interface IFileSpecificationGetter
IWorkspace
associated with the implementation, must
never be null.public IBinaryFileSpecification getLatestBinaryFileSpecification(String path)
IBinaryFileSpecification
given to the workspace
for a specified path. If the workspace has not seen the specified path
before a new IBinaryFileSpecification
is returned.
This method assumes that if there is an existing filespec, it is a binary
filespec.path
- Path for which a IBinaryFileSpecification
should be returned.IBinaryFileSpecification
given to the workspace
for a specified path.public ReferenceCache getReferenceCache()
public void deleteProject(ICompilerProject compilerProject)
compilerProject
- ICompilerProjectpublic IASDocDelegate getASDocDelegate()
IWorkspace
IASDocDelegate
that instances of
ASParser
will use to record information about ASDoc comments.getASDocDelegate
in interface IWorkspace
IASDocDelegate
that instances of
ASParser
will use to record information about ASDoc comments.public void setASDocDelegate(IASDocDelegate asDocDelegate)
IWorkspace
IASDocDelegate
that instances of
ASParser
will use to record information about ASDoc comments.setASDocDelegate
in interface IWorkspace
asDocDelegate
- IASDocDelegate
that instances of
ASParser
will use to record information about ASDoc comments.public void addProject(CompilerProject project)
Copyright © 2016 The Apache Software Foundation. All rights reserved.