mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Bug 225805 - Sourcelookup handling does not scale to large projects
This commit is contained in:
parent
49332004f6
commit
9aee6c4850
42 changed files with 1735 additions and 113 deletions
|
@ -29,7 +29,7 @@ import org.eclipse.core.runtime.IPath;
|
|||
* CDT has:
|
||||
* <ul>
|
||||
* <li>A global (common) source locator. Its containers are defined via Window > Preferences > C/C++ > Debug >
|
||||
* Common Source Lookup Path
|
||||
* Source Lookup Path
|
||||
* <li>Launch configuration source locators. The containers of such a locator are defined via the 'Source' tab
|
||||
* in a CDT launch configuration. The common source containers are automatically added to this locator.
|
||||
* <li>Launch source locators. Typically, a launch's locator is the one defined in the launch configuration
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# IBM Corporation
|
||||
# Texas Instruments - added extension point for source container type (279473)
|
||||
# Ericsson - Added support for Tracepoints (284286)
|
||||
# Sergey Prigogin (Google)
|
||||
###############################################################################
|
||||
pluginName=C/C++ Development Tools Debug Model
|
||||
providerName=Eclipse CDT
|
||||
|
@ -36,12 +37,18 @@ cAddressTracepoints.name=C/C++ Address Tracepoints
|
|||
cFunctionTracepoints.name=C/C++ Function Tracepoints
|
||||
breakpointProblem.name=C/C++ Breakpoint Problem
|
||||
|
||||
containerName.project=Project
|
||||
containerDescription.project=A project in the workspace.
|
||||
containerName.mapping=Path Mapping
|
||||
containerDescription.mapping=A path mapping.
|
||||
containerName.mapEntry=Path Map Entry
|
||||
containerDescription.mapEntry=An entry in a path mapping.
|
||||
containerName.directory=File System Directory
|
||||
containerDescription.directory=A directory in the local file system.
|
||||
containerName.compilationDirectory=Compilation Directory
|
||||
containerDescription.compilationDirectory=A directory in the local file system used for running the C/C++ compiler.
|
||||
containerName.sourceFoldersRelativePath=Project - Path Relative to Source Folders
|
||||
containerDescription.sourceFoldersRelativePath=A project where file system directories corresponding to source folders are used for running C/C++ compiler.
|
||||
containerName.absolutePath=Absolute File Path
|
||||
containerDescription.absolutePath=An absolute path to a file in the local file system.
|
||||
containerName.programRelativePath=Program Relative File Path
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.0"?>
|
||||
<plugin>
|
||||
|
||||
<extension-point id="CDebugger" name="%CDebugger.name" schema="schema/CDebugger.exsd"/>
|
||||
<extension-point id="BreakpointActionType" name="%BreakpointAction" schema="schema/BreakpointAction.exsd"/>
|
||||
<extension-point id="BreakpointExtension" name="%BreakpointAction" schema="schema/BreakpointExtension.exsd"/>
|
||||
|
@ -282,6 +281,11 @@
|
|||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.core.sourceContainerTypes">
|
||||
<sourceContainerType
|
||||
class="org.eclipse.cdt.debug.internal.core.sourcelookup.CProjectSourceContainerType"
|
||||
description="%containerDescription.project"
|
||||
id="org.eclipse.cdt.debug.core.containerType.project"
|
||||
name="%containerName.project"/>
|
||||
<sourceContainerType
|
||||
class="org.eclipse.cdt.debug.internal.core.sourcelookup.MappingSourceContainerType"
|
||||
description="%containerDescription.mapping"
|
||||
|
@ -297,6 +301,16 @@
|
|||
description="%containerDescription.directory"
|
||||
id="org.eclipse.cdt.debug.core.containerType.directory"
|
||||
name="%containerName.directory"/>
|
||||
<sourceContainerType
|
||||
class="org.eclipse.cdt.debug.internal.core.sourcelookup.CompilationDirectorySourceContainerType"
|
||||
description="%containerDescription.compilationDirectory"
|
||||
id="org.eclipse.cdt.debug.core.containerType.compilationDirectory"
|
||||
name="%containerName.compilationDirectory"/>
|
||||
<sourceContainerType
|
||||
class="org.eclipse.cdt.debug.internal.core.sourcelookup.SourceFoldersRelativePathSourceContainerType"
|
||||
description="%containerDescription.sourceFoldersRelativePath"
|
||||
id="org.eclipse.cdt.debug.core.containerType.sourceFoldersRelativePath"
|
||||
name="%containerName.sourceFoldersRelativePath"/>
|
||||
<sourceContainerType
|
||||
class="org.eclipse.cdt.debug.internal.core.sourcelookup.AbsolutePathSourceContainerType"
|
||||
description="%containerDescription.absolutePath"
|
||||
|
@ -341,14 +355,18 @@
|
|||
id="org.eclipse.cdt.debug.core.containerType.programRelativePath"/>
|
||||
<sourceContainer
|
||||
id="org.eclipse.cdt.debug.core.containerType.mapping"/>
|
||||
<sourceContainer
|
||||
id="org.eclipse.cdt.debug.core.containerType.compilationDirectory"/>
|
||||
<sourceContainer
|
||||
id="org.eclipse.cdt.debug.core.containerType.project"/>
|
||||
<sourceContainer
|
||||
id="org.eclipse.cdt.debug.core.containerType.sourceFoldersRelativePath"/>
|
||||
<sourceContainer
|
||||
id="org.eclipse.debug.core.containerType.folder"/>
|
||||
<sourceContainer
|
||||
id="org.eclipse.debug.core.containerType.workspace"/>
|
||||
<sourceContainer
|
||||
id="org.eclipse.debug.core.containerType.directory"/>
|
||||
<sourceContainer
|
||||
id="org.eclipse.debug.core.containerType.project"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.runtime.adapters">
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Ken Ryall (Nokia) - Support for breakpoint actions (bug 118308)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.core;
|
||||
|
||||
|
@ -21,7 +22,10 @@ import org.eclipse.cdt.debug.core.breakpointactions.BreakpointActionManager;
|
|||
import org.eclipse.cdt.debug.core.command.CCommandAdapterFactory;
|
||||
import org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService;
|
||||
import org.eclipse.cdt.debug.core.model.IRestart;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.AbsolutePathSourceContainer;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.CProjectSourceContainer;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.ProgramRelativePathSourceContainer;
|
||||
import org.eclipse.cdt.debug.internal.core.DebugConfiguration;
|
||||
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
|
||||
import org.eclipse.cdt.debug.internal.core.ListenerList;
|
||||
|
@ -45,6 +49,7 @@ import org.eclipse.debug.core.DebugPlugin;
|
|||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.debug.core.ILaunchDelegate;
|
||||
import org.eclipse.debug.core.ILaunchManager;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
|
@ -364,7 +369,12 @@ public class CDebugCorePlugin extends Plugin {
|
|||
private void initializeCommonSourceLookupDirector() {
|
||||
if (fCommonSourceLookupDirector == null) {
|
||||
fCommonSourceLookupDirector = new CommonSourceLookupDirector();
|
||||
String newMemento = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugInternalConstants.PREF_COMMON_SOURCE_CONTAINERS);
|
||||
boolean convertingFromLegacyFormat = false;
|
||||
String newMemento = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugInternalConstants.PREF_DEFAULT_SOURCE_CONTAINERS);
|
||||
if (newMemento.length() == 0) {
|
||||
newMemento = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugInternalConstants.PREF_COMMON_SOURCE_CONTAINERS);
|
||||
convertingFromLegacyFormat = true;
|
||||
}
|
||||
if (newMemento.length() == 0) {
|
||||
// Add the participant(s). This happens as part of
|
||||
// initializeFromMemento(), but since we're not calling it, we
|
||||
|
@ -380,6 +390,17 @@ public class CDebugCorePlugin extends Plugin {
|
|||
log(e.getStatus());
|
||||
}
|
||||
}
|
||||
if (convertingFromLegacyFormat) {
|
||||
// Add three source containers that used to be present implicitly.
|
||||
ISourceContainer[] oldContainers = fCommonSourceLookupDirector.getSourceContainers();
|
||||
ISourceContainer[] containers = new ISourceContainer[oldContainers.length + 3];
|
||||
int i = 0;
|
||||
containers[i++] = new AbsolutePathSourceContainer();
|
||||
containers[i++] = new ProgramRelativePathSourceContainer();
|
||||
containers[i++] = new CProjectSourceContainer(null, true);
|
||||
System.arraycopy(oldContainers, 0, containers, i, oldContainers.length);
|
||||
fCommonSourceLookupDirector.setSourceContainers(containers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,277 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* QNX Software Systems - Mikhail Khodjaiants - Bug 80857
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.core.sourcelookup;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.InternalSourceLookupMessages;
|
||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.SourceUtils;
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.CompositeSourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer;
|
||||
|
||||
/**
|
||||
* A project in the workspace. Source is searched for in the root project
|
||||
* folder and all folders within the project recursively. Optionally,
|
||||
* referenced projects may be searched as well.
|
||||
*
|
||||
* Source elements returned from <code>findSourceElements(...)</code> are instances of
|
||||
* <code>IFile</code>.
|
||||
* <p>
|
||||
* Clients may instantiate this class.
|
||||
* </p>
|
||||
* @since 7.1
|
||||
* @noextend This class is not intended to be subclassed by clients.
|
||||
*/
|
||||
public class CProjectSourceContainer extends CompositeSourceContainer {
|
||||
/**
|
||||
* Unique identifier for the project source container type
|
||||
* (value <code>org.eclipse.cdt.debug.core.containerType.project</code>).
|
||||
*/
|
||||
public static final String TYPE_ID =
|
||||
CDebugCorePlugin.getUniqueIdentifier() + ".containerType.project"; //$NON-NLS-1$
|
||||
private IProject fProject;
|
||||
private boolean fSearchReferencedProjects;
|
||||
private URI fRootURI;
|
||||
private boolean fInitializedRootURI;
|
||||
private IFileStore fRootFile;
|
||||
private IWorkspaceRoot fRoot;
|
||||
|
||||
/**
|
||||
* Constructs a project source container.
|
||||
*
|
||||
* @param project the project to search for source in
|
||||
* @param referenced whether referenced projects should be considered
|
||||
*/
|
||||
public CProjectSourceContainer(IProject project, boolean referenced) {
|
||||
fProject = project;
|
||||
fSearchReferencedProjects = referenced;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the project this source container references.
|
||||
*
|
||||
* @return the project this source container references
|
||||
*/
|
||||
public IProject getProject() {
|
||||
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;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#findSourceElements(java.lang.String)
|
||||
*/
|
||||
public Object[] findSourceElements(String name) throws CoreException {
|
||||
ArrayList<Object> sources = new ArrayList<Object>();
|
||||
|
||||
// An IllegalArgumentException is thrown from the "getFile" method
|
||||
// if the path created by appending the file name to the container
|
||||
// path doesn't conform with Eclipse resource restrictions.
|
||||
// To prevent the interruption of the search procedure we check
|
||||
// if the path is valid before passing it to "getFile".
|
||||
if (validateFile(name)) {
|
||||
IFile file = fProject.getFile(new Path(name));
|
||||
if (file.exists()) {
|
||||
sources.add(file);
|
||||
} else {
|
||||
if (!fInitializedRootURI) {
|
||||
initializeRootURI();
|
||||
}
|
||||
// See bug 82627 - perform case insensitive source lookup
|
||||
if (fRootURI == null) {
|
||||
return EMPTY;
|
||||
}
|
||||
// See bug 98090 - we need to handle relative path names
|
||||
IFileStore target = fRootFile.getFileStore(new Path(name));
|
||||
if (target.fetchInfo().exists()) {
|
||||
// We no longer have to account for bug 95832, and URIs take care
|
||||
// of canonical paths (fix to bug 95679 was removed).
|
||||
IFile[] files = fRoot.findFilesForLocationURI(target.toURI());
|
||||
if (isFindDuplicates() && files.length > 1) {
|
||||
for (IFile f : files) {
|
||||
sources.add(f);
|
||||
}
|
||||
} else if (files.length > 0) {
|
||||
sources.add(files[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check sub-folders
|
||||
if ((isFindDuplicates() && true) || (sources.isEmpty() && true)) {
|
||||
ISourceContainer[] containers = getSourceContainers();
|
||||
for (int i = 0; i < containers.length; i++) {
|
||||
Object[] objects = containers[i].findSourceElements(name);
|
||||
if (objects == null || objects.length == 0) {
|
||||
continue;
|
||||
}
|
||||
if (isFindDuplicates()) {
|
||||
for (Object object : objects)
|
||||
sources.add(object);
|
||||
} else {
|
||||
sources.add(objects[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sources.isEmpty())
|
||||
return EMPTY;
|
||||
return sources.toArray();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
IProject project = getResolvedProject();
|
||||
return project != null ? project.getName() : InternalSourceLookupMessages.CProjectSourceContainer_0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj != null && obj instanceof CProjectSourceContainer) {
|
||||
CProjectSourceContainer loc = (CProjectSourceContainer) obj;
|
||||
return fProject == null ? loc.fProject == null : fProject.equals(loc.fProject);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public int hashCode() {
|
||||
return TYPE_ID.hashCode() * 31 + (fProject == null ? 0 : fProject.hashCode());
|
||||
}
|
||||
|
||||
public boolean isComposite() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.core.sourcelookup.containers.CompositeSourceContainer#createSourceContainers()
|
||||
*/
|
||||
protected ISourceContainer[] createSourceContainers() throws CoreException {
|
||||
IProject project = getResolvedProject();
|
||||
if (project != null && project.isOpen()) {
|
||||
if (isSearchReferencedProjects()) {
|
||||
IProject[] projects = SourceUtils.getAllReferencedProjects(project);
|
||||
ISourceContainer[] folders = createFolderSourceContainers(project);
|
||||
List<ISourceContainer> containers = new ArrayList<ISourceContainer>(folders.length + projects.length);
|
||||
for (ISourceContainer folder : folders) {
|
||||
containers.add(folder);
|
||||
}
|
||||
for (IProject ref : projects) {
|
||||
if (ref.exists() && ref.isOpen()) {
|
||||
CProjectSourceContainer container = new CProjectSourceContainer(ref, false);
|
||||
container.init(getDirector());
|
||||
containers.add(container);
|
||||
}
|
||||
}
|
||||
return containers.toArray(new ISourceContainer[containers.size()]);
|
||||
}
|
||||
return createFolderSourceContainers(project);
|
||||
}
|
||||
return new ISourceContainer[0];
|
||||
}
|
||||
|
||||
private ISourceContainer[] createFolderSourceContainers(IProject project) throws CoreException {
|
||||
IResource[] resources = project.members();
|
||||
List<FolderSourceContainer> list = new ArrayList<FolderSourceContainer>(resources.length);
|
||||
for (IResource resource : resources) {
|
||||
if (resource.getType() == IResource.FOLDER) {
|
||||
list.add(new FolderSourceContainer((IFolder) resource, true));
|
||||
}
|
||||
}
|
||||
ISourceContainer[] containers = list.toArray(new ISourceContainer[list.size()]);
|
||||
for (ISourceContainer container : containers) {
|
||||
container.init(getDirector());
|
||||
}
|
||||
return containers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the given string as a path for a file in this container.
|
||||
*
|
||||
* @param name path name
|
||||
*/
|
||||
private boolean validateFile(String name) {
|
||||
IProject project = getResolvedProject();
|
||||
if (project == null) {
|
||||
return false;
|
||||
}
|
||||
IPath path = project.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.
|
||||
*
|
||||
* @return whether referenced projects are considered
|
||||
*/
|
||||
public boolean isSearchReferencedProjects() {
|
||||
return fSearchReferencedProjects;
|
||||
}
|
||||
|
||||
public ISourceContainerType getType() {
|
||||
return getSourceContainerType(TYPE_ID);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.core.sourcelookup;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
|
||||
/**
|
||||
* A source container that maps some filesystem locations to other filesystem locations.
|
||||
* @since 7.1
|
||||
*/
|
||||
public interface IMappingSourceContainer extends ISourceContainer {
|
||||
|
||||
/**
|
||||
* Returns path to the file as it appears in the debug information generated by the C/C++
|
||||
* compiler.
|
||||
* @param sourceName absolute filesystem path to a source or header file.
|
||||
* @return path to the file as it appears in the debug information generated by the compiler.
|
||||
*/
|
||||
public IPath getCompilationPath(String sourceName);
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.core.sourcelookup;
|
||||
|
||||
|
@ -30,7 +31,7 @@ import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainer;
|
|||
/**
|
||||
* The source container for path mappings.
|
||||
*/
|
||||
public class MappingSourceContainer extends AbstractSourceContainer {
|
||||
public class MappingSourceContainer extends AbstractSourceContainer implements IMappingSourceContainer {
|
||||
/**
|
||||
* Unique identifier for the mapping source container type
|
||||
* (value <code>org.eclipse.cdt.debug.core.containerType.mapping</code>).
|
||||
|
@ -180,6 +181,9 @@ public class MappingSourceContainer extends AbstractSourceContainer {
|
|||
fName = name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see IMappingSourceContainer#getCompilationPath(String)
|
||||
*/
|
||||
public IPath getCompilationPath(String sourceName) {
|
||||
IPath path = new Path(sourceName);
|
||||
IPath result = null;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2005 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2010 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core;
|
||||
|
||||
|
@ -26,9 +27,16 @@ public class ICDebugInternalConstants {
|
|||
|
||||
/**
|
||||
* String preference for the common source containers.
|
||||
* This preference is superseded by PREF_DEFAULT_SOURCE_CONTAINERS. Kept for backward
|
||||
* compatibility only.
|
||||
*/
|
||||
public static final String PREF_COMMON_SOURCE_CONTAINERS = CDebugCorePlugin.getUniqueIdentifier() + ".cDebug.common_source_containers"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* String preference for the default source containers.
|
||||
*/
|
||||
public static final String PREF_DEFAULT_SOURCE_CONTAINERS = CDebugCorePlugin.getUniqueIdentifier() + ".cDebug.default_source_containers"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Boolean preference indicating the on/off state of the Show Full Paths
|
||||
* toggle action. Actually, as the action appears in multiple views, and the
|
||||
|
|
|
@ -85,6 +85,7 @@ import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
|
|||
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
|
||||
import org.eclipse.cdt.debug.core.model.IPersistableRegisterGroup;
|
||||
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.CProjectSourceContainer;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.ISourceLookupChangeListener;
|
||||
import org.eclipse.cdt.debug.internal.core.CBreakpointManager;
|
||||
|
@ -1830,7 +1831,11 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
for (ISourceContainer container : containers) {
|
||||
String pathToAdd = null;
|
||||
|
||||
if (container instanceof ProjectSourceContainer) {
|
||||
if (container instanceof CProjectSourceContainer) {
|
||||
IProject project = ((CProjectSourceContainer) container).getProject();
|
||||
if (project != null && project.exists())
|
||||
pathToAdd = project.getLocation().toPortableString();
|
||||
} else if (container instanceof ProjectSourceContainer) { // For backward compatibility
|
||||
IProject project = ((ProjectSourceContainer) container).getProject();
|
||||
if (project != null && project.exists())
|
||||
pathToAdd = project.getLocation().toPortableString();
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.CProjectSourceContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTypeDelegate;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* The type for creating/restoring a project source container.
|
||||
*/
|
||||
public class CProjectSourceContainerType extends AbstractSourceContainerTypeDelegate {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer)
|
||||
*/
|
||||
public String getMemento(ISourceContainer container) throws CoreException {
|
||||
CProjectSourceContainer sourceContainer = (CProjectSourceContainer) container;
|
||||
Document document = newDocument();
|
||||
Element element = document.createElement("project"); //$NON-NLS-1$
|
||||
IProject project = sourceContainer.getProject();
|
||||
if (project != null) {
|
||||
element.setAttribute("name", project.getName()); //$NON-NLS-1$
|
||||
}
|
||||
element.setAttribute("referencedProjects", String.valueOf(sourceContainer.isSearchReferencedProjects())); //$NON-NLS-1$
|
||||
document.appendChild(element);
|
||||
return serializeDocument(document);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#createSourceContainer(java.lang.String)
|
||||
*/
|
||||
public ISourceContainer createSourceContainer(String memento) throws CoreException {
|
||||
Node node = parseDocument(memento);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element element = (Element)node;
|
||||
if ("project".equals(element.getNodeName())) { //$NON-NLS-1$
|
||||
String string = element.getAttribute("name"); //$NON-NLS-1$
|
||||
IProject project = null;
|
||||
if (string != null && string.length() > 0) {
|
||||
project = ResourcesPlugin.getWorkspace().getRoot().getProject(string);
|
||||
}
|
||||
String nest = element.getAttribute("referencedProjects"); //$NON-NLS-1$
|
||||
boolean ref = "true".equals(nest); //$NON-NLS-1$
|
||||
return new CProjectSourceContainer(project, ref);
|
||||
}
|
||||
abort(InternalSourceLookupMessages.CProjectSourceContainerType_1, null);
|
||||
}
|
||||
abort(InternalSourceLookupMessages.CProjectSourceContainerType_2, null);
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
* QNX Software Systems - Initial API and implementation
|
||||
* Nokia - Added support for AbsoluteSourceContainer(159833)
|
||||
* Texas Instruments - added extension point for source container type (279473)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||
|
||||
|
@ -19,8 +20,9 @@ import java.util.Set;
|
|||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.AbsolutePathSourceContainer;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.CProjectSourceContainer;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.IMappingSourceContainer;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.ProgramRelativePathSourceContainer;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -58,7 +60,7 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
|
|||
* @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#initializeParticipants()
|
||||
*/
|
||||
public void initializeParticipants() {
|
||||
addParticipants(new ISourceLookupParticipant[]{ new CSourceLookupParticipant() });
|
||||
addParticipants(new ISourceLookupParticipant[] { new CSourceLookupParticipant() });
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -98,7 +100,10 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
|
|||
}
|
||||
|
||||
private boolean contains(ISourceContainer container, IProject project) {
|
||||
if (container instanceof ProjectSourceContainer && ((ProjectSourceContainer) container).getProject().equals(project)) {
|
||||
if (container instanceof CProjectSourceContainer && project.equals(((CProjectSourceContainer) container).getProject())) {
|
||||
return true;
|
||||
}
|
||||
if (container instanceof ProjectSourceContainer && project.equals(((CProjectSourceContainer) container).getProject())) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
|
@ -115,7 +120,19 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
|
|||
IPath path = new Path(sourceName);
|
||||
if (!path.isValidPath(sourceName))
|
||||
return false;
|
||||
if (container instanceof ProjectSourceContainer) {
|
||||
if (container instanceof IMappingSourceContainer) {
|
||||
return ((IMappingSourceContainer) container).getCompilationPath(sourceName) != null;
|
||||
}
|
||||
if (container instanceof CProjectSourceContainer) {
|
||||
IProject project = ((CProjectSourceContainer) container).getProject();
|
||||
if (project != null) {
|
||||
IPath projPath = project.getLocation();
|
||||
if (projPath != null && projPath.isPrefixOf(path)) {
|
||||
IFile file = ((CProjectSourceContainer) container).getProject().getFile(path.removeFirstSegments(projPath.segmentCount()));
|
||||
return file != null && file.exists();
|
||||
}
|
||||
}
|
||||
} else if (container instanceof ProjectSourceContainer) {
|
||||
IProject project = ((ProjectSourceContainer) container).getProject();
|
||||
IPath projPath = project.getLocation();
|
||||
if (projPath != null && projPath.isPrefixOf(path)) {
|
||||
|
@ -135,11 +152,7 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
|
|||
IPath dirPath = new Path(dir.getAbsolutePath());
|
||||
if (searchSubfolders || dirPath.segmentCount() + 1 == path.segmentCount())
|
||||
return dirPath.isPrefixOf(path);
|
||||
}
|
||||
if (container instanceof MappingSourceContainer) {
|
||||
return (((MappingSourceContainer) container).getCompilationPath(sourceName) != null);
|
||||
}
|
||||
if (container instanceof AbsolutePathSourceContainer) {
|
||||
} else if (container instanceof AbsolutePathSourceContainer) {
|
||||
return ((AbsolutePathSourceContainer) container).isValidAbsoluteFilePath(sourceName);
|
||||
} else if (container instanceof ProgramRelativePathSourceContainer) {
|
||||
try {
|
||||
|
@ -160,8 +173,8 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
|
|||
}
|
||||
|
||||
public IPath getCompilationPath(String sourceName) {
|
||||
for (ISourceContainer cont : getSourceContainers()) {
|
||||
IPath path = getCompilationPath(cont, sourceName);
|
||||
for (ISourceContainer container : getSourceContainers()) {
|
||||
IPath path = SourceUtils.getCompilationPath(container, sourceName);
|
||||
if (path != null) {
|
||||
return path;
|
||||
}
|
||||
|
@ -169,22 +182,6 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
|
|||
return null;
|
||||
}
|
||||
|
||||
private IPath getCompilationPath(ISourceContainer container, String sourceName) {
|
||||
if (container instanceof MappingSourceContainer) {
|
||||
return ((MappingSourceContainer) container).getCompilationPath(sourceName);
|
||||
}
|
||||
|
||||
try {
|
||||
for (ISourceContainer cont : container.getSourceContainers()) {
|
||||
IPath path = getCompilationPath(cont, sourceName);
|
||||
if (path != null)
|
||||
return path;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// >> Bugzilla 279473
|
||||
private void readSupportedContainerTypes() {
|
||||
synchronized (fSupportedTypesLock) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2010 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||
|
||||
|
@ -26,7 +27,8 @@ public class CommonSourceLookupDirector extends CSourceLookupDirector {
|
|||
public void setSourceContainers(ISourceContainer[] containers) {
|
||||
try {
|
||||
super.setSourceContainers(containers);
|
||||
CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugInternalConstants.PREF_COMMON_SOURCE_CONTAINERS, getMemento());
|
||||
CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugInternalConstants.PREF_DEFAULT_SOURCE_CONTAINERS, getMemento());
|
||||
CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugInternalConstants.PREF_COMMON_SOURCE_CONTAINERS, ""); //$NON-NLS-1$
|
||||
CDebugCorePlugin.getDefault().savePluginPreferences();
|
||||
} catch (CoreException e) {
|
||||
CDebugCorePlugin.log(e.getStatus());
|
||||
|
|
|
@ -0,0 +1,204 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.IMappingSourceContainer;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.CompositeSourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
|
||||
|
||||
/**
|
||||
* A directory in the local file system that is used for running the C/C++ compiler. This container
|
||||
* is intended to be used when debugging information produced by the C/C++ compiler contains paths
|
||||
* to the source and header files relative to the directory where the compiler is run from.
|
||||
* The assumption is that all files under a compilation directory are compiled relative to
|
||||
* that directory, unless they belong to another compilation directory container that is higher on
|
||||
* the source container list.
|
||||
*
|
||||
* Source elements returned from <code>findSourceElements(...)</code> are instances of
|
||||
* <code>LocalFileStorage</code>.
|
||||
* <p>
|
||||
* Clients may instantiate this class.
|
||||
* </p>
|
||||
* @noextend This class is not intended to be subclassed by clients.
|
||||
*/
|
||||
public class CompilationDirectorySourceContainer extends CompositeSourceContainer implements IMappingSourceContainer {
|
||||
/**
|
||||
* Unique identifier for the compilation directory source container type
|
||||
* (value <code>org.eclipse.debug.core.containerType.compilationDirectory</code>).
|
||||
*/
|
||||
public static final String TYPE_ID =
|
||||
CDebugCorePlugin.getUniqueIdentifier() + ".containerType.compilationDirectory"; //$NON-NLS-1$
|
||||
|
||||
// Root directory.
|
||||
private File fDirectory;
|
||||
// Whether to each subdirectory of the compilation directory is also the compilation directory
|
||||
// for the files it contains.
|
||||
private boolean fSubfolders;
|
||||
|
||||
/**
|
||||
* Constructs an external folder container for the
|
||||
* directory identified by the given path.
|
||||
*
|
||||
* @param dirPath path to a directory in the local file system
|
||||
* @param subfolders whether folders within the root directory
|
||||
* should be searched for source elements
|
||||
*/
|
||||
public CompilationDirectorySourceContainer(IPath dirPath, boolean subfolders) {
|
||||
this(dirPath.toFile(), subfolders);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an external folder container for the
|
||||
* directory identified by the given file.
|
||||
*
|
||||
* @param dir a directory in the local file system
|
||||
* @param subfolders whether folders within the root directory
|
||||
* should be searched for source elements
|
||||
*/
|
||||
public CompilationDirectorySourceContainer(File dir, boolean subfolders) {
|
||||
fDirectory = dir;
|
||||
fSubfolders = subfolders;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return fDirectory.getAbsolutePath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the root directory in the local file system associated
|
||||
* with this source container.
|
||||
*
|
||||
* @return the root directory in the local file system associated
|
||||
* with this source container
|
||||
*/
|
||||
public File getDirectory() {
|
||||
return fDirectory;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType()
|
||||
*/
|
||||
public ISourceContainerType getType() {
|
||||
return getSourceContainerType(TYPE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Source elements returned from this method are instances of <code>LocalFileStorage</code>.
|
||||
* @see org.eclipse.debug.core.sourcelookup.ISourceContainer#findSourceElements(String)
|
||||
*/
|
||||
public Object[] findSourceElements(String name) throws CoreException {
|
||||
ArrayList<Object> sources = new ArrayList<Object>();
|
||||
File directory = getDirectory();
|
||||
File file = new File(directory, name);
|
||||
if (file.exists() && file.isFile()) {
|
||||
sources.add(new LocalFileStorage(file));
|
||||
}
|
||||
|
||||
// Check sub-folders
|
||||
if ((isFindDuplicates() && fSubfolders) || (sources.isEmpty() && fSubfolders)) {
|
||||
ISourceContainer[] containers = getSourceContainers();
|
||||
for (int i = 0; i < containers.length; i++) {
|
||||
Object[] objects = containers[i].findSourceElements(name);
|
||||
if (objects == null || objects.length == 0) {
|
||||
continue;
|
||||
}
|
||||
if (isFindDuplicates()) {
|
||||
for (int j = 0; j < objects.length; j++)
|
||||
sources.add(objects[j]);
|
||||
} else {
|
||||
sources.add(objects[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sources.isEmpty())
|
||||
return EMPTY;
|
||||
return sources.toArray();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.sourcelookup.ISourceContainer#isComposite()
|
||||
*/
|
||||
public boolean isComposite() {
|
||||
return fSubfolders;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof CompilationDirectorySourceContainer) {
|
||||
CompilationDirectorySourceContainer container = (CompilationDirectorySourceContainer) obj;
|
||||
return container.getDirectory().equals(getDirectory());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public int hashCode() {
|
||||
return getDirectory().hashCode();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.sourcelookup.containers.CompositeSourceContainer#createSourceContainers()
|
||||
*/
|
||||
protected ISourceContainer[] createSourceContainers() throws CoreException {
|
||||
if (fSubfolders) {
|
||||
String[] files = fDirectory.list();
|
||||
if (files != null) {
|
||||
List<ISourceContainer> dirs = new ArrayList<ISourceContainer>();
|
||||
for (String name : files) {
|
||||
File file = new File(getDirectory(), name);
|
||||
if (file.exists() && file.isDirectory()) {
|
||||
dirs.add(new CompilationDirectorySourceContainer(file, true));
|
||||
}
|
||||
}
|
||||
ISourceContainer[] containers = dirs.toArray(new ISourceContainer[dirs.size()]);
|
||||
for (ISourceContainer container : containers) {
|
||||
container.init(getDirector());
|
||||
}
|
||||
return containers;
|
||||
}
|
||||
}
|
||||
return new ISourceContainer[0];
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.sourcelookup.IMappingSourceContainer#getCompilationPath(java.lang.String)
|
||||
*/
|
||||
public IPath getCompilationPath(String sourceName) {
|
||||
IPath path = new Path(sourceName);
|
||||
IPath base = new Path(fDirectory.getPath());
|
||||
if (base.isPrefixOf(path)) {
|
||||
if (fSubfolders) {
|
||||
base = path.removeLastSegments(1);
|
||||
}
|
||||
return path.makeRelativeTo(base);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTypeDelegate;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* See <code>CompilationDirectorySourceContainer</code>.
|
||||
*/
|
||||
public class CompilationDirectorySourceContainerType extends AbstractSourceContainerTypeDelegate {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer)
|
||||
*/
|
||||
public String getMemento(ISourceContainer container) throws CoreException {
|
||||
CompilationDirectorySourceContainer folder = (CompilationDirectorySourceContainer) container;
|
||||
Document document = newDocument();
|
||||
Element element = document.createElement("directory"); //$NON-NLS-1$
|
||||
element.setAttribute("path", folder.getDirectory().getAbsolutePath()); //$NON-NLS-1$
|
||||
String nest = "false"; //$NON-NLS-1$
|
||||
if (folder.isComposite()) {
|
||||
nest = "true"; //$NON-NLS-1$
|
||||
}
|
||||
element.setAttribute("nest", nest); //$NON-NLS-1$
|
||||
document.appendChild(element);
|
||||
return serializeDocument(document);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#createSourceContainer(java.lang.String)
|
||||
*/
|
||||
public ISourceContainer createSourceContainer(String memento) throws CoreException {
|
||||
Node node = parseDocument(memento);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element element = (Element) node;
|
||||
if ("directory".equals(element.getNodeName())) { //$NON-NLS-1$
|
||||
String string = element.getAttribute("path"); //$NON-NLS-1$
|
||||
if (string == null || string.length() == 0) {
|
||||
abort(InternalSourceLookupMessages.CompilationDirectorySourceContainerType_0, null);
|
||||
}
|
||||
String nest = element.getAttribute("nest"); //$NON-NLS-1$
|
||||
boolean nested = "true".equals(nest); //$NON-NLS-1$
|
||||
return new CompilationDirectorySourceContainer(new Path(string), nested);
|
||||
}
|
||||
abort(InternalSourceLookupMessages.CompilationDirectorySourceContainerType_1, null);
|
||||
}
|
||||
abort(InternalSourceLookupMessages.CompilationDirectorySourceContainerType_2, null);
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2010 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -21,6 +21,12 @@ public class InternalSourceLookupMessages extends NLS {
|
|||
public static String CDirectorySourceContainerType_0;
|
||||
public static String CDirectorySourceContainerType_1;
|
||||
public static String CDirectorySourceContainerType_2;
|
||||
public static String CompilationDirectorySourceContainerType_0;
|
||||
public static String CompilationDirectorySourceContainerType_1;
|
||||
public static String CompilationDirectorySourceContainerType_2;
|
||||
public static String CProjectSourceContainer_0;
|
||||
public static String CProjectSourceContainerType_1;
|
||||
public static String CProjectSourceContainerType_2;
|
||||
public static String CProjectSourceLocation_0;
|
||||
public static String CProjectSourceLocation_1;
|
||||
public static String CProjectSourceLocation_2;
|
||||
|
@ -35,8 +41,12 @@ public class InternalSourceLookupMessages extends NLS {
|
|||
public static String MappingSourceContainerType_0;
|
||||
public static String MappingSourceContainerType_1;
|
||||
public static String MappingSourceContainerType_2;
|
||||
public static String SourceUtils_0;
|
||||
public static String ProgramRelativePathSourceContainerType_1;
|
||||
public static String SourceFoldersRelativePathSourceContainer_0;
|
||||
public static String SourceFoldersRelativePathSourceContainer_1;
|
||||
public static String SourceFoldersRelativePathSourceContainerType_1;
|
||||
public static String SourceFoldersRelativePathSourceContainerType_2;
|
||||
public static String SourceUtils_0;
|
||||
|
||||
static {
|
||||
NLS.initializeMessages(InternalSourceLookupMessages.class.getName(), InternalSourceLookupMessages.class);
|
||||
|
|
|
@ -17,6 +17,12 @@ CDirectorySourceLocation_3=Exception occurred initializing source location.
|
|||
CDirectorySourceContainerType_0=Unable to restore directory source lookup entry - missing path attribute.
|
||||
CDirectorySourceContainerType_1=Unable to restore directory source lookup entry - expecting directory element.
|
||||
CDirectorySourceContainerType_2=Unable to restore directory source lookup entry - invalid memento.
|
||||
CompilationDirectorySourceContainerType_0=Unable to restore compilation directory source lookup entry - missing path attribute.
|
||||
CompilationDirectorySourceContainerType_1=Unable to restore compilation directory source lookup entry - expecting directory element.
|
||||
CompilationDirectorySourceContainerType_2=Unable to restore compilation directory source lookup entry - invalid memento.
|
||||
CProjectSourceContainer_0=Project
|
||||
CProjectSourceContainerType_1=Unable to restore project source lookup entry - expecting project element.
|
||||
CProjectSourceContainerType_2=Unable to restore project source lookup entry - invalid memento.
|
||||
CProjectSourceLocation_0=Unable to create memento for C/C++ project source location {0}.
|
||||
CProjectSourceLocation_1=Unable to initialize source location - missing project name
|
||||
CProjectSourceLocation_2=Exception occurred initializing source location.
|
||||
|
@ -31,5 +37,9 @@ MapEntrySourceContainerType_3=Source lookup: unable to restore map entry - inval
|
|||
MappingSourceContainerType_0=Source lookup: unable to restore map entry - expecting memento attribute.
|
||||
MappingSourceContainerType_1=Source lookup: unable to restore mapping - expecting mapping element.
|
||||
MappingSourceContainerType_2=Source lookup: unable to restore mapping - invalid memento.
|
||||
SourceUtils_0=Mapping
|
||||
ProgramRelativePathSourceContainerType_1=Source lookup: unable to restore program relative source container - invalid memento.
|
||||
SourceFoldersRelativePathSourceContainer_0=Project - Path Relative to Source Folders.
|
||||
SourceFoldersRelativePathSourceContainer_1={0} - Path Relative to Source Folders.
|
||||
SourceFoldersRelativePathSourceContainerType_1=Unable to restore source folders relative path source lookup entry - expecting project element.
|
||||
SourceFoldersRelativePathSourceContainerType_2=Unable to restore source folders relative path source lookup entry - invalid memento.
|
||||
SourceUtils_0=Mapping
|
||||
|
|
|
@ -0,0 +1,208 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.IMappingSourceContainer;
|
||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.CompositeSourceContainer;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
/**
|
||||
* A project where source folders are used for running the C/C++ compiler. This container
|
||||
* is intended to be used when debugging information produced by the C/C++ compiler contains paths
|
||||
* to the source and header files relative to the directory where the compiler is run from.
|
||||
* The assumption is that all files under a source folder are compiled relative to that folder.
|
||||
*
|
||||
* Source elements returned from <code>findSourceElements(...)</code> are instances of
|
||||
* <code>LocalFileStorage</code>.
|
||||
* <p>
|
||||
* Clients may instantiate this class.
|
||||
* </p>
|
||||
* @noextend This class is not intended to be subclassed by clients.
|
||||
*/
|
||||
public class SourceFoldersRelativePathSourceContainer extends CompositeSourceContainer
|
||||
implements IMappingSourceContainer {
|
||||
/**
|
||||
* Unique identifier for the container type
|
||||
* (value <code>org.eclipse.cdt.debug.core.containerType.sourceFoldersRelativePath</code>).
|
||||
*/
|
||||
public static final String TYPE_ID =
|
||||
CDebugCorePlugin.getUniqueIdentifier() + ".containerType.sourceFoldersRelativePath"; //$NON-NLS-1$
|
||||
|
||||
private final IProject fProject;
|
||||
private boolean fSearchReferencedProjects;
|
||||
|
||||
/**
|
||||
* Constructs a source folder relative path source container.
|
||||
*
|
||||
* @param project the project to search for source in. A {@code null} project indicates
|
||||
* the the project from the launch configuration should be used.
|
||||
* @param referenced whether referenced projects should be considered
|
||||
*/
|
||||
public SourceFoldersRelativePathSourceContainer(IProject project, boolean referenced) {
|
||||
fProject = project;
|
||||
fSearchReferencedProjects = referenced;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.sourcelookup.ISourceContainer#isComposite()
|
||||
*/
|
||||
public boolean isComposite() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether referenced projects are considered.
|
||||
*
|
||||
* @return whether referenced projects are considered
|
||||
*/
|
||||
public boolean isSearchReferencedProjects() {
|
||||
return fSearchReferencedProjects;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
IProject project = getResolvedProject();
|
||||
return project == null ?
|
||||
InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainer_0 :
|
||||
NLS.bind(InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainer_1, project.getName());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType()
|
||||
*/
|
||||
public ISourceContainerType getType() {
|
||||
return getSourceContainerType(TYPE_ID);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj != null && obj instanceof SourceFoldersRelativePathSourceContainer) {
|
||||
SourceFoldersRelativePathSourceContainer loc = (SourceFoldersRelativePathSourceContainer) obj;
|
||||
return fProject == null ? loc.fProject == null : fProject.equals(loc.fProject);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public int hashCode() {
|
||||
return TYPE_ID.hashCode() * 31 + (fProject == null ? 0 : fProject.hashCode());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.sourcelookup.IMappingSourceContainer#getCompilationPath(java.lang.String)
|
||||
*/
|
||||
public IPath getCompilationPath(String sourceName) {
|
||||
IProject project = getResolvedProject();
|
||||
if (project == null)
|
||||
return null;
|
||||
ICProject cProject = CModelManager.getDefault().create(project);
|
||||
IPath path = new Path(sourceName);
|
||||
for (IFile file : ResourceLookup.findFilesForLocation(path)) {
|
||||
ISourceRoot root = cProject.findSourceRoot(file);
|
||||
if (root != null) {
|
||||
return path.makeRelativeTo(root.getResource().getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
// XXX
|
||||
// try {
|
||||
// for (ISourceContainer container : getSourceContainers()) {
|
||||
// path = SourceUtils.getCompilationPath(container, sourceName);
|
||||
// if (path != null) {
|
||||
// return path;
|
||||
// }
|
||||
// }
|
||||
// } catch (CoreException e) {
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
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 (isSearchReferencedProjects()) {
|
||||
IProject[] projects = SourceUtils.getAllReferencedProjects(project);
|
||||
ISourceContainer[] folders = createCompilationDirectoryContainers(project);
|
||||
List<ISourceContainer> containers = new ArrayList<ISourceContainer>(folders.length + projects.length);
|
||||
for (ISourceContainer folder : folders) {
|
||||
containers.add(folder);
|
||||
}
|
||||
for (IProject ref : projects) {
|
||||
if (ref.exists() && ref.isOpen()) {
|
||||
SourceFoldersRelativePathSourceContainer container =
|
||||
new SourceFoldersRelativePathSourceContainer(ref, false);
|
||||
container.init(getDirector());
|
||||
containers.add(container);
|
||||
}
|
||||
}
|
||||
return containers.toArray(new ISourceContainer[containers.size()]);
|
||||
}
|
||||
return createCompilationDirectoryContainers(project);
|
||||
}
|
||||
return new ISourceContainer[0];
|
||||
}
|
||||
|
||||
private ISourceContainer[] createCompilationDirectoryContainers(IProject project) throws CoreException {
|
||||
ICProject cProject = CModelManager.getDefault().create(project);
|
||||
ISourceRoot[] roots = cProject.getAllSourceRoots();
|
||||
List<ISourceContainer> list = new ArrayList<ISourceContainer>(roots.length);
|
||||
for (ISourceRoot root : roots) {
|
||||
IContainer folder = (IContainer) root.getResource();
|
||||
ISourceContainer container = new CompilationDirectorySourceContainer(folder.getLocation(), false);
|
||||
container.init(getDirector());
|
||||
list.add(container);
|
||||
}
|
||||
return list.toArray(new ISourceContainer[list.size()]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTypeDelegate;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* See <code>SourceFoldersRelativePathSourceContainer</code>.
|
||||
*/
|
||||
public class SourceFoldersRelativePathSourceContainerType extends AbstractSourceContainerTypeDelegate {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer)
|
||||
*/
|
||||
public String getMemento(ISourceContainer container) throws CoreException {
|
||||
SourceFoldersRelativePathSourceContainer sourceContainer = (SourceFoldersRelativePathSourceContainer) container;
|
||||
Document document = newDocument();
|
||||
Element element = document.createElement("project"); //$NON-NLS-1$
|
||||
IProject project = sourceContainer.getProject();
|
||||
if (project != null) {
|
||||
element.setAttribute("name", project.getName()); //$NON-NLS-1$
|
||||
}
|
||||
element.setAttribute("referencedProjects", String.valueOf(sourceContainer.isSearchReferencedProjects())); //$NON-NLS-1$
|
||||
document.appendChild(element);
|
||||
return serializeDocument(document);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#createSourceContainer(java.lang.String)
|
||||
*/
|
||||
public ISourceContainer createSourceContainer(String memento) throws CoreException {
|
||||
Node node = parseDocument(memento);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element element = (Element)node;
|
||||
if ("project".equals(element.getNodeName())) { //$NON-NLS-1$
|
||||
String string = element.getAttribute("name"); //$NON-NLS-1$
|
||||
IProject project = null;
|
||||
if (string != null && string.length() > 0) {
|
||||
project = ResourcesPlugin.getWorkspace().getRoot().getProject(string);
|
||||
}
|
||||
String nest = element.getAttribute("referencedProjects"); //$NON-NLS-1$
|
||||
boolean ref = "true".equals(nest); //$NON-NLS-1$
|
||||
return new SourceFoldersRelativePathSourceContainer(project, ref);
|
||||
}
|
||||
abort(InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainerType_1, null);
|
||||
}
|
||||
abort(InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainerType_2, null);
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2009 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2010 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||
|
||||
|
@ -14,25 +15,34 @@ import java.io.IOException;
|
|||
import java.io.StringReader;
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.CDebugUtils;
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.CProjectSourceContainer;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.IMappingSourceContainer;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
|
||||
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.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
@ -160,7 +170,7 @@ public class SourceUtils {
|
|||
int mappingCount = 0;
|
||||
for (ICSourceLocation location : locations) {
|
||||
if (location instanceof IProjectSourceLocation) {
|
||||
containers.add(new ProjectSourceContainer(((IProjectSourceLocation) location).getProject(), false));
|
||||
containers.add(new CProjectSourceContainer(((IProjectSourceLocation) location).getProject(), false));
|
||||
} else if (location instanceof IDirectorySourceLocation) {
|
||||
IDirectorySourceLocation d = (IDirectorySourceLocation) location;
|
||||
IPath a = d.getAssociation();
|
||||
|
@ -175,4 +185,49 @@ public class SourceUtils {
|
|||
}
|
||||
return containers.toArray(new ISourceContainer[containers.size()]);
|
||||
}
|
||||
|
||||
static IPath getCompilationPath(ISourceContainer container, String sourceName) {
|
||||
if (container instanceof IMappingSourceContainer) {
|
||||
return ((IMappingSourceContainer) container).getCompilationPath(sourceName);
|
||||
}
|
||||
|
||||
try {
|
||||
for (ISourceContainer cont : container.getSourceContainers()) {
|
||||
IPath path = getCompilationPath(cont, sourceName);
|
||||
if (path != null)
|
||||
return path;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IProject[] getAllReferencedProjects(IProject project) throws CoreException {
|
||||
Set<IProject> all = new HashSet<IProject>();
|
||||
getAllReferencedProjects(all, project);
|
||||
return all.toArray(new IProject[all.size()]);
|
||||
}
|
||||
|
||||
private static void getAllReferencedProjects(Set<IProject> all, IProject project) throws CoreException {
|
||||
for (IProject ref : project.getReferencedProjects()) {
|
||||
if (!all.contains(ref) && ref.exists() && ref.isOpen()) {
|
||||
all.add(ref);
|
||||
getAllReferencedProjects(all, ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IProject getLaunchConfigurationProject(ISourceLookupDirector director) {
|
||||
ILaunchConfiguration config = director.getLaunchConfiguration();
|
||||
if (config != null) {
|
||||
try {
|
||||
String name = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
|
||||
if (name.length() > 0)
|
||||
return ResourcesPlugin.getWorkspace().getRoot().getProject(name);
|
||||
} catch (CoreException e) {
|
||||
CDebugCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
BIN
debug/org.eclipse.cdt.debug.ui/icons/obj16/dir_anchor_obj.gif
Normal file
BIN
debug/org.eclipse.cdt.debug.ui/icons/obj16/dir_anchor_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 936 B |
BIN
debug/org.eclipse.cdt.debug.ui/icons/obj16/proj_anchor_obj.gif
Normal file
BIN
debug/org.eclipse.cdt.debug.ui/icons/obj16/proj_anchor_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 963 B |
|
@ -20,7 +20,7 @@ ExecutablesView.name=Executables
|
|||
CDebuggerPage.name=C Debugger UI Page
|
||||
MemoryPreferencePage.name=Memory View
|
||||
CDebugPreferencePage.name=Debug
|
||||
SourcePreferencePage.name=Common Source Lookup Path
|
||||
SourcePreferencePage.name=Source Lookup Path
|
||||
DebuggerTypesPreferencePage.name=Debugger Types
|
||||
BreakpointActionPage.name=Breakpoint Action UI Page
|
||||
|
||||
|
|
|
@ -1286,7 +1286,12 @@
|
|||
<adapter type="org.eclipse.ui.model.IWorkbenchAdapter"/>
|
||||
</factory>
|
||||
<factory
|
||||
adaptableType="org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer"
|
||||
adaptableType="org.eclipse.cdt.debug.core.sourcelookup.containers.CProjectSourceContainer"
|
||||
class="org.eclipse.cdt.debug.internal.ui.sourcelookup.SourceContainerAdapterFactory">
|
||||
<adapter type="org.eclipse.ui.model.IWorkbenchAdapter"/>
|
||||
</factory>
|
||||
<factory
|
||||
adaptableType="org.eclipse.cdt.debug.core.sourcelookup.containers.SourceFoldersRelativePathSourceContainer"
|
||||
class="org.eclipse.cdt.debug.internal.ui.sourcelookup.SourceContainerAdapterFactory">
|
||||
<adapter type="org.eclipse.ui.model.IWorkbenchAdapter"/>
|
||||
</factory>
|
||||
|
@ -1476,6 +1481,11 @@
|
|||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.sourceContainerPresentations">
|
||||
<sourceContainerPresentation
|
||||
browserClass="org.eclipse.cdt.debug.internal.ui.sourcelookup.CProjectSourceContainerBrowser"
|
||||
containerTypeID="org.eclipse.cdt.debug.core.containerType.project"
|
||||
icon="icons/obj16/project_obj.gif"
|
||||
id="org.eclipse.cdt.debug.ui.sourceContainerPresentation.project"/>
|
||||
<sourceContainerPresentation
|
||||
browserClass="org.eclipse.cdt.debug.internal.ui.sourcelookup.NewMappingSourceContainerBrowser"
|
||||
containerTypeID="org.eclipse.cdt.debug.core.containerType.mapping"
|
||||
|
@ -1491,9 +1501,20 @@
|
|||
icon="icons/obj16/abspath_obj.gif"
|
||||
id="org.eclipse.cdt.debug.ui.sourceContainerPresentation.absolutePath"/>
|
||||
<sourceContainerPresentation
|
||||
browserClass="org.eclipse.cdt.debug.internal.ui.sourcelookup.ProgramRelativePathSourceContainerBrowser"
|
||||
containerTypeID="org.eclipse.cdt.debug.core.containerType.programRelativePath"
|
||||
icon="icons/obj16/program_rel_path_obj.gif"
|
||||
id="org.eclipse.cdt.debug.ui.sourceContainerPresentation.programRelativePath"/>
|
||||
<sourceContainerPresentation
|
||||
browserClass="org.eclipse.cdt.debug.internal.ui.sourcelookup.CompilationDirectorySourceContainerBrowser"
|
||||
containerTypeID="org.eclipse.cdt.debug.core.containerType.compilationDirectory"
|
||||
icon="icons/obj16/dir_anchor_obj.gif"
|
||||
id="org.eclipse.cdt.debug.ui.sourceContainerPresentation.compilationDirectory"/>
|
||||
<sourceContainerPresentation
|
||||
browserClass="org.eclipse.cdt.debug.internal.ui.sourcelookup.SourceFoldersRelativePathSourceContainerBrowser"
|
||||
containerTypeID="org.eclipse.cdt.debug.core.containerType.sourceFoldersRelativePath"
|
||||
icon="icons/obj16/proj_anchor_obj.gif"
|
||||
id="org.eclipse.cdt.debug.ui.sourceContainerPresentation.sourceFoldersRelativePath"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.filebuffers.annotationModelCreation">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2010 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,14 +8,13 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui;
|
||||
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* Help context ids for the C/C++ debug ui.
|
||||
* <p>
|
||||
* This interface contains constants only; it is not intended to be implemented
|
||||
|
@ -80,9 +79,10 @@ public interface ICDebugHelpContextIds {
|
|||
public static final String ADD_DIRECTORY_CONTAINER_DIALOG = PREFIX + "add_directory_container_dialog"; //$NON-NLS-1$
|
||||
public static final String REGISTER_GROUP = PREFIX + "register_group_dialog"; //$NON-NLS-1$
|
||||
public static final String CONFIGURE_COLUMNS_DIALOG = PREFIX + "configure_columns_dialog_context"; //$NON-NLS-1$;
|
||||
public static final String COMPILATION_DIRECTORY_SOURCE_CONTAINER_DIALOG = PREFIX + "compilation_directory_source_container_dialog_context"; //$NON-NLS-1$;;
|
||||
public static final String ADD_TARGET_PROJECT_CONTAINER_DIALOG = PREFIX + "target_project_source_container_dialog";//$NON-NLS-1$
|
||||
|
||||
// Wizards
|
||||
public static final String IMPORT_EXECUTABLE_PAGE_ONE = PREFIX + "import_executable_page_one"; //$NON-NLS-1$
|
||||
public static final String IMPORT_EXECUTABLE_PAGE_TWO = PREFIX + "import_executable_page_two"; //$NON-NLS-1$
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2008 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2010 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui;
|
||||
|
||||
|
@ -43,7 +44,7 @@ public interface IInternalCDebugUIConstants {
|
|||
|
||||
public static final RGB DEFAULT_DISASSEMBLY_SOURCE_LINE_RGB = Display.getDefault().getSystemColor( SWT.COLOR_DARK_BLUE ).getRGB();
|
||||
|
||||
//Current stack frame instruction pointer
|
||||
// Current stack frame instruction pointer
|
||||
public static final String DISASM_INSTRUCTION_POINTER = PREFIX + "disassemblyInstructionPointer"; //$NON-NLS-1$
|
||||
|
||||
// marker types for instruction pointer annotations - top stack frame, and secondary
|
||||
|
@ -74,10 +75,12 @@ public interface IInternalCDebugUIConstants {
|
|||
*/
|
||||
public static final int INTERNAL_ERROR = 150;
|
||||
|
||||
// new disassembly (start)
|
||||
// new disassembly
|
||||
|
||||
public static final String DISASM_DISPLAY_MODE_INSTRUCTIONS = "instructions"; //$NON-NLS-1$
|
||||
public static final String DISASM_DISPLAY_MODE_SOURCE = "source"; //$NON-NLS-1$
|
||||
|
||||
// new disassembly (end)
|
||||
|
||||
// wizard images
|
||||
public static final String IMG_ADD_COMP_DIR_WIZ = "IMG_ADD_SRC_DIRECTORY"; //$NON-NLS-1$
|
||||
public static final String IMG_EDIT_COMP_DIR_WIZ = "IMG_EDIT_SRC_DIRECTORY"; //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2003, 2009 QNX Software Systems and others.
|
||||
# Copyright (c) 2003, 2010 QNX Software Systems and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
|
@ -25,7 +25,7 @@ CDebugPreferencePage.13=Value must be an integer between {0} and {1}.
|
|||
CDebugPreferencePage.14=Binary
|
||||
CDebugPreferencePage.15=Show source files in binaries
|
||||
CDebugPreferencePage.16=Character encoding:
|
||||
SourcePreferencePage.0=Common S&ource Lookup Path:
|
||||
SourcePreferencePage.0=Default S&ource Lookup Path:
|
||||
DebuggerTypesPage.0=Select All
|
||||
DebuggerTypesPage.1=Deselect All
|
||||
DebuggerTypesPage.2=Default
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.eclipse.ui.IWorkbench;
|
|||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
|
||||
/**
|
||||
* The "Common Source Lookup Path" preference page.
|
||||
* The "Source Lookup Path" preference page.
|
||||
*/
|
||||
public class SourcePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
|
||||
private SourceContainerViewer fPathViewer;
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.CProjectSourceContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
|
||||
import org.eclipse.debug.internal.ui.sourcelookup.BasicContainerContentProvider;
|
||||
import org.eclipse.debug.internal.ui.sourcelookup.browsers.ProjectSourceContainerDialog;
|
||||
import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.model.WorkbenchLabelProvider;
|
||||
|
||||
/**
|
||||
* The browser for adding a source folder relative path source container.
|
||||
*/
|
||||
public class CProjectSourceContainerBrowser extends AbstractSourceContainerBrowser {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration)
|
||||
*/
|
||||
public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) {
|
||||
if (director.getLaunchConfiguration() == null) {
|
||||
TargetProjectSourceContainerDialog dialog = new TargetProjectSourceContainerDialog(shell);
|
||||
if (dialog.open() == Window.OK) {
|
||||
return new ISourceContainer[] {
|
||||
new CProjectSourceContainer(null, dialog.isAddReferencedProjects()) };
|
||||
}
|
||||
} else {
|
||||
Object input = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IStructuredContentProvider contentProvider=new BasicContainerContentProvider();
|
||||
ILabelProvider labelProvider = new WorkbenchLabelProvider();
|
||||
ProjectSourceContainerDialog dialog =
|
||||
new ProjectSourceContainerDialog(shell, input, contentProvider, labelProvider,
|
||||
SourceLookupUIMessages.projectSelection_chooseLabel);
|
||||
if (dialog.open() == Window.OK) {
|
||||
ArrayList<ISourceContainer> res= new ArrayList<ISourceContainer>();
|
||||
for (Object element : dialog.getResult()) {
|
||||
if (!(element instanceof IProject))
|
||||
continue;
|
||||
res.add(new CProjectSourceContainer((IProject) element,
|
||||
dialog.isAddRequiredProjects()));
|
||||
}
|
||||
return res.toArray(new ISourceContainer[res.size()]);
|
||||
}
|
||||
}
|
||||
return new ISourceContainer[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
|
||||
import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser;
|
||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CompilationDirectorySourceContainer;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
/**
|
||||
* The browser for adding a compilation directory source container.
|
||||
*/
|
||||
public class CompilationDirectorySourceContainerBrowser extends AbstractSourceContainerBrowser {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration)
|
||||
*/
|
||||
public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) {
|
||||
ISourceContainer[] containers = new ISourceContainer[1];
|
||||
CompilationDirectorySourceContainerDialog dialog = new CompilationDirectorySourceContainerDialog(shell);
|
||||
if (dialog.open() == Window.OK) {
|
||||
String directory = dialog.getDirectory();
|
||||
if (directory != null) {
|
||||
containers[0] = new CompilationDirectorySourceContainer(new Path(directory), dialog.isCompilationSubfolders());
|
||||
return containers;
|
||||
}
|
||||
}
|
||||
return new ISourceContainer[0];
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#canEditSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[])
|
||||
*/
|
||||
public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) {
|
||||
return containers.length == 1 && CompilationDirectorySourceContainer.TYPE_ID.equals(containers[0].getType().getId());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#editSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[])
|
||||
*/
|
||||
public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) {
|
||||
if (containers.length == 1 && CompilationDirectorySourceContainer.TYPE_ID.equals(containers[0].getType().getId()) ) {
|
||||
CompilationDirectorySourceContainer c = (CompilationDirectorySourceContainer) containers[0];
|
||||
CompilationDirectorySourceContainerDialog dialog =
|
||||
new CompilationDirectorySourceContainerDialog(shell, c.getDirectory().getPath(), c.isComposite());
|
||||
if (dialog.open() == Window.OK) {
|
||||
String directory = dialog.getDirectory();
|
||||
if (directory != null) {
|
||||
containers[0].dispose();
|
||||
return new ISourceContainer[] { new CompilationDirectorySourceContainer(new Path(directory), dialog.isCompilationSubfolders()) };
|
||||
}
|
||||
}
|
||||
}
|
||||
return containers;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,231 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
|
||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.TitleAreaDialog;
|
||||
import org.eclipse.jface.resource.JFaceResources;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.DirectoryDialog;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
/**
|
||||
* The dialog for selecting the external folder for which a compilation directory source container
|
||||
* will be created.
|
||||
*/
|
||||
public class CompilationDirectorySourceContainerDialog extends TitleAreaDialog {
|
||||
private static final String LAST_PATH_SETTING = "EXT_FOLDER_LAST_PATH_SETTING"; //$NON-NLS-1$
|
||||
private static final String LAST_SUBDIR_SETTING = "EXT_FOLDER_LAST_SUBDIR_SETTING"; //$NON-NLS-1$
|
||||
|
||||
private String fDirectory;
|
||||
private boolean fCompilationSubfolders;
|
||||
|
||||
private Text fDirText;
|
||||
private Button fSubfoldersButton;
|
||||
private boolean fNewContainer;
|
||||
|
||||
/**
|
||||
* Creates a dialog to select a new file system folder.
|
||||
*
|
||||
* @param shell shell
|
||||
*/
|
||||
public CompilationDirectorySourceContainerDialog(Shell shell) {
|
||||
this(shell, "", //$NON-NLS-1$
|
||||
CDebugUIPlugin.getDefault().getDialogSettings().getBoolean(LAST_SUBDIR_SETTING));
|
||||
fNewContainer = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a dialog to edit file system folder.
|
||||
*
|
||||
* @param shell shell
|
||||
* @param directory directory to edit or empty string
|
||||
* @param compilationSubfolders whether the 'Subdirectories are also used for compilation'
|
||||
* checkbox should be checked
|
||||
* @param newContainer
|
||||
*/
|
||||
public CompilationDirectorySourceContainerDialog(Shell shell, String directory, boolean compilationSubfolders) {
|
||||
super(shell);
|
||||
setShellStyle(getShellStyle() | SWT.RESIZE);
|
||||
fDirectory = directory;
|
||||
fCompilationSubfolders = compilationSubfolders;
|
||||
fNewContainer = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the result of the dialog.open() operation
|
||||
* @return the dialog.open() result
|
||||
*/
|
||||
public String getDirectory() {
|
||||
return fDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the 'Subdirectories are also used for compilation' option is selected.
|
||||
*
|
||||
* @return whether the 'Subdirectories are also used for compilation' option is selected
|
||||
*/
|
||||
public boolean isCompilationSubfolders() {
|
||||
return fCompilationSubfolders;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
Image image = fNewContainer ?
|
||||
CDebugImages.get(IInternalCDebugUIConstants.IMG_ADD_COMP_DIR_WIZ) :
|
||||
CDebugImages.get(IInternalCDebugUIConstants.IMG_EDIT_COMP_DIR_WIZ);
|
||||
setTitle(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_2);
|
||||
setMessage(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_3);
|
||||
setTitleImage(image);
|
||||
Composite parentComposite = (Composite) super.createDialogArea(parent);
|
||||
Font font = parentComposite.getFont();
|
||||
Composite composite = new Composite(parentComposite, SWT.NONE);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
|
||||
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
|
||||
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
|
||||
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
|
||||
composite.setLayout(layout);
|
||||
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
composite.setFont(font);
|
||||
|
||||
Composite dirComposite = new Composite(composite, SWT.NONE);
|
||||
layout = new GridLayout(2, false);
|
||||
dirComposite.setLayout(layout);
|
||||
dirComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
dirComposite.setFont(font);
|
||||
|
||||
Label label = new Label(dirComposite, SWT.NONE);
|
||||
label.setText(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_4);
|
||||
GridData data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
data.horizontalSpan = 2;
|
||||
label.setLayoutData(data);
|
||||
label.setFont(font);
|
||||
|
||||
fDirText = new Text(dirComposite, SWT.BORDER);
|
||||
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
data.horizontalSpan = 1;
|
||||
fDirText.setLayoutData(data);
|
||||
fDirText.setFont(font);
|
||||
fDirText.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
validate();
|
||||
}
|
||||
});
|
||||
|
||||
Button button = new Button(dirComposite, SWT.PUSH);
|
||||
button.setText(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_5);
|
||||
data = new GridData();
|
||||
int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
|
||||
Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
|
||||
data.widthHint = Math.max(widthHint, minSize.x);
|
||||
button.setLayoutData(data);
|
||||
button.setFont(JFaceResources.getDialogFont());
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
browse();
|
||||
}
|
||||
});
|
||||
|
||||
fSubfoldersButton = new Button(dirComposite, SWT.CHECK);
|
||||
fSubfoldersButton.setText(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_6);
|
||||
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
data.verticalIndent = layout.verticalSpacing; // Extra vertical spacing
|
||||
fSubfoldersButton.setLayoutData(data);
|
||||
fSubfoldersButton.setFont(font);
|
||||
|
||||
return parentComposite;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
protected void configureShell(Shell newShell) {
|
||||
String title = null;
|
||||
if (fNewContainer) {
|
||||
title = SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_7;
|
||||
} else {
|
||||
title = SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_8;
|
||||
}
|
||||
newShell.setText(title);
|
||||
super.configureShell(newShell);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createContents(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
protected Control createContents(Composite parent) {
|
||||
Control c = super.createContents(parent);
|
||||
fDirText.setText(fDirectory);
|
||||
fSubfoldersButton.setSelection(fCompilationSubfolders);
|
||||
validate();
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(c, ICDebugHelpContextIds.COMPILATION_DIRECTORY_SOURCE_CONTAINER_DIALOG);
|
||||
return c;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
|
||||
*/
|
||||
protected void okPressed() {
|
||||
fDirectory = fDirText.getText().trim();
|
||||
fCompilationSubfolders = fSubfoldersButton.getSelection();
|
||||
CDebugUIPlugin.getDefault().getDialogSettings().put(LAST_PATH_SETTING, fDirectory);
|
||||
CDebugUIPlugin.getDefault().getDialogSettings().put(LAST_SUBDIR_SETTING, fCompilationSubfolders);
|
||||
super.okPressed();
|
||||
}
|
||||
|
||||
private void browse() {
|
||||
String last = fDirText.getText().trim();
|
||||
if (last.length() == 0) {
|
||||
last = CDebugUIPlugin.getDefault().getDialogSettings().get(LAST_PATH_SETTING);
|
||||
}
|
||||
if (last == null) {
|
||||
last = ""; //$NON-NLS-1$
|
||||
}
|
||||
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SINGLE);
|
||||
dialog.setText(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_0);
|
||||
dialog.setMessage(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_1);
|
||||
dialog.setFilterPath(last);
|
||||
String result = dialog.open();
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
fDirText.setText(result);
|
||||
}
|
||||
|
||||
private void validate() {
|
||||
File file = new File(fDirText.getText().trim());
|
||||
getButton(IDialogConstants.OK_ID).setEnabled(file.isDirectory() && file.exists());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.ProgramRelativePathSourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
|
||||
import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
/**
|
||||
* Adds a program-relative path to the source lookup path.
|
||||
*/
|
||||
public class ProgramRelativePathSourceContainerBrowser extends AbstractSourceContainerBrowser {
|
||||
|
||||
public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) {
|
||||
return new ISourceContainer[] { new ProgramRelativePathSourceContainer() };
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2010 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -14,6 +14,7 @@ import java.io.File;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.CProjectSourceContainer;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
|
||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer;
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
|
||||
|
@ -45,8 +46,15 @@ public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter {
|
|||
if (o instanceof MapEntrySourceContainer) {
|
||||
return CDebugImages.DESC_OBJS_PATH_MAP_ENTRY;
|
||||
}
|
||||
if (o instanceof ProjectSourceContainer) {
|
||||
IProject project = ((ProjectSourceContainer)o).getProject();
|
||||
if (o instanceof CProjectSourceContainer) {
|
||||
IProject project = ((CProjectSourceContainer) o).getProject();
|
||||
if (project != null) {
|
||||
ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
|
||||
if (cProject != null)
|
||||
return getImageDescriptor(cProject);
|
||||
}
|
||||
} else if (o instanceof ProjectSourceContainer) {
|
||||
IProject project = ((ProjectSourceContainer) o).getProject();
|
||||
ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
|
||||
if (cProject != null)
|
||||
return getImageDescriptor(cProject);
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.SourceFoldersRelativePathSourceContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
|
||||
import org.eclipse.debug.internal.ui.sourcelookup.BasicContainerContentProvider;
|
||||
import org.eclipse.debug.internal.ui.sourcelookup.browsers.ProjectSourceContainerDialog;
|
||||
import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.model.WorkbenchLabelProvider;
|
||||
|
||||
/**
|
||||
* The browser for adding a source folder relative path source container.
|
||||
*/
|
||||
public class SourceFoldersRelativePathSourceContainerBrowser extends AbstractSourceContainerBrowser {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration)
|
||||
*/
|
||||
public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) {
|
||||
if (director.getLaunchConfiguration() == null) {
|
||||
TargetProjectSourceContainerDialog dialog = new TargetProjectSourceContainerDialog(shell);
|
||||
if (dialog.open() == Window.OK) {
|
||||
return new ISourceContainer[] {
|
||||
new SourceFoldersRelativePathSourceContainer(null, dialog.isAddReferencedProjects()) };
|
||||
}
|
||||
} else {
|
||||
Object input = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IStructuredContentProvider contentProvider=new BasicContainerContentProvider();
|
||||
ILabelProvider labelProvider = new WorkbenchLabelProvider();
|
||||
ProjectSourceContainerDialog dialog =
|
||||
new ProjectSourceContainerDialog(shell, input, contentProvider, labelProvider,
|
||||
SourceLookupUIMessages.projectSelection_chooseLabel);
|
||||
if (dialog.open() == Window.OK) {
|
||||
ArrayList<ISourceContainer> res= new ArrayList<ISourceContainer>();
|
||||
for (Object element : dialog.getResult()) {
|
||||
if (!(element instanceof IProject))
|
||||
continue;
|
||||
res.add(new SourceFoldersRelativePathSourceContainer((IProject) element,
|
||||
dialog.isAddRequiredProjects()));
|
||||
}
|
||||
return res.toArray(new ISourceContainer[res.size()]);
|
||||
}
|
||||
}
|
||||
return new ISourceContainer[0];
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2010 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -53,6 +53,19 @@ public class SourceLookupUIMessages extends NLS {
|
|||
public static String CSourceNotFoundEditor_3;
|
||||
public static String CSourceNotFoundEditor_4;
|
||||
public static String CSourceNotFoundEditor_5;
|
||||
public static String CompilationDirectorySourceContainerDialog_0;
|
||||
public static String CompilationDirectorySourceContainerDialog_1;
|
||||
public static String CompilationDirectorySourceContainerDialog_2;
|
||||
public static String CompilationDirectorySourceContainerDialog_3;
|
||||
public static String CompilationDirectorySourceContainerDialog_4;
|
||||
public static String CompilationDirectorySourceContainerDialog_5;
|
||||
public static String CompilationDirectorySourceContainerDialog_6;
|
||||
public static String CompilationDirectorySourceContainerDialog_7;
|
||||
public static String CompilationDirectorySourceContainerDialog_8;
|
||||
public static String TargetProjectSourceContainerDialog_title;
|
||||
public static String TargetProjectSourceContainerDialog_description;
|
||||
public static String TargetProjectSourceContainerDialog_referencedLabel;
|
||||
public static String projectSelection_chooseLabel;
|
||||
|
||||
static {
|
||||
NLS.initializeMessages(SourceLookupUIMessages.class.getName(), SourceLookupUIMessages.class);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2005, 2009 QNX Software Systems and others.
|
||||
# Copyright (c) 2005, 2010 QNX Software Systems and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
|
@ -7,8 +7,9 @@
|
|||
#
|
||||
# Contributors:
|
||||
# QNX Software Systems - initial API and implementation
|
||||
# Ken Ryall (Nokia) - Added support for CSourceNotFoundElement ( 167305 )
|
||||
# Ken Ryall (Nokia) - Option to open disassembly view when no source ( 81353 )
|
||||
# Ken Ryall (Nokia) - Added support for CSourceNotFoundElement (167305)
|
||||
# Ken Ryall (Nokia) - Option to open disassembly view when no source (81353)
|
||||
# Sergey Prigogin (Google)
|
||||
###############################################################################
|
||||
AddContainerAction_0=&Add...
|
||||
AddSourceContainerDialog_0=Add Source
|
||||
|
@ -49,3 +50,16 @@ CSourceNotFoundEditor_2=Missing Source File
|
|||
CSourceNotFoundEditor_3=No source available for \"{0}\" \n
|
||||
CSourceNotFoundEditor_4=View Disassembly...
|
||||
CSourceNotFoundEditor_5=Edit Source Lookup Path...
|
||||
CompilationDirectorySourceContainerDialog_0=Directory Selection
|
||||
CompilationDirectorySourceContainerDialog_1=Choose directory to add:
|
||||
CompilationDirectorySourceContainerDialog_2=Compilation directory
|
||||
CompilationDirectorySourceContainerDialog_3=Specify directory and whether subdirectories are also used for compilation
|
||||
CompilationDirectorySourceContainerDialog_4=&Directory:
|
||||
CompilationDirectorySourceContainerDialog_5=&Browse...
|
||||
CompilationDirectorySourceContainerDialog_6=&Subdirectories are also used for compilation
|
||||
CompilationDirectorySourceContainerDialog_7=Add Compilation Directory
|
||||
CompilationDirectorySourceContainerDialog_8=Edit Compilation Directory
|
||||
TargetProjectSourceContainerDialog_title=Referenced Projects
|
||||
TargetProjectSourceContainerDialog_description=Specify whether referenced projects should be included
|
||||
TargetProjectSourceContainerDialog_referencedLabel=Add projects &referenced by the target project
|
||||
projectSelection_chooseLabel = Choose &project(s) to add:
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.dialogs.SelectionDialog;
|
||||
|
||||
/**
|
||||
* The dialog for configuring a source container for a project associated with the launch target.
|
||||
*/
|
||||
public class TargetProjectSourceContainerDialog extends SelectionDialog {
|
||||
private boolean fAddReferencedProjects;
|
||||
|
||||
public TargetProjectSourceContainerDialog(Shell parentShell) {
|
||||
super(parentShell);
|
||||
setTitle(SourceLookupUIMessages.TargetProjectSourceContainerDialog_title);
|
||||
setMessage(SourceLookupUIMessages.TargetProjectSourceContainerDialog_description);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
Font font = parent.getFont();
|
||||
|
||||
// Page group
|
||||
Composite composite = (Composite) super.createDialogArea(parent);
|
||||
initializeDialogUnits(composite);
|
||||
|
||||
createMessageArea(composite);
|
||||
|
||||
final Button addRequired = new Button(composite, SWT.CHECK);
|
||||
addRequired.setText(SourceLookupUIMessages.TargetProjectSourceContainerDialog_referencedLabel);
|
||||
addRequired.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
fAddReferencedProjects = addRequired.getSelection();
|
||||
}
|
||||
});
|
||||
addRequired.setSelection(fAddReferencedProjects);
|
||||
addRequired.setFont(font);
|
||||
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(),
|
||||
ICDebugHelpContextIds.ADD_TARGET_PROJECT_CONTAINER_DIALOG);
|
||||
applyDialogFont(composite);
|
||||
return composite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the user has selected to add referenced projects.
|
||||
*
|
||||
* @return whether the user has selected to add referenced projects
|
||||
*/
|
||||
public boolean isAddReferencedProjects() {
|
||||
return fAddReferencedProjects;
|
||||
}
|
||||
}
|
|
@ -121,9 +121,9 @@
|
|||
<topic href="reference/cdt_u_dbg_brkpt_actions.htm" label="Breakpoint Actions preferences"/>
|
||||
<topic href="tasks/cdt_t_addrmv_brk_action.htm" label="Attaching and Removing Breakpoint Actions"/>
|
||||
</context>
|
||||
<context id="source_preference_page_context" title="Common Source Lookup Path">
|
||||
<context id="source_preference_page_context" title="Source Lookup Path">
|
||||
<description>Manage common source paths.</description>
|
||||
<topic href="reference/cdt_u_dbg_src.htm" label="Common Source Lookup Path"/>
|
||||
<topic href="reference/cdt_u_dbg_src.htm" label="Source Lookup Path"/>
|
||||
</context>
|
||||
|
||||
</contexts>
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
|
||||
<img src="../images/trans.gif" border="0" width="100" height="1" alt=""><a style="text-decoration:none" href="cdt_u_debug.htm">Debug preferences</a><br>
|
||||
<img src="../images/trans.gif" border="0" width="150" height="1" alt=""><a style="text-decoration:none" href="cdt_u_dbg_brkpt_actions.htm">Breakpoint Actions</a><br>
|
||||
<img src="../images/trans.gif" border="0" width="150" height="1" alt=""><a style="text-decoration:none" href="cdt_u_dbg_src.htm">Common Source Lookup Path</a><br>
|
||||
<img src="../images/trans.gif" border="0" width="150" height="1" alt=""><a style="text-decoration:none" href="cdt_u_dbg_src.htm">Source Lookup Path</a><br>
|
||||
<img src="../images/trans.gif" border="0" width="150" height="1" alt=""><a style="text-decoration:none" href="cdt_u_gdb_mi.htm">GDB MI preferences</a><br>
|
||||
|
||||
<img src="../images/trans.gif" border="0" width="100" height="1" alt=""><a style="text-decoration:none" href="cdt_u_c_editor_gen.htm">Editor preferences</a><br>
|
||||
|
|
|
@ -4,21 +4,21 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Common Source Lookup Path preferences</title>
|
||||
<title>Source Lookup Path preferences</title>
|
||||
<link rel="stylesheet" type="text/css" href="../help.css">
|
||||
<script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Common Source Lookup Path preference</h1>
|
||||
<h1>Source Lookup Path preference</h1>
|
||||
|
||||
<p>Use the <img src="../images/command_link.png" border="0" alt="" > <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.cdt.debug.ui.SourcePreferencePage)")'>Common Source Lookup Path</a> preference page to add or remove source containers.</p>
|
||||
<p>Use the <img src="../images/command_link.png" border="0" alt="" > <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.cdt.debug.ui.SourcePreferencePage)")'>Source Lookup Path</a> preference page to add or remove source containers.</p>
|
||||
|
||||
<p><img src="../images/debug_src_pref.png" alt="Debug Source Code Locations Preferences" ></p>
|
||||
<p><img src="../images/debug_src_pref.png" alt="Debug Source Code Locations Preferences" ></p>
|
||||
|
||||
<table width="600px" cellpadding="5" cellspacing="0" border="1" >
|
||||
<caption>
|
||||
<strong>Common Source Lookup Path Options </strong>
|
||||
<strong>Default Source Lookup Path Options</strong>
|
||||
</caption>
|
||||
<colgroup>
|
||||
<col width="30%" valign="top" >
|
||||
|
@ -33,9 +33,13 @@
|
|||
<td width="99" valign="top"><strong>Add...</strong></td>
|
||||
<td width="475">Opens the <strong>Add Source</strong> dialog to insert a new source container of one of the following types:<br><br>
|
||||
<ul>
|
||||
<li>Absolute File Path</li>
|
||||
<li>Compilation Directory</li>
|
||||
<li>File System Directory</li>
|
||||
<li>Path Mapping</li>
|
||||
<li>Project</li>
|
||||
<li>Project - Path Relative to Source Folders</li>
|
||||
<li>Program Relative File Path</li>
|
||||
<li>Workspace</li>
|
||||
<li>Workspace Folder </li>
|
||||
</ul>
|
||||
|
@ -43,7 +47,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><strong>Edit...</strong></td>
|
||||
<td>Opens the <strong>Edit File System Director</strong>y dialog to modify the currently selected source container.</td>
|
||||
<td>Opens the <strong>Edit File System Directory</strong> dialog to modify the currently selected source container.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><strong>Remove</strong></td>
|
||||
|
|
|
@ -72,12 +72,11 @@
|
|||
|
||||
<topic label="Debug preferences" href="reference/cdt_u_debug.htm">
|
||||
<topic label="Breakpoint Actions" href="reference/cdt_u_dbg_brkpt_actions.htm"/>
|
||||
<topic label="Common Source Lookup Path" href="reference/cdt_u_dbg_src.htm"/>
|
||||
<topic label="Source Lookup Path" href="reference/cdt_u_dbg_src.htm"/>
|
||||
<topic label="GDB MI" href="reference/cdt_u_gdb_mi.htm"/>
|
||||
<topic label="GDB" href="reference/cdt_u_dsfgdb.htm"/>
|
||||
</topic>
|
||||
|
||||
|
||||
<topic label="Editor preferences" href="reference/cdt_u_c_editor_gen.htm">
|
||||
<topic label="Content Assist" href="reference/cdt_u_c_editor_con_assist.htm" >
|
||||
<topic label="Advanced" href="reference/cdt_u_c_editor_con_assist_adv.htm"/>
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.Hashtable;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.CProjectSourceContainer;
|
||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
|
||||
|
@ -79,7 +80,15 @@ public class CSourceLookup extends AbstractDsfService implements ISourceLookup {
|
|||
ArrayList<String> list = new ArrayList<String>(containers.length);
|
||||
|
||||
for (ISourceContainer container : containers) {
|
||||
if (container instanceof ProjectSourceContainer) {
|
||||
if (container instanceof CProjectSourceContainer) {
|
||||
IProject project = ((CProjectSourceContainer) container).getProject();
|
||||
if (project != null && project.exists()) {
|
||||
IPath location = project.getLocation();
|
||||
if (location != null) {
|
||||
list.add(location.toPortableString());
|
||||
}
|
||||
}
|
||||
} else if (container instanceof ProjectSourceContainer) { // For backward compatibility
|
||||
IProject project = ((ProjectSourceContainer) container).getProject();
|
||||
if (project != null && project.exists()) {
|
||||
IPath location = project.getLocation();
|
||||
|
|
Loading…
Add table
Reference in a new issue