Skip to main content
summaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorKen Ryall2008-06-27 14:26:22 -0400
committerKen Ryall2008-06-27 14:26:22 -0400
commit4b03e899d4293bca46ebd63361332cbdbf53e4fc (patch)
tree396ba01264ed49d08fd6bde6e5a59502adce29ad /debug
parent3b54befe6857e10bcc8cebedf5fd85fb70a13f30 (diff)
downloadorg.eclipse.cdt-4b03e899d4293bca46ebd63361332cbdbf53e4fc.tar.gz
org.eclipse.cdt-4b03e899d4293bca46ebd63361332cbdbf53e4fc.tar.xz
org.eclipse.cdt-4b03e899d4293bca46ebd63361332cbdbf53e4fc.zip
Cache the source file list for an executable and don't block the UI while getting it.
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java16
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java29
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesContentProvider.java3
3 files changed, 40 insertions, 8 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java
index 688d9101b3..c03a5e1122 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java
@@ -37,6 +37,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PlatformObject;
@@ -51,6 +52,7 @@ public class Executable extends PlatformObject {
private IResource resource;
private Map<ITranslationUnit, String> remappedPaths;
private ArrayList<ITranslationUnit> sourceFiles;
+ private boolean refreshSourceFiles;
public IPath getPath() {
return path;
@@ -67,6 +69,7 @@ public class Executable extends PlatformObject {
this.resource = resource;
remappedPaths = new HashMap<ITranslationUnit, String>();
sourceFiles = new ArrayList<ITranslationUnit>();
+ refreshSourceFiles = true;
}
public IResource getResource() {
@@ -203,7 +206,11 @@ public class Executable extends PlatformObject {
return null;
}
- public ITranslationUnit[] getSourceFiles() {
+ public TranslationUnit[] getSourceFiles(IProgressMonitor monitor) {
+
+ if (!refreshSourceFiles)
+ return sourceFiles.toArray(new TranslationUnit[sourceFiles.size()]) ;
+
// Try to get the list of source files used to build the binary from the
// symbol information.
@@ -296,7 +303,12 @@ public class Executable extends PlatformObject {
}
- return sourceFiles.toArray(new TranslationUnit[sourceFiles.size()]);
+ refreshSourceFiles = false;
+ return sourceFiles.toArray(new TranslationUnit[sourceFiles.size()]) ;
+ }
+
+ public void setRefreshSourceFiles(boolean refreshSourceFiles) {
+ this.refreshSourceFiles = refreshSourceFiles;
}
public String getOriginalLocation(ITranslationUnit tu) {
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java
index ac7835b9ce..862f70b3dc 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java
@@ -52,6 +52,7 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.XMLMemento;
import org.eclipse.ui.dialogs.ListSelectionDialog;
import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.progress.UIJob;
/**
* ExecutablesView displays a list of executable files either in the workspace
@@ -264,11 +265,29 @@ public class ExecutablesView extends ViewPart {
public void selectionChanged(SelectionChangedEvent event) {
ISelection newSelection = event.getSelection();
if (newSelection instanceof IStructuredSelection) {
- Object firstElement = ((IStructuredSelection) newSelection).getFirstElement();
- sourceFilesViewer.setInput(firstElement);
- if (firstElement instanceof Executable) {
- sourceFilesViewer.packColumns();
- }
+ final Object firstElement = ((IStructuredSelection) newSelection).getFirstElement();
+
+ Job setectExeJob = new Job("Select Executable") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ if (firstElement instanceof Executable) {
+ ((Executable)firstElement).getSourceFiles(monitor);
+ }
+ UIJob selectExeUIJob = new UIJob("Select Executable"){
+ @Override
+ public IStatus runInUIThread(
+ IProgressMonitor monitor) {
+ sourceFilesViewer.setInput(firstElement);
+ if (firstElement instanceof Executable) {
+ sourceFilesViewer.packColumns();
+ }
+ return Status.OK_STATUS;
+ }};
+ selectExeUIJob.schedule();
+ return Status.OK_STATUS;
+ }};
+ setectExeJob.schedule();
}
}
});
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesContentProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesContentProvider.java
index b875d93717..c2c23545bb 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesContentProvider.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesContentProvider.java
@@ -15,6 +15,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.debug.core.executables.Executable;
import org.eclipse.cdt.ui.CElementContentProvider;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
public class SourceFilesContentProvider extends CElementContentProvider {
@@ -35,7 +36,7 @@ public class SourceFilesContentProvider extends CElementContentProvider {
public Object[] getElements(Object inputElement) {
if (inputElement instanceof Executable) {
Executable executable = (Executable) inputElement;
- ITranslationUnit[] sourceFiles = executable.getSourceFiles();
+ ITranslationUnit[] sourceFiles = executable.getSourceFiles(new NullProgressMonitor());
if (sourceFiles.length == 0)
return new String[] { Messages.SourceFilesContentProvider_NoFilesFound + executable.getName() };
else

Back to the top