diff options
Diffstat (limited to 'debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourcePathComputerDelegate.java')
-rw-r--r-- | debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourcePathComputerDelegate.java | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourcePathComputerDelegate.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourcePathComputerDelegate.java index 8b16d5ddc47..6662f065389 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourcePathComputerDelegate.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourcePathComputerDelegate.java @@ -8,25 +8,17 @@ * Contributors: * QNX Software Systems - Initial API and implementation * Nokia - Added support for AbsoluteSourceContainer(159833) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.debug.internal.core.sourcelookup; -import java.util.ArrayList; -import java.util.List; - import org.eclipse.cdt.debug.core.CDebugCorePlugin; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.cdt.debug.core.sourcelookup.AbsolutePathSourceContainer; -import org.eclipse.cdt.debug.core.sourcelookup.ProgramRelativePathSourceContainer; -import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.sourcelookup.ISourceContainer; +import org.eclipse.debug.core.sourcelookup.ISourceContainerType; import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate; -import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer; /** * Computes the default source lookup path for a launch configuration. @@ -44,34 +36,16 @@ public class CSourcePathComputerDelegate implements ISourcePathComputerDelegate * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor) */ public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { - // First, get all the the containers in the global preferences (but add them last) ISourceContainer[] common = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().getSourceContainers(); - - List<ISourceContainer> containers = new ArrayList<ISourceContainer>(common.length + 3); + ISourceContainer[] containers = new ISourceContainer[common.length]; - // Add a container that fetches files that are specified with an absolute path - containers.add(new AbsolutePathSourceContainer()); - - // Add a container that fetches files that are specified with a program relative path - containers.add(new ProgramRelativePathSourceContainer()); - - // Add a container that looks in the project specified in the configuration - String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null); - if (projectName != null && projectName.length() > 0) { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - if (project.exists()) { - containers.add(new ProjectSourceContainer(project, true)); - } + for (int i = 0; i < common.length; i++) { + ISourceContainer container = common[i]; + ISourceContainerType type = container.getType(); + // Clone the container to make sure that the original can be safely disposed. + container = type.createSourceContainer(type.getMemento(container)); + containers[i] = container; } - - // Finally, add the common (global) containers - for (ISourceContainer sc : common) { - // If the container is a path-mapper, use a copy (why?) - if (sc.getType().getId().equals(MappingSourceContainer.TYPE_ID)) - sc = ((MappingSourceContainer) sc).copy(); - containers.add(sc); - } - - return containers.toArray(new ISourceContainer[containers.size()]); + return containers; } } |