java.lang.Object
org.eclipse.core.internal.events.BuildManager
- All Implemented Interfaces:
- org.eclipse.core.internal.resources.ICoreConstants, ILifecycleListener, org.eclipse.core.internal.resources.IManager
- public class BuildManager
- extends java.lang.Object
- implements org.eclipse.core.internal.resources.ICoreConstants, org.eclipse.core.internal.resources.IManager, ILifecycleListener
|
Nested Class Summary |
(package private) class |
BuildManager.DeltaCache
Cache used to optimize the common case of an autobuild against
a workspace where only a single project has changed (and hence
only a single delta is interesting). |
(package private) class |
BuildManager.MissingBuilder
These builders are added to build tables in place of builders that couldn't be instantiated |
| Fields inherited from interface org.eclipse.core.internal.resources.ICoreConstants |
EMPTY_FILE_STATES, EMPTY_PROJECT_ARRAY, EMPTY_RESOURCE_ARRAY, FIRST_INTERNAL_ERROR, FIRST_INTERNAL_INFO, FIRST_INTERNAL_WARNING, I_NULL_SYNC_INFO, I_UNKNOWN_SYNC_INFO, K_BUILD_MAP, LAST_INTERNAL_ERROR, LAST_INTERNAL_INFO, LAST_INTERNAL_WARNING, M_CONTENT_CACHE, M_DEFAULT_CONTENT_DESCRIPTION, M_DERIVED, M_LINK, M_LOCAL_EXISTS, M_MARKERS_SNAP_DIRTY, M_NO_CONTENT_DESCRIPTION, M_OPEN, M_PHANTOM, M_SYNCINFO_SNAP_DIRTY, M_TEAM_PRIVATE_MEMBER, M_TYPE, M_TYPE_START, M_USED, MINIMUM_FILE_SEGMENT_LENGTH, MINIMUM_FOLDER_SEGMENT_LENGTH, MSG_EVENTS_BUILDING_0, MSG_EVENTS_ERRORS, MSG_RESOURCES_UPDATING, NULL_FLAG, OPERATION_FAILED, PROJECT_SEGMENT_LENGTH, WORKSPACE_TREE_VERSION_1, WORKSPACE_TREE_VERSION_2 |
|
Method Summary |
protected void |
basicBuild(int trigger,
org.eclipse.core.resources.IncrementalProjectBuilder builder,
java.util.Map args,
org.eclipse.core.runtime.MultiStatus status,
org.eclipse.core.runtime.IProgressMonitor monitor)
|
protected void |
basicBuild(org.eclipse.core.resources.IProject project,
int trigger,
org.eclipse.core.resources.ICommand[] commands,
org.eclipse.core.runtime.MultiStatus status,
org.eclipse.core.runtime.IProgressMonitor monitor)
|
protected void |
basicBuild(org.eclipse.core.resources.IProject project,
int trigger,
org.eclipse.core.runtime.MultiStatus status,
org.eclipse.core.runtime.IProgressMonitor monitor)
|
protected void |
basicBuild(org.eclipse.core.resources.IProject project,
int trigger,
java.lang.String builderName,
java.util.Map args,
org.eclipse.core.runtime.MultiStatus status,
org.eclipse.core.runtime.IProgressMonitor monitor)
|
protected void |
basicBuildLoop(org.eclipse.core.resources.IProject[] ordered,
org.eclipse.core.resources.IProject[] unordered,
int trigger,
org.eclipse.core.runtime.MultiStatus status,
org.eclipse.core.runtime.IProgressMonitor monitor)
Loop the workspace build until no more builders request a rebuild. |
void |
build(int trigger,
org.eclipse.core.runtime.IProgressMonitor monitor)
|
void |
build(org.eclipse.core.resources.IProject project,
int trigger,
org.eclipse.core.runtime.IProgressMonitor monitor)
|
void |
build(org.eclipse.core.resources.IProject project,
int trigger,
java.lang.String builderName,
java.util.Map args,
org.eclipse.core.runtime.IProgressMonitor monitor)
|
protected boolean |
canRun(int trigger)
|
private void |
checkCanceled(int trigger,
org.eclipse.core.runtime.IProgressMonitor monitor)
Cancel the build if the user has canceled or if an auto-build has been interrupted. |
private void |
cleanup(int trigger)
|
protected org.eclipse.core.resources.IProject[] |
computeUnorderedProjects(org.eclipse.core.resources.IProject[] ordered)
|
java.util.Map |
createBuildersPersistentInfo(org.eclipse.core.resources.IProject project)
Creates and returns a Map mapping String(builder name) -> BuilderPersistentInfo. |
protected java.lang.String |
debugBuilder()
|
protected java.lang.String |
debugProject()
|
void |
endTopLevel(boolean needsBuild)
The outermost workspace operation has finished. |
protected org.eclipse.core.resources.IncrementalProjectBuilder |
getBuilder(java.lang.String builderName,
org.eclipse.core.resources.IProject project,
org.eclipse.core.runtime.MultiStatus status)
|
protected java.util.Hashtable |
getBuilders(org.eclipse.core.resources.IProject project)
Returns a hashtable of all instantiated builders for the given project. |
java.util.Map |
getBuildersPersistentInfo(org.eclipse.core.resources.IProject project)
Returns a Map mapping String(builder name) -> BuilderPersistentInfo. |
protected org.eclipse.core.resources.IResourceDelta |
getDelta(org.eclipse.core.resources.IProject project)
|
protected org.eclipse.core.runtime.ISafeRunnable |
getSafeRunnable(int trigger,
java.util.Map args,
org.eclipse.core.runtime.MultiStatus status,
org.eclipse.core.runtime.IProgressMonitor monitor)
Returns the safe runnable instance for invoking a builder |
private org.eclipse.core.internal.resources.WorkManager |
getWorkManager()
We know the work manager is always available in the middle of
a build. |
void |
handleEvent(LifecycleEvent event)
|
boolean |
hasBeenBuilt(org.eclipse.core.resources.IProject project)
Returns true if the given project has been built during this build cycle, and
false otherwise. |
private void |
hookEndBuild(org.eclipse.core.resources.IncrementalProjectBuilder builder)
Hook for adding trace options and debug information at the end of a build. |
private void |
hookStartBuild(org.eclipse.core.resources.IncrementalProjectBuilder builder,
int trigger)
Hook for adding trace options and debug information at the start of a build. |
protected org.eclipse.core.resources.IncrementalProjectBuilder |
initializeBuilder(java.lang.String builderName,
org.eclipse.core.resources.IProject project,
org.eclipse.core.runtime.MultiStatus status)
Instantiates the builder with the given name. |
protected org.eclipse.core.resources.IncrementalProjectBuilder |
instantiateBuilder(java.lang.String builderName)
Instantiates and returns the builder with the given name. |
void |
interrupt()
Another thread is attempting to modify the workspace. |
protected boolean |
isInterestingProject(org.eclipse.core.resources.IProject project)
Returns true if the current builder is interested in changes
to the given project, and false otherwise. |
protected boolean |
needsBuild(InternalBuilder builder)
Returns true if the given builder needs to be invoked, and false
otherwise. |
protected void |
removeBuilders(org.eclipse.core.resources.IProject project,
java.lang.String builderId)
Removes all builders with the given ID from the build spec. |
void |
requestRebuild()
Hook for builders to request a rebuild. |
void |
setBuildersPersistentInfo(org.eclipse.core.resources.IProject project,
java.util.Map map)
Sets the builder map for the given project. |
void |
shutdown(org.eclipse.core.runtime.IProgressMonitor monitor)
|
void |
startup(org.eclipse.core.runtime.IProgressMonitor monitor)
|
protected java.lang.String |
toString(InternalBuilder builder)
Returns a string representation of the given builder. |
protected boolean |
validateNature(InternalBuilder builder,
java.lang.String builderId)
Returns true if the nature membership rules are satisifed for the given
builder extension on the given project, and false otherwise. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TOTAL_BUILD_WORK
private static final int TOTAL_BUILD_WORK
autoBuildJob
protected final AutoBuildJob autoBuildJob
building
protected boolean building
builtProjects
protected final java.util.ArrayList builtProjects
currentBuilder
protected InternalBuilder currentBuilder
currentDelta
protected org.eclipse.core.internal.dtree.DeltaDataTree currentDelta
currentTree
protected org.eclipse.core.internal.watson.ElementTree currentTree
deltaCache
protected final BuildManager.DeltaCache deltaCache
- Caches the IResourceDelta for a pair of trees
deltaTreeCache
protected final BuildManager.DeltaCache deltaTreeCache
- Caches the DeltaDataTree used to determine if a build is necessary
lastBuiltTree
protected org.eclipse.core.internal.watson.ElementTree lastBuiltTree
rebuildRequested
protected boolean rebuildRequested
systemBundle
private final org.osgi.framework.Bundle systemBundle
timeStamp
private long timeStamp
workspace
protected org.eclipse.core.internal.resources.Workspace workspace
lock
private org.eclipse.core.runtime.jobs.ILock lock
BuildManager
public BuildManager(org.eclipse.core.internal.resources.Workspace workspace,
org.eclipse.core.runtime.jobs.ILock workspaceLock)
basicBuild
protected void basicBuild(int trigger,
org.eclipse.core.resources.IncrementalProjectBuilder builder,
java.util.Map args,
org.eclipse.core.runtime.MultiStatus status,
org.eclipse.core.runtime.IProgressMonitor monitor)
getWorkManager
private org.eclipse.core.internal.resources.WorkManager getWorkManager()
- We know the work manager is always available in the middle of
a build.
basicBuild
protected void basicBuild(org.eclipse.core.resources.IProject project,
int trigger,
org.eclipse.core.resources.ICommand[] commands,
org.eclipse.core.runtime.MultiStatus status,
org.eclipse.core.runtime.IProgressMonitor monitor)
basicBuild
protected void basicBuild(org.eclipse.core.resources.IProject project,
int trigger,
org.eclipse.core.runtime.MultiStatus status,
org.eclipse.core.runtime.IProgressMonitor monitor)
basicBuild
protected void basicBuild(org.eclipse.core.resources.IProject project,
int trigger,
java.lang.String builderName,
java.util.Map args,
org.eclipse.core.runtime.MultiStatus status,
org.eclipse.core.runtime.IProgressMonitor monitor)
basicBuildLoop
protected void basicBuildLoop(org.eclipse.core.resources.IProject[] ordered,
org.eclipse.core.resources.IProject[] unordered,
int trigger,
org.eclipse.core.runtime.MultiStatus status,
org.eclipse.core.runtime.IProgressMonitor monitor)
- Loop the workspace build until no more builders request a rebuild.
build
public void build(int trigger,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws org.eclipse.core.runtime.CoreException
cleanup
private void cleanup(int trigger)
build
public void build(org.eclipse.core.resources.IProject project,
int trigger,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws org.eclipse.core.runtime.CoreException
build
public void build(org.eclipse.core.resources.IProject project,
int trigger,
java.lang.String builderName,
java.util.Map args,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws org.eclipse.core.runtime.CoreException
canRun
protected boolean canRun(int trigger)
interrupt
public void interrupt()
- Another thread is attempting to modify the workspace. Cancel the
autobuild and wait until it completes.
checkCanceled
private void checkCanceled(int trigger,
org.eclipse.core.runtime.IProgressMonitor monitor)
- Cancel the build if the user has canceled or if an auto-build has been interrupted.
computeUnorderedProjects
protected org.eclipse.core.resources.IProject[] computeUnorderedProjects(org.eclipse.core.resources.IProject[] ordered)
createBuildersPersistentInfo
public java.util.Map createBuildersPersistentInfo(org.eclipse.core.resources.IProject project)
throws org.eclipse.core.runtime.CoreException
- Creates and returns a Map mapping String(builder name) -> BuilderPersistentInfo.
The table includes entries for all builders that are
in the builder spec, and that have a last built state, even if they
have not been instantiated this session.
debugBuilder
protected java.lang.String debugBuilder()
debugProject
protected java.lang.String debugProject()
endTopLevel
public void endTopLevel(boolean needsBuild)
- The outermost workspace operation has finished. Do an autobuild if necessary.
getBuilder
protected org.eclipse.core.resources.IncrementalProjectBuilder getBuilder(java.lang.String builderName,
org.eclipse.core.resources.IProject project,
org.eclipse.core.runtime.MultiStatus status)
throws org.eclipse.core.runtime.CoreException
getBuilders
protected java.util.Hashtable getBuilders(org.eclipse.core.resources.IProject project)
- Returns a hashtable of all instantiated builders for the given project.
This hashtable maps String(builder name) -> Builder.
getBuildersPersistentInfo
public java.util.Map getBuildersPersistentInfo(org.eclipse.core.resources.IProject project)
throws org.eclipse.core.runtime.CoreException
- Returns a Map mapping String(builder name) -> BuilderPersistentInfo.
The map includes entries for all builders that are in the builder spec,
and that have a last built state, even if they have not been instantiated
this session.
getDelta
protected org.eclipse.core.resources.IResourceDelta getDelta(org.eclipse.core.resources.IProject project)
getSafeRunnable
protected org.eclipse.core.runtime.ISafeRunnable getSafeRunnable(int trigger,
java.util.Map args,
org.eclipse.core.runtime.MultiStatus status,
org.eclipse.core.runtime.IProgressMonitor monitor)
- Returns the safe runnable instance for invoking a builder
handleEvent
public void handleEvent(LifecycleEvent event)
- Specified by:
handleEvent in interface ILifecycleListener
hasBeenBuilt
public boolean hasBeenBuilt(org.eclipse.core.resources.IProject project)
- Returns true if the given project has been built during this build cycle, and
false otherwise.
hookEndBuild
private void hookEndBuild(org.eclipse.core.resources.IncrementalProjectBuilder builder)
- Hook for adding trace options and debug information at the end of a build.
hookStartBuild
private void hookStartBuild(org.eclipse.core.resources.IncrementalProjectBuilder builder,
int trigger)
- Hook for adding trace options and debug information at the start of a build.
initializeBuilder
protected org.eclipse.core.resources.IncrementalProjectBuilder initializeBuilder(java.lang.String builderName,
org.eclipse.core.resources.IProject project,
org.eclipse.core.runtime.MultiStatus status)
throws org.eclipse.core.runtime.CoreException
- Instantiates the builder with the given name. If the builder, its plugin, or its nature
is missing, create a placeholder builder to takes its place. This is needed to generate
appropriate exceptions when somebody tries to invoke the builder, and to
prevent trying to instantiate it every time a build is run.
This method NEVER returns null.
instantiateBuilder
protected org.eclipse.core.resources.IncrementalProjectBuilder instantiateBuilder(java.lang.String builderName)
throws org.eclipse.core.runtime.CoreException
- Instantiates and returns the builder with the given name. If the builder, its plugin, or its nature
is missing, returns null.
isInterestingProject
protected boolean isInterestingProject(org.eclipse.core.resources.IProject project)
- Returns true if the current builder is interested in changes
to the given project, and false otherwise.
needsBuild
protected boolean needsBuild(InternalBuilder builder)
- Returns true if the given builder needs to be invoked, and false
otherwise.
The algorithm is to compute the intersection of the set of projects that
have changed since the last build, and the set of projects this builder
cares about. This is an optimization, under the assumption that computing
the forward delta once (not the resource delta) is more efficient than
computing project deltas and invoking builders for projects that haven't
changed.
removeBuilders
protected void removeBuilders(org.eclipse.core.resources.IProject project,
java.lang.String builderId)
throws org.eclipse.core.runtime.CoreException
- Removes all builders with the given ID from the build spec.
Does nothing if there were no such builders in the spec
requestRebuild
public void requestRebuild()
- Hook for builders to request a rebuild.
setBuildersPersistentInfo
public void setBuildersPersistentInfo(org.eclipse.core.resources.IProject project,
java.util.Map map)
- Sets the builder map for the given project. The builder map is
a Map mapping String(builder name) -> BuilderPersistentInfo.
The map includes entries for all builders that are
in the builder spec, and that have a last built state, even if they
have not been instantiated this session.
shutdown
public void shutdown(org.eclipse.core.runtime.IProgressMonitor monitor)
- Specified by:
shutdown in interface org.eclipse.core.internal.resources.IManager
startup
public void startup(org.eclipse.core.runtime.IProgressMonitor monitor)
- Specified by:
startup in interface org.eclipse.core.internal.resources.IManager
toString
protected java.lang.String toString(InternalBuilder builder)
- Returns a string representation of the given builder.
For debugging purposes only.
validateNature
protected boolean validateNature(InternalBuilder builder,
java.lang.String builderId)
throws org.eclipse.core.runtime.CoreException
- Returns true if the nature membership rules are satisifed for the given
builder extension on the given project, and false otherwise. A builder that
does not specify that it belongs to a nature is always valid. A builder
extension that belongs to a nature can be invalid for the following reasons:
- The nature that owns the builder does not exist on the given project
- The nature that owns the builder is disabled on the given project
Furthermore, if the nature that owns the builder does not exist on the project,
that builder will be removed from the build spec.
Note: This method only validates nature constraints that can vary at runtime.
Additional checks are done in the instantiateBuilder method for constraints
that cannot vary once the plugin registry is initialized.