From 1c9fa555b74e8dabc37b06845f4a63439767334f Mon Sep 17 00:00:00 2001 From: cperkonig Date: Wed, 11 Feb 2004 22:22:40 +0000 Subject: [PATCH] maps remote files to local files --- .../phpdt/internal/debug/ui/PHPSourceLocator.java | 49 ++++++++++++++++++- 1 files changed, 46 insertions(+), 3 deletions(-) diff --git a/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/PHPSourceLocator.java b/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/PHPSourceLocator.java index 07d0841..c61f815 100644 --- a/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/PHPSourceLocator.java +++ b/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/PHPSourceLocator.java @@ -1,5 +1,7 @@ package net.sourceforge.phpdt.internal.debug.ui; +import java.util.Map; + import net.sourceforge.phpdt.internal.debug.core.model.PHPStackFrame; import net.sourceforge.phpdt.internal.launching.PHPLaunchConfigurationAttribute; import net.sourceforge.phpeclipse.PHPeclipsePlugin; @@ -11,13 +13,14 @@ 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.boot.BootLoader; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.model.IPersistableSourceLocator; import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.debug.ui.ISourcePresentation; -import org.eclipse.ui.IEditorDescriptor; +//import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorRegistry; +//import org.eclipse.ui.IEditorRegistry; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; @@ -26,6 +29,10 @@ import org.eclipse.ui.part.FileEditorInput; public class PHPSourceLocator implements IPersistableSourceLocator, ISourcePresentation { private String absoluteWorkingDirectory; + private Map fileMap = null; + private boolean remoteDebug; + private IPath remotePath; + private String projectName; public PHPSourceLocator() { @@ -52,13 +59,47 @@ public class PHPSourceLocator implements IPersistableSourceLocator, ISourcePrese */ public void initializeDefaults(ILaunchConfiguration configuration) throws CoreException { this.absoluteWorkingDirectory = configuration.getAttribute(PHPLaunchConfigurationAttribute.WORKING_DIRECTORY, ""); + this.remoteDebug=configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG,false); + this.fileMap = configuration.getAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, (Map)null); + this.projectName =configuration.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, ""); + + if (BootLoader.getOS().equals(BootLoader.OS_WIN32)) + this.remotePath= new Path((configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, "")).toLowerCase()); + else + this.remotePath= new Path(configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, "")); + +// system.os.name + } /** * @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(IStackFrame) */ public Object getSourceElement(IStackFrame stackFrame) { - return ((PHPStackFrame) stackFrame).getFileName(); + + String key=((PHPStackFrame) stackFrame).getFileName(); + + + String file=""; + + if (remoteDebug) + { + IPath path = new Path(key); + if (remotePath.isPrefixOf(path)) + { + IPath projectPath; + path=path.removeFirstSegments(remotePath.matchingFirstSegments(path)); + file=path.toString(); + projectPath=(PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName).getLocation()); + file=(projectPath.append(path)).toString(); + } +// file=(String)(fileMap.get(key)); + } else + { + file=key; + } + + return file; } /** @@ -78,6 +119,8 @@ public class PHPSourceLocator implements IPersistableSourceLocator, ISourcePrese IWorkbenchWindow window = workbench.getWorkbenchWindows()[0]; IWorkbenchPage page = window.getActivePage(); IPath path = new Path(filename); + + // If the file exists in the workspace, open it IFile eclipseFile = PHPeclipsePlugin.getWorkspace().getRoot().getFileForLocation(path); -- 1.7.1