diff --git a/teavm-eclipse/teavm-eclipse-plugin/META-INF/MANIFEST.MF b/teavm-eclipse/teavm-eclipse-plugin/META-INF/MANIFEST.MF index 06e466a44..ef26e5020 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/META-INF/MANIFEST.MF +++ b/teavm-eclipse/teavm-eclipse-plugin/META-INF/MANIFEST.MF @@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.8.0,4.0)", org.eclipse.jdt.launching;bundle-version="[3.6.1,4.0.0)", org.eclipse.ui.editors;bundle-version="[3.8.0,4.0.0)", org.eclipse.ui.ide;bundle-version="[3.8.2,4.0.0)", - org.eclipse.jdt.ui;bundle-version="[3.8.2,4.0.0)" + org.eclipse.jdt.ui;bundle-version="[3.8.2,4.0.0)", + org.eclipse.core.filesystem;bundle-version="1.4.0" Bundle-ClassPath: ., lib/asm-5.0.1.jar, lib/asm-commons-5.0.1.jar, diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSStackFrame.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSStackFrame.java index 6cdf57399..9927c0461 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSStackFrame.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSStackFrame.java @@ -136,12 +136,12 @@ public class TeaVMJSStackFrame implements IStackFrame { @Override public int getCharEnd() throws DebugException { - return callFrame.getLocation() != null ? callFrame.getLocation().getColumn() + 2 : -1; + return -1; } @Override public int getCharStart() throws DebugException { - return callFrame.getLocation() != null ? callFrame.getLocation().getColumn() + 1 : -1; + return -1; } @Override diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourceLookupParticipant.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourceLookupParticipant.java index 3e0e4db0c..c5007fd5b 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourceLookupParticipant.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourceLookupParticipant.java @@ -15,9 +15,13 @@ */ package org.teavm.eclipse.debugger; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Arrays; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant; import org.teavm.debugging.information.SourceLocation; +import org.teavm.debugging.javascript.JavaScriptLocation; /** * @@ -26,11 +30,38 @@ import org.teavm.debugging.information.SourceLocation; public class TeaVMSourceLookupParticipant extends AbstractSourceLookupParticipant { @Override public String getSourceName(Object object) throws CoreException { - if (!(object instanceof TeaVMStackFrame)) { + if (object instanceof TeaVMStackFrame) { + TeaVMStackFrame stackFrame = (TeaVMStackFrame)object; + SourceLocation location = stackFrame.callFrame.getLocation(); + return location != null ? location.getFileName() : null; + } else if (object instanceof TeaVMJSStackFrame) { + TeaVMJSStackFrame stackFrame = (TeaVMJSStackFrame)object; + JavaScriptLocation location = stackFrame.callFrame.getLocation(); + return location != null ? location.getScript() : null; + } else { return null; } - TeaVMStackFrame stackFrame = (TeaVMStackFrame)object; - SourceLocation location = stackFrame.callFrame.getLocation(); - return location != null ? location.getFileName() : null; + } + + @Override + public Object[] findSourceElements(Object object) throws CoreException { + Object[] result = super.findSourceElements(object); + if (object instanceof TeaVMJSStackFrame) { + TeaVMJSStackFrame stackFrame = (TeaVMJSStackFrame)object; + JavaScriptLocation location = stackFrame.getCallFrame().getLocation(); + if (location != null) { + URL url; + try { + url = new URL(location.getScript()); + } catch (MalformedURLException e) { + url = null; + } + if (url != null) { + result = Arrays.copyOf(result, result.length + 1); + result[result.length - 1] = url; + } + } + } + return result; } } diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java index 4a07aec41..3f7a42c15 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java @@ -15,6 +15,11 @@ */ package org.teavm.eclipse.debugger.ui; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.resources.IFile; import org.eclipse.debug.core.model.ILineBreakpoint; import org.eclipse.debug.core.model.IValue; @@ -23,6 +28,8 @@ import org.eclipse.debug.ui.IValueDetailListener; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.editors.text.EditorsUI; +import org.eclipse.ui.ide.FileStoreEditorInput; import org.eclipse.ui.part.FileEditorInput; import org.teavm.debugging.CallFrame; import org.teavm.debugging.javascript.JavaScriptCallFrame; @@ -41,6 +48,8 @@ public class TeaVMDebugModelPresentation extends LabelProvider implements IDebug public String getEditorId(IEditorInput input, Object element) { if (element instanceof IFile || element instanceof ILineBreakpoint) { return JavaUI.ID_CU_EDITOR; + } else if (element instanceof URL) { + return EditorsUI.DEFAULT_TEXT_EDITOR_ID; } return null; } @@ -53,6 +62,15 @@ public class TeaVMDebugModelPresentation extends LabelProvider implements IDebug if (element instanceof ILineBreakpoint) { return new FileEditorInput((IFile)((ILineBreakpoint)element).getMarker().getResource()); } + if (element instanceof URL) { + try { + URI uri = new URI(element.toString()); + IFileStore store = EFS.getLocalFileSystem().getStore(uri); + return new FileStoreEditorInput(store); + } catch (URISyntaxException e) { + return null; + } + } return null; }