Minor improvements of Eclipse debugger UI

This commit is contained in:
konsoletyper 2014-08-31 00:14:51 +04:00
parent 45181bece7
commit 351d14e275
12 changed files with 63 additions and 38 deletions

View File

@ -450,15 +450,15 @@ public class ChromeRDPDebugger implements JavaScriptDebugger, ChromeRDPExchangeC
RDPValue value; RDPValue value;
switch (remoteValue.getType()) { switch (remoteValue.getType()) {
case "undefined": case "undefined":
value = new RDPValue(this, "undefined", "undefined", null); value = new RDPValue(this, "undefined", "undefined", null, false);
break; break;
case "object": case "object":
case "function": case "function":
value = new RDPValue(this, null, remoteValue.getType(), remoteValue.getObjectId()); value = new RDPValue(this, null, remoteValue.getType(), remoteValue.getObjectId(), true);
break; break;
default: default:
value = new RDPValue(this, remoteValue.getValue().asText(), remoteValue.getType(), value = new RDPValue(this, remoteValue.getValue().asText(), remoteValue.getType(),
remoteValue.getObjectId()); remoteValue.getObjectId(), false);
break; break;
} }

View File

@ -32,12 +32,15 @@ public class RDPValue implements JavaScriptValue {
private ChromeRDPDebugger debugger; private ChromeRDPDebugger debugger;
private String objectId; private String objectId;
private Map<String, ? extends JavaScriptVariable> properties; private Map<String, ? extends JavaScriptVariable> 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.representation.set(representation == null && objectId == null ? "" : representation);
this.typeName = typeName; this.typeName = typeName;
this.debugger = debugger; this.debugger = debugger;
this.objectId = objectId; this.objectId = objectId;
this.innerStructure = innerStructure;
properties = objectId != null ? new RDPScope(debugger, objectId) : properties = objectId != null ? new RDPScope(debugger, objectId) :
Collections.<String, RDPLocalVariable>emptyMap(); Collections.<String, RDPLocalVariable>emptyMap();
} }
@ -68,4 +71,9 @@ public class RDPValue implements JavaScriptValue {
public Map<String, JavaScriptVariable> getProperties() { public Map<String, JavaScriptVariable> getProperties() {
return (Map<String, JavaScriptVariable>)properties; return (Map<String, JavaScriptVariable>)properties;
} }
@Override
public boolean hasInnerStructure() {
return innerStructure;
}
} }

View File

@ -119,6 +119,7 @@ public class Debugger {
if (!exits) { if (!exits) {
break; break;
} }
enterMethod = true;
} }
for (JavaScriptLocation successor : successors) { for (JavaScriptLocation successor : successors) {
temporaryBreakpoints.add(javaScriptDebugger.createBreakpoint(successor)); temporaryBreakpoints.add(javaScriptDebugger.createBreakpoint(successor));

View File

@ -47,4 +47,8 @@ public class Value {
} }
return properties.get(); return properties.get();
} }
public boolean hasInnerStructure() {
return jsValue.hasInnerStructure();
}
} }

View File

@ -27,4 +27,6 @@ public interface JavaScriptValue {
String getClassName(); String getClassName();
Map<String, JavaScriptVariable> getProperties(); Map<String, JavaScriptVariable> getProperties();
boolean hasInnerStructure();
} }

View File

@ -16,9 +16,11 @@ public class TeaVMDebugProcess implements IProcess {
private Map<String, String> attributes = new HashMap<>(); private Map<String, String> attributes = new HashMap<>();
private ILaunch launch; private ILaunch launch;
private TeaVMStreamsProxy streamsProxy = new TeaVMStreamsProxy(); private TeaVMStreamsProxy streamsProxy = new TeaVMStreamsProxy();
private TeaVMDebugTarget debugTarget;
public TeaVMDebugProcess(ILaunch launch) { public TeaVMDebugProcess(ILaunch launch, TeaVMDebugTarget debugTarget) {
this.launch = launch; this.launch = launch;
this.debugTarget = debugTarget;
} }
@Override @Override
@ -28,16 +30,17 @@ public class TeaVMDebugProcess implements IProcess {
@Override @Override
public boolean canTerminate() { public boolean canTerminate() {
return false; return debugTarget.canTerminate();
} }
@Override @Override
public boolean isTerminated() { public boolean isTerminated() {
return false; return debugTarget.isTerminated();
} }
@Override @Override
public void terminate() throws DebugException { public void terminate() throws DebugException {
debugTarget.terminate();
} }
@Override @Override

View File

@ -1,5 +1,7 @@
package org.teavm.eclipse.debugger; 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.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.core.resources.IMarkerDelta;
@ -14,8 +16,7 @@ import org.teavm.chromerdp.ChromeRDPServer;
import org.teavm.debugging.Breakpoint; import org.teavm.debugging.Breakpoint;
import org.teavm.debugging.Debugger; import org.teavm.debugging.Debugger;
import org.teavm.debugging.DebuggerListener; import org.teavm.debugging.DebuggerListener;
import org.teavm.debugging.JavaScriptDebugger; import org.teavm.debugging.javascript.JavaScriptDebugger;
import static org.teavm.eclipse.debugger.TeaVMDebugConstants.*;
/** /**
@ -38,7 +39,7 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep {
this.launch = launch; this.launch = launch;
this.teavmDebugger = teavmDebugger; this.teavmDebugger = teavmDebugger;
this.server = server; this.server = server;
this.process = new TeaVMDebugProcess(launch); this.process = new TeaVMDebugProcess(launch, this);
this.thread = new TeaVMThread(this); this.thread = new TeaVMThread(this);
DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this); DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
for (IBreakpoint breakpoint : DebugPlugin.getDefault().getBreakpointManager().getBreakpoints()) { for (IBreakpoint breakpoint : DebugPlugin.getDefault().getBreakpointManager().getBreakpoints()) {
@ -101,7 +102,7 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep {
@Override @Override
public boolean canTerminate() { public boolean canTerminate() {
return true; return !terminated;
} }
@Override @Override
@ -113,13 +114,10 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep {
public void terminate() throws DebugException { public void terminate() throws DebugException {
terminated = true; terminated = true;
server.stop(); 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.TERMINATE));
fireEvent(new DebugEvent(thread, DebugEvent.CHANGE));
fireEvent(new DebugEvent(process, DebugEvent.TERMINATE)); fireEvent(new DebugEvent(process, DebugEvent.TERMINATE));
launch.removeProcess(process); fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
} }
@Override @Override
@ -155,12 +153,12 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep {
@Override @Override
public boolean canResume() { public boolean canResume() {
return true; return !terminated;
} }
@Override @Override
public boolean canSuspend() { public boolean canSuspend() {
return true; return !terminated;
} }
@Override @Override
@ -205,7 +203,7 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep {
@Override @Override
public boolean canDisconnect() { public boolean canDisconnect() {
return true; return !terminated && !isDisconnected();
} }
@Override @Override
@ -230,12 +228,12 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep {
@Override @Override
public IThread[] getThreads() throws DebugException { public IThread[] getThreads() throws DebugException {
return new IThread[] { thread }; return !terminated ? new IThread[] { thread } : new IThread[0];
} }
@Override @Override
public boolean hasThreads() throws DebugException { public boolean hasThreads() throws DebugException {
return true; return !terminated;
} }
@Override @Override
@ -245,22 +243,22 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep {
@Override @Override
public boolean canStepInto() { public boolean canStepInto() {
return true; return !terminated;
} }
@Override @Override
public boolean canStepOver() { public boolean canStepOver() {
return true; return !terminated;
} }
@Override @Override
public boolean canStepReturn() { public boolean canStepReturn() {
return true; return !terminated;
} }
@Override @Override
public boolean isStepping() { public boolean isStepping() {
return false; return !terminated;
} }
@Override @Override

View File

@ -9,7 +9,7 @@ import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
import org.teavm.chromerdp.ChromeRDPDebugger; import org.teavm.chromerdp.ChromeRDPDebugger;
import org.teavm.chromerdp.ChromeRDPServer; import org.teavm.chromerdp.ChromeRDPServer;
import org.teavm.debugging.Debugger; import org.teavm.debugging.Debugger;
import org.teavm.debugging.URLDebugInformationProvider; import org.teavm.debugging.information.URLDebugInformationProvider;
/** /**
* *

View File

@ -2,7 +2,7 @@ package org.teavm.eclipse.debugger;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant; import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
import org.teavm.debugging.SourceLocation; import org.teavm.debugging.information.SourceLocation;
/** /**
* *

View File

@ -22,16 +22,17 @@ public class TeaVMStackFrame implements IStackFrame {
@Override @Override
public boolean canTerminate() { public boolean canTerminate() {
return false; return thread.canTerminate();
} }
@Override @Override
public boolean isTerminated() { public boolean isTerminated() {
return false; return thread.isTerminated();
} }
@Override @Override
public void terminate() throws DebugException { public void terminate() throws DebugException {
thread.terminate();
} }
@Override @Override

View File

@ -73,7 +73,7 @@ public class TeaVMThread implements IThread {
@Override @Override
public boolean canTerminate() { public boolean canTerminate() {
return true; return debugTarget.canTerminate();
} }
@Override @Override
@ -94,12 +94,12 @@ public class TeaVMThread implements IThread {
@Override @Override
public boolean canResume() { public boolean canResume() {
return true; return debugTarget.canResume();
} }
@Override @Override
public boolean canSuspend() { public boolean canSuspend() {
return true; return debugTarget.canSuspend();
} }
@Override @Override
@ -119,22 +119,22 @@ public class TeaVMThread implements IThread {
@Override @Override
public boolean canStepInto() { public boolean canStepInto() {
return true; return debugTarget.canStepInto();
} }
@Override @Override
public boolean canStepOver() { public boolean canStepOver() {
return true; return debugTarget.canStepOver();
} }
@Override @Override
public boolean canStepReturn() { public boolean canStepReturn() {
return true; return debugTarget.canStepReturn();
} }
@Override @Override
public boolean isStepping() { public boolean isStepping() {
return false; return debugTarget.isStepping();
} }
@Override @Override
@ -184,18 +184,24 @@ public class TeaVMThread implements IThread {
@Override @Override
public IStackFrame[] getStackFrames() throws DebugException { public IStackFrame[] getStackFrames() throws DebugException {
if (isTerminated()) {
return new IStackFrame[0];
}
TeaVMStackFrame[] stackTrace = this.stackTrace; TeaVMStackFrame[] stackTrace = this.stackTrace;
return stackTrace != null ? stackTrace.clone() : new IStackFrame[0]; return stackTrace != null ? stackTrace.clone() : new IStackFrame[0];
} }
@Override @Override
public IStackFrame getTopStackFrame() { public IStackFrame getTopStackFrame() {
if (isTerminated()) {
return null;
}
TeaVMStackFrame[] stackTrace = this.stackTrace; TeaVMStackFrame[] stackTrace = this.stackTrace;
return stackTrace != null && stackTrace.length > 0 ? stackTrace[0] : null; return stackTrace != null && stackTrace.length > 0 ? stackTrace[0] : null;
} }
@Override @Override
public boolean hasStackFrames() throws DebugException { public boolean hasStackFrames() throws DebugException {
return stackTrace != null; return !isTerminated() && stackTrace != null;
} }
} }

View File

@ -15,10 +15,12 @@ public class TeaVMValue implements IValue {
TeaVMDebugTarget debugTarget; TeaVMDebugTarget debugTarget;
private Value teavmValue; private Value teavmValue;
private TeaVMVariablesHolder variablesHolder; private TeaVMVariablesHolder variablesHolder;
private boolean innerStructure;
public TeaVMValue(TeaVMDebugTarget debugTarget, Value teavmValue) { public TeaVMValue(TeaVMDebugTarget debugTarget, Value teavmValue) {
this.debugTarget = debugTarget; this.debugTarget = debugTarget;
this.teavmValue = teavmValue; this.teavmValue = teavmValue;
this.innerStructure = teavmValue.hasInnerStructure();
this.variablesHolder = new TeaVMVariablesHolder(debugTarget, teavmValue.getProperties().values()); this.variablesHolder = new TeaVMVariablesHolder(debugTarget, teavmValue.getProperties().values());
} }
@ -60,7 +62,7 @@ public class TeaVMValue implements IValue {
@Override @Override
public boolean hasVariables() throws DebugException { public boolean hasVariables() throws DebugException {
return true; return innerStructure;
} }
@Override @Override