aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwgalanciak2014-01-20 07:25:57 (EST)
committerwgalanciak2014-01-20 07:25:57 (EST)
commit579b8d82d4bc73797aeb3b963fd5cdbcf8310eb7 (patch)
treef4863cbff2f93f4160e7fd39193dcbd129a147f6
parentc1a4c16545b1e0d46e0c18d453e1ce90e447e11f (diff)
downloadorg.eclipse.pdt-579b8d82d4bc73797aeb3b963fd5cdbcf8310eb7.zip
org.eclipse.pdt-579b8d82d4bc73797aeb3b963fd5cdbcf8310eb7.tar.gz
org.eclipse.pdt-579b8d82d4bc73797aeb3b963fd5cdbcf8310eb7.tar.bz2
Bug 426114 - PHP executable in launch configuration is not updated whenrefs/changes/14/20814/1
project properties are changed Change-Id: Ida98e4ed204e6b39a3887323705abd35bef2500c Signed-off-by: wgalanciak <wojciech.galanciak@gmail.com>
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPExecutableLaunchDelegate.java38
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPLaunchDelegateProxy.java112
2 files changed, 96 insertions, 54 deletions
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPExecutableLaunchDelegate.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPExecutableLaunchDelegate.java
index 6fa625e..d50db51 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPExecutableLaunchDelegate.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPExecutableLaunchDelegate.java
@@ -27,10 +27,11 @@ import org.eclipse.debug.ui.RefreshTab;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.php.debug.core.debugger.parameters.IDebugParametersInitializer;
import org.eclipse.php.debug.core.debugger.parameters.IDebugParametersKeys;
-import org.eclipse.php.internal.core.PHPVersion;
-import org.eclipse.php.internal.debug.core.*;
+import org.eclipse.php.internal.debug.core.IPHPDebugConstants;
+import org.eclipse.php.internal.debug.core.Logger;
+import org.eclipse.php.internal.debug.core.PHPDebugCoreMessages;
+import org.eclipse.php.internal.debug.core.PHPDebugPlugin;
import org.eclipse.php.internal.debug.core.phpIni.PHPINIUtil;
-import org.eclipse.php.internal.debug.core.preferences.PHPDebugCorePreferenceNames;
import org.eclipse.php.internal.debug.core.preferences.PHPProjectPreferences;
import org.eclipse.php.internal.debug.core.preferences.PHPexeItem;
import org.eclipse.php.internal.debug.core.preferences.PHPexes;
@@ -113,37 +114,6 @@ public class PHPExecutableLaunchDelegate extends LaunchConfigurationDelegate {
if (monitor.isCanceled()) {
return;
}
- String path = configuration.getAttribute(PHPRuntime.PHP_CONTAINER,
- (String) null);
- if (path != null) {
- // update attributes,because php's execution environment may
- // change
- PHPVersion version = PHPRuntime.getPHPVersion(Path
- .fromPortableString(path));
- if (version != null) {
- PHPexeItem item = PHPDebugPlugin.getPHPexeItem(version);
- if (item != null) {
- ILaunchConfigurationWorkingCopy workingCopy = configuration
- .getWorkingCopy();
- workingCopy.setAttribute(
- IPHPDebugConstants.ATTR_EXECUTABLE_LOCATION, item
- .getExecutable().toString());
- workingCopy.setAttribute(
- PHPDebugCorePreferenceNames.PHP_DEBUGGER_ID,
- item.getDebuggerID());
- if (item.getINILocation() != null) {
- workingCopy.setAttribute(
- IPHPDebugConstants.ATTR_INI_LOCATION, item
- .getINILocation().toString());
- } else {
- workingCopy.setAttribute(
- IPHPDebugConstants.ATTR_INI_LOCATION,
- (String) null);
- }
- configuration = workingCopy.doSave();
- }
- }
- }
String phpExeString = configuration.getAttribute(
IPHPDebugConstants.ATTR_EXECUTABLE_LOCATION, (String) null);
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPLaunchDelegateProxy.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPLaunchDelegateProxy.java
index 3f0c0ed..01a0962 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPLaunchDelegateProxy.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPLaunchDelegateProxy.java
@@ -14,15 +14,22 @@
*/
package org.eclipse.php.internal.debug.core.launching;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
+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.*;
+import org.eclipse.debug.core.*;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate2;
+import org.eclipse.php.internal.core.PHPVersion;
+import org.eclipse.php.internal.debug.core.IPHPDebugConstants;
import org.eclipse.php.internal.debug.core.PHPDebugPlugin;
+import org.eclipse.php.internal.debug.core.PHPRuntime;
+import org.eclipse.php.internal.debug.core.debugger.AbstractDebuggerConfiguration;
import org.eclipse.php.internal.debug.core.preferences.PHPDebugCorePreferenceNames;
+import org.eclipse.php.internal.debug.core.preferences.PHPDebuggersRegistry;
+import org.eclipse.php.internal.debug.core.preferences.PHPexeItem;
+import org.eclipse.php.internal.debug.core.preferences.PHPexes;
/**
* The PHP launch delegate proxy is designed to supply flexibility in delegating
@@ -74,6 +81,12 @@ public class PHPLaunchDelegateProxy implements ILaunchConfigurationDelegate2 {
*/
public ILaunch getLaunch(ILaunchConfiguration configuration, String mode)
throws CoreException {
+ ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType exeType = lm
+ .getLaunchConfigurationType(IPHPDebugConstants.PHPEXELaunchType);
+ if (configuration.getType().equals(exeType)) {
+ configuration = updatePHPExeAttributes(configuration);
+ }
return getConfigurationDelegate(configuration).getLaunch(configuration,
mode);
}
@@ -103,12 +116,14 @@ public class PHPLaunchDelegateProxy implements ILaunchConfigurationDelegate2 {
*/
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
-
// Launch
- getConfigurationDelegate(configuration).launch(configuration, mode,
- launch, monitor);
- // Clear the launch configuration delegate.
- launchConfigurationDelegate = null;
+ try {
+ getConfigurationDelegate(configuration).launch(configuration, mode,
+ launch, monitor);
+ } finally {
+ // Clear the launch configuration delegate.
+ launchConfigurationDelegate = null;
+ }
}
/**
@@ -122,16 +137,15 @@ public class PHPLaunchDelegateProxy implements ILaunchConfigurationDelegate2 {
*/
protected ILaunchConfigurationDelegate2 getConfigurationDelegate(
ILaunchConfiguration configuration) throws CoreException {
- if (launchConfigurationDelegate == null) {
+ String className = configuration.getAttribute(
+ PHPDebugCorePreferenceNames.CONFIGURATION_DELEGATE_CLASS, ""); //$NON-NLS-1$
+ if (className.length() == 0) {
+ throw new IllegalArgumentException();
+ }
+ if (launchConfigurationDelegate == null
+ || !launchConfigurationDelegate.getClass().getCanonicalName()
+ .equals(className)) {
try {
- String className = configuration
- .getAttribute(
- PHPDebugCorePreferenceNames.CONFIGURATION_DELEGATE_CLASS,
- ""); //$NON-NLS-1$
- if (className.length() == 0) {
- throw new IllegalArgumentException();
- }
-
launchConfigurationDelegate = (ILaunchConfigurationDelegate2) Class
.forName(className).newInstance();
} catch (Throwable t) {
@@ -142,4 +156,62 @@ public class PHPLaunchDelegateProxy implements ILaunchConfigurationDelegate2 {
}
return launchConfigurationDelegate;
}
+
+ private ILaunchConfiguration updatePHPExeAttributes(
+ ILaunchConfiguration configuration) throws CoreException {
+ PHPexeItem item = null;
+ String path = configuration.getAttribute(PHPRuntime.PHP_CONTAINER,
+ (String) null);
+ if (path == null) {
+ IProject project = null;
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace()
+ .getRoot();
+ String projectName = configuration.getAttribute(
+ IPHPDebugConstants.PHP_Project, (String) null);
+ if (projectName != null) {
+ project = workspaceRoot.getProject(projectName);
+ } else {
+ String phpScriptString = configuration.getAttribute(
+ IPHPDebugConstants.ATTR_FILE, (String) null);
+ IPath filePath = new Path(phpScriptString);
+ IResource scriptRes = workspaceRoot.findMember(filePath);
+ if (scriptRes != null) {
+ project = scriptRes.getProject();
+ }
+ }
+ item = PHPDebugPlugin.getPHPexeItem(project);
+ } else {
+ IPath exePath = Path.fromPortableString(path);
+ PHPVersion version = PHPRuntime.getPHPVersion(exePath);
+ if (version == null) {
+ String exeName = exePath.lastSegment();
+ item = PHPexes.getInstance().getItem(exeName);
+ } else {
+ item = PHPDebugPlugin.getPHPexeItem(version);
+ }
+ }
+ if (item != null) {
+ ILaunchConfigurationWorkingCopy wc = configuration.getWorkingCopy();
+ wc.setAttribute(IPHPDebugConstants.ATTR_EXECUTABLE_LOCATION, item
+ .getExecutable().toString());
+ String debuggerId = item.getDebuggerID();
+ wc.setAttribute(PHPDebugCorePreferenceNames.PHP_DEBUGGER_ID,
+ debuggerId);
+ AbstractDebuggerConfiguration debuggerConfiguration = PHPDebuggersRegistry
+ .getDebuggerConfiguration(debuggerId);
+ wc.setAttribute(
+ PHPDebugCorePreferenceNames.CONFIGURATION_DELEGATE_CLASS,
+ debuggerConfiguration.getScriptLaunchDelegateClass());
+ if (item.getINILocation() != null) {
+ wc.setAttribute(IPHPDebugConstants.ATTR_INI_LOCATION, item
+ .getINILocation().toString());
+ } else {
+ wc.setAttribute(IPHPDebugConstants.ATTR_INI_LOCATION,
+ (String) null);
+ }
+ configuration = wc.doSave();
+ }
+ return configuration;
+ }
+
}