a few tweaks to prevent npes and a better debug test script
diff --git a/bundles/org.eclipse.e4.languages.javascript.debug.jsdi.rhino/src/org/eclipse/e4/languages/javascript/jsdi/rhino/request/BreakpointRequestImpl.java b/bundles/org.eclipse.e4.languages.javascript.debug.jsdi.rhino/src/org/eclipse/e4/languages/javascript/jsdi/rhino/request/BreakpointRequestImpl.java
index 8ac1082..a84a627 100644
--- a/bundles/org.eclipse.e4.languages.javascript.debug.jsdi.rhino/src/org/eclipse/e4/languages/javascript/jsdi/rhino/request/BreakpointRequestImpl.java
+++ b/bundles/org.eclipse.e4.languages.javascript.debug.jsdi.rhino/src/org/eclipse/e4/languages/javascript/jsdi/rhino/request/BreakpointRequestImpl.java
@@ -19,8 +19,7 @@
*
* @since 1.0
*/
-public class BreakpointRequestImpl extends EventRequestImpl implements
- BreakpointRequest {
+public class BreakpointRequestImpl extends EventRequestImpl implements BreakpointRequest {
private final Location location;
private ThreadReference thread;
@@ -41,8 +40,7 @@
/*
* (non-Javadoc)
*
- * @seeorg.eclipse.e4.languages.javascript.jsdi.request.BreakpointRequest#
- * addThreadFilter(org.eclipse.e4.languages.javascript.jsdi.ThreadReference)
+ * @seeorg.eclipse.e4.languages.javascript.jsdi.request.BreakpointRequest# addThreadFilter(org.eclipse.e4.languages.javascript.jsdi.ThreadReference)
*/
public synchronized void addThreadFilter(ThreadReference thread) {
checkDeleted();
@@ -61,8 +59,7 @@
/*
* (non-Javadoc)
*
- * @seeorg.eclipse.e4.languages.javascript.jsdi.request.BreakpointRequest#
- * addConditionFilter(java.lang.String)
+ * @seeorg.eclipse.e4.languages.javascript.jsdi.request.BreakpointRequest# addConditionFilter(java.lang.String)
*/
public synchronized void addConditionFilter(String condition) {
checkDeleted();
@@ -81,9 +78,7 @@
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.e4.languages.javascript.jsdi.request.BreakpointRequest#location
- * ()
+ * @see org.eclipse.e4.languages.javascript.jsdi.request.BreakpointRequest#location ()
*/
public Location location() {
return this.location;
@@ -92,9 +87,7 @@
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.e4.languages.javascript.rhino.jsdi.request.EventRequestImpl
- * #setEnabled(boolean)
+ * @see org.eclipse.e4.languages.javascript.rhino.jsdi.request.EventRequestImpl #setEnabled(boolean)
*/
public synchronized void setEnabled(boolean enabled) {
checkDeleted();
@@ -102,22 +95,18 @@
return;
if (enabled) {
- ScriptReferenceImpl scriptReferenceImpl = (ScriptReferenceImpl) this.location
- .scriptReference();
+ ScriptReferenceImpl scriptReferenceImpl = (ScriptReferenceImpl) this.location.scriptReference();
Long scriptId = scriptReferenceImpl.getScriptId();
Request request = new Request(JSONConstants.SETBREAKPOINT);
request.getArguments().put(JSONConstants.SCRIPT_ID, scriptId);
if (this.location.functionName() != null)
- request.getArguments().put(JSONConstants.FUNCTION,
- this.location.functionName());
+ request.getArguments().put(JSONConstants.FUNCTION, this.location.functionName());
else
- request.getArguments().put(JSONConstants.LINE,
- new Integer(this.location.lineNumber()));
+ request.getArguments().put(JSONConstants.LINE, new Integer(this.location.lineNumber()));
try {
Response response = this.vm.sendRequest(request);
- Map body = (Map) response.getBody().get(
- JSONConstants.BREAKPOINT);
+ Map body = (Map) response.getBody().get(JSONConstants.BREAKPOINT);
Number id = (Number) body.get(JSONConstants.BREAKPOINT_ID);
this.breakpointId = new Long(id.longValue());
} catch (TimeoutException e) {
@@ -129,25 +118,22 @@
}
} else {
Request request = new Request(JSONConstants.CLEARBREAKPOINT);
- request.getArguments().put(JSONConstants.BREAKPOINT_ID,
- this.breakpointId);
+ request.getArguments().put(JSONConstants.BREAKPOINT_ID, breakpointId);
try {
- this.vm.sendRequest(request);
- this.breakpointId = null;
+ vm.sendRequest(request);
} catch (TimeoutException e) {
// TODO log this
e.printStackTrace();
} catch (DisconnectException e) {
- // TODO log this
- e.printStackTrace();
+ // ignore
}
+ breakpointId = null;
}
this.enabled = enabled;
}
/**
- * Returns the id reported back from the underlying {@link VirtualMachine}
- * for this breakpoint
+ * Returns the id reported back from the underlying {@link VirtualMachine} for this breakpoint
*
* @return the id of the breakpoint
*/
diff --git a/bundles/org.eclipse.e4.languages.javascript.debug.rhino/src/org/eclipse/e4/languages/javascript/debug/rhino/ThreadData.java b/bundles/org.eclipse.e4.languages.javascript.debug.rhino/src/org/eclipse/e4/languages/javascript/debug/rhino/ThreadData.java
index e325d01..02445c6 100644
--- a/bundles/org.eclipse.e4.languages.javascript.debug.rhino/src/org/eclipse/e4/languages/javascript/debug/rhino/ThreadData.java
+++ b/bundles/org.eclipse.e4.languages.javascript.debug.rhino/src/org/eclipse/e4/languages/javascript/debug/rhino/ThreadData.java
@@ -7,8 +7,8 @@
import java.util.List;
import java.util.Map;
-import org.eclipse.e4.languages.javascript.debug.connect.JSONConstants;
import org.eclipse.e4.languages.javascript.debug.connect.EventPacket;
+import org.eclipse.e4.languages.javascript.debug.connect.JSONConstants;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.debug.DebugFrame;
import org.mozilla.javascript.debug.DebuggableScript;
@@ -44,8 +44,12 @@
public synchronized Object toJSON() {
Map result = new HashMap();
result.put(JSONConstants.THREAD_ID, threadId);
- Context top = (Context) contexts.getFirst();
- result.put(JSONConstants.STATE, top == null ? JSONConstants.RUNNING : ((ContextData) top.getDebuggerContextData()).getState());
+ if (contexts.isEmpty()) {
+ result.put(JSONConstants.STATE, JSONConstants.RUNNING);
+ } else {
+ Context top = (Context) contexts.getFirst();
+ result.put(JSONConstants.STATE, ((ContextData) top.getDebuggerContextData()).getState());
+ }
ArrayList contextIds = new ArrayList(contexts.size());
for (Iterator iterator = contexts.iterator(); iterator.hasNext();) {
Context context = (Context) iterator.next();
diff --git a/examples/sample.js.debug/META-INF/MANIFEST.MF b/examples/sample.js.debug/META-INF/MANIFEST.MF
index 9180c12..67d0683 100644
--- a/examples/sample.js.debug/META-INF/MANIFEST.MF
+++ b/examples/sample.js.debug/META-INF/MANIFEST.MF
@@ -4,7 +4,6 @@
Bundle-SymbolicName: sample.js.debug
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: sample.js.debug.Activator
-Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Import-Package: org.eclipse.e4.internal.languages.javascript,
org.eclipse.e4.languages.javascript,
diff --git a/examples/sample.js.debug/scripts/script.js b/examples/sample.js.debug/scripts/script.js
index ba70fb8..7cafc01 100644
--- a/examples/sample.js.debug/scripts/script.js
+++ b/examples/sample.js.debug/scripts/script.js
@@ -2,6 +2,7 @@
var clazz = Packages.javascript.dummy.Activator;
return clazz.TEST;
};
+var t = {a:7, b:"car"};
var v = test();
debugger;