Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-04-12 10:16:49 +0000
committerUwe Stieber2013-04-12 10:16:49 +0000
commitccf1b162686a47401aee384afb648b699c030cc3 (patch)
treedeebbc1a34d6c67f01bb4ff3af4ef396fe07b0ad /target_explorer/plugins/org.eclipse.tcf.te.launch.core
parent902ec1e3a213082f30ce5c70157e1dc6c195c4c0 (diff)
downloadorg.eclipse.tcf-ccf1b162686a47401aee384afb648b699c030cc3.tar.gz
org.eclipse.tcf-ccf1b162686a47401aee384afb648b699c030cc3.tar.xz
org.eclipse.tcf-ccf1b162686a47401aee384afb648b699c030cc3.zip
Target Explorer: Fix bugzilla 405548 and rework default source lookup handling
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.launch.core')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/computers/SourcePathComputerDelegate.java83
3 files changed, 93 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF
index 07f12c8c7..91f35811d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/META-INF/MANIFEST.MF
@@ -8,6 +8,7 @@ Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0",
org.eclipse.core.expressions;bundle-version="3.4.400",
org.eclipse.debug.core;bundle-version="3.7.100",
+ org.eclipse.tcf.te.core.cdt;bundle-version="1.1.0",
org.eclipse.tcf.te.runtime;bundle-version="1.1.0",
org.eclipse.tcf.te.runtime.concurrent;bundle-version="1.1.0",
org.eclipse.tcf.te.runtime.model;bundle-version="1.1.0",
@@ -23,6 +24,7 @@ Export-Package: org.eclipse.tcf.te.launch.core.activator;x-internal:=true,
org.eclipse.tcf.te.launch.core.bindings,
org.eclipse.tcf.te.launch.core.bindings.interfaces,
org.eclipse.tcf.te.launch.core.bindings.internal;x-internal:=true,
+ org.eclipse.tcf.te.launch.core.computers,
org.eclipse.tcf.te.launch.core.delegates,
org.eclipse.tcf.te.launch.core.exceptions,
org.eclipse.tcf.te.launch.core.interfaces,
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
index 97452e1eb..a3b561e6b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
@@ -48,6 +48,14 @@
</propertyTester>
</extension>
+<!-- Source path computers contibutions -->
+ <extension point="org.eclipse.debug.core.sourcePathComputers">
+ <sourcePathComputer
+ class="org.eclipse.tcf.te.launch.core.computers.SourcePathComputerDelegate"
+ id="org.eclipse.tcf.te.launch.core.sourcePathComputer">
+ </sourcePathComputer>
+ </extension>
+
<!-- Launch Step contributions -->
<extension point="org.eclipse.tcf.te.runtime.stepper.steps">
<step
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/computers/SourcePathComputerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/computers/SourcePathComputerDelegate.java
new file mode 100644
index 000000000..257435209
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/computers/SourcePathComputerDelegate.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Wind River Systems, 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.computers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+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.ISourceLookupDirector;
+import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
+import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
+import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer;
+import org.eclipse.tcf.te.core.cdt.CdtUtils;
+import org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem;
+import org.eclipse.tcf.te.launch.core.persistence.projects.ReferencedProjectsPersistenceDelegate;
+
+/**
+ * Computes default source path containers based on the CDT preferences.
+ */
+public class SourcePathComputerDelegate implements ISourcePathComputerDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
+ List<ISourceContainer> containers = new ArrayList<ISourceContainer>();
+
+ // Get the default CDT source lookup director to access the default source lookup
+ // settings from the preferences
+ ISourceLookupDirector director = CdtUtils.getDefaultSourceLookupDirector();
+ if (director != null) {
+ // Get the default source lookup containers
+ ISourceContainer[] candidates = director.getSourceContainers();
+ for (ISourceContainer candidate : candidates) {
+ // CProjectSourceContainer instances does not make sense for our launches
+ // as the container won't be able to identify the correct project. We
+ // are going to replace this source lookup container with ordinary project
+ // source lookup containers based on our referenced projects.
+ if ("CProjectSourceContainer".equals(candidate.getClass().getSimpleName())) { //$NON-NLS-1$
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+
+ // Get the list of referenced projects
+ IReferencedProjectItem[] items = ReferencedProjectsPersistenceDelegate.getReferencedProjects(configuration);
+ for (IReferencedProjectItem item : items) {
+ IProject project = root.getProject(item.getProjectName());
+ if (project != null && project.isAccessible()) {
+ ISourceContainer container = new ProjectSourceContainer(project, true);
+ if (!containers.contains(container)) containers.add(container);
+ }
+ }
+
+ continue;
+ }
+
+ // Just add the source container to the list of containers
+ if (!containers.contains(candidate)) containers.add(candidate);
+ }
+ }
+
+ // Fallback to the whole workspace if there are no default source
+ // lookup containers from the preferences
+ if (containers.size() == 0) {
+ containers.add(new WorkspaceSourceContainer());
+ }
+
+ return containers.toArray(new ISourceContainer[containers.size()]);
+ }
+
+}

Back to the top