1) Made breakpoint working for direct script debugging (php cli) on Win systems.
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / launching / PHPSourceLookupParticipant.java
index 5397391..f913069 100644 (file)
@@ -1,5 +1,6 @@
 package net.sourceforge.phpeclipse.xdebug.php.launching;
 
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -12,12 +13,14 @@ import net.sourceforge.phpeclipse.xdebug.php.model.XDebugStackFrame;
 import org.eclipse.core.resources.IFile;
 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.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.MultiStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationType;
 import org.eclipse.debug.core.model.IStackFrame;
 import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
@@ -62,12 +65,21 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant
                String          local;
                List            pathMap;
                PathMapItem pmi = null;
+               Object      test;
+               IProject    project;
 
                projectName      = getDirector().getLaunchConfiguration().getAttribute (IXDebugConstants.ATTR_PHP_PROJECT, "");
-               pathMap          = getDirector().getLaunchConfiguration().getAttribute(IXDebugConstants.ATTR_PHP_PATHMAP, (List) null);
-
+               pathMap          = getDirector().getLaunchConfiguration().getAttribute (IXDebugConstants.ATTR_PHP_PATHMAP, (List) null);        
+               project          = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+               
+               if (getDirector ().getLaunchConfiguration ().getType ().getName ().equals ("PHP XDebug Script")) {
+                   remoteDebug = false;
+               }
+               else {
+                   remoteDebug = true;
+               }
+               
                fileName = ((XDebugStackFrame) stackFrame).getFullSourceName ();        // Get the filename as it is submitted by XDebug
-               //file     = "";
 
            if (remoteDebug) {                                                  // Is it a remote debugging session
                        path = new Path (fileName);                                     // Create a IPath object for the server side filename
@@ -76,7 +88,7 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant
                                if (remoteSourcePath.isPrefixOf (path)) {                   // Is the server side filename with the remote source path
                                        path        = path.removeFirstSegments (remoteSourcePath.matchingFirstSegments (path)); // Remove the remote source path
                                        //file        = path.toString ();                         // The filename without the remote source path
-                                       projectPath = (PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName).getLocation()); // Get the absolute project path
+                                       projectPath = (ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).getLocation()); // Get the absolute project path
 
                                        return (projectPath.append (path)).toOSString ();       // Return the filename as absolute client side path
                                }
@@ -104,7 +116,7 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant
                                                localPath = new Path (local);                       // Create new IPath object for the local/client side path
                                                path      = localPath.append (path);                // Prepend the project relative path to filename
 
-                                               projectPath = (PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName).getLocation()); // Get the absolute project path
+                                               projectPath = (ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).getLocation()); // Get the absolute project path
 
 //                                             return path;
                                                return (projectPath.append (path)).toString ();   // Return the filename as absolute client side path
@@ -138,13 +150,13 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant
                        return fileName;
 
            } else { // no remote debug
-/*
-               IWorkspaceRoot root = PHPLaunchingPlugin.getWorkspace().getRoot();
-               Path filePath = new Path(fileName);
-
+               IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+               IPath filePath = new Path(fileName);
+               
                if (root.getFileForLocation(filePath) == null) {
-                               IProject proj = root.getProject(projectName);
-                               IFile[] files = root.findFilesForLocation(filePath);
+                               IProject proj = root.getProject (projectName);
+                               IFile[] files = root.findFilesForLocation (filePath);
+                               
                                for (int i = 0; i < files.length; i++) {
                                        if (files[i].getProject().equals(proj)) {
                                                fileName = proj.getFullPath().append(files[i].getProjectRelativePath()).toOSString();
@@ -152,7 +164,13 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant
                                        }
                                }
                        }
-*/
+               else {
+                   projectPath = (ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).getLocation());
+                   filePath    = filePath.removeFirstSegments (projectPath.matchingFirstSegments (filePath));
+                   
+                   return filePath.toString ();
+               }
+               
                        return fileName;
            }
          }
@@ -160,7 +178,7 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant
        /* (non-Javadoc)
         * @see org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant#findSourceElements(java.lang.Object)
         */
-       public Object[] findSourceElements(Object object) throws CoreException {
+       public Object[] findSourceElements (Object object) throws CoreException {
                String name = null;
 
                if (object == null) {