### Eclipse Workspace Patch 1.0 #P org.eclipse.wst.jsdt.debug.core Index: src/org/eclipse/wst/jsdt/debug/internal/core/launching/JavaScriptSourceLookupParticipant.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.core/src/org/eclipse/wst/jsdt/debug/internal/core/launching/JavaScriptSourceLookupParticipant.java,v retrieving revision 1.15 diff -u -r1.15 JavaScriptSourceLookupParticipant.java --- src/org/eclipse/wst/jsdt/debug/internal/core/launching/JavaScriptSourceLookupParticipant.java 10 Mar 2011 02:03:19 -0000 1.15 +++ src/org/eclipse/wst/jsdt/debug/internal/core/launching/JavaScriptSourceLookupParticipant.java 5 Dec 2011 18:28:35 -0000 @@ -12,13 +12,21 @@ import java.net.URI; import java.util.HashMap; +import java.util.Iterator; +import java.util.List; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant; import org.eclipse.debug.core.sourcelookup.ISourceContainer; +import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference; +import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame; +import org.eclipse.wst.jsdt.debug.core.model.IScript; import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin; +import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptDebugTarget; +import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptStackFrame; +import org.eclipse.wst.jsdt.debug.internal.core.model.Script; /** * Default source lookup participant @@ -45,6 +53,10 @@ * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant#findSourceElements(java.lang.Object) */ public Object[] findSourceElements(Object object) throws CoreException { + IFile file = resolveFile(object); + if(file != null && file.exists()) { + return new IFile[] {file}; + } ISourceContainer[] containers = getSourceContainers(); if(containers != null && containers.length > 0) { String name = getSourceName(object); @@ -61,7 +73,7 @@ //in the external source project and show it URI sourceURI = SourceLookup.getSourceURI(object); if (sourceURI != null) { - IFile file = (IFile) sourcemap.get(sourceURI); + file = (IFile) sourcemap.get(sourceURI); if(file != null && file.exists()) { return new IFile[] { file }; } @@ -72,6 +84,41 @@ } /** + * Tries to resolve the workspace local {@link IFile}(s) that match the underlying {@link ScriptReference} + * for either an {@link IJavaScriptStackFrame} or an {@link IScript} + * + * @param object the object to try and resolve the {@link IFile} from + * @return the corresponding {@link IFile} for the object or null if one could not be determined + * @since 1.4 + */ + IFile resolveFile(Object object) { + String uri = null; + JavaScriptDebugTarget target = null; + if(object instanceof JavaScriptStackFrame) { + JavaScriptStackFrame frame = (JavaScriptStackFrame) object; + uri = frame.getSourcePath(); + target = (JavaScriptDebugTarget) frame.getDebugTarget(); + } + if(object instanceof Script) { + Script script = (Script) object; + uri = script.sourceURI().toString(); + target = (JavaScriptDebugTarget) script.getDebugTarget(); + } + if(uri != null && target != null) { + List scripts = target.getVM().allScripts(); + for (Iterator i = scripts.iterator(); i.hasNext();) { + ScriptReference ref = (ScriptReference) i.next(); + if(uri.equals(ref.sourceURI().toString())) { + return JavaScriptDebugPlugin.getResolutionManager().getFile(ref); + } + } + } + return null; + } + + + + /** * Shows the source in an external editor * * @param sourceuri @@ -106,4 +153,4 @@ public boolean isFindDuplicates() { return true; } -} +} \ No newline at end of file Index: src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolutionManager.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.core/src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolutionManager.java,v retrieving revision 1.1 diff -u -r1.1 ScriptResolutionManager.java --- src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolutionManager.java 25 Nov 2011 17:36:58 -0000 1.1 +++ src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolutionManager.java 5 Dec 2011 18:28:35 -0000 @@ -143,7 +143,7 @@ file = null; IPath p = SourceLookup.getSourcePath(script.sourceURI()); IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(p); - if(res.getType() == IResource.FILE) { + if(res != null && res.getType() == IResource.FILE) { file = (IFile) res; } if(files.size() > 0) {