added StringAutoIndentStrategy for single quoted strings
[phpeclipse.git] / net.sourceforge.phpeclipse.launching / src / net / sourceforge / phpdt / internal / launching / DebuggerRunner.java
index 01e4f6c..461bf7b 100644 (file)
@@ -14,15 +14,14 @@ package net.sourceforge.phpdt.internal.launching;
 
 import java.util.Iterator;
 
+import net.sourceforge.phpdt.internal.core.JavaProject;
+import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy;
+import net.sourceforge.phpdt.internal.debug.core.model.PHPDebugTarget;
+
 import org.eclipse.core.resources.IProject;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import net.sourceforge.phpdt.internal.debug.core.model.PHPDebugTarget;
-import net.sourceforge.phpdt.internal.debug.core.Environment;
-import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy;
-import net.sourceforge.phpeclipse.resourcesview.PHPProject;
+//import net.sourceforge.phpeclipse.resourcesview.PHPProject;
 
 public class DebuggerRunner extends InterpreterRunner {
 
@@ -44,22 +43,9 @@ public class DebuggerRunner extends InterpreterRunner {
                }
                else
                {
-               
-                       env= setEnvironmentVariables(newPHPDBGProxy.getPort(), configuration.getAbsoluteFileName(), configuration.getInterpreter().getCommand());
-                       for(int i= 0; i < env.length; i++) {
-                               pos= env[i].indexOf("=");
-                               if(pos > -1) {
-                                       name= env[i].substring(0, pos);
-                                       value= env[i].substring(pos + 1);
-                               } else {
-                                       name= env[i];
-                                       value= "";
-                               }
-                               Environment.setenv(name, value);
-                       }
-                       // now enviroment settings is made with Environment class
-                       // because if new parameters are passed by array, doesn't inherit system vars
-                        process = super.run(configuration, launch, null);
+                       setEnvironmentVariables(configuration,newPHPDBGProxy.getPort());
+//                     env=configuration.getEnvironment();
+                       process = super.run(configuration, launch);
                        debugTarget.setProcess(process);
                }       
                launch.addDebugTarget(debugTarget);
@@ -67,14 +53,22 @@ public class DebuggerRunner extends InterpreterRunner {
                return process;
        }
        
-       protected String[] setEnvironmentVariables(int listenPort, String AbsoluteFileName, String interpreter) {
-               IPath FilePath= new Path(AbsoluteFileName);
-               String OSFilePath= FilePath.toOSString();
+       protected void setEnvironmentVariables(InterpreterRunnerConfiguration configuration,int listenPort) {
                String DBGSessID;
                String env[]= new String[18];
+               long id = Math.round(Math.random()*100000);
+               
 
-               DBGSessID = "DBGSESSID=0753972710000018@clienthost:" + listenPort;
-
+               DBGSessID = "DBGSESSID="+id+"@clienthost:" + listenPort;
+               configuration.addEnvironmentValue("HTTP_COOKIE",DBGSessID,false);
+/*             configuration.addEnvironmentValue("REDIRECT_URL",OSFilePath,true);
+               configuration.addEnvironmentValue("REQUEST_URI",OSFilePath,true);
+               configuration.addEnvironmentValue("PATH_INFO",OSFilePath,true);
+               configuration.addEnvironmentValue("PATH_TRANSLATED",OSFilePath,true);
+               configuration.addEnvironmentValue("SCRIPT_FILENAME",interpreter,true);
+               configuration.addEnvironmentValue("SERVER_PROTOCOL","HTTP / 1.1",true);
+*/
+/*             
                env[0]= "HTTP_COOKIE=" + DBGSessID;
                env[1]= "REDIRECT_QUERY_STRING=";
                env[2]= "REDIRECT_STATUS=200";
@@ -88,13 +82,13 @@ public class DebuggerRunner extends InterpreterRunner {
                env[10]= "GATEWAY_INTERFACE=CGI / 1.1";
                env[11]= "SERVER_PROTOCOL=HTTP / 1.1";
                env[12]= "REQUEST_METHOD=GET";
-               env[13]= "QUERY_STRING=";
+               env[13]= "QUERY_STRING=test=1";
                env[14]= "REQUEST_URI=" + OSFilePath;
                env[15]= "PATH_INFO=" + OSFilePath;
                env[16]= "PATH_TRANSLATED=" + OSFilePath;
                env[17]= "SystemRoot=" + Environment.getenv("SystemRoot");
-
-               return env;
+*/
+       //      return env;
        }
 
        protected String getDebugCommandLineArgument() {
@@ -104,7 +98,7 @@ public class DebuggerRunner extends InterpreterRunner {
        protected String renderLoadPath(InterpreterRunnerConfiguration configuration) {
                StringBuffer loadPath = new StringBuffer();
 
-               PHPProject project = configuration.getProject();
+               JavaProject project = configuration.getProject();
                addToLoadPath(loadPath, project.getProject());
 
                Iterator referencedProjects = project.getReferencedProjects().iterator();