From 351d14e275f5d3341fcb50867fbdec627384695f Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Sun, 31 Aug 2014 00:14:51 +0400 Subject: [PATCH] Minor improvements of Eclipse debugger UI --- .../teavm/chromerdp/ChromeRDPDebugger.java | 6 ++-- .../java/org/teavm/chromerdp/RDPValue.java | 10 +++++- .../java/org/teavm/debugging/Debugger.java | 1 + .../main/java/org/teavm/debugging/Value.java | 4 +++ .../debugging/javascript/JavaScriptValue.java | 2 ++ .../eclipse/debugger/TeaVMDebugProcess.java | 9 +++-- .../eclipse/debugger/TeaVMDebugTarget.java | 34 +++++++++---------- .../TeaVMLaunchConfigurationDelegate.java | 2 +- .../TeaVMSourceLookupParticipant.java | 2 +- .../eclipse/debugger/TeaVMStackFrame.java | 5 +-- .../teavm/eclipse/debugger/TeaVMThread.java | 22 +++++++----- .../teavm/eclipse/debugger/TeaVMValue.java | 4 ++- 12 files changed, 63 insertions(+), 38 deletions(-) diff --git a/teavm-chrome-rdp/src/main/java/org/teavm/chromerdp/ChromeRDPDebugger.java b/teavm-chrome-rdp/src/main/java/org/teavm/chromerdp/ChromeRDPDebugger.java index 7890dd67e..5d3afe746 100644 --- a/teavm-chrome-rdp/src/main/java/org/teavm/chromerdp/ChromeRDPDebugger.java +++ b/teavm-chrome-rdp/src/main/java/org/teavm/chromerdp/ChromeRDPDebugger.java @@ -450,15 +450,15 @@ public class ChromeRDPDebugger implements JavaScriptDebugger, ChromeRDPExchangeC RDPValue value; switch (remoteValue.getType()) { case "undefined": - value = new RDPValue(this, "undefined", "undefined", null); + value = new RDPValue(this, "undefined", "undefined", null, false); break; case "object": case "function": - value = new RDPValue(this, null, remoteValue.getType(), remoteValue.getObjectId()); + value = new RDPValue(this, null, remoteValue.getType(), remoteValue.getObjectId(), true); break; default: value = new RDPValue(this, remoteValue.getValue().asText(), remoteValue.getType(), - remoteValue.getObjectId()); + remoteValue.getObjectId(), false); break; } diff --git a/teavm-chrome-rdp/src/main/java/org/teavm/chromerdp/RDPValue.java b/teavm-chrome-rdp/src/main/java/org/teavm/chromerdp/RDPValue.java index 4969e9c15..6918a9b48 100644 --- a/teavm-chrome-rdp/src/main/java/org/teavm/chromerdp/RDPValue.java +++ b/teavm-chrome-rdp/src/main/java/org/teavm/chromerdp/RDPValue.java @@ -32,12 +32,15 @@ public class RDPValue implements JavaScriptValue { private ChromeRDPDebugger debugger; private String objectId; private Map properties; + private boolean innerStructure; - public RDPValue(ChromeRDPDebugger debugger, String representation, String typeName, String objectId) { + public RDPValue(ChromeRDPDebugger debugger, String representation, String typeName, String objectId, + boolean innerStructure) { this.representation.set(representation == null && objectId == null ? "" : representation); this.typeName = typeName; this.debugger = debugger; this.objectId = objectId; + this.innerStructure = innerStructure; properties = objectId != null ? new RDPScope(debugger, objectId) : Collections.emptyMap(); } @@ -68,4 +71,9 @@ public class RDPValue implements JavaScriptValue { public Map getProperties() { return (Map)properties; } + + @Override + public boolean hasInnerStructure() { + return innerStructure; + } } diff --git a/teavm-core/src/main/java/org/teavm/debugging/Debugger.java b/teavm-core/src/main/java/org/teavm/debugging/Debugger.java index b3a5c4ddf..ee62ae067 100644 --- a/teavm-core/src/main/java/org/teavm/debugging/Debugger.java +++ b/teavm-core/src/main/java/org/teavm/debugging/Debugger.java @@ -119,6 +119,7 @@ public class Debugger { if (!exits) { break; } + enterMethod = true; } for (JavaScriptLocation successor : successors) { temporaryBreakpoints.add(javaScriptDebugger.createBreakpoint(successor)); diff --git a/teavm-core/src/main/java/org/teavm/debugging/Value.java b/teavm-core/src/main/java/org/teavm/debugging/Value.java index 22accbbf4..84ab319eb 100644 --- a/teavm-core/src/main/java/org/teavm/debugging/Value.java +++ b/teavm-core/src/main/java/org/teavm/debugging/Value.java @@ -47,4 +47,8 @@ public class Value { } return properties.get(); } + + public boolean hasInnerStructure() { + return jsValue.hasInnerStructure(); + } } diff --git a/teavm-core/src/main/java/org/teavm/debugging/javascript/JavaScriptValue.java b/teavm-core/src/main/java/org/teavm/debugging/javascript/JavaScriptValue.java index f1d3e9d8e..d1e069d31 100644 --- a/teavm-core/src/main/java/org/teavm/debugging/javascript/JavaScriptValue.java +++ b/teavm-core/src/main/java/org/teavm/debugging/javascript/JavaScriptValue.java @@ -27,4 +27,6 @@ public interface JavaScriptValue { String getClassName(); Map getProperties(); + + boolean hasInnerStructure(); } diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugProcess.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugProcess.java index 066ad68da..8e44bcaf2 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugProcess.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugProcess.java @@ -16,9 +16,11 @@ public class TeaVMDebugProcess implements IProcess { private Map attributes = new HashMap<>(); private ILaunch launch; private TeaVMStreamsProxy streamsProxy = new TeaVMStreamsProxy(); + private TeaVMDebugTarget debugTarget; - public TeaVMDebugProcess(ILaunch launch) { + public TeaVMDebugProcess(ILaunch launch, TeaVMDebugTarget debugTarget) { this.launch = launch; + this.debugTarget = debugTarget; } @Override @@ -28,16 +30,17 @@ public class TeaVMDebugProcess implements IProcess { @Override public boolean canTerminate() { - return false; + return debugTarget.canTerminate(); } @Override public boolean isTerminated() { - return false; + return debugTarget.isTerminated(); } @Override public void terminate() throws DebugException { + debugTarget.terminate(); } @Override diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugTarget.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugTarget.java index 8aa63a239..6aaf86f1c 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugTarget.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugTarget.java @@ -1,5 +1,7 @@ package org.teavm.eclipse.debugger; +import static org.teavm.eclipse.debugger.TeaVMDebugConstants.DEBUG_TARGET_ID; +import static org.teavm.eclipse.debugger.TeaVMDebugConstants.JAVA_BREAKPOINT_INSTALL_COUNT; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import org.eclipse.core.resources.IMarkerDelta; @@ -14,8 +16,7 @@ import org.teavm.chromerdp.ChromeRDPServer; import org.teavm.debugging.Breakpoint; import org.teavm.debugging.Debugger; import org.teavm.debugging.DebuggerListener; -import org.teavm.debugging.JavaScriptDebugger; -import static org.teavm.eclipse.debugger.TeaVMDebugConstants.*; +import org.teavm.debugging.javascript.JavaScriptDebugger; /** @@ -38,7 +39,7 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep { this.launch = launch; this.teavmDebugger = teavmDebugger; this.server = server; - this.process = new TeaVMDebugProcess(launch); + this.process = new TeaVMDebugProcess(launch, this); this.thread = new TeaVMThread(this); DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this); for (IBreakpoint breakpoint : DebugPlugin.getDefault().getBreakpointManager().getBreakpoints()) { @@ -101,7 +102,7 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep { @Override public boolean canTerminate() { - return true; + return !terminated; } @Override @@ -113,13 +114,10 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep { public void terminate() throws DebugException { terminated = true; server.stop(); - fireEvent(new DebugEvent(this, DebugEvent.RESUME)); - fireEvent(new DebugEvent(thread, DebugEvent.RESUME)); - fireEvent(new DebugEvent(process, DebugEvent.RESUME)); - fireEvent(new DebugEvent(this, DebugEvent.TERMINATE)); fireEvent(new DebugEvent(thread, DebugEvent.TERMINATE)); + fireEvent(new DebugEvent(thread, DebugEvent.CHANGE)); fireEvent(new DebugEvent(process, DebugEvent.TERMINATE)); - launch.removeProcess(process); + fireEvent(new DebugEvent(this, DebugEvent.TERMINATE)); } @Override @@ -155,12 +153,12 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep { @Override public boolean canResume() { - return true; + return !terminated; } @Override public boolean canSuspend() { - return true; + return !terminated; } @Override @@ -205,7 +203,7 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep { @Override public boolean canDisconnect() { - return true; + return !terminated && !isDisconnected(); } @Override @@ -230,12 +228,12 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep { @Override public IThread[] getThreads() throws DebugException { - return new IThread[] { thread }; + return !terminated ? new IThread[] { thread } : new IThread[0]; } @Override public boolean hasThreads() throws DebugException { - return true; + return !terminated; } @Override @@ -245,22 +243,22 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep { @Override public boolean canStepInto() { - return true; + return !terminated; } @Override public boolean canStepOver() { - return true; + return !terminated; } @Override public boolean canStepReturn() { - return true; + return !terminated; } @Override public boolean isStepping() { - return false; + return !terminated; } @Override diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMLaunchConfigurationDelegate.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMLaunchConfigurationDelegate.java index 4bdaca246..c93bd9ce9 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMLaunchConfigurationDelegate.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMLaunchConfigurationDelegate.java @@ -9,7 +9,7 @@ import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; import org.teavm.chromerdp.ChromeRDPDebugger; import org.teavm.chromerdp.ChromeRDPServer; import org.teavm.debugging.Debugger; -import org.teavm.debugging.URLDebugInformationProvider; +import org.teavm.debugging.information.URLDebugInformationProvider; /** * 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 cff14b8f8..5a2d1be27 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 @@ -2,7 +2,7 @@ package org.teavm.eclipse.debugger; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant; -import org.teavm.debugging.SourceLocation; +import org.teavm.debugging.information.SourceLocation; /** * diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStackFrame.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStackFrame.java index bd69abe6b..33e13d726 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStackFrame.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStackFrame.java @@ -22,16 +22,17 @@ public class TeaVMStackFrame implements IStackFrame { @Override public boolean canTerminate() { - return false; + return thread.canTerminate(); } @Override public boolean isTerminated() { - return false; + return thread.isTerminated(); } @Override public void terminate() throws DebugException { + thread.terminate(); } @Override diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMThread.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMThread.java index c1f8022ea..a892a043f 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMThread.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMThread.java @@ -73,7 +73,7 @@ public class TeaVMThread implements IThread { @Override public boolean canTerminate() { - return true; + return debugTarget.canTerminate(); } @Override @@ -94,12 +94,12 @@ public class TeaVMThread implements IThread { @Override public boolean canResume() { - return true; + return debugTarget.canResume(); } @Override public boolean canSuspend() { - return true; + return debugTarget.canSuspend(); } @Override @@ -119,22 +119,22 @@ public class TeaVMThread implements IThread { @Override public boolean canStepInto() { - return true; + return debugTarget.canStepInto(); } @Override public boolean canStepOver() { - return true; + return debugTarget.canStepOver(); } @Override public boolean canStepReturn() { - return true; + return debugTarget.canStepReturn(); } @Override public boolean isStepping() { - return false; + return debugTarget.isStepping(); } @Override @@ -184,18 +184,24 @@ public class TeaVMThread implements IThread { @Override public IStackFrame[] getStackFrames() throws DebugException { + if (isTerminated()) { + return new IStackFrame[0]; + } TeaVMStackFrame[] stackTrace = this.stackTrace; return stackTrace != null ? stackTrace.clone() : new IStackFrame[0]; } @Override public IStackFrame getTopStackFrame() { + if (isTerminated()) { + return null; + } TeaVMStackFrame[] stackTrace = this.stackTrace; return stackTrace != null && stackTrace.length > 0 ? stackTrace[0] : null; } @Override public boolean hasStackFrames() throws DebugException { - return stackTrace != null; + return !isTerminated() && stackTrace != null; } } diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMValue.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMValue.java index 351fea2af..893dc9fbd 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMValue.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMValue.java @@ -15,10 +15,12 @@ public class TeaVMValue implements IValue { TeaVMDebugTarget debugTarget; private Value teavmValue; private TeaVMVariablesHolder variablesHolder; + private boolean innerStructure; public TeaVMValue(TeaVMDebugTarget debugTarget, Value teavmValue) { this.debugTarget = debugTarget; this.teavmValue = teavmValue; + this.innerStructure = teavmValue.hasInnerStructure(); this.variablesHolder = new TeaVMVariablesHolder(debugTarget, teavmValue.getProperties().values()); } @@ -60,7 +62,7 @@ public class TeaVMValue implements IValue { @Override public boolean hasVariables() throws DebugException { - return true; + return innerStructure; } @Override