Skip to main content
summaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorSergey Prigogin2010-12-15 21:14:35 -0500
committerSergey Prigogin2010-12-15 21:14:35 -0500
commit47f70de67b8ab138434c8e1dee6174c430a8fef8 (patch)
treed4def78a005fe0e11ae1d6499876ab67360b3e03 /debug
parent686dacabdb81948ab919fd96f1210735d398b975 (diff)
downloadorg.eclipse.cdt-47f70de67b8ab138434c8e1dee6174c430a8fef8.tar.gz
org.eclipse.cdt-47f70de67b8ab138434c8e1dee6174c430a8fef8.tar.xz
org.eclipse.cdt-47f70de67b8ab138434c8e1dee6174c430a8fef8.zip
Bug 225805. Few more tweaks for CProjectSourceContainer and SourceFoldersRelativePathSourceContainer
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CProjectSourceContainer.java69
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceFoldersRelativePathSourceContainer.java55
2 files changed, 56 insertions, 68 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CProjectSourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CProjectSourceContainer.java
index 7ac108d17b..5e441153af 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CProjectSourceContainer.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CProjectSourceContainer.java
@@ -56,10 +56,10 @@ public class CProjectSourceContainer extends CompositeSourceContainer {
*/
public static final String TYPE_ID =
CDebugCorePlugin.getUniqueIdentifier() + ".containerType.project"; //$NON-NLS-1$
+ private final IProject fOwnProject; // Project assigned to this container at construction time.
private IProject fProject;
private boolean fSearchReferencedProjects;
private URI fRootURI;
- private boolean fInitializedRootURI;
private IFileStore fRootFile;
private IWorkspaceRoot fRoot;
@@ -70,6 +70,7 @@ public class CProjectSourceContainer extends CompositeSourceContainer {
* @param referenced whether referenced projects should be considered
*/
public CProjectSourceContainer(IProject project, boolean referenced) {
+ fOwnProject = project;
fProject = project;
fSearchReferencedProjects = referenced;
}
@@ -83,19 +84,28 @@ public class CProjectSourceContainer extends CompositeSourceContainer {
return fProject;
}
- /**
- * Returns the project associated with this source container either directly or through
- * the current launch configuration.
- * @return an IProject instance or {@code null}.
- */
- private IProject getResolvedProject() {
- if (fProject != null)
- return fProject;
- ISourceLookupDirector director = getDirector();
+ @Override
+ public void init(ISourceLookupDirector director) {
+ super.init(director);
if (director != null) {
- return SourceUtils.getLaunchConfigurationProject(director);
+ fProject = SourceUtils.getLaunchConfigurationProject(director);
+ if (fProject != null) {
+ fRootURI = fProject.getLocationURI();
+ if (fRootURI == null)
+ return;
+ try {
+ fRootFile = EFS.getStore(fRootURI);
+ } catch (CoreException e) {
+ }
+ fRoot = ResourcesPlugin.getWorkspace().getRoot();
+ }
}
- return null;
+ }
+
+ @Override
+ public void dispose() {
+ fProject = fOwnProject;
+ super.dispose();
}
/* (non-Javadoc)
@@ -117,9 +127,6 @@ public class CProjectSourceContainer extends CompositeSourceContainer {
if (file.exists()) {
sources.add(file);
} else {
- if (!fInitializedRootURI) {
- initializeRootURI();
- }
// See bug 82627 - perform case insensitive source lookup
if (fRootURI == null) {
return EMPTY;
@@ -168,8 +175,7 @@ public class CProjectSourceContainer extends CompositeSourceContainer {
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#getName()
*/
public String getName() {
- IProject project = getResolvedProject();
- return project != null ? project.getName() : InternalSourceLookupMessages.CProjectSourceContainer_0;
+ return fProject != null ? fProject.getName() : InternalSourceLookupMessages.CProjectSourceContainer_0;
}
/* (non-Javadoc)
@@ -198,11 +204,10 @@ public class CProjectSourceContainer extends CompositeSourceContainer {
* @see org.eclipse.debug.internal.core.sourcelookup.containers.CompositeSourceContainer#createSourceContainers()
*/
protected ISourceContainer[] createSourceContainers() throws CoreException {
- IProject project = getResolvedProject();
- if (project != null && project.isOpen()) {
+ if (fProject != null && fProject.isOpen()) {
if (isSearchReferencedProjects()) {
- IProject[] projects = SourceUtils.getAllReferencedProjects(project);
- ISourceContainer[] folders = createFolderSourceContainers(project);
+ IProject[] projects = SourceUtils.getAllReferencedProjects(fProject);
+ ISourceContainer[] folders = createFolderSourceContainers(fProject);
List<ISourceContainer> containers = new ArrayList<ISourceContainer>(folders.length + projects.length);
for (ISourceContainer folder : folders) {
containers.add(folder);
@@ -216,7 +221,7 @@ public class CProjectSourceContainer extends CompositeSourceContainer {
}
return containers.toArray(new ISourceContainer[containers.size()]);
}
- return createFolderSourceContainers(project);
+ return createFolderSourceContainers(fProject);
}
return new ISourceContainer[0];
}
@@ -242,29 +247,13 @@ public class CProjectSourceContainer extends CompositeSourceContainer {
* @param name path name
*/
private boolean validateFile(String name) {
- IProject project = getResolvedProject();
- if (project == null) {
+ if (fProject == null) {
return false;
}
- IPath path = project.getFullPath().append(name);
+ IPath path = fProject.getFullPath().append(name);
return ResourcesPlugin.getWorkspace().validatePath(path.toOSString(), IResource.FILE).isOK();
}
- private void initializeRootURI() {
- fInitializedRootURI = true;
- IProject project = getResolvedProject();
- if (project == null)
- return;
- fRootURI = project.getLocationURI();
- if (fRootURI == null)
- return;
- try {
- fRootFile = EFS.getStore(fRootURI);
- } catch (CoreException e) {
- }
- fRoot = ResourcesPlugin.getWorkspace().getRoot();
- }
-
/**
* Returns whether referenced projects are considered.
*
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceFoldersRelativePathSourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceFoldersRelativePathSourceContainer.java
index f8961cab5b..7b03ffade3 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceFoldersRelativePathSourceContainer.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceFoldersRelativePathSourceContainer.java
@@ -53,7 +53,8 @@ public class SourceFoldersRelativePathSourceContainer extends CompositeSourceCon
public static final String TYPE_ID =
CDebugCorePlugin.getUniqueIdentifier() + ".containerType.sourceFoldersRelativePath"; //$NON-NLS-1$
- private final IProject fProject;
+ private final IProject fOwnProject; // Project assigned to this container at construction time.
+ private IProject fProject;
private boolean fSearchReferencedProjects;
/**
@@ -64,10 +65,26 @@ public class SourceFoldersRelativePathSourceContainer extends CompositeSourceCon
* @param referenced whether referenced projects should be considered
*/
public SourceFoldersRelativePathSourceContainer(IProject project, boolean referenced) {
+ fOwnProject = project;
fProject = project;
fSearchReferencedProjects = referenced;
}
-
+
+ @Override
+ public void init(ISourceLookupDirector director) {
+ super.init(director);
+ if (director != null) {
+ fProject = SourceUtils.getLaunchConfigurationProject(director);
+ }
+ }
+
+ @Override
+ public void dispose() {
+ fProject = fOwnProject;
+ super.dispose();
+ }
+
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.sourcelookup.ISourceContainer#isComposite()
*/
@@ -88,10 +105,9 @@ public class SourceFoldersRelativePathSourceContainer extends CompositeSourceCon
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#getName()
*/
public String getName() {
- IProject project = getResolvedProject();
- return project == null ?
+ return fProject == null ?
InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainer_0 :
- NLS.bind(InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainer_1, project.getName());
+ NLS.bind(InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainer_1, fProject.getName());
}
/* (non-Javadoc)
@@ -123,10 +139,9 @@ public class SourceFoldersRelativePathSourceContainer extends CompositeSourceCon
* @see org.eclipse.cdt.debug.core.sourcelookup.IMappingSourceContainer#getCompilationPath(java.lang.String)
*/
public IPath getCompilationPath(String sourceName) {
- IProject project = getResolvedProject();
- if (project == null)
+ if (fProject == null)
return null;
- ICProject cProject = CModelManager.getDefault().create(project);
+ ICProject cProject = CModelManager.getDefault().create(fProject);
IPath path = new Path(sourceName);
for (IFile file : ResourceLookup.findFilesForLocation(path)) {
ISourceRoot root = cProject.findSourceRoot(file);
@@ -141,28 +156,12 @@ public class SourceFoldersRelativePathSourceContainer extends CompositeSourceCon
return fProject;
}
- /**
- * Returns the project associated with this source container either directly or through
- * the current launch configuration.
- * @return an IProject instance or {@code null}.
- */
- private IProject getResolvedProject() {
- if (fProject != null)
- return fProject;
- ISourceLookupDirector director = getDirector();
- if (director != null) {
- return SourceUtils.getLaunchConfigurationProject(director);
- }
- return null;
- }
-
@Override
protected ISourceContainer[] createSourceContainers() throws CoreException {
- IProject project = getResolvedProject();
- if (project != null && project.isOpen()) {
+ if (fProject != null && fProject.isOpen()) {
if (isSearchReferencedProjects()) {
- IProject[] projects = SourceUtils.getAllReferencedProjects(project);
- ISourceContainer[] folders = createCompilationDirectoryContainers(project);
+ IProject[] projects = SourceUtils.getAllReferencedProjects(fProject);
+ ISourceContainer[] folders = createCompilationDirectoryContainers(fProject);
List<ISourceContainer> containers = new ArrayList<ISourceContainer>(folders.length + projects.length);
for (ISourceContainer folder : folders) {
containers.add(folder);
@@ -177,7 +176,7 @@ public class SourceFoldersRelativePathSourceContainer extends CompositeSourceCon
}
return containers.toArray(new ISourceContainer[containers.size()]);
}
- return createCompilationDirectoryContainers(project);
+ return createCompilationDirectoryContainers(fProject);
}
return new ISourceContainer[0];
}

Back to the top