Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java430
1 files changed, 243 insertions, 187 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java
index ab306a322eb..803eab9b2c4 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java
@@ -71,32 +71,32 @@ import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
* The Executables Manager maintains a collection of executables built by all of
* the projects in the workspace. Executables are contributed by instances of
* IExecutablesProvider.
- *
+ *
* @author Ken Ryall
- *
+ *
*/
-public class ExecutablesManager extends PlatformObject implements ICProjectDescriptionListener, IElementChangedListener, IResourceChangeListener {
+public class ExecutablesManager extends PlatformObject
+ implements ICProjectDescriptionListener, IElementChangedListener, IResourceChangeListener {
private Map<IProject, IProjectExecutablesProvider> executablesProviderMap = new HashMap<IProject, IProjectExecutablesProvider>();
- private List<IExecutablesChangeListener> changeListeners = Collections.synchronizedList(new ArrayList<IExecutablesChangeListener>());
+ private List<IExecutablesChangeListener> changeListeners = Collections
+ .synchronizedList(new ArrayList<IExecutablesChangeListener>());
private List<IProjectExecutablesProvider> executableProviders;
private List<ISourceFilesProvider> sourceFileProviders;
private List<ISourceFileRemappingFactory> sourceFileRemappingFactories;
private List<IExecutableImporter> executableImporters;
-
-
+
/**
* Map of launch config names to the path locator memento string in the
* launch config, recorded in the most recent launch config change
* notification. We use this to ensure we flush source file mappings only
* when the launch config change involves a change to the source locators.
*/
- private Map<String, String> locatorMementos = new HashMap<String,String>();
-
+ private Map<String, String> locatorMementos = new HashMap<String, String>();
/**
- * A cache of the executables in the workspace, categorized by project.
- *
+ * A cache of the executables in the workspace, categorized by project.
+ *
* <p>
* This cache is updated by scheduling an asynchronous search. SearchJob is
* the only class that should <i>modify</i> this collection, including the
@@ -107,16 +107,16 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
* The same Executable may appear more than once.
*/
private Map<IProject, List<Executable>> executablesMap = new HashMap<IProject, List<Executable>>();
-
+
/**
* Provide a flat list of the executables in {@link #executablesMap}, with
* duplicates removed. That is effectively the list of all executables in
* the workspace that we know of as of now.
- *
+ *
* @return
*/
private List<Executable> flattenExecutablesMap() {
- List<Executable> result = new ArrayList<Executable>(executablesMap.size() * 5); // most projects will have less than five executables
+ List<Executable> result = new ArrayList<Executable>(executablesMap.size() * 5); // most projects will have less than five executables
synchronized (executablesMap) {
for (List<Executable> exes : executablesMap.values()) {
for (Executable exe : exes) {
@@ -128,7 +128,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
}
return result;
}
-
+
/**
* Job which searches through CDT projects for executables. Only one thread
* should be running this job at any one time. Running job should be
@@ -139,37 +139,36 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
super("Executables Search"); //$NON-NLS-1$
}
-
/**
* The projects given to us when scheduled. If null, flush our entire
* cache and search all projects
*/
private IProject[] projectsToRefresh;
-
+
@Override
public IStatus run(IProgressMonitor monitor) {
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Search for executables started"); //$NON-NLS-1$
-
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null, "Search for executables started"); //$NON-NLS-1$
+
IStatus status = Status.OK_STATUS;
// The executables we know of now. We'll compare the search results
// to this and see if we need to notify change listeners
List<Executable> before = flattenExecutablesMap();
-
- // Get the CDT projects in the workspace that we have no cached
+
+ // Get the CDT projects in the workspace that we have no cached
// results for (are not in 'executablesMap'). Also, we may have been
// asked to refresh the cache for some projects we've search before
List<IProject> projects = new ArrayList<IProject>();
synchronized (executablesMap) {
if (projectsToRefresh == null) {
executablesMap.clear();
- }
- else {
+ } else {
for (IProject project : projectsToRefresh) {
executablesMap.remove(project);
}
}
-
+
// Get the list of projects we plan to search
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
if (!executablesMap.containsKey(project) && CoreModel.hasCNature(project)) {
@@ -178,24 +177,27 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
}
}
-
SubMonitor subMonitor = SubMonitor.convert(monitor, projects.size());
for (IProject project : projects) {
if (subMonitor.isCanceled()) {
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Search for executables canceled"); //$NON-NLS-1$
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null, "Search for executables canceled"); //$NON-NLS-1$
status = Status.CANCEL_STATUS;
break; // we've already changed our model; stop searching but proceed to notify listeners that the model changed
}
-
+
subMonitor.subTask("Checking project: " + project.getName()); //$NON-NLS-1$
// get the executables provider for this project
IProjectExecutablesProvider provider = getExecutablesProviderForProject(project);
if (provider != null) {
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Getting executables for project: " + project.getName() + " using " + provider.toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null, "Getting executables for project: " + project.getName() + " using " //$NON-NLS-1$//$NON-NLS-2$
+ + provider.toString());
- List<Executable> executables = provider.getExecutables(project, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
+ List<Executable> executables = provider.getExecutables(project,
+ subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
// store the list of executables for this project
synchronized (executablesMap) {
executablesMap.put(project, executables);
@@ -203,7 +205,6 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
}
}
-
// See if, after all that work, there's a net change in the
// executables list. If so, notify listeners.
List<Executable> after = flattenExecutablesMap();
@@ -221,10 +222,10 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
// New interface
if (listener instanceof IExecutablesChangeListener2) {
if (removed.size() > 0) {
- ((IExecutablesChangeListener2)listener).executablesRemoved(removed);
+ ((IExecutablesChangeListener2) listener).executablesRemoved(removed);
}
if (added.size() > 0) {
- ((IExecutablesChangeListener2)listener).executablesAdded(added);
+ ((IExecutablesChangeListener2) listener).executablesAdded(added);
}
}
// Old interface
@@ -233,7 +234,8 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
}
}
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Search for executables finished"); //$NON-NLS-1$
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null, "Search for executables finished"); //$NON-NLS-1$
return status;
}
@@ -241,7 +243,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
/**
* Schedules the search job. Use this, not the standard Job.schedule()
* method.
- *
+ *
* @param projectsToRefresh
* if null, all CDT projects in the workspace are searched.
* If not null, we search only newly present projects and the
@@ -253,7 +255,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
super.schedule();
}
};
-
+
/** The search job. We only let one of these run at any one time */
private SearchJob searchJob = new SearchJob();
@@ -274,103 +276,122 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
public ExecutablesManager() {
searchJob.setPriority(Job.SHORT);
-
+
// load the extension points
loadExecutableProviderExtensions();
loadSoureFileProviderExtensions();
loadSoureRemappingExtensions();
loadExecutableImporterExtensions();
-
+
// add the standard providers
executableProviders.add(0, new StandardExecutableProvider());
sourceFileProviders.add(0, new StandardSourceFilesProvider());
sourceFileRemappingFactories.add(0, new StandardSourceFileRemappingFactory());
executableImporters.add(0, new StandardExecutableImporter());
-
+
// listen for events we're interested in
CModelManager.getDefault().addElementChangedListener(this);
CoreModel.getDefault().getProjectDescriptionManager().addCProjectDescriptionListener(this,
CProjectDescriptionEvent.APPLIED);
-
+
// Listen for changes to the global source locators. These locators
// affect how source files are found locally. The Executable objects
// cache their local source file paths and rely on us to tell them to
// flush those caches when applicable locators change.
- CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().addParticipants(new ISourceLookupParticipant[] { new ISourceLookupParticipant(){
+ CDebugCorePlugin.getDefault().getCommonSourceLookupDirector()
+ .addParticipants(new ISourceLookupParticipant[] { new ISourceLookupParticipant() {
+
+ @Override
+ public void init(ISourceLookupDirector director) {
+ }
+
+ @Override
+ public Object[] findSourceElements(Object object) {
+ return new Object[0];
+ }
+
+ @Override
+ public String getSourceName(Object object) throws CoreException {
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public void sourceContainersChanged(ISourceLookupDirector director) {
+ // Unfortunately, it would be extremely difficult/costly to
+ // determine which binaries are effected by the source locator
+ // change, so we have to tell all Executables to flush
+ flushExecutablesSourceMappings();
+ }
+ } });
- @Override
- public void init(ISourceLookupDirector director) {}
- @Override
- public Object[] findSourceElements(Object object) { return new Object[0]; }
- @Override
- public String getSourceName(Object object) throws CoreException { return ""; } //$NON-NLS-1$
- @Override
- public void dispose() {}
- @Override
- public void sourceContainersChanged(ISourceLookupDirector director) {
- // Unfortunately, it would be extremely difficult/costly to
- // determine which binaries are effected by the source locator
- // change, so we have to tell all Executables to flush
- flushExecutablesSourceMappings();
- }
- } });
-
// Source locators are also in launch configurations, and those too come
// into play when an Executable looks for a source file locally. So,
// listen for changes in those locators, too.
DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(new ILaunchConfigurationListener() {
@Override
public void launchConfigurationChanged(ILaunchConfiguration configuration) {
- // Expect lots of noise for working copies. We only care about
+ // Expect lots of noise for working copies. We only care about
// changes to actual configs
if (configuration.isWorkingCopy()) {
return;
}
-
- // If the source locators in the launch config were not modified, then no-op
+
+ // If the source locators in the launch config were not modified, then no-op
try {
String configName = configuration.getName();
String mementoBefore = locatorMementos.get(configName);
- String mementoNow = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, ""); //$NON-NLS-1$
+ String mementoNow = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO,
+ ""); //$NON-NLS-1$
if (mementoNow.equals(mementoBefore)) {
return; // launch config change had no affect on source locators
}
- locatorMementos.put(configName, mementoNow);
+ locatorMementos.put(configName, mementoNow);
} catch (CoreException e) {
CDebugCorePlugin.log(e);
}
- // TODO: For now, just tell all Executables to flush. Look
- // into identifying which binary the config is associated
+ // TODO: For now, just tell all Executables to flush. Look
+ // into identifying which binary the config is associated
// with so we can flush only that Executable
flushExecutablesSourceMappings();
}
+
@Override
- public void launchConfigurationRemoved(ILaunchConfiguration configuration) { configAddedOrRemoved(configuration); }
+ public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
+ configAddedOrRemoved(configuration);
+ }
+
@Override
- public void launchConfigurationAdded(ILaunchConfiguration configuration) { configAddedOrRemoved(configuration); }
+ public void launchConfigurationAdded(ILaunchConfiguration configuration) {
+ configAddedOrRemoved(configuration);
+ }
+
private void configAddedOrRemoved(ILaunchConfiguration configuration) {
- // Expect lots of noise for working copies. We only care about
+ // Expect lots of noise for working copies. We only care about
// changes to actual configs
if (configuration.isWorkingCopy()) {
return;
}
-
- // The addition or removal of a launch config could affect
- // how files are found. It would be extremely costly to
- // determine here whether it will or not, so assume it will.
-
- // TODO: For now, just tell all Executables to flush. Look
- // into identifying which binary the config is associated
+
+ // The addition or removal of a launch config could affect
+ // how files are found. It would be extremely costly to
+ // determine here whether it will or not, so assume it will.
+
+ // TODO: For now, just tell all Executables to flush. Look
+ // into identifying which binary the config is associated
// with so we can flush only that Executable
flushExecutablesSourceMappings();
}
});
-
+
// schedule a refresh so we get up to date
scheduleExecutableSearch(null);
}
-
+
/**
* Tell all Executable objects to flush their source file mappings, then
* notify our listeners that the executables changed. Even though the
@@ -379,7 +400,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
* information the Executable provided, that info can no longer be trusted.
* The primary purpose of an Executable is to provide source file path
* information--not only the compile paths burned into the executable but
- * also the local mappings of those paths.
+ * also the local mappings of those paths.
*/
private void flushExecutablesSourceMappings() {
List<Executable> exes = flattenExecutablesMap();
@@ -413,7 +434,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
* Gets the list of executables in the workspace. This method doesn't
* initiate a search. It returns the cached results of the most recent
* search, or waits for the ongoing search to complete.
- *
+ *
* @param wait
* Whether or not to wait if the cache is in the process of being
* updated when this method is called. When true, the call will
@@ -428,19 +449,23 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
* @since 7.0
*/
public Collection<Executable> getExecutables(boolean wait) {
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, Boolean.valueOf(wait));
-
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().traceEntry(null, Boolean.valueOf(wait));
+
// Wait for running search to finish, if asked to
if (wait && searchJob.getState() != Job.NONE) {
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Waiting for executable search to finish..."); //$NON-NLS-1$
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null, "Waiting for executable search to finish..."); //$NON-NLS-1$
try {
searchJob.join();
} catch (InterruptedException e) {
}
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "...executable search finished."); //$NON-NLS-1$
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null, "...executable search finished."); //$NON-NLS-1$
}
-
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceExit(null);
+
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().traceExit(null);
return flattenExecutablesMap();
}
@@ -453,7 +478,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
public Collection<Executable> getExecutables() {
return getExecutables(false);
}
-
+
/**
* @since 7.0
* Gets the collection of executables for the given project
@@ -498,7 +523,8 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
if (p0 > p1)
return -1;
return 0;
- }});
+ }
+ });
for (IExecutableImporter importer : executableImporters) {
handled = importer.importExecutables(fileNames, new SubProgressMonitor(monitor, 1));
@@ -507,7 +533,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
}
}
}
-
+
if (handled)
scheduleExecutableSearch(null);
}
@@ -527,7 +553,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
}
}
}
-
+
return false;
}
@@ -538,8 +564,9 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
* @return an array of source files which may be empty
*/
public String[] getSourceFiles(final Executable executable, IProgressMonitor monitor) {
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, executable);
-
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().traceEntry(null, executable);
+
String[] result = new String[0];
synchronized (sourceFileProviders) {
@@ -554,21 +581,25 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
if (p0 > p1)
return -1;
return 0;
- }});
-
+ }
+ });
+
monitor.beginTask("Finding source files in " + executable.getName(), sourceFileProviders.size() * 1000); //$NON-NLS-1$
for (ISourceFilesProvider provider : sourceFileProviders) {
String[] sourceFiles = provider.getSourceFiles(executable, new SubProgressMonitor(monitor, 1000));
if (sourceFiles.length > 0) {
result = sourceFiles;
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Got " + sourceFiles.length + " files from " + provider.toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null,
+ "Got " + sourceFiles.length + " files from " + provider.toString()); //$NON-NLS-1$ //$NON-NLS-2$
break;
}
}
monitor.done();
}
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceExit(null, result);
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().traceExit(null, result);
return result;
}
@@ -577,15 +608,16 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
* @param executables the array of executables to be removed
* @param monitor progress monitor
* @return IStatus of the operation
- *
+ *
* @since 6.0
*/
public IStatus removeExecutables(Executable[] executables, IProgressMonitor monitor) {
- MultiStatus status = new MultiStatus(CDebugCorePlugin.PLUGIN_ID, IStatus.WARNING, "Couldn't remove all of the selected executables", null); //$NON-NLS-1$
-
+ MultiStatus status = new MultiStatus(CDebugCorePlugin.PLUGIN_ID, IStatus.WARNING,
+ "Couldn't remove all of the selected executables", null); //$NON-NLS-1$
+
monitor.beginTask("Remove Executables", executables.length); //$NON-NLS-1$
for (Executable executable : executables) {
-
+
IProjectExecutablesProvider provider = getExecutablesProviderForProject(executable.getProject());
if (provider != null) {
IStatus result = provider.removeExecutable(executable, new SubProgressMonitor(monitor, 1));
@@ -594,11 +626,11 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
}
}
}
-
+
// We don't need to directly call our listeners. The file removal will
// cause a C model change, which we will react to by then calling the
// listeners
-
+
return status;
}
@@ -606,12 +638,12 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
* Initiates an asynchronous search of workspace CDT projects for
* executables. If a search is ongoing, it's cancelled and a new one is
* started. In all cases, this method returns quickly (does not wait/block).
- *
+ *
* <p>
* Listeners are notified when the search is complete and there is a change
* in the collection of found executables. The results of the search can be
* obtained by calling {@link #getExecutables(boolean)}.
- *
+ *
* @param projectsToRefresh
* if null, we discard our entire Executables cache and search
* all CDT projects in the workspace. If not null, we purge our
@@ -621,11 +653,12 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
* executables in any newly available projects. This parameter is
* simply a way to get us to <i>not</i> skip one or more projects
* we already have the executables list for.
- *
+ *
* @since 7.0
*/
public void refresh(List<IProject> projectsToRefresh) {
- scheduleExecutableSearch(projectsToRefresh != null ? projectsToRefresh.toArray(new IProject[projectsToRefresh.size()]) : null);
+ scheduleExecutableSearch(
+ projectsToRefresh != null ? projectsToRefresh.toArray(new IProject[projectsToRefresh.size()]) : null);
}
/**
@@ -636,21 +669,23 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
*/
@Override
@Deprecated
- public void resourceChanged(IResourceChangeEvent event) {}
+ public void resourceChanged(IResourceChangeEvent event) {
+ }
/**
* @since 7.0
*/
@Override
public void handleEvent(CProjectDescriptionEvent event) {
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, event);
-
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().traceEntry(null, event);
+
// this handles the cases where the active build configuration changes,
// and when new projects are created or loaded at startup.
int eventType = event.getEventType();
if (eventType == CProjectDescriptionEvent.APPLIED) {
-
+
// see if the active build config has changed
ICProjectDescription newDesc = event.getNewCProjectDescription();
ICProjectDescription oldDesc = event.getOldCProjectDescription();
@@ -658,13 +693,16 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
String newConfigName = newDesc.getActiveConfiguration().getName();
String oldConfigName = oldDesc.getActiveConfiguration().getName();
if (!newConfigName.equals(oldConfigName)) {
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Scheduling refresh because active build configuration changed"); //$NON-NLS-1$
- scheduleExecutableSearch(new IProject[]{newDesc.getProject()});
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null, "Scheduling refresh because active build configuration changed"); //$NON-NLS-1$
+ scheduleExecutableSearch(new IProject[] { newDesc.getProject() });
}
} else if (newDesc != null && oldDesc == null) {
// project just created
scheduleExecutableSearch(null);
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Scheduling refresh because project " + newDesc.getProject().getName() + " created"); //$NON-NLS-1$//$NON-NLS-2$
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null,
+ "Scheduling refresh because project " + newDesc.getProject().getName() + " created"); //$NON-NLS-1$//$NON-NLS-2$
}
}
}
@@ -676,7 +714,8 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
* takes an array instead of a list
*/
private void scheduleExecutableSearch(final IProject[] projectsToRefresh) {
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, projectsToRefresh);
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().traceEntry(null, projectsToRefresh);
// Don't schedule multiple search jobs simultaneously. If one is
// running, cancel it, wait for it to terminate, then schedule a new
@@ -690,18 +729,20 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
searchJob.cancel();
if (searchJob.getState() != Job.NONE) {
try {
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Waiting for canceled job to terminate"); //$NON-NLS-1$
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null, "Waiting for canceled job to terminate"); //$NON-NLS-1$
searchJob.join();
} catch (InterruptedException e) {
}
}
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Scheduling new search job"); //$NON-NLS-1$
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null, "Scheduling new search job"); //$NON-NLS-1$
searchJob.schedule(projectsToRefresh);
}
-
+
return Status.OK_STATUS;
}
-
+
};
job.setPriority(Job.SHORT);
job.schedule();
@@ -724,7 +765,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
naturesMatched++;
}
}
-
+
if (naturesMatched > mostNaturesMatched) {
provider = exeProvider;
mostNaturesMatched = naturesMatched;
@@ -738,72 +779,75 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
e.printStackTrace();
}
}
-
+
return provider;
}
-
+
ISourceFileRemappingFactory[] getSourceFileRemappingFactories() {
- return sourceFileRemappingFactories.toArray(new ISourceFileRemappingFactory[sourceFileRemappingFactories.size()]);
+ return sourceFileRemappingFactories
+ .toArray(new ISourceFileRemappingFactory[sourceFileRemappingFactories.size()]);
}
private void loadExecutableProviderExtensions() {
executableProviders = Collections.synchronizedList(new ArrayList<IProjectExecutablesProvider>());
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".ExecutablesProvider"); //$NON-NLS-1$
+ IExtensionPoint extensionPoint = extensionRegistry
+ .getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".ExecutablesProvider"); //$NON-NLS-1$
IExtension[] extensions = extensionPoint.getExtensions();
-
+
for (int i = 0; i < extensions.length; i++) {
IExtension extension = extensions[i];
IConfigurationElement[] elements = extension.getConfigurationElements();
IConfigurationElement element = elements[0];
-
+
boolean failed = false;
try {
Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$
if (extObject instanceof IProjectExecutablesProvider) {
- executableProviders.add((IProjectExecutablesProvider)extObject);
+ executableProviders.add((IProjectExecutablesProvider) extObject);
} else {
failed = true;
}
- }
- catch (CoreException e) {
+ } catch (CoreException e) {
failed = true;
}
-
+
if (failed) {
- CDebugCorePlugin.log("Unable to load ExecutablesProvider extension from " + extension.getContributor().getName()); //$NON-NLS-1$
+ CDebugCorePlugin.log(
+ "Unable to load ExecutablesProvider extension from " + extension.getContributor().getName()); //$NON-NLS-1$
}
}
}
-
+
private void loadSoureFileProviderExtensions() {
sourceFileProviders = Collections.synchronizedList(new ArrayList<ISourceFilesProvider>());
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".SourceFilesProvider"); //$NON-NLS-1$
+ IExtensionPoint extensionPoint = extensionRegistry
+ .getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".SourceFilesProvider"); //$NON-NLS-1$
IExtension[] extensions = extensionPoint.getExtensions();
-
+
for (int i = 0; i < extensions.length; i++) {
IExtension extension = extensions[i];
IConfigurationElement[] elements = extension.getConfigurationElements();
IConfigurationElement element = elements[0];
-
+
boolean failed = false;
try {
Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$
if (extObject instanceof ISourceFilesProvider) {
- sourceFileProviders.add((ISourceFilesProvider)extObject);
+ sourceFileProviders.add((ISourceFilesProvider) extObject);
} else {
failed = true;
}
- }
- catch (CoreException e) {
+ } catch (CoreException e) {
failed = true;
}
-
+
if (failed) {
- CDebugCorePlugin.log("Unable to load SourceFilesProvider extension from " + extension.getContributor().getName()); //$NON-NLS-1$
+ CDebugCorePlugin.log(
+ "Unable to load SourceFilesProvider extension from " + extension.getContributor().getName()); //$NON-NLS-1$
}
}
}
@@ -812,29 +856,30 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
sourceFileRemappingFactories = Collections.synchronizedList(new ArrayList<ISourceFileRemappingFactory>());
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".SourceRemappingProvider"); //$NON-NLS-1$
+ IExtensionPoint extensionPoint = extensionRegistry
+ .getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".SourceRemappingProvider"); //$NON-NLS-1$
IExtension[] extensions = extensionPoint.getExtensions();
-
+
for (int i = 0; i < extensions.length; i++) {
IExtension extension = extensions[i];
IConfigurationElement[] elements = extension.getConfigurationElements();
IConfigurationElement element = elements[0];
-
+
boolean failed = false;
try {
Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$
if (extObject instanceof ISourceFileRemappingFactory) {
- sourceFileRemappingFactories.add((ISourceFileRemappingFactory)extObject);
+ sourceFileRemappingFactories.add((ISourceFileRemappingFactory) extObject);
} else {
failed = true;
}
- }
- catch (CoreException e) {
+ } catch (CoreException e) {
failed = true;
}
-
+
if (failed) {
- CDebugCorePlugin.log("Unable to load SourceRemappingProvider extension from " + extension.getContributor().getName()); //$NON-NLS-1$
+ CDebugCorePlugin.log("Unable to load SourceRemappingProvider extension from " //$NON-NLS-1$
+ + extension.getContributor().getName());
}
}
}
@@ -843,29 +888,30 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
executableImporters = Collections.synchronizedList(new ArrayList<IExecutableImporter>());
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".ExecutablesImporter"); //$NON-NLS-1$
+ IExtensionPoint extensionPoint = extensionRegistry
+ .getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".ExecutablesImporter"); //$NON-NLS-1$
IExtension[] extensions = extensionPoint.getExtensions();
-
+
for (int i = 0; i < extensions.length; i++) {
IExtension extension = extensions[i];
IConfigurationElement[] elements = extension.getConfigurationElements();
IConfigurationElement element = elements[0];
-
+
boolean failed = false;
try {
Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$
if (extObject instanceof IExecutableImporter) {
- executableImporters.add((IExecutableImporter)extObject);
+ executableImporters.add((IExecutableImporter) extObject);
} else {
failed = true;
}
- }
- catch (CoreException e) {
+ } catch (CoreException e) {
failed = true;
}
-
+
if (failed) {
- CDebugCorePlugin.log("Unable to load ExecutablesImporter extension from " + extension.getContributor().getName()); //$NON-NLS-1$
+ CDebugCorePlugin.log(
+ "Unable to load ExecutablesImporter extension from " + extension.getContributor().getName()); //$NON-NLS-1$
}
}
}
@@ -874,36 +920,44 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
* We listen to C model changes and see if they affect what executables are
* in the workspace, and/or if the executables we already know of have
* changed.
- *
+ *
* @since 7.1
*/
@Override
public void elementChanged(ElementChangedEvent event) {
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null);
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "event = \n" + event); // must be done separately because of traceEntry() limitation //$NON-NLS-1$
-
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().traceEntry(null);
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null, "event = \n" + event); // must be done separately because of traceEntry() limitation //$NON-NLS-1$
+
// Examine the event and figure out what needs to be done
- Set<IProject> refreshProjects = new HashSet<IProject>(5);
+ Set<IProject> refreshProjects = new HashSet<IProject>(5);
Set<Executable> executablesChanged = new HashSet<Executable>(5);
Set<Executable> executablesRemoved = new HashSet<Executable>(5);
- processDeltas(event.getDelta().getAddedChildren(), null, refreshProjects, executablesRemoved, executablesChanged);
- processDeltas(event.getDelta().getChangedChildren(), null, refreshProjects, executablesRemoved, executablesChanged);
- processDeltas(event.getDelta().getRemovedChildren(), null, refreshProjects, executablesRemoved, executablesChanged);
-
- // Schedule executable searches in projects
+ processDeltas(event.getDelta().getAddedChildren(), null, refreshProjects, executablesRemoved,
+ executablesChanged);
+ processDeltas(event.getDelta().getChangedChildren(), null, refreshProjects, executablesRemoved,
+ executablesChanged);
+ processDeltas(event.getDelta().getRemovedChildren(), null, refreshProjects, executablesRemoved,
+ executablesChanged);
+
+ // Schedule executable searches in projects
if (refreshProjects.size() > 0) {
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "One or more projects need to be re-searched"); //$NON-NLS-1$
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null, "One or more projects need to be re-searched"); //$NON-NLS-1$
scheduleExecutableSearch(refreshProjects.toArray(new IProject[refreshProjects.size()]));
}
-
+
// Invalidate the source file cache in changed Executables and inform
// listeners
if (executablesChanged.size() > 0) {
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "One or more executables changed"); //$NON-NLS-1$
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null, "One or more executables changed"); //$NON-NLS-1$
for (Executable exec : executablesChanged) {
exec.setRefreshSourceFiles(true);
}
- List<Executable> list = Arrays.asList(executablesChanged.toArray(new Executable[executablesChanged.size()]));
+ List<Executable> list = Arrays
+ .asList(executablesChanged.toArray(new Executable[executablesChanged.size()]));
synchronized (changeListeners) {
for (IExecutablesChangeListener listener : changeListeners) {
listener.executablesChanged(list);
@@ -912,7 +966,8 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
}
if (executablesRemoved.size() > 0) {
// Update our model (i.e., our collection of Executables) and inform listeners
- if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "One or more executables were removed"); //$NON-NLS-1$
+ if (Trace.DEBUG_EXECUTABLES)
+ Trace.getTrace().trace(null, "One or more executables were removed"); //$NON-NLS-1$
synchronized (executablesMap) {
for (Executable executableRemoved : executablesRemoved) {
List<Executable> execs = executablesMap.get(executableRemoved.getProject());
@@ -922,12 +977,13 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
}
}
}
- List<Executable> list = Arrays.asList(executablesRemoved.toArray(new Executable[executablesRemoved.size()]));
+ List<Executable> list = Arrays
+ .asList(executablesRemoved.toArray(new Executable[executablesRemoved.size()]));
synchronized (changeListeners) {
for (IExecutablesChangeListener listener : changeListeners) {
// call newer interface if supported
if (listener instanceof IExecutablesChangeListener2) {
- ((IExecutablesChangeListener2)listener).executablesRemoved(list);
+ ((IExecutablesChangeListener2) listener).executablesRemoved(list);
}
// and call older interface, which is less informative
listener.executablesListChanged();
@@ -936,11 +992,11 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
}
return;
}
-
+
/**
* Drills down a hierarchy of CDT model change events to determine the
* course of action.
- *
+ *
* @param deltas
* CDT model events received by the viewer
* @param cproject
@@ -961,13 +1017,14 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
* Executable objects that have changed, requiring listeners to
* be notified.
*/
- private void processDeltas(ICElementDelta[] deltas, ICProject cproject, final Set<IProject> projectsToRefresh, final Set<Executable> removedExecutables, final Set<Executable> changedExecutables) {
+ private void processDeltas(ICElementDelta[] deltas, ICProject cproject, final Set<IProject> projectsToRefresh,
+ final Set<Executable> removedExecutables, final Set<Executable> changedExecutables) {
for (ICElementDelta delta : deltas) {
ICElement element = delta.getElement();
if (element instanceof ICProject) {
// When a project is deleted, we get a REMOVED delta for the
- // project only--none for the elements in the project.
- IProject project = ((ICProject)element).getProject();
+ // project only--none for the elements in the project.
+ IProject project = ((ICProject) element).getProject();
if (delta.getKind() == ICElementDelta.REMOVED) {
projectsToRefresh.add(project);
List<Executable> execs = null;
@@ -977,37 +1034,35 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
if (execs != null) {
for (Executable exec : execs) {
if (exec.getResource().equals(delta.getElement().getResource())) {
- removedExecutables.add(exec);
+ removedExecutables.add(exec);
break;
}
}
}
- // Note that it's not our job to update 'executablesMap'.
- // The async exec search job will do that.
+ // Note that it's not our job to update 'executablesMap'.
+ // The async exec search job will do that.
}
- }
- else if (element instanceof IBinary) {
+ } else if (element instanceof IBinary) {
IProject project = cproject.getProject();
int deltaKind = delta.getKind();
switch (deltaKind) {
case ICElementDelta.ADDED:
projectsToRefresh.add(project);
break;
- case ICElementDelta.REMOVED:
+ case ICElementDelta.REMOVED:
case ICElementDelta.CHANGED: {
List<Executable> execs = null;
synchronized (executablesMap) {
execs = executablesMap.get(project);
if (execs == null) {
- // Somehow, we missed the addition of the project.
- // Request that the project be researched for
+ // Somehow, we missed the addition of the project.
+ // Request that the project be researched for
// executables
projectsToRefresh.add(project);
- }
- else {
+ } else {
// See if it's one of the executables we already know
- // is in the project. If so, we'll update our
+ // is in the project. If so, we'll update our
// executables map (if removed) and notifying
// listeners
for (Executable exec : execs) {
@@ -1026,10 +1081,11 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr
}
}
if (element instanceof ICProject) {
- cproject = (ICProject)element;
+ cproject = (ICProject) element;
}
// recursively call ourselves to handle this delta's children
- processDeltas(delta.getAffectedChildren(), cproject, projectsToRefresh, removedExecutables, changedExecutables);
+ processDeltas(delta.getAffectedChildren(), cproject, projectsToRefresh, removedExecutables,
+ changedExecutables);
}
}
}

Back to the top