aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacek Pospychala2012-07-31 06:03:15 (EDT)
committerJacek Pospychala2012-07-31 06:03:15 (EDT)
commita8e7c8ef1b125c97664bebeec8699f8c606a6c8e (patch)
treef229df00823876fdc1db97b6ce497b7c284d6f82
parent809fd62913d31912a1ae2efe41813fd4bda54d21 (diff)
downloadorg.eclipse.pdt-a8e7c8ef1b125c97664bebeec8699f8c606a6c8e.zip
org.eclipse.pdt-a8e7c8ef1b125c97664bebeec8699f8c606a6c8e.tar.gz
org.eclipse.pdt-a8e7c8ef1b125c97664bebeec8699f8c606a6c8e.tar.bz2
Bug 386297 - Path mapping selector should try to match path base on
project name
-rw-r--r--plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/pathmapper/PathEntrySelector.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/pathmapper/PathEntrySelector.java b/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/pathmapper/PathEntrySelector.java
index 7cc2a29..1647b95 100644
--- a/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/pathmapper/PathEntrySelector.java
+++ b/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/pathmapper/PathEntrySelector.java
@@ -13,14 +13,21 @@ package org.eclipse.php.internal.debug.ui.pathmapper;
import java.util.*;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.jface.window.Window;
+import org.eclipse.php.internal.debug.core.IPHPDebugConstants;
import org.eclipse.php.internal.debug.core.pathmapper.IPathEntryFilter;
import org.eclipse.php.internal.debug.core.pathmapper.PathEntry;
import org.eclipse.php.internal.debug.core.pathmapper.VirtualPath;
import org.eclipse.php.internal.debug.core.zend.model.PHPDebugTarget;
import org.eclipse.php.internal.debug.core.zend.model.ResolveBlackList.Type;
+import org.eclipse.php.internal.debug.ui.PHPDebugUIPlugin;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
@@ -37,8 +44,15 @@ public class PathEntrySelector implements IPathEntryFilter {
final List<PathEntry> l = new LinkedList<PathEntry>();
final PathEntry[] mostMatchEntries = getMostMatchEntries(entries,
remotePath);
+ PathEntry matchByConfig = null;
+ if (mostMatchEntries.length == 0 || mostMatchEntries.length > 1) {
+ matchByConfig = getMatchFromLaunchConfiguration(entries,
+ debugTarget.getLaunch().getLaunchConfiguration());
+ }
if (mostMatchEntries.length == 1) {
l.add(mostMatchEntries[0]);
+ } else if (matchByConfig != null) {
+ l.add(matchByConfig);
} else {
Runnable r = new Runnable() {
public void run() {
@@ -72,6 +86,31 @@ public class PathEntrySelector implements IPathEntryFilter {
return l.toArray(new PathEntry[l.size()]);
}
+ private PathEntry getMatchFromLaunchConfiguration(PathEntry[] entries,
+ ILaunchConfiguration launchConfiguration) {
+ try {
+ String projectName = launchConfiguration.getAttribute(
+ IPHPDebugConstants.PHP_Project, (String) null);
+ if (projectName != null) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(projectName);
+ for (PathEntry pathEntry : entries) {
+ Object container = pathEntry.getContainer();
+ if (container instanceof IContainer) {
+ IProject p = ((IContainer) container).getProject();
+ if (p != null && p.equals(project)) {
+ return pathEntry;
+ }
+ }
+ }
+ }
+ } catch (CoreException e) {
+ // log exception and continue debugging
+ PHPDebugUIPlugin.log(e);
+ }
+ return null;
+ }
+
private PathEntry[] removeDuplicate(PathEntry[] entries) {
Set<PathEntry> set = new HashSet<PathEntry>();
for (int i = 0; i < entries.length; i++) {