1 package net.sourceforge.phpdt.internal.launching;
4 import java.io.FileWriter;
5 import java.io.IOException;
6 import java.util.ArrayList;
8 import net.sourceforge.phpdt.internal.ui.phpdocexport.JavadocExportMessages;
9 import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
11 import org.eclipse.core.runtime.CoreException;
12 import org.eclipse.core.runtime.IStatus;
13 import org.eclipse.core.runtime.Status;
14 import org.eclipse.debug.core.DebugPlugin;
15 import org.eclipse.debug.core.IDebugEventSetListener;
16 import org.eclipse.debug.core.ILaunch;
17 import org.eclipse.debug.core.ILaunchConfigurationType;
18 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
19 import org.eclipse.debug.core.ILaunchManager;
20 import org.eclipse.debug.core.Launch;
21 import org.eclipse.debug.core.model.IProcess;
22 import org.eclipse.debug.ui.IDebugUIConstants;
24 public class PHPInterpreter {
26 protected File installLocation;
28 public PHPInterpreter(File interpreter) {
29 installLocation = interpreter;
32 public File getInstallLocation() {
33 return installLocation;
36 public void setInstallLocation(File interpreter) {
37 installLocation = interpreter;
40 public String getCommand() {
41 return installLocation.toString();
44 private boolean executePHPProcess(String arguments, File workingDirectory, String[] env) {
45 Process process = null;
47 StringBuffer buf = new StringBuffer();
48 buf.append(getCommand() + " " + arguments);
49 process = Runtime.getRuntime().exec(buf.toString(), env, workingDirectory);
50 if (process != null) {
51 // construct a formatted command line for the process properties
53 // for (int i= 0; i < args.length; i++) {
54 // buf.append(args[i]);
58 ILaunchConfigurationWorkingCopy wc = null;
60 ILaunchConfigurationType lcType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(
61 PHPLaunchConfigurationAttribute.PHP_LAUNCH_CONFIGURATION_TYPE);
62 String name = "PHP Launcher"; //$NON-NLS-1$
63 wc = lcType.newInstance(null, name);
64 wc.setAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, true);
66 ILaunch newLaunch = new Launch(wc, ILaunchManager.RUN_MODE, null);
67 IProcess iprocess = DebugPlugin.newProcess(newLaunch, process, "PHP Process"); //$NON-NLS-1$
68 iprocess.setAttribute(IProcess.ATTR_CMDLINE, buf.toString());
69 iprocess.setAttribute(IProcess.ATTR_PROCESS_TYPE, PHPLaunchConfigurationAttribute.PHP_LAUNCH_PROCESS_TYPE);
71 DebugPlugin.getDefault().getLaunchManager().addLaunch(newLaunch);
73 } catch (CoreException e) {
79 } catch (IOException e) {
86 public Process exec(String arguments, File workingDirectory, String[] env) throws IOException {
87 return Runtime.getRuntime().exec(getCommand() + " " + arguments, env, workingDirectory);
88 // executePHPProcess(arguments, workingDirectory, env);
91 public boolean equals(Object other) {
92 if (other instanceof PHPInterpreter) {
93 PHPInterpreter otherInterpreter = (PHPInterpreter) other;
94 return installLocation.equals(otherInterpreter.getInstallLocation());