mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Cache the source file list for an executable and don't block the UI while getting it.
This commit is contained in:
parent
c198a352ec
commit
50b3346cec
1 changed files with 14 additions and 2 deletions
|
@ -37,6 +37,7 @@ import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
@ -51,6 +52,7 @@ public class Executable extends PlatformObject {
|
||||||
private IResource resource;
|
private IResource resource;
|
||||||
private Map<ITranslationUnit, String> remappedPaths;
|
private Map<ITranslationUnit, String> remappedPaths;
|
||||||
private ArrayList<ITranslationUnit> sourceFiles;
|
private ArrayList<ITranslationUnit> sourceFiles;
|
||||||
|
private boolean refreshSourceFiles;
|
||||||
|
|
||||||
public IPath getPath() {
|
public IPath getPath() {
|
||||||
return path;
|
return path;
|
||||||
|
@ -67,6 +69,7 @@ public class Executable extends PlatformObject {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
remappedPaths = new HashMap<ITranslationUnit, String>();
|
remappedPaths = new HashMap<ITranslationUnit, String>();
|
||||||
sourceFiles = new ArrayList<ITranslationUnit>();
|
sourceFiles = new ArrayList<ITranslationUnit>();
|
||||||
|
refreshSourceFiles = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IResource getResource() {
|
public IResource getResource() {
|
||||||
|
@ -203,7 +206,11 @@ public class Executable extends PlatformObject {
|
||||||
return null;
|
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
|
// Try to get the list of source files used to build the binary from the
|
||||||
// symbol information.
|
// symbol information.
|
||||||
|
|
||||||
|
@ -296,9 +303,14 @@ public class Executable extends PlatformObject {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshSourceFiles = false;
|
||||||
return sourceFiles.toArray(new TranslationUnit[sourceFiles.size()]) ;
|
return sourceFiles.toArray(new TranslationUnit[sourceFiles.size()]) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRefreshSourceFiles(boolean refreshSourceFiles) {
|
||||||
|
this.refreshSourceFiles = refreshSourceFiles;
|
||||||
|
}
|
||||||
|
|
||||||
public String getOriginalLocation(ITranslationUnit tu) {
|
public String getOriginalLocation(ITranslationUnit tu) {
|
||||||
String orgLocation = remappedPaths.get(tu);
|
String orgLocation = remappedPaths.get(tu);
|
||||||
if (orgLocation == null)
|
if (orgLocation == null)
|
||||||
|
|
Loading…
Add table
Reference in a new issue