Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorKen Ryall2008-08-13 13:27:20 +0000
committerKen Ryall2008-08-13 13:27:20 +0000
commit037111a067d86239d86f02a64549f84485c9b30d (patch)
treec315f6858b30c3877652eac0b2ef4efe4448c7c2 /debug
parent5ff757551b8ebb29dfc3e3b49054de973146a94b (diff)
downloadorg.eclipse.cdt-037111a067d86239d86f02a64549f84485c9b30d.tar.gz
org.eclipse.cdt-037111a067d86239d86f02a64549f84485c9b30d.tar.xz
org.eclipse.cdt-037111a067d86239d86f02a64549f84485c9b30d.zip
Fix build break caused by incomplete commit.
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java60
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutableImporter.java17
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableImporter.java15
3 files changed, 74 insertions, 18 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 f0c8bd5b101..a8f9ae26b32 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
@@ -117,24 +117,43 @@ public class ExecutablesManager extends PlatformObject {
if (tempDisableRefresh) {
return Status.OK_STATUS;
}
+
synchronized (executables) {
- ArrayList<Executable> oldList = new ArrayList<Executable>(executables);
+ HashMap<String, Executable> oldList = new HashMap<String, Executable>(executables);
executables.clear();
- synchronized (executableProviders) {
- monitor.beginTask("Refresh Executables", executableProviders.size());
- for (IExecutableProvider provider : executableProviders) {
- executables.addAll(provider.getExecutables(new SubProgressMonitor(monitor, 1)));
+ IExecutableProvider[] exeProviders = getExecutableProviders();
+
+ Arrays.sort(exeProviders, new Comparator<IExecutableProvider>() {
+
+ public int compare(IExecutableProvider arg0, IExecutableProvider arg1) {
+ int p0 = arg0.getPriority();
+ int p1 = arg1.getPriority();
+ if (p0 > p1)
+ return 1;
+ if (p0 < p1)
+ return -1;
+ return 0;
+ }});
+
+ refreshNeeded = false;
+ monitor.beginTask("Refresh Executables", exeProviders.length);
+ for (IExecutableProvider provider : exeProviders) {
+ Executable[] exes = provider.getExecutables(new SubProgressMonitor(monitor, 1));
+ for (Executable executable : exes) {
+ executables.put(executable.getPath().toOSString(), executable);
}
- monitor.done();
}
- refreshNeeded = false;
+ monitor.done();
synchronized (changeListeners) {
+ Collection<Executable> newExes = executables.values();
+ Executable[] exeArray = newExes.toArray(new Executable[newExes.size()]);
+ Collection<Executable> oldExes = oldList.values();
+ Executable[] oldArray = oldExes.toArray(new Executable[oldExes.size()]);
for (IExecutablesChangeListener listener : changeListeners) {
- listener.executablesChanged(new ExecutablesChangeEvent(oldList, executables) {
- });
+ listener.executablesChanged(new ExecutablesChangeEvent(oldArray, exeArray));
}
}
}
@@ -166,19 +185,32 @@ public class ExecutablesManager extends PlatformObject {
return filePath;
}
- public void importExecutables(String[] fileNames, IProgressMonitor monitor) {
+ public void importExecutables(final String[] fileNames, IProgressMonitor monitor) {
try {
+
+ tempDisableRefresh = true;
+ monitor.beginTask("Import Executables", executableImporters.size());
synchronized (executableImporters) {
- tempDisableRefresh = true;
+ Collections.sort(executableImporters, new Comparator<IExecutableImporter>() {
+
+ public int compare(IExecutableImporter arg0, IExecutableImporter arg1) {
+ int p0 = arg0.getPriority(fileNames);
+ int p1 = arg1.getPriority(fileNames);
+ if (p0 < p1)
+ return 1;
+ if (p0 > p1)
+ return -1;
+ return 0;
+ }});
- monitor.beginTask("Import Executables", executableImporters.size());
for (IExecutableImporter importer : executableImporters) {
- importer.importExecutables(fileNames, new SubProgressMonitor(monitor, 1));
- if (monitor.isCanceled()) {
+ boolean handled = importer.importExecutables(fileNames, new SubProgressMonitor(monitor, 1));
+ if (handled || monitor.isCanceled()) {
break;
}
}
}
+
} finally {
tempDisableRefresh = false;
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutableImporter.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutableImporter.java
index 8fe0ef324ce..9800a0254ae 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutableImporter.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutableImporter.java
@@ -14,6 +14,21 @@ import org.eclipse.core.runtime.IProgressMonitor;
public interface IExecutableImporter {
- public abstract void importExecutables(String[] fileNames, IProgressMonitor monitor);
+ static int LOW_PRIORITY = 25;
+ static int NORMAL_PRIORITY = 50;
+ static int HIGH_PRIORITY = 75;
+
+ /**
+ * Gets the priority to be used when importing these executables.
+ * The priority is used by the Executables Manager when multiple IExecutableImporters are available.
+ * IExecutableImporter.importExecutables will be called for each one in priority order and will
+ * stop with the first one that returns TRUE.
+ *
+ * @param executable
+ * @return the priority level to be used for this ISourceFilesProvider
+ */
+ int getPriority(String[] fileNames);
+
+ public abstract boolean importExecutables(String[] fileNames, IProgressMonitor monitor);
} \ No newline at end of file
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableImporter.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableImporter.java
index fa1a1203627..c98e864e3e7 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableImporter.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableImporter.java
@@ -51,7 +51,7 @@ public class StandardExecutableImporter implements IExecutableImporter {
* @see org.eclipse.cdt.debug.core.executables.IExecutableImporter#importExecutables(java.lang.String[],
* org.eclipse.core.runtime.IProgressMonitor)
*/
- public void importExecutables(String[] fileNames, IProgressMonitor monitor) {
+ public boolean importExecutables(String[] fileNames, IProgressMonitor monitor) {
monitor.beginTask("Import Executables", fileNames.length);
IProject exeProject = null;
@@ -63,7 +63,7 @@ public class StandardExecutableImporter implements IExecutableImporter {
path = new File(path).getCanonicalPath();
} catch (IOException e1) {
}
- if (!ExecutablesManager.getExecutablesManager().executableExists(Path.fromOSString(path))) {
+ if (AllowImport(Path.fromOSString(path))) {
if (!checkProject) {
// See if the default project exists
String defaultProjectName = "Executables";
@@ -115,9 +115,14 @@ public class StandardExecutableImporter implements IExecutableImporter {
}
}
monitor.done();
+ return true;
}
- private IContainer createFromRoot(IProject exeProject, IPath path) throws CoreException {
+ public boolean AllowImport(IPath path) {
+ return (!ExecutablesManager.getExecutablesManager().executableExists(path));
+ }
+
+ private IContainer createFromRoot(IProject exeProject, IPath path) throws CoreException {
int segmentCount = path.segmentCount() - 1;
IContainer currentFolder = exeProject;
@@ -224,4 +229,8 @@ public class StandardExecutableImporter implements IExecutableImporter {
return false;
}
+ public int getPriority(String[] fileNames) {
+ return NORMAL_PRIORITY;
+ }
+
}

Back to the top