Commiting more changes to fix RSE issues with PHP projects.
[phpeclipse.git] / net.sourceforge.phpeclipse.launching / src / net / sourceforge / phpdt / internal / launching / PHPSourceLocator.java
index 652a6c7..4898a06 100644 (file)
@@ -9,11 +9,12 @@ import net.sourceforge.phpeclipse.builder.ExternalEditorInput;
 import net.sourceforge.phpeclipse.builder.FileStorage;
 
 import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.model.IPersistableSourceLocator;
 import org.eclipse.debug.core.model.IStackFrame;
@@ -62,14 +63,7 @@ public class PHPSourceLocator implements IPersistableSourceLocator, ISourcePrese
        this.pathMap                  = configuration.getAttribute (PHPLaunchConfigurationAttribute.FILE_MAP, (Map)null);
        this.projectName              = configuration.getAttribute (PHPLaunchConfigurationAttribute.PROJECT_NAME, "");
 
-       if (Platform.getOS().equals(Platform.OS_WIN32)) {
-               this.remoteSourcePath = new Path ((configuration.getAttribute (PHPLaunchConfigurationAttribute.REMOTE_PATH, "")).toLowerCase());
-       }
-       else {
-               this.remoteSourcePath = new Path (configuration.getAttribute (PHPLaunchConfigurationAttribute.REMOTE_PATH, ""));
-       }
-
-//             system.os.name
+       this.remoteSourcePath = new Path (configuration.getAttribute (PHPLaunchConfigurationAttribute.REMOTE_PATH, ""));
   }
 
   /**
@@ -103,7 +97,7 @@ public class PHPSourceLocator implements IPersistableSourceLocator, ISourcePrese
                        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 = (PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName).getFullPath()); // Get the absolute project path
 
                                return (projectPath.append (path)).toOSString ();       // Return the filename as absolute client side path
                        }
@@ -124,7 +118,7 @@ public class PHPSourceLocator implements IPersistableSourceLocator, ISourcePrese
                                        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 = (PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName).getFullPath()); // Get the absolute project path
 
                                        return (projectPath.append (path)).toOSString ();       // Return the filename as absolute client side path
                                }
@@ -151,7 +145,23 @@ public class PHPSourceLocator implements IPersistableSourceLocator, ISourcePrese
                }
 
                return fileName;
-       } else {
+
+    } else {
+
+       IWorkspaceRoot root = PHPLaunchingPlugin.getWorkspace().getRoot();
+       Path filePath = new Path(fileName);
+
+       if (root.getFileForLocation(filePath) == null) {
+                       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();
+                                       break;
+                               }
+                       }
+               }
+
                return fileName;
     }
   }