null
+ * @param path the path to match against the source {@link URI} - never null
+ *
+ * @return true
if the source {@link URI} of the given {@link ScriptReference} is considered to match the given {@link IPath}, false
otherwise.
+ */
+ public boolean matches(ScriptReference script, IPath path);
+
+ /**
+ * This method is used to find the workspace {@link IFile} that corresponds to the source {@link URI} from the given {@link ScriptReference}.
+ * null
. The result will be checked for existence.
+ *
+ * @param script the {@link ScriptReference} to find the {@link IFile} for
+ * @return the {@link IFile} for the {@link ScriptReference} or null
+ */
+ public IFile getFile(ScriptReference script);
+}
Index: src/org/eclipse/wst/jsdt/debug/core/model/ScriptResolver.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/core/model/ScriptResolver.java
diff -N src/org/eclipse/wst/jsdt/debug/core/model/ScriptResolver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/core/model/ScriptResolver.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.core.model;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
+
+/**
+ * This is the default base class for all {@link IScriptResolver}s
+ * null
. If the project
* is not accessible it can be created by passing true
in for the create parameter.
*
@@ -130,7 +147,7 @@
* @return true
if the path is in the external source project, false
otherwise
*/
public static boolean isExternalSource(IPath path) {
- if(path.segment(0).equals(Messages.external_javascript_source)) {
+ if(Messages.external_javascript_source.equals(path.segment(0))) {
return true;
}
//try to look it up. The name might not have the project name in it
@@ -169,7 +186,7 @@
if(prefmanager != null) {
prefmanager.stop();
}
- if(new InstanceScope().getNode(PLUGIN_ID).getBoolean(Constants.DELETE_EXT_PROJECT_ON_EXIT, false)) {
+ if(InstanceScope.INSTANCE.getNode(PLUGIN_ID).getBoolean(Constants.DELETE_EXT_PROJECT_ON_EXIT, false)) {
if(extSrcProject != null && extSrcProject.exists()) {
extSrcProject.delete(true, null);
}
Index: src/org/eclipse/wst/jsdt/debug/internal/core/JavaScriptDebugPreferenceInitializer.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.core/src/org/eclipse/wst/jsdt/debug/internal/core/JavaScriptDebugPreferenceInitializer.java,v
retrieving revision 1.3
diff -u -r1.3 JavaScriptDebugPreferenceInitializer.java
--- src/org/eclipse/wst/jsdt/debug/internal/core/JavaScriptDebugPreferenceInitializer.java 27 Oct 2010 19:12:39 -0000 1.3
+++ src/org/eclipse/wst/jsdt/debug/internal/core/JavaScriptDebugPreferenceInitializer.java 4 Jan 2012 20:13:15 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -32,7 +32,7 @@
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() {
- IEclipsePreferences prefs = new DefaultScope().getNode(JavaScriptDebugPlugin.PLUGIN_ID);
+ IEclipsePreferences prefs = DefaultScope.INSTANCE.getNode(JavaScriptDebugPlugin.PLUGIN_ID);
if(prefs != null) {
prefs.putBoolean(Constants.SUSPEND_ON_ALL_SCRIPT_LOADS, false);
prefs.putBoolean(Constants.SUSPEND_ON_THROWN_EXCEPTION, true);
Index: src/org/eclipse/wst/jsdt/debug/internal/core/JavaScriptPreferencesManager.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.core/src/org/eclipse/wst/jsdt/debug/internal/core/JavaScriptPreferencesManager.java,v
retrieving revision 1.10
diff -u -r1.10 JavaScriptPreferencesManager.java
--- src/org/eclipse/wst/jsdt/debug/internal/core/JavaScriptPreferencesManager.java 25 Feb 2011 20:02:29 -0000 1.10
+++ src/org/eclipse/wst/jsdt/debug/internal/core/JavaScriptPreferencesManager.java 4 Jan 2012 20:13:15 -0000
@@ -88,7 +88,7 @@
* Starts the manager
*/
public void start() {
- IEclipsePreferences node = new InstanceScope().getNode(JavaScriptDebugPlugin.PLUGIN_ID);
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(JavaScriptDebugPlugin.PLUGIN_ID);
node.addPreferenceChangeListener(this);
StartJob job = new StartJob(node.getBoolean(Constants.SUSPEND_ON_ALL_SCRIPT_LOADS, false),
node.getBoolean(Constants.SUSPEND_ON_THROWN_EXCEPTION, true));
@@ -101,7 +101,7 @@
* Stops the manager and clean up
*/
public void stop() {
- IEclipsePreferences node = new InstanceScope().getNode(JavaScriptDebugPlugin.PLUGIN_ID);
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(JavaScriptDebugPlugin.PLUGIN_ID);
if(node != null) {
node.removePreferenceChangeListener(this);
}
Index: src/org/eclipse/wst/jsdt/debug/internal/core/TextUtils.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.core/src/org/eclipse/wst/jsdt/debug/internal/core/TextUtils.java,v
retrieving revision 1.1
diff -u -r1.1 TextUtils.java
--- src/org/eclipse/wst/jsdt/debug/internal/core/TextUtils.java 29 Jun 2010 19:18:14 -0000 1.1
+++ src/org/eclipse/wst/jsdt/debug/internal/core/TextUtils.java 4 Jan 2012 20:13:15 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,10 +31,12 @@
*/
public static String shortenText(String string, int threshold) {
int length = string.length();
- if(length > threshold) {
+ if (length > threshold) {
int chomp = length - threshold + 3;
int begin = Math.round(threshold/2)-1;
- return string.replaceAll(string.substring(begin, begin+chomp), "..."); //$NON-NLS-1$
+ StringBuffer buff = new StringBuffer();
+ buff.append(string.substring(0, begin)).append("...").append(string.substring(begin+chomp)); //$NON-NLS-1$
+ return buff.toString();
}
return string;
}
Index: src/org/eclipse/wst/jsdt/debug/internal/core/breakpoints/JavaScriptBreakpoint.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.core/src/org/eclipse/wst/jsdt/debug/internal/core/breakpoints/JavaScriptBreakpoint.java,v
retrieving revision 1.18
diff -u -r1.18 JavaScriptBreakpoint.java
--- src/org/eclipse/wst/jsdt/debug/internal/core/breakpoints/JavaScriptBreakpoint.java 21 Mar 2011 14:08:20 -0000 1.18
+++ src/org/eclipse/wst/jsdt/debug/internal/core/breakpoints/JavaScriptBreakpoint.java 4 Jan 2012 20:13:15 -0000
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.wst.jsdt.debug.internal.core.breakpoints;
-import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -20,7 +19,6 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -43,7 +41,6 @@
import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel;
import org.eclipse.wst.jsdt.debug.internal.core.Constants;
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
-import org.eclipse.wst.jsdt.debug.internal.core.Messages;
import org.eclipse.wst.jsdt.debug.internal.core.launching.SourceLookup;
import org.eclipse.wst.jsdt.debug.internal.core.model.IJavaScriptEventListener;
import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptDebugTarget;
@@ -61,7 +58,7 @@
* The total count of all of the targets this breakpoint is installed in
*/
public static final String INSTALL_COUNT = JavaScriptDebugPlugin.PLUGIN_ID + ".install_count"; //$NON-NLS-1$
-
+
private HashSet targets = null;
private HashMap requestspertarget = new HashMap(4);
@@ -165,8 +162,9 @@
boolean success = true;
for (Iterator iter = scripts.iterator(); iter.hasNext();) {
ScriptReference script = (ScriptReference) iter.next();
- if (scriptPathMatches(script))
+ if (JavaScriptDebugPlugin.getResolutionManager().matches(script, new Path(getScriptPath()))) {
success &= createRequest(target, script);
+ }
}
if (success) {
if (this.targets == null) {
@@ -437,8 +435,9 @@
ScriptReference script = sevent.script();
try {
- if (scriptPathMatches(script))
+ if (JavaScriptDebugPlugin.getResolutionManager().matches(script, new Path(getScriptPath()))) {
createRequest(target, script);
+ }
} catch (CoreException ce) {
JavaScriptDebugPlugin.log(ce);
}
@@ -446,26 +445,6 @@
return true;
}
- protected boolean scriptPathMatches(ScriptReference script) throws CoreException {
- URI sourceURI = script.sourceURI();
- if ("file".equals(sourceURI.getScheme())) {//$NON-NLS-1$
- IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- URI workspaceURI = workspaceRoot.getRawLocationURI();
- sourceURI = workspaceURI.relativize(sourceURI);
- }
- String path = getScriptPath();
- IPath spath = new Path(path);
- if(spath.segment(0).equals(Messages.external_javascript_source)) {
- spath = spath.removeFirstSegments(1).makeAbsolute();
- }
- //XXX use the same algorithm we use to save the source to 'encode' the source URI for comparison
- IPath uripath = SourceLookup.getSourcePath(sourceURI);
- if(uripath != null) {
- uripath = uripath.makeAbsolute();
- }
- return spath.equals(uripath);
- }
-
/**
* Returns if the type names for the breakpoint are equal or not. Two null
type names are considered to be equal.
*
Index: src/org/eclipse/wst/jsdt/debug/internal/core/breakpoints/JavaScriptLoadBreakpoint.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.core/src/org/eclipse/wst/jsdt/debug/internal/core/breakpoints/JavaScriptLoadBreakpoint.java,v
retrieving revision 1.14
diff -u -r1.14 JavaScriptLoadBreakpoint.java
--- src/org/eclipse/wst/jsdt/debug/internal/core/breakpoints/JavaScriptLoadBreakpoint.java 24 May 2010 22:37:40 -0000 1.14
+++ src/org/eclipse/wst/jsdt/debug/internal/core/breakpoints/JavaScriptLoadBreakpoint.java 4 Jan 2012 20:13:15 -0000
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.wst.jsdt.debug.internal.core.breakpoints;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Map;
@@ -19,11 +20,13 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpointParticipant;
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLoadBreakpoint;
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
import org.eclipse.wst.jsdt.debug.core.jsdi.event.Event;
import org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet;
import org.eclipse.wst.jsdt.debug.core.jsdi.event.ScriptLoadEvent;
@@ -101,6 +104,9 @@
JavaScriptThread thread = target.findThread((sevent).thread());
if (thread != null) {
if(isGlobalLoadSuspend()) {
+ if(!supportsGlobalSuspend(target.getVM())) {
+ return true;
+ }
JavaScriptPreferencesManager.setGlobalSuspendOn(script.sourceURI().toString());
thread.addBreakpoint(this);
return false;
@@ -124,7 +130,7 @@
*/
private boolean isMatchedScriptLoadSuspend(ScriptReference script, JavaScriptThread thread, boolean suspendVote) {
try {
- if (scriptPathMatches(script)) {
+ if (JavaScriptDebugPlugin.getResolutionManager().matches(script, new Path(getScriptPath()))) {
int vote = thread.suspendForScriptLoad(this, script, suspendVote);
return (vote & IJavaScriptBreakpointParticipant.SUSPEND) > 0 || vote == IJavaScriptBreakpointParticipant.DONT_CARE;
}
@@ -136,6 +142,26 @@
}
/**
+ * Use reflection hack to opt-out of global suspend
+ *
+ * @param vm
+ * @return true
if the backing {@link VirtualMachine} supports global suspend
+ */
+ boolean supportsGlobalSuspend(VirtualMachine vm) {
+ boolean supports = true;
+ try {
+ //TODO consider supportsSuspendOnScriptLoads for future VirtualMachine extensions
+ Method m = vm.getClass().getMethod("supportsSuspendOnScriptLoads", new Class[0]); //$NON-NLS-1$
+ Boolean b = (Boolean) m.invoke(vm, null);
+ supports = b.booleanValue();
+ } catch (Exception e) {
+ //assume the method is not there / problematic
+ supports = true;
+ }
+ return supports;
+ }
+
+ /**
* Returns if this breakpoint supports global suspend
*
* @return true
if we should suspend on all script loads false
otherwise
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 4 Jan 2012 20:13:15 -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/launching/SourceLookup.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.core/src/org/eclipse/wst/jsdt/debug/internal/core/launching/SourceLookup.java,v
retrieving revision 1.9
diff -u -r1.9 SourceLookup.java
--- src/org/eclipse/wst/jsdt/debug/internal/core/launching/SourceLookup.java 15 Mar 2011 14:48:52 -0000 1.9
+++ src/org/eclipse/wst/jsdt/debug/internal/core/launching/SourceLookup.java 4 Jan 2012 20:13:15 -0000
@@ -40,7 +40,7 @@
public final class SourceLookup {
public static final QualifiedName SCRIPT_URL = new QualifiedName(JavaScriptCore.PLUGIN_ID, "scriptURL"); //$NON-NLS-1$
-
+ public static final IPath TOP_LEVEL_PATH = new Path("/"); //$NON-NLS-1$
/**
* Returns the name of the source object to lookup or null
* if the object is not a {@link IJavaScriptStackFrame} or an {@link IScript}
@@ -50,11 +50,21 @@
* @since 1.1
*/
public static String getSourceName(Object object) {
+ String name = null;
if (object instanceof IJavaScriptStackFrame) {
- return ((IJavaScriptStackFrame) object).getSourceName();
+ name = ((IJavaScriptStackFrame) object).getSourceName();
}
if(object instanceof IScript) {
- return URIUtil.lastSegment(((IScript)object).sourceURI());
+ name = URIUtil.lastSegment(((IScript)object).sourceURI());
+ }
+ if(name != null) {
+ if(new Path(name).getFileExtension() == null) {
+ //append .js, there is no case where we would look up a file with no extension from a script node
+ StringBuffer buf = new StringBuffer(name.length()+3);
+ buf.append(name).append('.').append(Constants.JS_EXTENSION);
+ return buf.toString();
+ }
+ return name;
}
return null;
}
@@ -133,7 +143,7 @@
else {
file = doFormat(file, source);
}
- file.setPersistentProperty(SCRIPT_URL, sourceuri.getPath());
+ file.setPersistentProperty(SCRIPT_URL, sourceuri.toString());
return file;
}
return null;
@@ -158,7 +168,7 @@
return null;
}
if(uripath.trim().equals("/")) { //$NON-NLS-1$
- uripath = "page.js"; //$NON-NLS-1$
+ uripath = "index.htm"; //$NON-NLS-1$
}
String host = sourceuri.getHost();
IPath path = null;
@@ -237,7 +247,7 @@
newpath = newpath.append((String) segments.get(i));
}
String ext = newpath.getFileExtension();
- if(ext == null || !Constants.JS_EXTENSION.equals(ext)) {
+ if(ext == null && !Constants.JS_EXTENSION.equals(ext)) {
newpath = newpath.addFileExtension(Constants.JS_EXTENSION);
}
return newpath;
Index: src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptStackFrame.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.core/src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptStackFrame.java,v
retrieving revision 1.10
diff -u -r1.10 JavaScriptStackFrame.java
--- src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptStackFrame.java 1 Nov 2010 18:08:23 -0000 1.10
+++ src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptStackFrame.java 4 Jan 2012 20:13:15 -0000
@@ -102,7 +102,7 @@
* @see org.eclipse.debug.core.model.IStackFrame#getName()
*/
public String getName() throws DebugException {
- return this.stackFrame.location().scriptReference().sourceURI().toString();
+ return this.stackFrame.location().functionName();
}
/*
Index: src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptThread.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.core/src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptThread.java,v
retrieving revision 1.32
diff -u -r1.32 JavaScriptThread.java
--- src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptThread.java 25 Oct 2010 15:05:06 -0000 1.32
+++ src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptThread.java 4 Jan 2012 20:13:15 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -848,6 +848,9 @@
if(event instanceof SuspendEvent) {
if(canSuspend()) {
if(this.thread.equals(((SuspendEvent)event).thread())) {
+ if(pendingstep != null) {
+ pendingstep.abort();
+ }
markSuspended();
fireSuspendEvent(DebugEvent.UNSPECIFIED);
return false;
@@ -868,6 +871,8 @@
if(pendingstep != null) {
//we need to handle the case where a step has caused a resume and no StepEvent has been sent
pendingstep.abort();
+ //send an event as we have stepped to resume
+ fireResumeEvent(DebugEvent.UNSPECIFIED);
}
}
return true;
Index: src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptValue.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.core/src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptValue.java,v
retrieving revision 1.16
diff -u -r1.16 JavaScriptValue.java
--- src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptValue.java 26 Nov 2010 18:16:08 -0000 1.16
+++ src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptValue.java 4 Jan 2012 20:13:15 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -46,6 +46,8 @@
*/
public class JavaScriptValue extends JavaScriptDebugElement implements IJavaScriptValue {
+ public static final IVariable[] NO_VARIABLES = new IVariable[0];
+
/**
* the '[proto]' value
*/
@@ -206,7 +208,7 @@
*/
public synchronized IVariable[] getVariables() throws DebugException {
if (!hasVariables()) {
- return null;
+ return NO_VARIABLES;
}
if (this.properties == null) {
final ObjectReference reference = (ObjectReference) this.value;
Index: src/org/eclipse/wst/jsdt/debug/internal/core/model/ModelMessages.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.core/src/org/eclipse/wst/jsdt/debug/internal/core/model/ModelMessages.java,v
retrieving revision 1.9
diff -u -r1.9 ModelMessages.java
--- src/org/eclipse/wst/jsdt/debug/internal/core/model/ModelMessages.java 28 Feb 2011 18:05:11 -0000 1.9
+++ src/org/eclipse/wst/jsdt/debug/internal/core/model/ModelMessages.java 4 Jan 2012 20:13:15 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Index: src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolutionManager.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolutionManager.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolutionManager.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolutionManager.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.core.model;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
+import org.eclipse.wst.jsdt.debug.core.model.IScriptResolver;
+import org.eclipse.wst.jsdt.debug.internal.core.Constants;
+import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
+import org.eclipse.wst.jsdt.debug.internal.core.Messages;
+import org.eclipse.wst.jsdt.debug.internal.core.launching.SourceLookup;
+
+/**
+ * Handles the collection of {@link ScriptResolverExtension}s and provide useful utilities for path / script handling
+ * @since 3.4
+ */
+public final class ScriptResolutionManager {
+
+ static IScriptResolver[] NO_RESOLVERS = new IScriptResolver[0];
+ ListenerList resolvers = null;
+
+ /**
+ * This is a convenience method that consults all of the registered {@link IScriptResolver}s.
+ * true
iff any one (or all) of the {@link IScriptResolver}s returns true
or
+ * the default matching algorithm returns true
- which is consulted after all extensions have been asked.
+ * @param script the script to check
+ * @param path the path to compare against
+ * @return true
if any one (or all) of the {@link IScriptResolver}s return true
, false
otherwise
+ */
+ public boolean matches(ScriptReference script, IPath path) {
+ IScriptResolver[] res = getResolvers();
+ for (int i = 0; i < res.length; i++) {
+ if(res[i].matches(script, path)) {
+ return true;
+ }
+ }
+ //no extensions matched, fall-back to the old way
+ return isMatch(script, path);
+ }
+
+ boolean isMatch(ScriptReference script, IPath path) {
+ if(guessScriptMatches(script, path)) {
+ return true;
+ }
+ //no luck, try an exact match
+ URI sourceURI = script.sourceURI();
+ if (URIUtil.isFileURI(sourceURI)) {
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ URI workspaceURI = workspaceRoot.getRawLocationURI();
+ sourceURI = workspaceURI.relativize(sourceURI);
+ }
+ IPath spath = path;
+ if(spath.segmentCount() > 0 && spath.segment(0).equals(Messages.external_javascript_source)) {
+ spath = spath.removeFirstSegments(1).makeAbsolute();
+ }
+ IPath uripath = SourceLookup.getSourcePath(sourceURI);
+ if(uripath != null) {
+ uripath = uripath.makeAbsolute();
+ }
+ return spath.equals(uripath);
+ }
+
+ /**
+ * Guesses if the paths are considered equal by walking backward from the last segment of the paths and counting the matching segments.
+ * The paths are guessed to be equal iff any two or more segments match in order.
+ *
+ * @param script the {@link ScriptReference}
+ * @param path the path to compare
+ * @return true
if the paths 'match', false
otherwise
+ */
+ boolean guessScriptMatches(ScriptReference script, IPath path) {
+ IPath newpath = path.makeAbsolute();
+ IPath uri = new Path(script.sourceURI().getPath());
+ if(SourceLookup.TOP_LEVEL_PATH.equals(newpath) && SourceLookup.TOP_LEVEL_PATH.equals(uri)) {
+ return true;
+ }
+ uri = uri.makeAbsolute();
+ int matched_segments = 0;
+ int last = uri.segmentCount()-1;
+ for(int i = newpath.segmentCount()-1; i > -1; i--) {
+ if(last < 0) {
+ break;
+ }
+ if(newpath.segment(i).equals(uri.segment(last))) {
+ matched_segments++;
+ last--;
+ }
+ }
+ return matched_segments > 1;
+ }
+
+ /**
+ * Convenience method to consult all of the registered {@link IScriptResolver}s for the matching {@link IFile}.
+ * null
the first {@link IFile}
+ * will be selected.null
+ */
+ public IFile getFile(ScriptReference script) {
+ IScriptResolver[] resolvers = getResolvers();
+ ArrayList files = new ArrayList();
+ IFile file = null;
+ for (int i = 0; i < resolvers.length; i++) {
+ file = resolvers[i].getFile(script);
+ if(file != null) {
+ if(files.contains(file)) {
+ return file;
+ }
+ files.add(file);
+ }
+ }
+ file = null;
+ IPath p = SourceLookup.getSourcePath(script.sourceURI());
+ IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(p);
+ if(res != null && res.getType() == IResource.FILE) {
+ file = (IFile) res;
+ }
+ if(files.size() > 0) {
+ if(files.contains(file)) {
+ return file;
+ }
+ return (IFile) files.get(0);
+ }
+ return file;
+ }
+
+ /**
+ * Returns the complete listing of {@link IScriptResolver}s or an empty array, never null
+ *
+ * @return the complete listing of {@link IScriptResolver}s
+ */
+ public IScriptResolver[] getResolvers() {
+ loadResolvers();
+ if(resolvers.size() < 1) {
+ return NO_RESOLVERS;
+ }
+ List res = Arrays.asList(resolvers.getListeners());
+ return (IScriptResolver[]) res.toArray(new IScriptResolver[res.size()]);
+ }
+
+ /**
+ * load up all the extension points to the delegate listeners
+ */
+ void loadResolvers() {
+ if(resolvers == null) {
+ resolvers = new ListenerList();
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(JavaScriptDebugPlugin.PLUGIN_ID, Constants.SCRIPT_RESOLVERS);
+ IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
+ for (int i = 0; i < elements.length; i++) {
+ resolvers.add(new ScriptResolverExtension(elements[i]));
+ }
+ }
+ }
+
+ /**
+ * Clean up
+ */
+ public void dispose() {
+ if(resolvers != null) {
+ resolvers.clear();
+ resolvers = null;
+ }
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolverExtension.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolverExtension.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolverExtension.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolverExtension.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.core.model;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
+import org.eclipse.wst.jsdt.debug.core.model.IScriptResolver;
+import org.eclipse.wst.jsdt.debug.internal.core.Constants;
+
+/**
+ * Default implementation of the delegate class for all {@link IScriptResolver}s
+ *
+ * @since 3.4
+ */
+public class ScriptResolverExtension implements IScriptResolver {
+
+ private IConfigurationElement element = null;
+ private IScriptResolver delegate = null;
+
+ /**
+ * Constructor
+ * @param element the backing {@link IConfigurationElement} to lazily load and delegate to
+ */
+ public ScriptResolverExtension(IConfigurationElement element) {
+ this.element = element;
+ }
+
+ /**
+ * Returns the delegate {@link IScriptResolver} from the backing {@link IConfigurationElement}
+ *
+ * @return the delegate {@link IScriptResolver}
+ * @throws CoreException thrown if the delegate class fails to be created
+ */
+ synchronized IScriptResolver getDelegate() throws CoreException {
+ if(delegate == null) {
+ delegate = (IScriptResolver) element.createExecutableExtension(Constants.CLASS);
+ }
+ return delegate;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.model.IScriptPathResolver#matches(org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference, org.eclipse.core.runtime.IPath)
+ */
+ public boolean matches(ScriptReference script, IPath path) {
+ try {
+ return getDelegate().matches(script, path);
+ }
+ catch(CoreException ce) {
+ return false;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.model.IScriptPathResolver#getFile(org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference)
+ */
+ public IFile getFile(ScriptReference script) {
+ try {
+ return getDelegate().getFile(script);
+ }
+ catch(CoreException ce) {
+ return null;
+ }
+ }
+}
\ No newline at end of file
Index: src/org/eclipse/wst/jsdt/debug/internal/core/model/modelmessages.properties
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.core/src/org/eclipse/wst/jsdt/debug/internal/core/model/modelmessages.properties,v
retrieving revision 1.9
diff -u -r1.9 modelmessages.properties
--- src/org/eclipse/wst/jsdt/debug/internal/core/model/modelmessages.properties 28 Feb 2011 18:05:11 -0000 1.9
+++ src/org/eclipse/wst/jsdt/debug/internal/core/model/modelmessages.properties 4 Jan 2012 20:13:16 -0000
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2010 IBM Corporation and others.
+# Copyright (c) 2010, 2011 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
#P org.eclipse.wst.jsdt.debug.crossfire
Index: .classpath
===================================================================
RCS file: .classpath
diff -N .classpath
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ .classpath 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,7 @@
+
+April 20, 2007
+The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.
+ +If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.
+ +The Content includes items that have been sourced from third parties as set out below. If you +did not receive this Content directly from the Eclipse Foundation, the following is provided +for informational purposes only, and you should look to the Redistributor’s license for +terms and conditions of use.
+ +The plug-in is accompanied by software developed by Geoff Kuenning. The following files:
+are based on Ispell 3.1.20. The home page for Ispell is located at http://lasr.cs.ucla.edu/geoff/ispell.html.
+ +Your use of Ispell 3.1.20 in the plug-in is subject to the terms and conditions of the Ispell license. A copy of the Ispell license is included in +about_files/ispell-license.txt and is also reproduced below:
+ ++ Copyright 1993, Geoff Kuenning, Granada Hills, CA+ + + \ No newline at end of file Index: build.properties =================================================================== RCS file: build.properties diff -N build.properties --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ build.properties 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,18 @@ +############################################################################### +# Copyright (c) 2011 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + OSGI-INF/,\ + about.html,\ + .options Index: plugin.xml =================================================================== RCS file: plugin.xml diff -N plugin.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ plugin.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,19 @@ + + +
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. All modifications to the source code must be clearly marked as
+ such. Binary redistributions based on modified source code
+ must be clearly marked as modified versions in the documentation
+ and/or other materials provided with the distribution.
+ 4. All advertising materials mentioning features or use of this software
+ must display the following acknowledgment:
+ This product includes software developed by Geoff Kuenning and
+ other unpaid contributors.
+ 5. The name of Geoff Kuenning may not be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS
+ IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GEOFF
+ KUENNING OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
null
+ *
+ * @return the error category or null
+ */
+ public String getCategory() {
+ if(error != null) {
+ String val = (String) error.get(Attributes.CATEGORY);
+ return val;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the name of the script the error occurred in or null
if it could not be determined
+ *
+ * @return the name of the script or null
+ */
+ public String scriptName() {
+ if(error != null) {
+ String val = (String) error.get(Attributes.FILE_NAME);
+ if(val == null) {
+ //try the source attribute
+ val = (String) error.get(Attributes.SOURCE_NAME);
+ }
+ return val;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the name of the function the error originated from or null
if it could not be determined
+ *
+ * @return the name of the function or null
+ */
+ public String functionName() {
+ if(frame != null) {
+ String val = (String) frame.get(Attributes.FUNCTION_NAME);
+ return val;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Throwable#printStackTrace()
+ */
+ public void printStackTrace() {
+ if(frame != null) {
+ return;
+ }
+ super.printStackTrace();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
+ */
+ public void printStackTrace(PrintStream s) {
+ if(frame != null) {
+ return;
+ }
+ super.printStackTrace(s);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
+ */
+ public void printStackTrace(PrintWriter s) {
+ if(frame != null) {
+ return;
+ }
+ super.printStackTrace(s);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/Constants.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/Constants.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/Constants.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/Constants.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire;
+
+/**
+ * Constants for the bundle
+ *
+ * @since 1.0
+ */
+public interface Constants {
+
+ /**
+ * Constant representing a space
+ */
+ public static final String SPACE = " "; //$NON-NLS-1$
+ /**
+ * Constant representing a colon.:
+ */
+ public static final String COLON = ":"; //$NON-NLS-1$
+ /**
+ * Constant representing the empty string
+ */
+ public static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ /**
+ * UTF-8 encoding constant UTF-8
+ */
+ public static final String UTF_8 = "UTF-8"; //$NON-NLS-1$
+ public static String URI_FILE_SCHEME = "file"; //$NON-NLS-1$
+ public static final String UNKNOWN = "unknown"; //$NON-NLS-1$
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/CrossFirePlugin.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/CrossFirePlugin.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/CrossFirePlugin.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/CrossFirePlugin.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.event.CFEventQueue;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFMirror;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Crossfire {@link BundleActivator}
+ *
+ * @since 1.0
+ */
+public class CrossFirePlugin extends Plugin {
+
+ /**
+ * Id of the bundle
+ */
+ public static final String PLUGIN_ID = "org.eclipse.wst.jsdt.debug.crossfire"; //$NON-NLS-1$
+ /**
+ * CFPacket tracing option name
+ */
+ public static final String TRC_PACKETS = PLUGIN_ID + "/packets"; //$NON-NLS-1$
+ /**
+ * CFEventPacket queue tracing option name
+ */
+ public static final String TRC_EVENTQUEUE = PLUGIN_ID + "/eventqueue"; //$NON-NLS-1$
+ /**
+ * JSDI implementation tracing option name
+ */
+ public static final String TRC_JSDI = PLUGIN_ID + "/jsdi"; //$NON-NLS-1$
+ /**
+ * JSON parser tracing option
+ */
+ public static final String TRC_JSON = PLUGIN_ID + "/json"; //$NON-NLS-1$
+
+ /**
+ * Status code indicating an unexpected internal error.
+ */
+ public static final int INTERNAL_ERROR = 120;
+
+ private static CrossFirePlugin plugin = null;
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ super.start(bundleContext);
+ plugin = this;
+ configureTracing();
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ try {
+ plugin = null;
+ }
+ finally {
+ super.stop(bundleContext);
+ }
+ }
+
+ /**
+ * @return the singleton instance
+ */
+ public static CrossFirePlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Logs the specified status with this plug-in's log.
+ *
+ * @param status status to log
+ */
+ public static void log(IStatus status) {
+ if (plugin != null) {
+ plugin.getLog().log(status);
+ }
+ }
+
+ /**
+ * Logs the specified throwable with this plug-in's log.
+ *
+ * @param t throwable to log
+ */
+ public static void log(Throwable t) {
+ log(newErrorStatus("Error logged from Crossfire Debug: ", t)); //$NON-NLS-1$
+ }
+
+ /**
+ * Logs an internal error with the specified message.
+ *
+ * @param message the error message to log
+ */
+ public static void logErrorMessage(String message) {
+ log(newErrorStatus("Internal message logged from Crossfire Debug: " + message, null)); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns a new error status for this plug-in with the given message
+ * @param message the message to be included in the status
+ * @param exception the exception to be included in the status or null
if none
+ * @return a new error status
+ */
+ public static IStatus newErrorStatus(String message, Throwable exception) {
+ return new Status(IStatus.ERROR, PLUGIN_ID, INTERNAL_ERROR, message, exception);
+ }
+
+ /**
+ * Turns on / off any tracing options
+ */
+ public void configureTracing() {
+ if(CrossFirePlugin.getDefault().isDebugging()) {
+ String option = Platform.getDebugOption(TRC_PACKETS);
+ if(option != null) {
+ CFPacket.setTracing(Boolean.valueOf(option).booleanValue());
+ }
+ option = Platform.getDebugOption(TRC_EVENTQUEUE);
+ if(option != null) {
+ CFEventQueue.setTracing(Boolean.valueOf(option).booleanValue());
+ }
+ option = Platform.getDebugOption(TRC_JSDI);
+ if(option != null) {
+ CFMirror.setTracing(Boolean.valueOf(option).booleanValue());
+ }
+ option = Platform.getDebugOption(TRC_JSON);
+ if(option != null) {
+ JSON.setTracing(Boolean.valueOf(option).booleanValue());
+ }
+ }
+ }
+
+ /**
+ * Creates a new {@link URI} with the file
scheme
+ * @param path
+ * @return a new {@link URI}
+ * @throws URISyntaxException
+ */
+ public static URI fileURI(IPath path) throws URISyntaxException {
+ return new URI(Constants.URI_FILE_SCHEME, null, path.makeAbsolute().toString(), null);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/LaunchHelper.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/LaunchHelper.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/LaunchHelper.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/LaunchHelper.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,109 @@
+package org.eclipse.wst.jsdt.debug.internal.crossfire;
+
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.ILaunchConfigurationDelegate2;
+import org.eclipse.debug.core.model.ISourceLocator;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
+import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector;
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument;
+import org.eclipse.wst.jsdt.debug.internal.core.launching.ILaunchConstants;
+import org.eclipse.wst.jsdt.debug.internal.core.launching.RemoteJavaScriptLaunchDelegate;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.connect.CrossfireAttachingConnector;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.connect.CrossfireListeningConnector;
+
+/**
+ *
+ */
+public class LaunchHelper {
+
+ public static final String REMOTE_LAUNCH_CONFIG_TYPE_ID = "org.eclipse.wst.jsdt.debug.core.launchConfigurationType"; //$NON-NLS-1$
+
+ public static ILaunchConfiguration newRemoteConfiguration(String name, boolean attach) throws CoreException {
+ ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType type = mgr.getLaunchConfigurationType(REMOTE_LAUNCH_CONFIG_TYPE_ID);
+ if(type != null) {
+ ILaunchConfigurationWorkingCopy copy = type.newInstance(null, mgr.generateLaunchConfigurationName(name));
+ Connector connector = null;
+ if(attach) {
+ connector = new CrossfireAttachingConnector();
+ copy.setAttribute(ILaunchConstants.CONNECTOR_ID, CrossfireAttachingConnector.CROSSFIRE_REMOTE_ATTACH_CONNECTOR_ID);
+ }
+ else {
+ connector = new CrossfireListeningConnector();
+ copy.setAttribute(ILaunchConstants.CONNECTOR_ID, CrossfireListeningConnector.CROSSFIRE_REMOTE_ATTACH_CONNECTOR_ID);
+ }
+ Map args = connector.defaultArguments();
+ Map newargs = new HashMap();
+ Entry entry = null;
+ Argument arg = null;
+ for(Iterator i = args.entrySet().iterator(); i.hasNext();) {
+ entry = (Entry) i.next();
+ arg = (Argument) entry.getValue();
+ newargs.put(entry.getKey(), arg.toString());
+ }
+ copy.setAttribute(ILaunchConstants.ARGUMENT_MAP, newargs);
+ return copy.doSave();
+ }
+ return null;
+ }
+
+ public static void doLaunch(ILaunchConfigurationDelegate2 delegate, ILaunch launch, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException {
+ SubMonitor localmonitor = SubMonitor.convert(monitor, "launch both", 6); //$NON-NLS-1$
+ try {
+ delegate.launch(config, "debug", launch, localmonitor); //$NON-NLS-1$
+ if(!localmonitor.isCanceled()) {
+ localmonitor.worked(2);
+ }
+ ILaunchConfiguration cfg = newRemoteConfiguration("foo", true); //$NON-NLS-1$
+ if(!localmonitor.isCanceled()) {
+ localmonitor.worked(2);
+ }
+ if(cfg != null) {
+ RemoteJavaScriptLaunchDelegate del = new RemoteJavaScriptLaunchDelegate();
+ del.launch(cfg, "debug", launch, localmonitor); //$NON-NLS-1$
+ }
+ if(!localmonitor.isCanceled()) {
+ localmonitor.worked(2);
+ }
+ }
+ finally {
+ if(!localmonitor.isCanceled()) {
+ localmonitor.done();
+ }
+ }
+ }
+
+ public static void appendProjectContainer(ILaunch launch, String pname) {
+ ISourceLocator loc = launch.getSourceLocator();
+ if(loc instanceof ISourceLookupDirector) {
+ ISourceLookupDirector director = (ISourceLookupDirector) loc;
+ IProject pj = ResourcesPlugin.getWorkspace().getRoot().getProject(pname);
+ if(pj.exists()) {
+ ProjectSourceContainer container = new ProjectSourceContainer(pj, false);
+ ISourceContainer[] containers = director.getSourceContainers();
+ ISourceContainer[] newcontainers = new ISourceContainer[containers.length+1];
+ newcontainers[0] = container;
+ System.arraycopy(containers, 0, newcontainers, 1, containers.length);
+ director.setSourceContainers(newcontainers);
+ }
+ }
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/Tracing.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/Tracing.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/Tracing.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/Tracing.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire;
+
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
+
+/**
+ * Helper class for common tracing functions
+ *
+ * @since 1.0
+ */
+public class Tracing {
+
+ public static final String PRINTABLE_LINE_FEED = "\\\\r\\\\n"; //$NON-NLS-1$
+
+ /**
+ * Writes the string to system out cleaning it of control chars before printing it
+ *
+ * @param string
+ */
+ public static void writeString(String string) {
+ String s = string.replaceAll(JSON.LINE_FEED, PRINTABLE_LINE_FEED);
+ s = s.replaceAll("\r", "\\\\r"); //$NON-NLS-1$//$NON-NLS-2$
+ s = s.replaceAll("\n", "\\\\n"); //$NON-NLS-1$//$NON-NLS-2$
+ System.out.println("[CROSSFIRE]" + s); //$NON-NLS-1$
+ }
+
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/BrowserArgument.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/BrowserArgument.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/BrowserArgument.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/BrowserArgument.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument;
+
+/**
+ * Option to automatically launch the browser and connect to it
+ *
+ * @since 1.0
+ */
+public class BrowserArgument implements BooleanArgument {
+
+ /**
+ * name of the argument
+ */
+ public static final String BROWSER = "browser"; //$NON-NLS-1$
+
+ private boolean doit = false;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
+ */
+ public String description() {
+ return Messages.auto_attach_desc;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
+ */
+ public String label() {
+ return Messages.auto_attach_label;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
+ */
+ public boolean mustSpecify() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
+ */
+ public String name() {
+ return BROWSER;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
+ */
+ public void setValue(String value) {
+ doit = Boolean.valueOf(value).booleanValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
+ */
+ public String value() {
+ return Boolean.toString(doit);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#booleanValue()
+ */
+ public boolean booleanValue() {
+ return doit;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#isValid(java.lang.String)
+ */
+ public boolean isValid(String value) {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#setValue(boolean)
+ */
+ public void setValue(boolean booleanValue) {
+ doit = booleanValue;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/ConsoleArgument.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/ConsoleArgument.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/ConsoleArgument.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/ConsoleArgument.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument;
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument;
+
+/**
+ * An {@link Argument} to enable the console
tool
+ *
+ * @since 1.0
+ */
+public class ConsoleArgument implements BooleanArgument {
+
+ public static final String CONSOLE = "console"; //$NON-NLS-1$
+
+ private boolean fValue = true;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
+ */
+ public String description() {
+ return Messages.console_arg_description;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
+ */
+ public String label() {
+ return Messages.console_arg_label;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
+ */
+ public boolean mustSpecify() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
+ */
+ public String name() {
+ return CONSOLE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
+ */
+ public void setValue(String value) {
+ fValue = Boolean.valueOf(value).booleanValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
+ */
+ public String value() {
+ return Boolean.toString(fValue);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#booleanValue()
+ */
+ public boolean booleanValue() {
+ return fValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#isValid(java.lang.String)
+ */
+ public boolean isValid(String value) {
+ return value != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#setValue(boolean)
+ */
+ public void setValue(boolean booleanValue) {
+ fValue = booleanValue;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/CrossfireAttachingConnector.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/CrossfireAttachingConnector.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/CrossfireAttachingConnector.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/CrossfireAttachingConnector.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.AttachingConnector;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFVirtualMachine;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFTransportService;
+import org.eclipse.wst.jsdt.debug.transport.Connection;
+import org.eclipse.wst.jsdt.debug.transport.DebugSession;
+import org.eclipse.wst.jsdt.debug.transport.TransportService;
+
+/**
+ * Attaching connector for Crossfire
+ *
+ * @since 1.0
+ */
+public class CrossfireAttachingConnector implements AttachingConnector {
+
+ public static final String CROSSFIRE_REMOTE_ATTACH_CONNECTOR_ID = "crossfire.remote.attach.connector"; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ */
+ public CrossfireAttachingConnector() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#defaultArguments()
+ */
+ public Map defaultArguments() {
+ HashMap args = new HashMap(5);
+ args.put(HostArgument.HOST, new HostArgument(null));
+ args.put(PortArgument.PORT, new PortArgument(5000));
+ args.put(TimeoutArgument.TIMEOUT, new TimeoutArgument());
+ args.put(ConsoleArgument.CONSOLE, new ConsoleArgument());
+ args.put(DOMArgument.DOM, new DOMArgument());
+ args.put(InspectorArgument.INSPECTOR, new InspectorArgument());
+ args.put(NetArgument.NET, new NetArgument());
+ args.put(TraceArgument.TRACE, new TraceArgument());
+ //XXX hack because there is no good way to find the Firefox executable on Win
+ if(!Platform.OS_WIN32.equals(Platform.getOS())) {
+ args.put(BrowserArgument.BROWSER, new BrowserArgument());
+ }
+ return args;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#description()
+ */
+ public String description() {
+ return Messages.attach_connector_desc;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#name()
+ */
+ public String name() {
+ return Messages.crossfire_remote_attach;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#id()
+ */
+ public String id() {
+ return CROSSFIRE_REMOTE_ATTACH_CONNECTOR_ID;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.AttachingConnector#attach
+ * (java.util.Map)
+ */
+ public VirtualMachine attach(Map arguments) throws IOException {
+ String str = (String) arguments.get(BrowserArgument.BROWSER);
+ //XXX hack because there is no good way to find the Firefox executable on Win
+ boolean browser = Boolean.valueOf(str).booleanValue() && !Platform.OS_WIN32.equals(Platform.getOS());
+ if (browser && !HostArgument.isLocalhost((String) arguments.get(HostArgument.HOST))) {
+ // we cannot auto launch the browser on a different host
+ throw new IOException(Messages.cannot_launch_browser_not_localhost);
+ }
+ Connection c = null;
+ if (browser) {
+ c = launchForBrowser(arguments);
+ } else {
+ c = launch(arguments);
+ }
+ DebugSession session = new DebugSession(c);
+ return new CFVirtualMachine(session);
+ }
+
+ /**
+ * Launches the browser and connects to it. This method will poll for the
+ * browser to be launched but only for a fixed timeout.
+ *
+ * @param arguments
+ * @return the created connection or null
if the attempt to
+ * connect times out, the browser process terminates before we can
+ * connect
+ * @throws IOException
+ */
+ Connection launchForBrowser(final Map arguments) throws IOException {
+ String host = (String) arguments.get(HostArgument.HOST);
+ String port = (String) arguments.get(PortArgument.PORT);
+ StringBuffer buffer = new StringBuffer("firefox -ProfileManager -load-fb-modules -crossfire-server-port ").append(port); //$NON-NLS-1$
+ Process p = Runtime.getRuntime().exec(buffer.toString());
+ TransportService service = new CFTransportService(getToolArgs(arguments));
+ String timeoutstr = (String) arguments.get(TimeoutArgument.TIMEOUT);
+ int timeout = Integer.parseInt(timeoutstr);
+ buffer = new StringBuffer();
+ buffer.append(host).append(':').append(Integer.parseInt(port));
+ long timer = System.currentTimeMillis() + 20000;
+ Connection c = null;
+ while (p != null && System.currentTimeMillis() < timer && c == null) {
+ try {
+ c = service.attach(buffer.toString(), timeout,timeout);
+ } catch (IOException ioe) {
+ // ignore while pinging to connect
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ //do nothing
+ }
+ }
+ }
+ if (c == null) {
+ throw new IOException(NLS.bind(Messages.failed_to_attach_to_auto_browser, new String[] {host, port }));
+ }
+ return c;
+ }
+
+ /**
+ * Tries to connect to the given
+ *
+ * @param arguments
+ * @return the {@link Connection} or throws an exception
+ * @throws IOException
+ */
+ Connection launch(Map arguments) throws IOException {
+ TransportService service = new CFTransportService(getToolArgs(arguments));
+ String host = (String) arguments.get(HostArgument.HOST);
+ String port = (String) arguments.get(PortArgument.PORT);
+ String timeoutstr = (String) arguments.get(TimeoutArgument.TIMEOUT);
+ int timeout = Integer.parseInt(timeoutstr);
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(host).append(':').append(Integer.parseInt(port));
+ return service.attach(buffer.toString(), timeout, timeout);
+ }
+
+ String[] getToolArgs(Map arguments) {
+ ArrayList tools = new ArrayList();
+ String value = (String) arguments.get(ConsoleArgument.CONSOLE);
+ if(Boolean.valueOf(value).booleanValue()) {
+ tools.add(ConsoleArgument.CONSOLE);
+ }
+ value = (String) arguments.get(DOMArgument.DOM);
+ if(Boolean.valueOf(value).booleanValue()) {
+ tools.add(DOMArgument.DOM);
+ }
+ value = (String) arguments.get(InspectorArgument.INSPECTOR);
+ if(Boolean.valueOf(value).booleanValue()) {
+ tools.add(InspectorArgument.INSPECTOR);
+ }
+ value = (String) arguments.get(NetArgument.NET);
+ if(Boolean.valueOf(value).booleanValue()) {
+ tools.add(NetArgument.NET);
+ }
+ value = (String) arguments.get(TraceArgument.TRACE);
+ if(Boolean.valueOf(value).booleanValue()) {
+ tools.add(TraceArgument.TRACE);
+ }
+ return (String[]) tools.toArray(new String[tools.size()]);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/CrossfireListeningConnector.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/CrossfireListeningConnector.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/CrossfireListeningConnector.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/CrossfireListeningConnector.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.ListeningConnector;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFVirtualMachine;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFTransportService;
+import org.eclipse.wst.jsdt.debug.transport.Connection;
+import org.eclipse.wst.jsdt.debug.transport.DebugSession;
+import org.eclipse.wst.jsdt.debug.transport.TransportService;
+
+/**
+ * Default launching connector for CrossFire
+ *
+ * @since 1.0
+ */
+public class CrossfireListeningConnector implements ListeningConnector {
+
+ /**
+ * The id of the connector
+ */
+ public static final String CROSSFIRE_REMOTE_ATTACH_CONNECTOR_ID = "crossfire.remote.listen.connector"; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ */
+ public CrossfireListeningConnector() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#defaultArguments()
+ */
+ public Map defaultArguments() {
+ HashMap args = new HashMap(5);
+ args.put(HostArgument.HOST, new HostArgument(null));
+ args.put(PortArgument.PORT, new PortArgument(5000));
+ args.put(TimeoutArgument.TIMEOUT, new TimeoutArgument());
+ args.put(ConsoleArgument.CONSOLE, new ConsoleArgument());
+ return args;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#description()
+ */
+ public String description() {
+ return Messages.attach_connector_desc;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#name()
+ */
+ public String name() {
+ return Messages.attach_connector_name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#id()
+ */
+ public String id() {
+ return CROSSFIRE_REMOTE_ATTACH_CONNECTOR_ID;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.ListeningConnector#accept(java.util.Map)
+ */
+ public VirtualMachine accept(Map arguments) throws IOException {
+ TransportService service = new CFTransportService(null);
+ String host = (String) arguments.get(HostArgument.HOST);
+ String port = (String) arguments.get(PortArgument.PORT);
+ String timeoutstr = (String) arguments.get(TimeoutArgument.TIMEOUT);
+ int timeout = Integer.parseInt(timeoutstr);
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(host).append(':').append(Integer.parseInt(port));
+ Connection c = service.accept(service.startListening(buffer.toString()), timeout, timeout);
+ DebugSession session = new DebugSession(c);
+ return new CFVirtualMachine(session);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/DOMArgument.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/DOMArgument.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/DOMArgument.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/DOMArgument.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument;
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument;
+
+/**
+ * An {@link Argument} to enable DOM tooling support in the crossfire server
+ *
+ * @since 1.0
+ */
+public class DOMArgument implements BooleanArgument {
+
+ public static final String DOM = "dom"; //$NON-NLS-1$
+
+ private boolean fValue = true;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
+ */
+ public String description() {
+ return Messages.dom_arg_description;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
+ */
+ public String label() {
+ return Messages.dom_arg_label;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
+ */
+ public boolean mustSpecify() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
+ */
+ public String name() {
+ return DOM;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
+ */
+ public void setValue(String value) {
+ fValue = Boolean.valueOf(value).booleanValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
+ */
+ public String value() {
+ return Boolean.toString(fValue);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#booleanValue()
+ */
+ public boolean booleanValue() {
+ return fValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#isValid(java.lang.String)
+ */
+ public boolean isValid(String value) {
+ return value != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#setValue(boolean)
+ */
+ public void setValue(boolean booleanValue) {
+ fValue = booleanValue;
+ }
+}
\ No newline at end of file
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/HostArgument.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/HostArgument.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/HostArgument.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/HostArgument.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.StringArgument;
+import org.eclipse.wst.jsdt.debug.transport.Constants;
+
+/**
+ * Implementation of a string argument that describes the host argument
+ *
+ * @since 1.0
+ */
+public class HostArgument implements StringArgument {
+
+ private static final long serialVersionUID = 3057403815318177030L;
+ private String host;
+
+ /**
+ * Host attribute name
+ */
+ public static final String HOST = "host"; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ *
+ * @param host
+ */
+ public HostArgument(String host) {
+ setValue(host);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
+ */
+ public String description() {
+ return Messages.host_arg_desc;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.StringArgument#isValid(java.lang.String)
+ */
+ public boolean isValid(String value) {
+ return value != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
+ */
+ public String label() {
+ return Messages.host_arg_name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
+ */
+ public boolean mustSpecify() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
+ */
+ public String name() {
+ return HOST;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
+ */
+ public void setValue(String host) {
+ if(host == null) {
+ this.host = Constants.LOCALHOST;
+ }
+ else {
+ if (!isValid(host)) {
+ throw new IllegalArgumentException();
+ }
+ this.host = host;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
+ */
+ public String value() {
+ return host;
+ }
+
+ /**
+ * Returns if the given host is localhost
or 127.0.0.1
+ * @param host
+ * @return true if the given host it localhost (127.0.0.1) false otherwise
+ */
+ public static boolean isLocalhost(String host) {
+ return host.equals(Constants.LOCALHOST) || host.equals(Constants.LOCALHOST_IP);
+ }
+}
\ No newline at end of file
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/InspectorArgument.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/InspectorArgument.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/InspectorArgument.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/InspectorArgument.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument;
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument;
+
+/**
+ * An {@link Argument} to allow the page inspector tooling to be enabled in the
+ * Crossfire server
+ *
+ * @since 1.0
+ */
+public class InspectorArgument implements BooleanArgument {
+
+ public static final String INSPECTOR = "inspector"; //$NON-NLS-1$
+ private boolean fValue = true;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
+ */
+ public String description() {
+ return Messages.inspector_arg_description;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
+ */
+ public String label() {
+ return Messages.inspector_arg_label;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
+ */
+ public boolean mustSpecify() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
+ */
+ public String name() {
+ return INSPECTOR;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
+ */
+ public void setValue(String value) {
+ fValue = Boolean.valueOf(value).booleanValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
+ */
+ public String value() {
+ return Boolean.toString(fValue);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#booleanValue()
+ */
+ public boolean booleanValue() {
+ return fValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#isValid(java.lang.String)
+ */
+ public boolean isValid(String value) {
+ return value != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#setValue(boolean)
+ */
+ public void setValue(boolean booleanValue) {
+ fValue = booleanValue;
+ }
+}
\ No newline at end of file
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/Messages.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/Messages.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/Messages.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/Messages.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ *
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.crossfire.connect.messages"; //$NON-NLS-1$
+ public static String attach_connector_desc;
+ public static String attach_connector_name;
+ public static String auto_attach_desc;
+ public static String auto_attach_label;
+ public static String cannot_launch_browser_not_localhost;
+ public static String console_arg_description;
+ public static String console_arg_label;
+ public static String crossfire_remote_attach;
+ public static String dom_arg_description;
+ public static String dom_arg_label;
+ public static String failed_to_attach_to_auto_browser;
+ public static String host_arg_desc;
+ public static String host_arg_name;
+ public static String inspector_arg_description;
+ public static String inspector_arg_label;
+ public static String net_arg_description;
+ public static String net_arg_label;
+ public static String port_arg_desc;
+ public static String port_arg_name;
+ public static String timeout;
+ public static String timeout_desc;
+ public static String trace_arg_description;
+ public static String trace_arg_label;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/NetArgument.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/NetArgument.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/NetArgument.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/NetArgument.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument;
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument;
+
+/**
+ * An {@link Argument} to allow the the Net panel and support to be enabled in the Crossfire server
+ *
+ * @since 1.0
+ */
+public class NetArgument implements BooleanArgument {
+
+ public static final String NET = "net"; //$NON-NLS-1$
+
+ private boolean fValue = true;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
+ */
+ public String description() {
+ return Messages.net_arg_description;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
+ */
+ public String label() {
+ return Messages.net_arg_label;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
+ */
+ public boolean mustSpecify() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
+ */
+ public String name() {
+ return NET;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
+ */
+ public void setValue(String value) {
+ fValue = Boolean.valueOf(value).booleanValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
+ */
+ public String value() {
+ return Boolean.toString(fValue);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#booleanValue()
+ */
+ public boolean booleanValue() {
+ return fValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#isValid(java.lang.String)
+ */
+ public boolean isValid(String value) {
+ return value != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#setValue(boolean)
+ */
+ public void setValue(boolean booleanValue) {
+ fValue = booleanValue;
+ }
+}
\ No newline at end of file
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/PortArgument.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/PortArgument.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/PortArgument.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/PortArgument.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument;
+
+/**
+ * Implementation of an {@link IntegerArgument} that describes the port to try connecting to
+ *
+ * @since 1.0
+ */
+public class PortArgument implements IntegerArgument {
+
+ private static final long serialVersionUID = -1954469572907116388L;
+ private int port;
+
+ /**
+ * The port attribute name
+ */
+ public static final String PORT = "port"; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ *
+ * @param port
+ */
+ public PortArgument(int port) {
+ setValue(port);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#intValue()
+ */
+ public int intValue() {
+ return port;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#isValid(int)
+ */
+ public boolean isValid(int intValue) {
+ return intValue > 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#max()
+ */
+ public int max() {
+ return Integer.MAX_VALUE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#min()
+ */
+ public int min() {
+ return 1;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#setValue(int)
+ */
+ public void setValue(int port) {
+ this.port = port;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
+ */
+ public String description() {
+ return Messages.port_arg_desc;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#isValid(java.lang.String)
+ */
+ public boolean isValid(String value) {
+ try {
+ int intValue = Integer.parseInt(value);
+ return isValid(intValue);
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
+ */
+ public String label() {
+ return Messages.port_arg_name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
+ */
+ public boolean mustSpecify() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
+ */
+ public String name() {
+ return PORT;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
+ */
+ public void setValue(String value) {
+ try {
+ int intValue = Integer.parseInt(value);
+ setValue(intValue);
+ } catch (NumberFormatException nfe) {
+ // re-throw IllegalArgumentException
+ throw new IllegalArgumentException(nfe.getMessage());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
+ */
+ public String value() {
+ return Integer.toString(port);
+ }
+}
\ No newline at end of file
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/TimeoutArgument.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/TimeoutArgument.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/TimeoutArgument.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/TimeoutArgument.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument;
+
+/**
+ * Argument used to specify a timeout (in ms)
+ *
+ * @since 1.1
+ */
+public class TimeoutArgument implements IntegerArgument {
+
+ /**
+ * Argument to specify a timeout
+ */
+ public static final String TIMEOUT = "timeout"; //$NON-NLS-1$
+ /**
+ * default connecting timeout
+ */
+ public static final Integer CONNECT_TIMEOUT = new Integer(30000);
+
+ /**
+ * The timeout
+ */
+ private int timeout = 0;
+
+ /**
+ * Constructor
+ */
+ public TimeoutArgument() {
+ setValue(CONNECT_TIMEOUT.intValue());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
+ */
+ public String description() {
+ return Messages.timeout_desc;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
+ */
+ public String label() {
+ return Messages.timeout;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
+ */
+ public boolean mustSpecify() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
+ */
+ public String name() {
+ return TIMEOUT;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
+ */
+ public void setValue(String value) {
+ try {
+ timeout = Integer.parseInt(value);
+ }
+ catch(NumberFormatException nfe) {
+ //do nothing the new value will not be set
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
+ */
+ public String value() {
+ return Integer.toString(timeout);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#intValue()
+ */
+ public int intValue() {
+ return timeout;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#isValid(int)
+ */
+ public boolean isValid(int intValue) {
+ return intValue > 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#isValid(java.lang.String)
+ */
+ public boolean isValid(String value) {
+ try {
+ return Integer.parseInt(value) > 0;
+ }
+ catch(NumberFormatException bfe) {
+ //do nothing, just not valid
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#max()
+ */
+ public int max() {
+ return Integer.MAX_VALUE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#min()
+ */
+ public int min() {
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#setValue(int)
+ */
+ public void setValue(int intValue) {
+ timeout = intValue;
+ }
+
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/TraceArgument.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/TraceArgument.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/TraceArgument.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/TraceArgument.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument;
+import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument;
+
+/**
+ * An {@link Argument} to allow server error tracing to be reported back to the client
+ *
+ * @since 1.0
+ */
+public class TraceArgument implements BooleanArgument {
+
+ public static final String TRACE = "trace"; //$NON-NLS-1$
+
+ private boolean fValue = false;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
+ */
+ public String description() {
+ return Messages.trace_arg_description;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
+ */
+ public String label() {
+ return Messages.trace_arg_label;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
+ */
+ public boolean mustSpecify() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
+ */
+ public String name() {
+ return TRACE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
+ */
+ public void setValue(String value) {
+ fValue = Boolean.valueOf(value).booleanValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
+ */
+ public String value() {
+ return Boolean.toString(fValue);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#booleanValue()
+ */
+ public boolean booleanValue() {
+ return fValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#isValid(java.lang.String)
+ */
+ public boolean isValid(String value) {
+ return value != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#setValue(boolean)
+ */
+ public void setValue(boolean booleanValue) {
+ fValue = booleanValue;
+ }
+}
\ No newline at end of file
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/messages.properties
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/messages.properties
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/messages.properties
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/messages.properties 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,33 @@
+###############################################################################
+# Copyright (c) 2010, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+attach_connector_desc=Allows you to connect to a Mozilla-based browser with the CrossFire extension installed
+attach_connector_name=CrossFire - Remote Listen
+auto_attach_desc=Automatically launch Firefox and attach to it
+auto_attach_label=Auto&matically launch Firefox and attach to it (extremely experimental)
+cannot_launch_browser_not_localhost=You cannot launch a browser on a different host than localhost (127.0.0.1)
+console_arg_description=Allows Crossfire to forward messages logged in the Firebug console to the Eclipse Error Log.
+console_arg_label=Enable Firebug console message logging in the Error &Log
+crossfire_remote_attach=Crossfire - Remote Attach
+dom_arg_description=Allows the client to take part in DOM inspections
+dom_arg_label=Enable DO&M inspection support
+failed_to_attach_to_auto_browser=Failed to attach to debugger at {0} on port {1}
+host_arg_desc=The name of the host address to try attaching to.
+host_arg_name=&Host:
+inspector_arg_description=Allows the client to enable page inspections in the Crossfire server
+inspector_arg_label=Enable pa&ge inspections
+net_arg_description=Allows network traffic inspections to be enabled in the Crossfire server
+net_arg_label=Enable network tra&ffic inspections
+port_arg_desc=The port on the host machine to try attaching to.
+port_arg_name=&Port:
+timeout=&Timeout (ms):
+timeout_desc=A timeout value in milliseconds to wait for a debugger to connect
+trace_arg_description=Allows server error tracing to be enabled. When enabled exception messages and stack traces are returned with failure error codes.
+trace_arg_label=Enable server error tr&acing
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFBreakpointEvent.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFBreakpointEvent.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFBreakpointEvent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFBreakpointEvent.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.BreakpointEvent;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
+
+/**
+ * Default implementation of {@link BreakpointEvent} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFBreakpointEvent extends CFLocatableEvent implements BreakpointEvent {
+
+ /**
+ * Constructor
+ * @param vm
+ * @param request
+ * @param thread
+ * @param location
+ */
+ public CFBreakpointEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, Location location) {
+ super(vm, request, thread, location);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFDebuggerStatementEvent.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFDebuggerStatementEvent.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFDebuggerStatementEvent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFDebuggerStatementEvent.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.DebuggerStatementEvent;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
+
+/**
+ * Default implementation of {@link DebuggerStatementEvent} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFDebuggerStatementEvent extends CFLocatableEvent implements DebuggerStatementEvent {
+
+ /**
+ * Constructor
+ * @param vm
+ * @param request
+ * @param thread
+ * @param location
+ */
+ public CFDebuggerStatementEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, Location location) {
+ super(vm, request, thread, location);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEvent.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEvent.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEvent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEvent.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.Event;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
+
+/**
+ * Default implementation of an {@link CFEvent} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFEvent implements Event {
+
+ private VirtualMachine vm = null;
+ private EventRequest request = null;
+
+ /**
+ * Constructor
+ *
+ * @param vm
+ * @param request
+ */
+ public CFEvent(VirtualMachine vm, EventRequest request) {
+ this.vm = vm;
+ this.request = request;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Mirror#virtualMachine()
+ */
+ public VirtualMachine virtualMachine() {
+ return vm;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.Event#request()
+ */
+ public EventRequest request() {
+ return request;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEventQueue.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEventQueue.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEventQueue.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEventQueue.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,391 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.EventQueue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ResumeRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ScriptLoadRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.SuspendRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadEnterRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadExitRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.VMDeathRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.CFThrowable;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.CrossFirePlugin;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFLocation;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFMirror;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFScriptReference;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFThreadReference;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFVirtualMachine;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFEventPacket;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
+import org.eclipse.wst.jsdt.debug.transport.exception.DisconnectedException;
+import org.eclipse.wst.jsdt.debug.transport.exception.TimeoutException;
+
+/**
+ * Default {@link EventQueue} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFEventQueue extends CFMirror implements EventQueue {
+
+ private static boolean TRACE = false;
+
+ private EventRequestManager eventmgr = null;
+ private boolean disposed = false;
+
+ /**
+ * Constructor
+ *
+ * @param vm
+ * @param manager
+ */
+ public CFEventQueue(CFVirtualMachine vm, EventRequestManager manager) {
+ super(vm);
+ this.eventmgr = manager;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.EventQueue#remove()
+ */
+ public EventSet remove() {
+ return remove(-1);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.EventQueue#remove(int)
+ */
+ public EventSet remove(int timeout) {
+ try {
+ while(true && !disposed) {
+ CFEventPacket event = crossfire().receiveEvent(timeout);
+ String name = event.getEvent();
+ CFEventSet set = new CFEventSet(crossfire());
+ if(CFEventPacket.CLOSED.equals(name)) {
+ List deaths = eventmgr.vmDeathRequests();
+ for (Iterator iter = deaths.iterator(); iter.hasNext();) {
+ VMDeathRequest request = (VMDeathRequest) iter.next();
+ set.add(new CFVMDeathEvent(crossfire(), request));
+ }
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.CLOSED+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ else if(CFEventPacket.ON_BREAK.equals(name)) {
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_BREAK+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ String threadid = event.getContextId();
+ if(threadid != null) {
+ CFThreadReference thread = crossfire().findThread(threadid);
+ set.setThread(thread);
+ if(thread != null && !thread.isSuspended()) {
+ List suspends = eventmgr.suspendRequests();
+ for (Iterator iter = suspends.iterator(); iter.hasNext();) {
+ SuspendRequest request = (SuspendRequest) iter.next();
+ Map locaction = (Map) event.getBody().get(Attributes.LOCATION);
+ if(locaction == null) {
+ continue;
+ }
+ String url = (String) locaction.get(Attributes.URL);
+ Number line = (Number) locaction.get(Attributes.LINE);
+ CFScriptReference script = crossfire().findScript(url);
+ if(script != null) {
+ CFLocation loc = new CFLocation(crossfire(), script, null, line.intValue());
+ set.add(new CFSuspendEvent(crossfire(), request, thread, loc));
+ }
+ }
+ thread.markSuspended(true);
+ }
+ else {
+ return null;
+ }
+ }
+ else {
+ return null;
+ }
+ }
+ else if(CFEventPacket.ON_RESUME.equals(name)) {
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_RESUME+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ String threadid = event.getContextId();
+ if(threadid != null) {
+ CFThreadReference thread = crossfire().findThread(threadid);
+ if(thread != null) {
+ set.setThread(thread);
+ List resumes = eventmgr.resumeRequests();
+ for (Iterator iter = resumes.iterator(); iter.hasNext();) {
+ ResumeRequest request = (ResumeRequest) iter.next();
+ if(request.thread().equals(thread)) {
+ CFLocation loc = new CFLocation(crossfire(), null, null, 0);
+ set.add(new CFResumeEvent(crossfire(), request, thread, loc));
+ }
+ }
+ thread.eventResume();
+ }
+ else {
+ return null;
+ }
+ }
+ else {
+ return null;
+ }
+ }
+ else if(CFEventPacket.ON_SCRIPT.equals(name)) {
+ ThreadReference thread = crossfire().findThread(event.getContextId());
+ if(thread != null) {
+ set.setThread(thread);
+ Map json = (Map) event.getBody().get(Attributes.SCRIPT);
+ if(json != null) {
+ CFScriptReference script = crossfire().addScript(event.getContextId(), json);
+ List scripts = eventmgr.scriptLoadRequests();
+ for (Iterator iter = scripts.iterator(); iter.hasNext();) {
+ ScriptLoadRequest request = (ScriptLoadRequest) iter.next();
+ set.add(new CFScriptLoadEvent(crossfire(), request, thread, script));
+ }
+ }
+ else {
+ return null;
+ }
+ }
+ else {
+ return null;
+ }
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_SCRIPT+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ else if(CFEventPacket.ON_CONTEXT_SELECTED.equals(name)) {
+ handleContext(set, event, true);
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONTEXT_SELECTED+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ else if(CFEventPacket.ON_CONTEXT_CREATED.equals(name)) {
+ handleContext(set, event, true);
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONTEXT_CREATED+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ else if(CFEventPacket.ON_CONTEXT_LOADED.equals(name)) {
+ handleContext(set, event, true);
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONTEXT_LOADED+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ else if(CFEventPacket.ON_CONTEXT_DESTROYED.equals(name)) {
+ ThreadReference thread = crossfire().findThread(event.getContextId());
+ crossfire().removeThread(event.getContextId());
+ crossfire().removeScriptsForContext(event.getContextId());
+ if(thread != null) {
+ List threads = eventmgr.threadExitRequests();
+ for (Iterator iter = threads.iterator(); iter.hasNext();) {
+ ThreadExitRequest request = (ThreadExitRequest) iter.next();
+ set.add(new CFThreadExitEvent(crossfire(), request, thread));
+ }
+ }
+ else {
+ return null;
+ }
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONTEXT_DESTROYED+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ else if(CFEventPacket.ON_CONSOLE_DEBUG.equals(name)) {
+ Map info = (Map) event.getBody().get(Attributes.VALUE);
+ if(info != null) {
+ log(IStatus.INFO, info);
+ }
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONSOLE_DEBUG+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return null;
+ }
+ else if(CFEventPacket.ON_CONSOLE_ERROR.equals(name)) {
+ logError(event.getBody());
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONSOLE_ERROR+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return null;
+ }
+ else if(CFEventPacket.ON_CONSOLE_INFO.equals(name)) {
+ Map info = (Map) event.getBody().get(Attributes.VALUE);
+ if(info != null) {
+ log(IStatus.INFO, info);
+ }
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONSOLE_INFO+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return null;
+ }
+ else if(CFEventPacket.ON_CONSOLE_LOG.equals(name)) {
+ Map info = (Map) event.getBody().get(Attributes.VALUE);
+ if(info != null) {
+ log(IStatus.INFO, info);
+ }
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONSOLE_LOG+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return null;
+ }
+ else if(CFEventPacket.ON_CONSOLE_WARN.equals(name)) {
+ Map info = (Map) event.getBody().get(Attributes.VALUE);
+ if(info != null) {
+ log(IStatus.WARNING, info);
+ }
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONSOLE_WARN+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return null;
+ }
+ else if(CFEventPacket.ON_ERROR.equals(name)) {
+ Map body = event.getBody();
+ if(body != null) {
+ Throwable thro = new CFThrowable(body);
+ Status status = new Status(IStatus.ERROR, CrossFirePlugin.PLUGIN_ID, thro.getMessage(), thro);
+ CrossFirePlugin.log(status);
+ }
+ }
+ else if(CFEventPacket.ON_INSPECT_NODE.equals(name)) {
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_INSPECT_NODE+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return null;
+ }
+ else if(CFEventPacket.ON_TOGGLE_BREAKPOINT.equals(name)) {
+ crossfire().toggleBreakpoint(event.getBody());
+ if(TRACE) {
+ Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_TOGGLE_BREAKPOINT+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return null;
+ }
+ else {
+ if(TRACE) {
+ Tracing.writeString("QUEUE [unknown event - "+name+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ if (set.isEmpty()) {
+ set.resume();
+ continue;
+ }
+ return set;
+ }
+ }
+ catch(DisconnectedException de) {
+ if(TRACE) {
+ Tracing.writeString("QUEUE [disconnect exception]: "+de.getMessage()); //$NON-NLS-1$
+ }
+ crossfire().disconnectVM();
+ handleException(de.getMessage(), (de.getCause() == null ? de : de.getCause()));
+ }
+ catch(TimeoutException te) {
+ CrossFirePlugin.log(te);
+ }
+ return null;
+ }
+
+ void logError(Map info) {
+ if(info != null) {
+ MultiStatus mstatus = new MultiStatus(CrossFirePlugin.PLUGIN_ID, IStatus.ERROR, "Error message logged in Firebug console", null); //$NON-NLS-1$
+ String message = (String) info.get(Attributes.MESSAGE);
+ CFThrowable thrw = new CFThrowable((Map) info.get(Attributes.STACKTRACE));
+ if(message != null) {
+ IStatus status = new Status(IStatus.ERROR, CrossFirePlugin.PLUGIN_ID, message, thrw);
+ mstatus.add(status);
+ }
+ if(mstatus.getChildren().length > 0) {
+ CrossFirePlugin.log(mstatus);
+ }
+ }
+ }
+
+ /**
+ * Logs the entry from the queue
+ *
+ * @param kind
+ * @param objects
+ */
+ void log(int kind, Map objects) {
+ IStatus status = null;
+ if(objects.size() > 1) {
+ MultiStatus mstatus = new MultiStatus(CrossFirePlugin.PLUGIN_ID, kind, "Messages logged from Firebug console", null); //$NON-NLS-1$
+ Entry entry = null;
+ for (Iterator i = objects.entrySet().iterator(); i.hasNext();) {
+ entry = (Entry) i.next();
+ Object value = entry.getValue();
+ if(value instanceof Map) {
+ Map map = (Map) entry.getValue();
+ if(!map.containsKey(Attributes.HANDLE)) {
+ Object val = map.get(Attributes.VALUE);
+ if(val != null) {
+ mstatus.add(new Status(kind, CrossFirePlugin.PLUGIN_ID, val.toString()));
+ }
+ }
+ }
+ }
+ status = mstatus;
+ }
+ if(status != null) {
+ CrossFirePlugin.log(status);
+ }
+ }
+
+ /**
+ * Handles a context created, loaded, and changed event
+ * @param set the {@link EventSet} to add to
+ * @param event the {@link CFEventPacket} received
+ * @param lookup if we should try to lookup the {@link ThreadReference} before creating a new one
+ */
+ void handleContext(CFEventSet set, CFEventPacket event, boolean lookup) {
+ List threads = eventmgr.threadEnterRequests();
+ CFThreadReference thread = null;
+ String context = event.getContextId();
+ if(lookup) {
+ thread = crossfire().findThread(context);
+ }
+ if(thread == null) {
+ thread = crossfire().addThread(context, (String) event.getBody().get(Attributes.URL));
+ }
+ set.setThread(thread);
+ for (Iterator iter = threads.iterator(); iter.hasNext();) {
+ ThreadEnterRequest request = (ThreadEnterRequest) iter.next();
+ set.add(new CFThreadEnterEvent(crossfire(), request, thread));
+ }
+ }
+
+ /**
+ * Flushes and cleans up the queue
+ */
+ public void dispose() {
+ disposed = true;
+ }
+
+ /**
+ * Turns on / off tracing in the event queue
+ * @param tracing
+ */
+ public static void setTracing(boolean tracing) {
+ TRACE = tracing;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEventSet.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEventSet.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEventSet.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEventSet.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
+
+import java.util.ArrayList;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet;
+
+/**
+ * Default implementation of {@link EventSet} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFEventSet extends ArrayList implements EventSet {
+
+ private VirtualMachine vm = null;
+ private ThreadReference thread = null;
+
+ /**
+ * Constructor
+ * @param vm
+ */
+ public CFEventSet(VirtualMachine vm) {
+ this.vm = vm;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet#suspended()
+ */
+ public boolean suspended() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet#resume()
+ */
+ public void resume() {
+ if(thread != null) {
+ thread.resume();
+ }
+ else {
+ vm.resume();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Mirror#virtualMachine()
+ */
+ public VirtualMachine virtualMachine() {
+ return vm;
+ }
+
+ /**
+ * Sets the thread context for the set
+ * @param thread
+ */
+ public void setThread(ThreadReference thread) {
+ this.thread = thread;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFExceptionEvent.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFExceptionEvent.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFExceptionEvent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFExceptionEvent.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.ExceptionEvent;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
+
+/**
+ * Default implementation of {@link ExceptionEvent} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFExceptionEvent extends CFLocatableEvent implements ExceptionEvent {
+
+ private String message = null;
+
+ /**
+ * Constructor
+ * @param vm
+ * @param request
+ * @param thread
+ * @param location
+ * @param message
+ */
+ public CFExceptionEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, Location location, String message) {
+ super(vm, request, thread, location);
+ this.message = message;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.ExceptionEvent#message()
+ */
+ public String message() {
+ return message;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFLocatableEvent.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFLocatableEvent.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFLocatableEvent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFLocatableEvent.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.LocatableEvent;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
+
+/**
+ * Default implementation of {@link LocatableEvent} for Crossfire
+ *
+ * @sicne 1.0
+ */
+public class CFLocatableEvent extends CFEvent implements LocatableEvent {
+
+ private ThreadReference thread = null;
+ private Location location = null;
+
+ /**
+ * Constructor
+ * @param vm
+ * @param request
+ */
+ public CFLocatableEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, Location location) {
+ super(vm, request);
+ this.thread = thread;
+ this.location = location;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Locatable#location()
+ */
+ public Location location() {
+ return location;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.LocatableEvent#thread()
+ */
+ public ThreadReference thread() {
+ return thread;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFResumeEvent.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFResumeEvent.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFResumeEvent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFResumeEvent.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.ResumeEvent;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
+
+/**
+ * Crossfire implementation of {@link ResumeEvent}
+ *
+ * @since 1.0
+ */
+public class CFResumeEvent extends CFLocatableEvent implements ResumeEvent {
+
+ /**
+ * Constructor
+ * @param vm
+ * @param request
+ * @param thread
+ * @param location
+ */
+ public CFResumeEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, Location location) {
+ super(vm, request, thread, location);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFScriptLoadEvent.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFScriptLoadEvent.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFScriptLoadEvent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFScriptLoadEvent.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.ScriptLoadEvent;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
+
+/**
+ * Default implementation of {@link ScriptLoadEvent} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFScriptLoadEvent extends CFLocatableEvent implements ScriptLoadEvent {
+
+ private ScriptReference script = null;
+
+ /**
+ * Constructor
+ * @param vm
+ * @param request
+ */
+ public CFScriptLoadEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, ScriptReference script) {
+ super(vm, request, thread, null);
+ this.script = script;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.ScriptLoadEvent#script()
+ */
+ public ScriptReference script() {
+ return script;
+ }
+
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFSuspendEvent.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFSuspendEvent.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFSuspendEvent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFSuspendEvent.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.SuspendEvent;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
+
+/**
+ * Default implementation of {@link SuspendEvent} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFSuspendEvent extends CFLocatableEvent implements SuspendEvent {
+
+ /**
+ * Constructor
+ * @param vm
+ * @param request
+ * @param thread
+ * @param location
+ */
+ public CFSuspendEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, Location location) {
+ super(vm, request, thread, location);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFThreadEnterEvent.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFThreadEnterEvent.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFThreadEnterEvent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFThreadEnterEvent.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.ThreadEnterEvent;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
+
+/**
+ * Default implementation of {@link ThreadEnterEvent} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFThreadEnterEvent extends CFLocatableEvent implements ThreadEnterEvent {
+
+ /**
+ * Constructor
+ * @param vm
+ * @param request
+ * @param thread
+ */
+ public CFThreadEnterEvent(VirtualMachine vm, EventRequest request, ThreadReference thread) {
+ super(vm, request, thread, null);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFThreadExitEvent.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFThreadExitEvent.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFThreadExitEvent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFThreadExitEvent.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.ThreadExitEvent;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
+
+/**
+ * Default implementation of {@link ThreadExitEvent} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFThreadExitEvent extends CFLocatableEvent implements ThreadExitEvent {
+
+ /**
+ * Constructor
+ * @param vm
+ * @param request
+ * @param thread
+ */
+ public CFThreadExitEvent(VirtualMachine vm, EventRequest request, ThreadReference thread) {
+ super(vm, request, thread, null);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFVMDeathEvent.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFVMDeathEvent.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFVMDeathEvent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFVMDeathEvent.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.VMDeathEvent;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
+
+/**
+ * Default implementation of a {@link VMDeathEvent} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFVMDeathEvent extends CFEvent implements VMDeathEvent {
+
+ /**
+ * Constructor
+ * @param vm
+ * @param request
+ */
+ public CFVMDeathEvent(VirtualMachine vm, EventRequest request) {
+ super(vm, request);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFArrayReference.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFArrayReference.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFArrayReference.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFArrayReference.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ArrayReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.Value;
+
+/**
+ * Default implementation of {@link ArrayReference} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFArrayReference extends CFObjectReference implements ArrayReference {
+
+ /**
+ * The "array" value type
+ */
+ public static final String ARRAY = "array"; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ * @param vm
+ * @param frame
+ * @param body
+ */
+ public CFArrayReference(CFVirtualMachine vm, CFStackFrame frame, Map body) {
+ super(vm, frame, body);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ArrayReference#length()
+ */
+ public int length() {
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ArrayReference#getValue(int)
+ */
+ public Value getValue(int index) throws IndexOutOfBoundsException {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ArrayReference#getValues()
+ */
+ public List getValues() {
+ return null;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFBooleanValue.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFBooleanValue.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFBooleanValue.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFBooleanValue.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.BooleanValue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+
+/**
+ * Default implementation of a {@link BooleanValue} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFBooleanValue extends CFMirror implements BooleanValue {
+
+ private boolean bool = false;
+
+ /**
+ * Constructor
+ *
+ * @param vm
+ * @param bool the underlying boolean value
+ */
+ public CFBooleanValue(VirtualMachine vm, boolean bool) {
+ super(vm);
+ this.bool = bool;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#intValue()
+ */
+ public int intValue() {
+ return (bool ? 1 : 0);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#doubleValue()
+ */
+ public double doubleValue() {
+ return (bool ? 1 : 0);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#booleanValue()
+ */
+ public boolean booleanValue() {
+ return bool;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#stringValue()
+ */
+ public String stringValue() {
+ return Boolean.toString(bool);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString()
+ */
+ public String valueString() {
+ return stringValue();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return stringValue();
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFEventRequestManager.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFEventRequestManager.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFEventRequestManager.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFEventRequestManager.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,296 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.DebuggerStatementRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ExceptionRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ResumeRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ScriptLoadRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.SuspendRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadEnterRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadExitRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.VMDeathRequest;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.VMDisconnectRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFBreakpointRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFDeathRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFDebuggerRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFDisconnectRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFExceptionRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFResumeRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFScriptLoadRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFStepRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFSuspendRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFThreadEnterRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFThreadExitRequest;
+
+/**
+ * Default {@link EventRequestManager} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFEventRequestManager implements EventRequestManager {
+
+ private List threadexits = Collections.synchronizedList(new ArrayList(4));
+ private List threadenters = Collections.synchronizedList(new ArrayList(4));
+ private List breakpoints = Collections.synchronizedList(new ArrayList(4));
+ private List debuggers = Collections.synchronizedList(new ArrayList(4));
+ private List exceptions = Collections.synchronizedList(new ArrayList(4));
+ private List loads = Collections.synchronizedList(new ArrayList(4));
+ private List steps = Collections.synchronizedList(new ArrayList(4));
+ private List suspends = Collections.synchronizedList(new ArrayList(4));
+ private List resumes = Collections.synchronizedList(new ArrayList(4));
+ private List disconnects = Collections.synchronizedList(new ArrayList(4));
+ private List deaths = Collections.synchronizedList(new ArrayList(4));
+
+ private HashMap kind = new HashMap(10);
+
+ private VirtualMachine vm = null;
+
+ /**
+ * Constructor
+ *
+ * @param vm
+ */
+ public CFEventRequestManager(VirtualMachine vm) {
+ this.vm = vm;
+ kind.put(CFBreakpointRequest.class, breakpoints);
+ kind.put(CFDebuggerRequest.class, debuggers);
+ kind.put(CFExceptionRequest.class, exceptions);
+ kind.put(CFScriptLoadRequest.class, loads);
+ kind.put(CFStepRequest.class, steps);
+ kind.put(CFSuspendRequest.class, suspends);
+ kind.put(CFResumeRequest.class, resumes);
+ kind.put(CFThreadEnterRequest.class, threadenters);
+ kind.put(CFThreadExitRequest.class, threadexits);
+ kind.put(CFDisconnectRequest.class, disconnects);
+ kind.put(CFDeathRequest.class, deaths);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createBreakpointRequest(org.eclipse.wst.jsdt.debug.core.jsdi.Location)
+ */
+ public BreakpointRequest createBreakpointRequest(Location location) {
+ CFBreakpointRequest request = new CFBreakpointRequest(vm, location);
+ breakpoints.add(request);
+ return request;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#breakpointRequests()
+ */
+ public List breakpointRequests() {
+ return Collections.unmodifiableList(breakpoints);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createDebuggerStatementRequest()
+ */
+ public DebuggerStatementRequest createDebuggerStatementRequest() {
+ CFDebuggerRequest request = new CFDebuggerRequest(vm);
+ debuggers.add(request);
+ return request;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#debuggerStatementRequests()
+ */
+ public List debuggerStatementRequests() {
+ return Collections.unmodifiableList(debuggers);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createExceptionRequest()
+ */
+ public ExceptionRequest createExceptionRequest() {
+ CFExceptionRequest request = new CFExceptionRequest(vm);
+ exceptions.add(request);
+ return request;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#exceptionRequests()
+ */
+ public List exceptionRequests() {
+ return Collections.unmodifiableList(exceptions);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createScriptLoadRequest()
+ */
+ public ScriptLoadRequest createScriptLoadRequest() {
+ CFScriptLoadRequest request = new CFScriptLoadRequest(vm);
+ loads.add(request);
+ return request;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#scriptLoadRequests()
+ */
+ public List scriptLoadRequests() {
+ return Collections.unmodifiableList(loads);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createStepRequest(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference, int)
+ */
+ public StepRequest createStepRequest(ThreadReference thread, int step) {
+ CFStepRequest request = new CFStepRequest(vm, thread, step);
+ steps.add(request);
+ return request;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#stepRequests()
+ */
+ public List stepRequests() {
+ return Collections.unmodifiableList(steps);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createSuspendRequest(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
+ */
+ public SuspendRequest createSuspendRequest(ThreadReference thread) {
+ CFSuspendRequest request = new CFSuspendRequest(vm, thread);
+ suspends.add(request);
+ return request;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#suspendRequests()
+ */
+ public List suspendRequests() {
+ return Collections.unmodifiableList(suspends);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createResumeRequest(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
+ */
+ public ResumeRequest createResumeRequest(ThreadReference thread) {
+ CFResumeRequest request = new CFResumeRequest(vm, thread);
+ resumes.add(request);
+ return request;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#resumeRequests()
+ */
+ public List resumeRequests() {
+ return Collections.unmodifiableList(resumes);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createThreadEnterRequest()
+ */
+ public ThreadEnterRequest createThreadEnterRequest() {
+ CFThreadEnterRequest request = new CFThreadEnterRequest(vm);
+ threadenters.add(request);
+ return request;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#threadEnterRequests()
+ */
+ public List threadEnterRequests() {
+ return Collections.unmodifiableList(threadenters);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createThreadExitRequest()
+ */
+ public ThreadExitRequest createThreadExitRequest() {
+ CFThreadExitRequest request = new CFThreadExitRequest(vm);
+ threadexits.add(request);
+ return request;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#threadExitRequests()
+ */
+ public List threadExitRequests() {
+ return Collections.unmodifiableList(threadexits);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#deleteEventRequest(org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest)
+ */
+ public void deleteEventRequest(EventRequest eventRequest) {
+ List requests = (List) kind.get(eventRequest.getClass());
+ if(requests != null) {
+ requests.remove(eventRequest);
+ eventRequest.setEnabled(false);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#deleteEventRequest(java.util.List)
+ */
+ public void deleteEventRequest(List eventRequests) {
+ for (Iterator iter = eventRequests.iterator(); iter.hasNext();) {
+ deleteEventRequest((EventRequest) iter.next());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createVMDeathRequest()
+ */
+ public VMDeathRequest createVMDeathRequest() {
+ CFDeathRequest request = new CFDeathRequest(vm);
+ deaths.add(request);
+ return request;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#vmDeathRequests()
+ */
+ public List vmDeathRequests() {
+ return Collections.unmodifiableList(deaths);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createVMDisconnectRequest()
+ */
+ public VMDisconnectRequest createVMDisconnectRequest() {
+ CFDisconnectRequest request = new CFDisconnectRequest(vm);
+ disconnects.add(request);
+ return request;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#vmDisconnectRequests()
+ */
+ public List vmDisconnectRequests() {
+ return Collections.unmodifiableList(disconnects);
+ }
+
+ /**
+ * Cleans up all requests
+ */
+ public void dispose() {
+ for (Iterator iter = kind.keySet().iterator(); iter.hasNext();) {
+ List list = (List) kind.get(iter.next());
+ list.clear();
+ }
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFFunctionReference.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFFunctionReference.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFFunctionReference.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFFunctionReference.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import java.util.Map;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.FunctionReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.Value;
+
+/**
+ * Default implementation of {@link FunctionReference} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFFunctionReference extends CFObjectReference implements FunctionReference {
+
+ /**
+ * The "function" type
+ */
+ public static final String FUNCTION = "function"; //$NON-NLS-1$
+
+ private String funcname = null;
+
+
+ /**
+ * Constructor
+ * @param vm
+ * @param frame
+ * @param body
+ */
+ public CFFunctionReference(CFVirtualMachine vm, CFStackFrame frame, Map body) {
+ super(vm, frame, body);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.FunctionReference#functionName()
+ */
+ public String functionName() {
+ synchronized (frame()) {
+ if(funcname == null) {
+ Value val = frame().lookup(id());
+ System.out.println(val);
+ }
+ }
+ return funcname;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.FunctionReference#functionBody()
+ */
+ public String functionBody() {
+ return source();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFObjectReference#valueString()
+ */
+ public String valueString() {
+ if(source() != null) {
+ return source();
+ }
+ return FUNCTION;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFLocation.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFLocation.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFLocation.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFLocation.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+
+/**
+ * Default implementation of {@link Location} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFLocation extends CFMirror implements Location {
+
+ private CFScriptReference script = null;
+ private String function = null;
+ private int line = -1;
+
+ /**
+ * Constructor
+ * @param vm
+ * @param script
+ * @param function
+ * @param line
+ */
+ public CFLocation(VirtualMachine vm, CFScriptReference script, String function, int line) {
+ super(vm);
+ this.script = script;
+ this.function = function;
+ this.line = line;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Location#scriptReference()
+ */
+ public ScriptReference scriptReference() {
+ return script;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Location#lineNumber()
+ */
+ public int lineNumber() {
+ return line;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Location#functionName()
+ */
+ public String functionName() {
+ return function;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("LocationImpl: "); //$NON-NLS-1$
+ buffer.append("[script - ").append(script.sourceURI()).append("] "); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append("[function - ").append(function).append("] "); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append("[line - ").append(line).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ return buffer.toString();
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFMirror.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFMirror.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFMirror.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFMirror.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.Mirror;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+
+/**
+ * Default implementation for a {@link Mirror} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFMirror implements Mirror {
+
+ public static boolean TRACE = false;
+
+ private VirtualMachine vm = null;
+
+ /**
+ * Constructor
+ * For use by the {@link CFVirtualMachine} only
+ * @noreference This constructor is not intended to be referenced by clients.
+ */
+ public CFMirror() {
+ vm = (VirtualMachine) this;
+ }
+
+ /**
+ * Constructor
+ */
+ public CFMirror(VirtualMachine vm) {
+ this.vm = vm;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Mirror#virtualMachine()
+ */
+ public VirtualMachine virtualMachine() {
+ return this.vm;
+ }
+
+ /**
+ * Re-throws the given exception as a {@link RuntimeException} with the given message
+ * @param message
+ * @param t
+ */
+ protected void handleException(String message, Throwable t) {
+ throw new RuntimeException(message, t);
+ }
+
+ /**
+ * Returns the handle to the {@link CFVirtualMachine}
+ *
+ * @return the {@link CFVirtualMachine} handle
+ */
+ protected CFVirtualMachine crossfire() {
+ return (CFVirtualMachine) vm;
+ }
+
+ /**
+ * Enables / Disables tracing in the all of the JSDI implementations
+ *
+ * @param trace
+ */
+ public static void setTracing(boolean trace) {
+ TRACE = trace;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFNullValue.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFNullValue.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFNullValue.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFNullValue.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.NullValue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+
+/**
+ * Default implementation of the {@link NullValue} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFNullValue extends CFMirror implements NullValue {
+
+ public static final String NULL = "null"; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ */
+ public CFNullValue(VirtualMachine vm) {
+ super(vm);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString()
+ */
+ public String valueString() {
+ return CFNullValue.NULL;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return valueString();
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFNumberValue.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFNumberValue.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFNumberValue.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFNumberValue.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.NumberValue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+
+/**
+ * Default implementation of {@link NumberValue} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFNumberValue extends CFMirror implements NumberValue {
+
+ /**
+ * Object representing 'Not a Number'
+ */
+ public static final Double NAN_OBJ = new Double(Double.NaN);
+ /**
+ * Object representing '-Infinity'
+ */
+ public static final Double NEG_INFINITY_OBJ = new Double(Double.NEGATIVE_INFINITY);
+ /**
+ * Object representing 'Infinity'
+ */
+ public static final Double INFINITY_OBJ = new Double(Double.POSITIVE_INFINITY);
+
+ private Number number = null;
+
+ /**
+ * Constructor
+ * @param vm
+ * @param number
+ */
+ public CFNumberValue(VirtualMachine vm, Number number) {
+ super(vm);
+ if(number != null) {
+ this.number = number;
+ }
+ else {
+ this.number = NAN_OBJ;
+ }
+ }
+
+ /**
+ * Constructor
+ * @param vm the backing {@link VirtualMachine}
+ * @param number the name of the number
+ * @see #INFINITY
+ * @see #NEG_INFINTY
+ */
+ public CFNumberValue(VirtualMachine vm, String number) {
+ super(vm);
+ if(INFINITY.equals(number)) {
+ this.number = INFINITY_OBJ;
+ }
+ else if(NEG_INFINITY.equals(number)) {
+ this.number = NEG_INFINITY_OBJ;
+ }
+ if(this.number == null) {
+ this.number = NAN_OBJ;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#intValue()
+ */
+ public int intValue() {
+ return number.intValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#doubleValue()
+ */
+ public double doubleValue() {
+ return number.doubleValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#booleanValue()
+ */
+ public boolean booleanValue() {
+ return number.intValue() > 0 ? true : false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#stringValue()
+ */
+ public String stringValue() {
+ return number.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString()
+ */
+ public String valueString() {
+ return stringValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.NumberValue#value()
+ */
+ public Number value() {
+ return number;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.NumberValue#isNaN()
+ */
+ public boolean isNaN() {
+ return Double.isNaN(this.number.doubleValue());
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFObjectReference.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFObjectReference.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFObjectReference.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFObjectReference.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame;
+import org.eclipse.wst.jsdt.debug.core.jsdi.Value;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
+
+/**
+ * Default implementation of {@link ObjectReference} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFObjectReference extends CFMirror implements ObjectReference {
+
+ /**
+ * The "type" of this mirror element
+ */
+ public static final String OBJECT = "object"; //$NON-NLS-1$
+
+ private CFStackFrame frame = null;
+ private String classname = null;
+ private Number handle = null;
+ private Number constref = null;
+ private Number protoref = null;
+ private Value constructor = null;
+ private Value prototype = null;
+ private List properties = null;
+ private String source = null;
+
+ /**
+ * Constructor
+ * @param vm
+ * @param frame
+ * @param body
+ */
+ public CFObjectReference(CFVirtualMachine vm, CFStackFrame frame, Map body) {
+ super(vm);
+ this.frame = frame;
+ handle = (Number) body.get(Attributes.HANDLE);
+ source = (String) body.get(Attributes.SOURCE);
+ //init properties - we are dealing with evaluation results
+ Map props = (Map) body.get(Attributes.RESULT);
+ if(props == null) {
+ Object o = body.get(Attributes.VALUE);
+ if(o instanceof Map) {
+ props = (Map) body.get(Attributes.VALUE);
+ }
+ else if(this.handle == null) {
+ props = body;
+ }
+ }
+ if(props != null) {
+ if(properties == null) {
+ properties = new ArrayList(props.size());
+ }
+ Entry entry = null;
+ String name = null;
+ Map json = null;
+ Number ref = null;
+ for(Iterator i = props.entrySet().iterator(); i.hasNext();) {
+ entry = (Entry) i.next();
+ name = (String)entry.getKey();
+ if(entry.getValue() instanceof Map) {
+ json = (Map) entry.getValue();
+ ref = (Number) json.get(Attributes.HANDLE);
+ //don't add constructor and proto to the properties heap
+ //they are requested specially
+ if(Attributes.CONSTRUCTOR.equals(name)) {
+ constref = ref;
+ continue;
+ }
+ else if(Attributes.PROTO.equals(name)) {
+ protoref = ref;
+ continue;
+ }
+ }
+ properties.add(new CFVariable(crossfire(), frame, name, ref, json));
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString()
+ */
+ public String valueString() {
+ if(source != null) {
+ return source;
+ }
+ return OBJECT;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#className()
+ */
+ public String className() {
+ return classname;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#constructor()
+ */
+ public Value constructor() {
+ synchronized (frame) {
+ if(constructor == null) {
+ if(constref == null) {
+ constructor = crossfire().mirrorOfUndefined();
+ }
+ constructor = frame.lookup(constref);
+ }
+ }
+ return constructor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#prototype()
+ */
+ public Value prototype() {
+ synchronized (frame) {
+ if(prototype == null) {
+ if(protoref == null) {
+ prototype = crossfire().mirrorOfUndefined();
+ }
+ prototype = frame.lookup(protoref);
+ }
+ }
+ return prototype;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#properties()
+ */
+ public List properties() {
+ return properties;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#handle()
+ */
+ public Number id() {
+ return handle;
+ }
+
+ /**
+ * @return the backing {@link StackFrame}
+ */
+ protected CFStackFrame frame() {
+ return this.frame;
+ }
+
+ /**
+ * @return the source for the body of the object, or null
+ */
+ protected String source() {
+ return this.source;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFProperty.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFProperty.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFProperty.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFProperty.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.NullValue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.Property;
+import org.eclipse.wst.jsdt.debug.core.jsdi.Value;
+
+/**
+ * Default implementation of {@link Property} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFProperty extends CFMirror implements Property {
+
+ private String name = null;
+ private Number ref = null;
+ private CFStackFrame frame = null;
+ private Value value = null;
+
+ /**
+ * Constructor
+ *
+ * @param vm
+ * @param frame
+ * @param name
+ * @param ref
+ */
+ public CFProperty(CFVirtualMachine vm, CFStackFrame frame, String name, Number ref) {
+ super(vm);
+ this.frame = frame;
+ this.name = name;
+ this.ref = ref;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Property#name()
+ */
+ public String name() {
+ return this.name;
+ }
+
+ /**
+ * Allows the value to be set. Passing in null
for newvalue
will result
+ * in {@link #value} being set to {@link NullValue}
+ *
+ * @param newvalue
+ */
+ protected void setValue(Value newvalue) {
+ if(newvalue == null) {
+ this.value = crossfire().mirrorOfNull();
+ }
+ else {
+ this.value = newvalue;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Property#value()
+ */
+ public synchronized Value value() {
+ if(this.value == null) {
+ this.value = frame.lookup(this.ref);
+ if(this.value == null) {
+ this.value = crossfire().mirrorOfUndefined();
+ }
+ }
+ if(this.value == null) {
+ return crossfire().mirrorOfUndefined();
+ }
+ return this.value;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFScriptReference.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFScriptReference.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFScriptReference.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFScriptReference.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.CrossFirePlugin;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Commands;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFRequestPacket;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFResponsePacket;
+
+/**
+ * Default implementation of {@link ScriptReference} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFScriptReference extends CFMirror implements ScriptReference {
+
+ private String context_id = null;
+ private String url = null;
+ private int srclength = 0;
+ private int linecount = 0;
+ private int coloffset = 0;
+ private int lineoffset = 0;
+ private String source = null;
+ private URI sourceuri = null;
+
+ private List linelocs = new ArrayList();
+
+ /**
+ * Constructor
+ * @param vm
+ * @param context_id
+ * @param json
+ */
+ public CFScriptReference(VirtualMachine vm, String context_id, Map json) {
+ super(vm);
+ this.context_id = context_id;
+ this.url = (String) json.get(Attributes.URL);
+ initializeScript(json);
+ }
+
+ /**
+ * Initialize the script from the given JSON map
+ *
+ * @param json
+ */
+ void initializeScript(Map json) {
+ Number value = (Number) json.get(Attributes.SOURCE_LENGTH);
+ if(value != null) {
+ this.srclength = value.intValue();
+ }
+ value = (Number) json.get(Attributes.LINE_COUNT);
+ if(value != null) {
+ this.linecount = value.intValue();
+ }
+ value = (Number) json.get(Attributes.LINE_OFFSET);
+ if(value != null) {
+ this.lineoffset = value.intValue();
+ }
+ value = (Number) json.get(Attributes.COLUMN_OFFSET);
+ if(value != null) {
+ this.coloffset = value.intValue();
+ }
+ source = (String) json.get(Attributes.SOURCE);
+ prepareLocations(linecount);
+ }
+
+ /**
+ * Creates the line locations
+ *
+ * @param lines
+ */
+ void prepareLocations(int lines) {
+ linelocs.clear(); //remove old line infos
+ for (int i = 1; i <= lines; i++) {
+ linelocs.add(new CFLocation(virtualMachine(), this, null, i));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#allLineLocations()
+ */
+ public List allLineLocations() {
+ return Collections.unmodifiableList(linelocs);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#lineLocation(int)
+ */
+ public Location lineLocation(int lineNumber) {
+ if(lineNumber <= linelocs.size()) {
+ return (Location) linelocs.get(lineNumber-1);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#allFunctionLocations()
+ */
+ public List allFunctionLocations() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#functionLocation(java.lang.String)
+ */
+ public Location functionLocation(String functionName) {
+ return null;
+ }
+
+ /**
+ * The url of the script
+ * @return the url
+ */
+ public String url() {
+ return url;
+ }
+
+ /**
+ * Returns the context id of this script - this represents the id of the owning thread
+ * null
+ *
+ * @return the context id for the owning thread or null
+ */
+ public String context() {
+ return context_id;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#source()
+ */
+ public synchronized String source() {
+ if(source == null) {
+ CFRequestPacket request = new CFRequestPacket(Commands.SCRIPTS, context_id);
+ request.setArgument(Attributes.INCLUDE_SOURCE, Boolean.TRUE);
+ request.setArgument(Attributes.URLS, Arrays.asList(new String[] {url}));
+ CFResponsePacket response = crossfire().sendRequest(request);
+ if(response.isSuccess()) {
+ List list = (List)response.getBody().get(Attributes.SCRIPTS);
+ if (list != null && list.size() > 0) {
+ initializeScript((Map)list.get(0));
+ }
+ }
+ else if(TRACE) {
+ Tracing.writeString("SCRIPTREF [failed source request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ return source;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#sourceURI()
+ */
+ public synchronized URI sourceURI() {
+ if(sourceuri == null) {
+ try {
+ sourceuri = URIUtil.fromString(url);
+ }
+ catch(IllegalArgumentException iae) {
+ try {
+ sourceuri = CrossFirePlugin.fileURI(new Path(url));
+ } catch (URISyntaxException e) {
+ CrossFirePlugin.log(e);
+ }
+ }
+ catch(URISyntaxException urise) {
+ CrossFirePlugin.log(urise);
+ }
+ }
+ return sourceuri;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Crossfire ScriptReference: [context_id - ").append(context_id).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append(" [url - ").append(url).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append(" [srclength - ").append(srclength).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append(" [linecount - ").append(linecount).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append(" [lineoffset - ").append(lineoffset).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append(" [coloffset - ").append(coloffset).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append("\nSource: \n").append(source); //$NON-NLS-1$
+ return buffer.toString();
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFStackFrame.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFStackFrame.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFStackFrame.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFStackFrame.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,340 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
+import org.eclipse.wst.jsdt.debug.core.jsdi.NullValue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame;
+import org.eclipse.wst.jsdt.debug.core.jsdi.Value;
+import org.eclipse.wst.jsdt.debug.core.jsdi.Variable;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFRequestPacket;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFResponsePacket;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Commands;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
+
+/**
+ * Default implementation of {@link StackFrame} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFStackFrame extends CFMirror implements StackFrame {
+
+ private int index = -1;
+ private String scriptUrl = null;
+ private String funcname = null;
+ private int linenumber = -1;
+ private List vars = null;
+ private Variable thisvar = null;
+ private CFLocation loc = null;
+ private CFThreadReference thread = null;
+
+ /**
+ * Constructor
+ * @param vm
+ * @param json
+ */
+ public CFStackFrame(VirtualMachine vm, CFThreadReference thread, Map json) {
+ super(vm);
+ this.thread = thread;
+ Number value = (Number) json.get(Attributes.INDEX);
+ if(value != null) {
+ index = value.intValue();
+ }
+ value = (Number) json.get(Attributes.LINE);
+ if(value != null) {
+ linenumber = value.intValue();
+ }
+ scriptUrl = (String) json.get(Attributes.URL);
+ funcname = (String) json.get(Attributes.FUNCTION_NAME);
+
+ parseLocals((Map) json.get(Attributes.LOCALS));
+ parseScopes((List) json.get(Attributes.SCOPES));
+ }
+
+ /**
+ * Parses the scopes object node, if there is one
+ *
+ * @param list the list of scopes
+ */
+ void parseScopes(List list) {
+ if(list != null) {
+ if(vars == null) {
+ vars = new ArrayList(list.size());
+ }
+ for (Iterator i = list.iterator(); i.hasNext();) {
+ Map map = (Map) i.next();
+ Map scope = (Map)map.get(Attributes.SCOPE);
+ if(scope != null) {
+ vars.add(0, new CFVariable(crossfire(), this, "Enclosing Scope", (Number) scope.get(Attributes.HANDLE), scope)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ /**
+ * Read the local variable information from the JSON mapping
+ *
+ * @param json
+ */
+ void parseLocals(Map json) {
+ if(json != null) {
+ Object val = json.get(Attributes.VALUE);
+ if(val instanceof Map) {
+ Map locals = (Map) json.get(Attributes.VALUE);
+ if(locals != null) {
+ vars = new ArrayList(locals.size());
+ parseVariables(locals, vars);
+ }
+ }
+ else {
+ vars = new ArrayList();
+ }
+ Map thismap = (Map) json.get(Attributes.THIS);
+ thisvar = new CFVariable(crossfire(), this, Attributes.THIS, null, (thismap == null ? new HashMap(0) : thismap));
+ }
+ }
+
+ void parseVariables(Map map, List varcollector) {
+ Entry entry = null;
+ for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
+ entry = (Entry) iter.next();
+ if(entry.getValue() instanceof Map) {
+ Map info = (Map) entry.getValue();
+ Object obj = info.get(Attributes.HANDLE);
+ if(obj instanceof Number) {
+ varcollector.add(
+ new CFVariable(
+ crossfire(),
+ this,
+ (String) entry.getKey(),
+ (Number) obj,
+ info));
+ }
+ }
+ else {
+ varcollector.add(
+ new CFVariable(
+ crossfire(),
+ this,
+ (String) entry.getKey(),
+ null,
+ null));
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame#thisObject()
+ */
+ public Variable thisObject() {
+ return thisvar;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame#variables()
+ */
+ public synchronized List variables() {
+ if(vars != null) {
+ return vars;
+ }
+ return Collections.EMPTY_LIST;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame#location()
+ */
+ public synchronized Location location() {
+ if(loc == null) {
+ CFScriptReference script = crossfire().findScript(scriptUrl);
+ if(script != null) {
+ loc = new CFLocation(crossfire(), script, funcname, linenumber);
+ }
+ }
+ return loc;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame#evaluate(java.lang.String)
+ */
+ public Value evaluate(String expression) {
+ CFRequestPacket request = new CFRequestPacket(Commands.EVALUATE, thread.id());
+ request.setArgument(Attributes.FRAME_INDEX, new Integer(index));
+ request.setArgument(Attributes.EXPRESSION, expression);
+ CFResponsePacket response = crossfire().sendRequest(request);
+ if(response.isSuccess()) {
+ return createValue(response.getBody().get(Attributes.RESULT));
+ }
+ else if(TRACE) {
+ Tracing.writeString("STACKFRAME [failed evaluate request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ return virtualMachine().mirrorOfNull();
+ }
+
+ /**
+ * Returns the index of the frame in the stack
+ *
+ * @return the frame index
+ */
+ public int frameindex() {
+ return index;
+ }
+
+ /**
+ * Looks up the value given its handle ref
+ *
+ * @param ref
+ * @return the {@link Value} or null
+ */
+ public Value lookup(Number ref) {
+ if(ref != null) {
+ CFRequestPacket request = new CFRequestPacket(Commands.LOOKUP, thread.id());
+ request.setArgument(Attributes.HANDLES, Arrays.asList(new Number[] {ref}));
+ request.setArgument(Attributes.INCLUDE_SOURCE, Boolean.TRUE);
+ CFResponsePacket response = crossfire().sendRequest(request);
+ if(response.isSuccess()) {
+ List list = (List)response.getBody().get(Attributes.VALUES);
+ if (list != null && list.size() > 0) {
+ return createValue(list.get(0));
+ }
+ }
+ else if(TRACE) {
+ Tracing.writeString("STACKFRAME [request for value lookup failed]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ return crossfire().mirrorOfNull();
+ }
+
+ /**
+ * Creates the correct type if {@link Value} from the given json mapping
+ * @param json
+ * @return the new {@link Value} or null
if one could not be created
+ */
+ Value createValue(Object val) {
+ //resolve the smallest type from the crossfire insanity
+ if(val instanceof Map) {
+ Map values = (Map) val;
+ String type = (String) values.get(Attributes.TYPE);
+ if(type != null) {
+ return createTypeValue(type, values);
+ }
+ }
+ else if(val instanceof String) {
+ String str = (String) val;
+ if(CFUndefinedValue.UNDEFINED.equals(str)) {
+ return crossfire().mirrorOfUndefined();
+ }
+ return crossfire().mirrorOf((String) val);
+ }
+ else if(val instanceof Number) {
+ return crossfire().mirrorOf((Number) val);
+ }
+ return crossfire().mirrorOfNull();
+ }
+
+ /**
+ * Create a new {@link Value} based on the given type
+ *
+ * @param type the type
+ * @param map the map of value information
+ * @return the new {@link Value} for the given type or {@link NullValue} if a value cannot be computed
+ */
+ Value createTypeValue(String type, Map map) {
+ if(CFUndefinedValue.UNDEFINED.equals(type)) {
+ return crossfire().mirrorOfUndefined();
+ }
+ if(Attributes.NUMBER.equals(type)) {
+ //could be NaN, Infinity or -Infinity, check for strings
+ Object o = map.get(Attributes.VALUE);
+ if(o instanceof Number) {
+ return crossfire().mirrorOf((Number)o);
+ }
+ if(o instanceof String) {
+ return crossfire().mirrorOf((String)o);
+ }
+ }
+ if(CFStringValue.STRING.equals(type)) {
+ return crossfire().mirrorOf(map.get(Attributes.VALUE).toString());
+ }
+ if(CFObjectReference.OBJECT.equals(type) || Attributes.REF.equals(type)) {
+ return new CFObjectReference(crossfire(), this, map);
+ }
+ if(CFArrayReference.ARRAY.equals(type)) {
+ return new CFArrayReference(crossfire(), this, map);
+ }
+ if(CFFunctionReference.FUNCTION.equals(type)) {
+ return new CFFunctionReference(crossfire(), this, map);
+ }
+ return crossfire().mirrorOfNull();
+ }
+
+ /**
+ * Returns if this stack frame is visible
+ *
+ * @param variable
+ * @return true if this frame is visible, false otherwise
+ */
+ public synchronized boolean isVisible(CFVariable variable) {
+ return vars != null && (thisvar == variable || vars.contains(variable));
+ }
+
+ /**
+ * Gets all of the scopes from Firebug
+ */
+ void allScopes() {
+ CFRequestPacket request = new CFRequestPacket(Commands.SCOPES, thread.id());
+ request.setArgument(Attributes.FRAME_INDEX, new Integer(index));
+ CFResponsePacket response = crossfire().sendRequest(request);
+ if(response.isSuccess()) {
+ List list = (List) response.getBody().get(Attributes.SCOPES);
+ if(list != null) {
+ parseScopes(list);
+ }
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed scopes request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Gets the scope for this frame
+ */
+ void scope(int frameindex, int scopeindex) {
+ CFRequestPacket request = new CFRequestPacket(Commands.SCOPES, thread.id());
+ request.setArgument(Attributes.FRAME_INDEX, new Integer(frameindex));
+ request.setArgument(Attributes.SCOPE_INDEXES, Arrays.asList(new Number[] {new Integer(scopeindex)}));
+ CFResponsePacket response = crossfire().sendRequest(request);
+ if(response.isSuccess()) {
+ if(vars == null) {
+ vars = new ArrayList();
+ }
+ List list = (List)response.getBody().get(Attributes.SCOPES);
+ if (list != null && list.size() > 0) {
+ Map scope = ((Map)list.get(0));
+ vars.add(0, new CFVariable(crossfire(), this, "Enclosing Scope", (Number) scope.get(Attributes.HANDLE), scope)); //$NON-NLS-1$
+ }
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed scopes request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFStringValue.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFStringValue.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFStringValue.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFStringValue.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.StringValue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+
+/**
+ * Default implementation of {@link StringValue} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFStringValue extends CFMirror implements StringValue {
+
+ /**
+ * The "type" of this value
+ */
+ public static final String STRING = "string"; //$NON-NLS-1$
+
+ private String string = null;
+
+ /**
+ * Constructor
+ *
+ * @param vm
+ * @param string
+ */
+ public CFStringValue(VirtualMachine vm, String string) {
+ super(vm);
+ this.string = string;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString()
+ */
+ public String valueString() {
+ return string;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.StringValue#value()
+ */
+ public String value() {
+ return string;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return string;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFThreadReference.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFThreadReference.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFThreadReference.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFThreadReference.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,326 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFRequestPacket;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFResponsePacket;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Commands;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
+
+/**
+ * Default implementation of {@link ThreadReference} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFThreadReference extends CFMirror implements ThreadReference {
+
+ static final int RUNNING = 0;
+ static final int SUSPENDED = 1;
+ static final int TERMINATED = 2;
+ static final int EVENT_RESUME = 3;
+
+ private String id = null;
+ private String url = null;
+ private boolean current = false;
+ private int state = RUNNING;
+ private ArrayList frames = null;
+ private int stepkind = -1;
+
+ /**
+ * Constructor
+ *
+ * @param vm
+ * @param id
+ * @param url
+ */
+ public CFThreadReference(VirtualMachine vm, String id, String url) {
+ super(vm);
+ this.id = id;
+ this.url = url;
+ }
+
+ /**
+ * Constructor
+ * @param vm
+ * @param json
+ */
+ public CFThreadReference(VirtualMachine vm, Map json) {
+ super(vm);
+ this.id = (String) json.get(Attributes.CONTEXT_ID);
+ this.url = (String) json.get(Attributes.URL);
+ Boolean bool = (Boolean) json.get(Attributes.CURRENT);
+ if(bool != null) {
+ this.current = bool.booleanValue();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#frameCount()
+ */
+ public int frameCount() {
+ return frames == null ? 0 : frames.size();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#frame(int)
+ */
+ public synchronized StackFrame frame(int index) {
+ if(frames == null || index < 0 || index > frames.size()) {
+ return null;
+ }
+ return (StackFrame) frames.get(index);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#frames()
+ */
+ public synchronized List frames() {
+ if(frames == null) {
+ CFRequestPacket request = new CFRequestPacket(Commands.BACKTRACE, id);
+ request.setArgument(Attributes.FROM_FRAME, new Integer(0));
+ request.setArgument(Attributes.INCLUDE_SCOPES, Boolean.TRUE);
+ CFResponsePacket response = crossfire().sendRequest(request);
+ if(response.isSuccess()) {
+ frames = new ArrayList();
+ List frms = (List) response.getBody().get(Attributes.FRAMES);
+ if(frms != null) {
+ Map fmap = null;
+ for (int i = 0; i < frms.size(); i++) {
+ fmap = (Map) frms.get(i);
+ //XXX hack to prevent http://code.google.com/p/fbug/issues/detail?id=4203
+ if(fmap.containsKey(Attributes.URL)) {
+ frames.add(new CFStackFrame(virtualMachine(), this, fmap));
+ }
+ else if(TRACE) {
+ Tracing.writeString("STACKFRAME [got bogus stackframe infos]: "+fmap.values().toString()); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ else {
+ if(TRACE) {
+ Tracing.writeString("STACKFRAME [backtrace request failed]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ if(frames != null) {
+ frames.clear();
+ }
+ return Collections.EMPTY_LIST;
+ }
+ }
+ return frames;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#interrupt()
+ */
+ public void interrupt() {
+ try {
+ resume();
+ }
+ finally {
+ state = TERMINATED;
+ }
+ }
+
+ /**
+ * The thread has been resumed by an event
+ */
+ public void eventResume() {
+ state = EVENT_RESUME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#resume()
+ */
+ public void resume() {
+ if(isSuspended()) {
+ try {
+ if(state != EVENT_RESUME) {
+ //XXX only send an request if we were not resumed by an event
+ CFRequestPacket request = new CFRequestPacket(Commands.CONTINUE, id);
+ String step = resolveStepKind();
+ if(step != null) {
+ request.setArgument(Attributes.STEPACTION, step);
+ }
+
+ CFResponsePacket response = crossfire().sendRequest(request);
+ if(response.isSuccess()) {
+ state = RUNNING;
+ }
+ else if(TRACE) {
+ Tracing.writeString("THREAD [failed continue request] "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ }
+ finally {
+ clearFrames();
+ state = RUNNING;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#suspend()
+ */
+ public void suspend() {
+ if(isRunning()) {
+ CFRequestPacket request = new CFRequestPacket(Commands.SUSPEND, id);
+ try {
+ CFResponsePacket response = crossfire().sendRequest(request);
+ if(response.isSuccess()) {
+ //XXX catch in case the last resume failed
+ state = SUSPENDED;
+ }
+ else if(TRACE) {
+ Tracing.writeString("THREAD [failed suspend request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ finally {
+ clearFrames();
+ }
+ }
+ }
+
+ /**
+ * Clears out any stale stack frames
+ */
+ void clearFrames() {
+ if(frames != null) {
+ frames.clear();
+ frames = null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#status()
+ */
+ public int status() {
+ return THREAD_STATUS_RUNNING;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#isAtBreakpoint()
+ */
+ public boolean isAtBreakpoint() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#isSuspended()
+ */
+ public boolean isSuspended() {
+ return state == SUSPENDED;
+ }
+
+ /**
+ * @return if the thread is in a running state
+ */
+ public boolean isRunning() {
+ return state == RUNNING;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#name()
+ */
+ public String name() {
+ return NLS.bind(Messages.thread_name, new Object[] {id, url});
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("ThreadReference: [contextId - ").append(id).append("] [url - ").append(url).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return buffer.toString();
+ }
+
+ /**
+ * Returns the Crossfire id for this thread
+ *
+ * @return the id
+ */
+ public String id() {
+ return id;
+ }
+
+ /**
+ * Returns the URL for this thread
+ *
+ * @return the URL
+ */
+ public String url() {
+ return url;
+ }
+
+ /**
+ * Marks the thread as suspended or not. This is a call-back from the
+ * VM when suspending a VM.
+ *
+ * @param suspended
+ */
+ public void markSuspended(boolean suspended) {
+ //XXX catch - this causes a state change
+ clearFrames();
+ state = suspended ? SUSPENDED : RUNNING;
+ }
+
+ /**
+ * Sets the current step kind kind to perform, or -1 to remove the kind
+ * @param stepkind
+ */
+ public void setStep(int step) {
+ this.stepkind = step;
+ }
+
+ /**
+ * @return the step kind to use in the continue request or null
+ */
+ String resolveStepKind() {
+ if(stepkind != -1) {
+ switch(stepkind) {
+ case StepRequest.STEP_INTO: return Commands.STEP_IN;
+ case StepRequest.STEP_OUT: return Commands.STEP_OUT;
+ case StepRequest.STEP_OVER: return Commands.STEP_NEXT;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns if the this thread is the current (focus) context in the browser
+ *
+ * @return true
if this thread is the current (focus) context
+ */
+ public boolean isCurrent() {
+ return this.current;
+ }
+
+ /**
+ * Allows the current (focus) status of the thread to be set
+ * @param current the new current state
+ */
+ public void setCurrent(boolean current) {
+ this.current = current;
+ }
+}
\ No newline at end of file
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFUndefinedValue.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFUndefinedValue.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFUndefinedValue.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFUndefinedValue.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.UndefinedValue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+
+/**
+ * Default implementation for an {@link UndefinedValue} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFUndefinedValue extends CFMirror implements UndefinedValue {
+
+ public static final String UNDEFINED = "undefined"; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ *
+ * @param vm
+ */
+ public CFUndefinedValue(VirtualMachine vm) {
+ super(vm);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString()
+ */
+ public String valueString() {
+ return UNDEFINED;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return valueString();
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFVariable.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFVariable.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFVariable.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFVariable.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import java.util.Map;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame;
+import org.eclipse.wst.jsdt.debug.core.jsdi.Value;
+import org.eclipse.wst.jsdt.debug.core.jsdi.Variable;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
+
+/**
+ * Default implementation of a {@link Variable} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFVariable extends CFProperty implements Variable {
+
+ /**
+ * Constructor
+ *
+ * @param vm
+ * @param frame
+ * @param name
+ * @param ref
+ * @param values
+ */
+ public CFVariable(CFVirtualMachine vm, CFStackFrame frame, String name, Number ref, Map values) {
+ super(vm, frame, name, ref);
+ Value value = null;
+ try {
+ if(values != null) {
+ String kind = (String) values.get(Attributes.TYPE);
+ //if we have a primitive type create it value now
+ if(kind != null) {
+ if(kind.equals(Attributes.STRING)) {
+ value = new CFStringValue(vm, (String) values.get(Attributes.VALUE));
+ }
+ else if(kind.equals(Attributes.NUMBER)) {
+ Object o = values.get(Attributes.VALUE);
+ if(o instanceof Number) {
+ value = new CFNumberValue(vm, (Number)o);
+ }
+ else if(o instanceof String) {
+ value = new CFNumberValue(vm, (String)o);
+ }
+ }
+ else if(kind.equals(Attributes.BOOLEAN)) {
+ value = new CFBooleanValue(vm, ((Boolean)values.get(Attributes.VALUE)).booleanValue());
+ }
+ if(Attributes.THIS.equals(name)) {
+ //special object that has no lookup so we have to pre-populate the properties
+ value = new CFObjectReference(crossfire(), frame, values);
+ }
+ if(CFUndefinedValue.UNDEFINED.equals(kind)) {
+ value = crossfire().mirrorOfUndefined();
+ }
+ }
+ }
+ else {
+ value = crossfire().mirrorOfNull();
+ }
+ }
+ catch(Exception e) {
+ value = crossfire().mirrorOfUndefined();
+ }
+ if(value != null) {
+ setValue(value);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Variable#isArgument()
+ */
+ public boolean isArgument() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Variable#isVisible(org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame)
+ */
+ public boolean isVisible(StackFrame frame) {
+ if(frame instanceof CFStackFrame) {
+ return ((CFStackFrame)frame).isVisible(this);
+ }
+ return false;
+ }
+}
\ No newline at end of file
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFVirtualMachine.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFVirtualMachine.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFVirtualMachine.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFVirtualMachine.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,839 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IBreakpointListener;
+import org.eclipse.debug.core.IBreakpointManager;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.wst.jsdt.core.JavaScriptCore;
+import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLineBreakpoint;
+import org.eclipse.wst.jsdt.debug.core.jsdi.BooleanValue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.NullValue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.NumberValue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.StringValue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.UndefinedValue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.event.EventQueue;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager;
+import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel;
+import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
+import org.eclipse.wst.jsdt.debug.internal.core.breakpoints.JavaScriptLineBreakpoint;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.Constants;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.CrossFirePlugin;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.event.CFEventQueue;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFEventPacket;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFRequestPacket;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFResponsePacket;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Commands;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
+import org.eclipse.wst.jsdt.debug.transport.DebugSession;
+import org.eclipse.wst.jsdt.debug.transport.exception.DisconnectedException;
+import org.eclipse.wst.jsdt.debug.transport.exception.TimeoutException;
+
+/**
+ * Default CrossFire implementation of {@link VirtualMachine}
+ *
+ * @since 1.0
+ */
+public class CFVirtualMachine extends CFMirror implements VirtualMachine, IBreakpointListener {
+
+ private final NullValue nullvalue = new CFNullValue(this);
+ private final UndefinedValue undefinedvalue = new CFUndefinedValue(this);
+
+ private final DebugSession session;
+ private final CFEventRequestManager ermanager = new CFEventRequestManager(this);
+ private final CFEventQueue queue = new CFEventQueue(this, ermanager);
+ private boolean disconnected = false;
+
+ private Map threads = null;
+ private Map scripts = null;
+ private Map breakpointHandles = new HashMap();
+
+ /**
+ * Constructor
+ *
+ * @param session
+ */
+ public CFVirtualMachine(DebugSession session) {
+ super();
+ this.session = session;
+ initializeBreakpoints();
+ }
+
+ /**
+ * Synchronizes the set of breakpoints between client and server
+ */
+ void initializeBreakpoints() {
+ IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
+ manager.addBreakpointListener(this);
+ IBreakpoint[] managerBreakpoints = manager.getBreakpoints(JavaScriptDebugModel.MODEL_ID);
+ Vector allBps = new Vector();
+ for (int i = 0; i < managerBreakpoints.length; i++) {
+ IBreakpoint current = managerBreakpoints[i];
+ if (current instanceof JavaScriptLineBreakpoint) {
+ try {
+ JavaScriptLineBreakpoint breakpoint = (JavaScriptLineBreakpoint)current;
+
+ IResource resource = breakpoint.getMarker().getResource();
+ QualifiedName qName = new QualifiedName(JavaScriptCore.PLUGIN_ID, "scriptURL"); //$NON-NLS-1$
+ String url = resource.getPersistentProperty(qName);
+ if (url == null) {
+ String path = breakpoint.getScriptPath();
+ url = JavaScriptDebugPlugin.getExternalScriptPath(new Path(path));
+ }
+
+ if (url != null) {
+ Map location = new HashMap();
+ location.put(Attributes.LINE, new Integer(breakpoint.getLineNumber()));
+ location.put(Attributes.URL, url);
+ Map attributes = new HashMap();
+ if (breakpoint.isConditionEnabled()) {
+ String condition = breakpoint.getCondition();
+ if (condition != null) {
+ attributes.put(Attributes.CONDITION, condition);
+ }
+ }
+ int hitCount = breakpoint.getHitCount();
+ if (hitCount != -1) {
+ attributes.put(Attributes.HIT_COUNT, new Integer(hitCount));
+ }
+ Map bpMap = new HashMap();
+ bpMap.put(Attributes.TYPE, Attributes.LINE);
+ bpMap.put(Attributes.LOCATION, location);
+ bpMap.put(Attributes.ATTRIBUTES, attributes);
+ allBps.add(bpMap);
+ }
+ } catch (CoreException e) {
+ CrossFirePlugin.log(e);
+ }
+ }
+ }
+ if (allBps.size() > 0) {
+ CFRequestPacket request = new CFRequestPacket(Commands.SET_BREAKPOINTS, null);
+ request.setArgument(Attributes.BREAKPOINTS, Arrays.asList(allBps.toArray()));
+ CFResponsePacket response = ((CFVirtualMachine)virtualMachine()).sendRequest(request);
+ if (!response.isSuccess()) {
+ if(TRACE) {
+ Tracing.writeString("VM [failed setbreakpoints request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ }
+
+ CFRequestPacket request = new CFRequestPacket(Commands.GET_BREAKPOINTS, null);
+ CFResponsePacket response = sendRequest(request);
+ if(response.isSuccess()) {
+ List list = (List) response.getBody().get(Attributes.BREAKPOINTS);
+ Map bp = null;
+ for (Iterator i = list.iterator(); i.hasNext();) {
+ bp = (Map) i.next();
+ addBreakpoint(bp);
+ }
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed getbreakpoints request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Sends the getbreakpoint
request for the given breakpoint handle
+ * @param handle
+ * @return the {@link RemoteBreakpoint} representing the request or null
if the breakpoint could not be found
+ */
+ public RemoteBreakpoint getBreakpoint(Number handle) {
+ CFRequestPacket request = new CFRequestPacket(Commands.GET_BREAKPOINTS, null);
+ request.setArgument(Attributes.HANDLES, Arrays.asList(new Number[] {handle}));
+ CFResponsePacket response = sendRequest(request);
+ if(response.isSuccess()) {
+ List list = (List)response.getBody().get(Attributes.BREAKPOINTS);
+ if (list != null && list.size() > 0) {
+ addBreakpoint((Map)list.get(0));
+ }
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed getbreakpoint request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ return (RemoteBreakpoint) breakpointHandles.get(handle);
+ }
+
+ /**
+ * Sends the changebreakpoint
request for the given breakpoint handle to change the given map of attributes
+ * @param handle
+ * @param attributes
+ * @return the changed {@link RemoteBreakpoint} object or null
if the request failed
+ */
+ public RemoteBreakpoint changeBreakpoint(Number handle, Map attributes) {
+ CFRequestPacket request = new CFRequestPacket(Commands.CHANGE_BREAKPOINTS, null);
+ request.setArgument(Attributes.HANDLES, Arrays.asList(new Number[] {handle}));
+ request.setArgument(Attributes.ATTRIBUTES, attributes);
+ CFResponsePacket response = sendRequest(request);
+ if(response.isSuccess()) {
+ updateBreakpoint(response.getBody());
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed getbreakpoint request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ return (RemoteBreakpoint) breakpointHandles.get(handle);
+ }
+
+ /**
+ * Called via reflection to determine if the VM supports suspend on script loads
+ * @return true
if this VM can suspend when a script loads false
otherwise
+ */
+ public boolean supportsSuspendOnScriptLoads() {
+ return false;
+ }
+
+ /**
+ * Add the breakpoint described by the given JSON to the handles list
+ * @param json
+ */
+ public void addBreakpoint(Map json) {
+ if(json != null) {
+ Number handle = (Number) json.get(Attributes.HANDLE);
+ if(handle != null) {
+ RemoteBreakpoint bp = (RemoteBreakpoint) breakpointHandles.get(handle);
+ if(bp == null) {
+ bp = new RemoteBreakpoint(this,
+ handle,
+ (Map) json.get(Attributes.LOCATION),
+ (Map) json.get(Attributes.ATTRIBUTES),
+ (String)json.get(Attributes.TYPE));
+ }
+ }
+ }
+ }
+
+ /**
+ * Locates the breakpoint for the handle given in the map and updates its attributes
+ *
+ * @param json the JSON map, cannot be null
+ */
+ public void updateBreakpoint(Map json) {
+ if(json != null) {
+ Number handle = (Number) json.get(Attributes.HANDLE);
+ if(handle != null) {
+ RemoteBreakpoint bp = (RemoteBreakpoint) breakpointHandles.get(handle);
+ if(bp != null) {
+ bp.setEnabled(RemoteBreakpoint.getEnabled(json));
+ bp.setCondition(RemoteBreakpoint.getCondition(json));
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds or removes the breakpoint from the cache based on the isset
attribute
+ *
+ * @param json the JSON map, cannot be null
+ */
+ public void toggleBreakpoint(Map json) {
+ if(json != null) {
+ Boolean isset = (Boolean)json.get(Attributes.SET);
+ if(isset != null && isset.booleanValue()) {
+ updateBreakpoint(json);
+ }
+ else {
+ Number handle = (Number) json.get(Attributes.HANDLE);
+ breakpointHandles.remove(handle);
+ }
+ }
+ }
+
+ /**
+ * @return the 'readiness' of the VM - i.e. is it in a state to process requests, etc
+ */
+ boolean ready() {
+ return !disconnected;
+ }
+
+ /**
+ * Sends an createcontext
request for the given URL and returns the status of the request.
+ *
+ * @param url the URL to open / update in the remote target, null
is not accepted
+ * @return true
if the request was successful, false
otherwise
+ */
+ boolean createContext(String url) {
+ if(url != null && ready()) {
+ CFRequestPacket request = new CFRequestPacket(Commands.CREATE_CONTEXT, null);
+ request.getArguments().put(Attributes.URL, url);
+ CFResponsePacket response = sendRequest(request);
+ if(response.isSuccess()) {
+ return true;
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed createcontext request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Sends the frame request
+ * @param contextid
+ * @param index
+ * @param includescopes
+ * @return
+ */
+ CFStackFrame getFrame(String contextid, int index, boolean includescopes) {
+ if(index > -1) {
+ CFThreadReference thread = findThread(contextid);
+ if(thread != null) {
+ CFRequestPacket request = new CFRequestPacket(Commands.FRAME, thread.id());
+ request.setArgument(Attributes.INDEX, new Integer(index));
+ request.setArgument(Attributes.INCLUDE_SCOPES, new Boolean(includescopes));
+ CFResponsePacket response = sendRequest(request);
+ if(response.isSuccess()) {
+ return new CFStackFrame(this, thread, response.getBody());
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed frame request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ }
+ return null;
+
+ }
+
+ /**
+ * Sends a request to enable the tool with the given name in the remote Crossfire server
+ *
+ * @param tools the array of tool names to enable, null
is not allowed
+ * @return true
if the server reports the tool became enabled, false
otherwise
+ */
+ boolean enableTools(String[] tools) {
+ if(tools != null && tools.length > 0 && ready()) {
+ CFRequestPacket request = new CFRequestPacket(Commands.ENABLE_TOOLS, null);
+ request.getArguments().put(Attributes.TOOLS, Arrays.asList(tools));
+ CFResponsePacket response = sendRequest(request);
+ if(response.isSuccess()) {
+ //TODO handle the tool being enabled
+ return true;
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed enabletool request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Sends a request to disable the tool with the given name in the remote Crossfire server
+ *
+ * @param tools the array of tool names to disable, null
is not allowed
+ * @return true
if the server reports the tool became disabled, false
otherwise
+ */
+ boolean disableTools(String[] tools) {
+ if(tools != null && tools.length > 0 && ready()) {
+ CFRequestPacket request = new CFRequestPacket(Commands.DISABLE_TOOLS, null);
+ request.getArguments().put(Attributes.TOOLS, Arrays.asList(tools));
+ CFResponsePacket response = sendRequest(request);
+ if(response.isSuccess()) {
+ //TODO handle the tool being enabled
+ return true;
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed disabletool request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns the complete listing of tools from Crossfire regardless of their enabled state.
+ *
+ * @return the listing of tools or an empty list, never null
+ */
+ List allTools() {
+ if(ready()) {
+ CFRequestPacket request = new CFRequestPacket(Commands.GET_TOOLS, null);
+ CFResponsePacket response = sendRequest(request);
+ if(response.isSuccess()) {
+ //TODO do we want to make these first-class objects in our model so we can track state, etc for tools?
+ List tools = (List) response.getBody().get(Attributes.TOOLS);
+ if(tools != null) {
+ return tools;
+ }
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed alltools request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ return Collections.EMPTY_LIST;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#resume()
+ */
+ public void resume() {
+ if(ready()) {
+ if(threads != null) {
+ Entry entry = null;
+ for (Iterator iter = threads.entrySet().iterator(); iter.hasNext();) {
+ entry = (Entry) iter.next();
+ CFThreadReference thread = (CFThreadReference) entry.getValue();
+ if(thread.isSuspended()) {
+ CFRequestPacket request = new CFRequestPacket(Commands.CONTINUE, thread.id());
+ CFResponsePacket response = sendRequest(request);
+ if(response.isSuccess()) {
+ if(thread.isSuspended()) {
+ thread.markSuspended(false);
+ }
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed continue request][context: "+thread.id()+"]: "+JSON.serialize(request)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#suspend()
+ */
+ public void suspend() {
+ if(ready()) {
+ if(threads != null) {
+ Entry entry = null;
+ for (Iterator iter = threads.entrySet().iterator(); iter.hasNext();) {
+ entry = (Entry) iter.next();
+ CFThreadReference thread = (CFThreadReference) entry.getValue();
+ if(thread.isRunning()) {
+ CFRequestPacket request = new CFRequestPacket(Commands.SUSPEND, thread.id());
+ CFResponsePacket response = sendRequest(request);
+ if(response.isSuccess()) {
+ if(!thread.isSuspended()) {
+ thread.markSuspended(true);
+ }
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed suspend request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#terminate()
+ */
+ public void terminate() {
+ if(ready()) {
+ disconnectVM();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#name()
+ */
+ public String name() {
+ return Messages.vm_name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#description()
+ */
+ public String description() {
+ return Messages.crossfire_vm;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#version()
+ */
+ public synchronized String version() {
+ if(ready()) {
+ CFRequestPacket request = new CFRequestPacket(Commands.VERSION, null);
+ CFResponsePacket response = sendRequest(request);
+ if(response.isSuccess()) {
+ Map json = response.getBody();
+ return (String) json.get(Commands.VERSION);
+ }
+ if(TRACE) {
+ Tracing.writeString("VM [failed version request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ return Constants.UNKNOWN;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#allThreads()
+ */
+ public synchronized List allThreads() {
+ if(threads == null) {
+ threads = new HashMap();
+ CFRequestPacket request = new CFRequestPacket(Commands.LISTCONTEXTS, null);
+ CFResponsePacket response = sendRequest(request);
+ if(response.isSuccess()) {
+ List contexts = (List) response.getBody().get(Attributes.CONTEXTS);
+ for (Iterator iter = contexts.iterator(); iter.hasNext();) {
+ Map json = (Map) iter.next();
+ CFThreadReference thread = new CFThreadReference(this, json);
+ threads.put(thread.id(), thread);
+ }
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed allthreads request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ return new ArrayList(threads.values());
+ }
+
+ /**
+ * Adds a thread to the listing
+ *
+ * @param id
+ * @param url
+ * @return the new thread
+ */
+ public CFThreadReference addThread(String id, String url) {
+ if(threads == null) {
+ allThreads();
+ }
+ CFThreadReference thread = new CFThreadReference(this, id, url);
+ threads.put(thread.id(), thread);
+ return thread;
+ }
+
+ /**
+ * Removes the thread with the given id
+ *
+ * @param id the id of the thread to remove
+ */
+ public void removeThread(String id) {
+ if(threads != null) {
+ Object obj = threads.remove(id);
+ if(TRACE && obj == null) {
+ Tracing.writeString("VM [failed to remove thread]: "+id); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * Returns the thread with the given id or null
+ *
+ * @param id
+ * @return the thread or null
+ */
+ public synchronized CFThreadReference findThread(String id) {
+ if(threads == null) {
+ allThreads();
+ }
+ CFThreadReference thread = (CFThreadReference) threads.get(id);
+ if(TRACE && thread == null) {
+ Tracing.writeString("VM [failed to find thread]: "+id); //$NON-NLS-1$
+ }
+ return thread;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#allScripts()
+ */
+ public synchronized List allScripts() {
+ if(scripts == null) {
+ scripts = new HashMap();
+ List threads = allThreads();
+ for (Iterator iter = threads.iterator(); iter.hasNext();) {
+ CFThreadReference thread = (CFThreadReference) iter.next();
+ CFRequestPacket request = new CFRequestPacket(Commands.SCRIPTS, thread.id());
+ request.setArgument(Attributes.INCLUDE_SOURCE, Boolean.FALSE);
+ CFResponsePacket response = sendRequest(request);
+ if(response.isSuccess()) {
+ List scriptz = (List) response.getBody().get(Attributes.SCRIPTS);
+ for (Iterator iter2 = scriptz.iterator(); iter2.hasNext();) {
+ Map smap = (Map) iter2.next();
+ if(smap != null) {
+ CFScriptReference script = new CFScriptReference(this, thread.id(), smap);
+ scripts.put(script.url(), script);
+ }
+ }
+ }
+ else if(TRACE) {
+ Tracing.writeString("VM [failed scripts request]: "+JSON.serialize(request)); //$NON-NLS-1$
+ }
+ }
+ if(scripts.size() < 1) {
+ scripts = null;
+ return Collections.EMPTY_LIST;
+ }
+ }
+ return new ArrayList(scripts.values());
+ }
+
+ /**
+ * Returns the script with the given url or null
+ *
+ * @param url
+ * @return the thread or null
+ */
+ public synchronized CFScriptReference findScript(String url) {
+ if(scripts == null) {
+ allScripts();
+ }
+ CFScriptReference script = null;
+ if(scripts != null) {
+ //the scripts collection can be null after a call to allScripts()
+ //when the remote target had no scripts loaded. In this case
+ //we do not keep the initialized collection so that any successive
+ //calls the this method or allScripts will cause the remote target
+ //to be asked for all of its scripts
+ script = (CFScriptReference) scripts.get(url);
+ }
+ //if we find we have a script id that is not cached, we should try a lookup + add in the vm
+ if(script == null) {
+ if(TRACE) {
+ Tracing.writeString("VM [failed to find script]: "+url); //$NON-NLS-1$
+ }
+ }
+ return script;
+ }
+
+ /**
+ * Adds the given script to the listing
+ *
+ * @param context_id
+ * @param json
+ *
+ * @return the new script
+ */
+ public CFScriptReference addScript(String context_id, Map json) {
+ if(scripts == null) {
+ allScripts();
+ }
+ CFScriptReference script = new CFScriptReference(this, context_id, json);
+ scripts.put(script.url(), script);
+ return script;
+ }
+
+ /**
+ * Removes all {@link CFScriptReference}s from the cache when the associated context is destroyed
+ *
+ * @param contextid
+ */
+ public void removeScriptsForContext(String contextid) {
+ if(scripts != null) {
+ Entry e = null;
+ for(Iterator i = scripts.entrySet().iterator(); i.hasNext();) {
+ e = (Entry) i.next();
+ if(contextid.equals(((CFScriptReference)e.getValue()).context())) {
+ i.remove();
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes the script with the given url from the listing
+ *
+ * @param url the script to remove
+ */
+ public void removeScript(String url) {
+ if(scripts != null) {
+ Object obj = scripts.remove(url);
+ if(TRACE && obj == null) {
+ Tracing.writeString("VM [failed to remove script]: "+url); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#dispose()
+ */
+ public synchronized void dispose() {
+ try {
+ if(TRACE) {
+ Tracing.writeString("VM [disposing]"); //$NON-NLS-1$
+ }
+ queue.dispose();
+ ermanager.dispose();
+ }
+ finally {
+ //fall-back in case the VM has been disposed but not disconnected
+ disconnectVM();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOfUndefined()
+ */
+ public UndefinedValue mirrorOfUndefined() {
+ return undefinedvalue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOfNull()
+ */
+ public NullValue mirrorOfNull() {
+ return nullvalue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOf(boolean)
+ */
+ public BooleanValue mirrorOf(boolean bool) {
+ return new CFBooleanValue(this, bool);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOf(java.lang.Number)
+ */
+ public NumberValue mirrorOf(Number number) {
+ return new CFNumberValue(this, number);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOf(java.lang.String)
+ */
+ public StringValue mirrorOf(String string) {
+ return new CFStringValue(this, string);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#eventRequestManager()
+ */
+ public synchronized EventRequestManager eventRequestManager() {
+ return ermanager;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#eventQueue()
+ */
+ public synchronized EventQueue eventQueue() {
+ return queue;
+ }
+
+ /**
+ * Receives an {@link CFEventPacket} from the underlying {@link DebugSession},
+ * waiting for the {@link VirtualMachine#DEFAULT_TIMEOUT}.
+ *
+ * @return the next {@link CFEventPacket} never null
+ * @throws TimeoutException
+ * @throws DisconnectedException
+ */
+ public CFEventPacket receiveEvent() throws TimeoutException, DisconnectedException {
+ return (CFEventPacket) session.receive(CFEventPacket.EVENT, DEFAULT_TIMEOUT);
+ }
+
+ /**
+ * Receives an {@link CFEventPacket} from the underlying {@link DebugSession},
+ * waiting for the {@link VirtualMachine#DEFAULT_TIMEOUT}.
+ * @param timeout
+ * @return the next {@link CFEventPacket} never null
+ * @throws TimeoutException
+ * @throws DisconnectedException
+ */
+ public CFEventPacket receiveEvent(int timeout) throws TimeoutException, DisconnectedException {
+ return (CFEventPacket) session.receive(CFEventPacket.EVENT, timeout);
+ }
+
+ /**
+ * Sends a request to the underlying {@link DebugSession}, waiting
+ * for the {@link VirtualMachine#DEFAULT_TIMEOUT}.
+ *
+ * @param request
+ * @return the {@link CFResponsePacket} for the request
+ */
+ public CFResponsePacket sendRequest(CFRequestPacket request) {
+ try {
+ session.send(request);
+ return (CFResponsePacket) session.receiveResponse(request.getSequence(), 3000);
+ }
+ catch(DisconnectedException de) {
+ disconnectVM();
+ handleException(de.getMessage(), (de.getCause() == null ? de : de.getCause()));
+ }
+ catch(TimeoutException te) {
+ CrossFirePlugin.log(te);
+ }
+ return CFResponsePacket.FAILED;
+ }
+
+ /**
+ * disconnects the VM
+ */
+ public synchronized void disconnectVM() {
+ if (disconnected) {
+ // no-op it is already disconnected
+ if(TRACE) {
+ Tracing.writeString("VM [already disconnected]"); //$NON-NLS-1$
+ }
+ return;
+ }
+ if(TRACE) {
+ Tracing.writeString("VM [disconnecting]"); //$NON-NLS-1$
+ }
+ try {
+ if(threads != null) {
+ threads.clear();
+ }
+ if(scripts != null) {
+ scripts.clear();
+ }
+ this.queue.dispose();
+ this.ermanager.dispose();
+ this.session.dispose();
+ } finally {
+ disconnected = true;
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointAdded(org.eclipse.debug.core.model.IBreakpoint)
+ */
+ public void breakpointAdded(IBreakpoint breakpoint) {
+ if (JavaScriptDebugModel.MODEL_ID.equals(breakpoint.getModelIdentifier())) {
+ if (breakpoint instanceof IJavaScriptLineBreakpoint) {
+ //TODO check handle map send request as needed
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
+ */
+ public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
+ if (JavaScriptDebugModel.MODEL_ID.equals(breakpoint.getModelIdentifier())) {
+ if (breakpoint instanceof IJavaScriptLineBreakpoint) {
+ //TODO check handle map send request as needed
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
+ */
+ public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
+ if (JavaScriptDebugModel.MODEL_ID.equals(breakpoint.getModelIdentifier())) {
+ if (breakpoint instanceof IJavaScriptLineBreakpoint) {
+ //TODO check handle map send request as needed
+ }
+ }
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/Messages.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/Messages.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/Messages.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/Messages.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ *
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.messages"; //$NON-NLS-1$
+ public static String crossfire_vm;
+ public static String thread_name;
+ public static String vm_name;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/RemoteBreakpoint.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/RemoteBreakpoint.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/RemoteBreakpoint.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/RemoteBreakpoint.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,276 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
+
+
+/**
+ * This class holds the description of a breakpoint from the crossfire server
+ *
+ * @since 1.0
+ */
+public class RemoteBreakpoint implements Comparable {
+
+ public static final String TYPE_LINE = "line"; //$NON-NLS-1$
+ public static final String TYPE_HTML_ATTRIBUTE_CHANGE = "html_attribute_change"; //$NON-NLS-1$
+ public static final String TYPE_HTML_CHILD_CHANGE = "html_child_change"; //$NON-NLS-1$
+ public static final String TYPE_HTML_REMOVE = "html_remove"; //$NON-NLS-1$
+ public static final String TYPE_HTML_TEXT = "html_text"; //$NON-NLS-1$
+ public static final String TYPE_HTML_UNKNOWN = "html_unknown_type"; //$NON-NLS-1$
+
+ CFVirtualMachine vm = null;
+ Number handle = null;
+ String kind = null;
+ Map location = null;
+ Map attributes = null;
+
+ /**
+ * Constructor
+ * @param vm
+ * @param handle
+ * @param location
+ * @param attributes
+ * @param kind
+ */
+ public RemoteBreakpoint(CFVirtualMachine vm, Number handle, Map location, Map attributes, String kind) {
+ this.vm = vm;
+ this.handle = handle;
+ this.location = location;
+ this.attributes = attributes;
+ this.kind = kind;
+ }
+
+ /**
+ * @return the handle
+ */
+ public Number getHandle() {
+ return handle;
+ }
+
+ /**
+ * @return the url
+ */
+ public String getUrl() {
+ if(this.location != null) {
+ return (String) this.location.get(Attributes.URL);
+ }
+ return null;
+ }
+
+ /**
+ * @return the line
+ */
+ public int getLine() {
+ if(this.location != null) {
+ Number line = (Number) this.location.get(Attributes.LINE);
+ if(line != null) {
+ return line.intValue();
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * @return the condition
+ */
+ public String getCondition() {
+ if(this.attributes != null) {
+ return (String) this.attributes.get(Attributes.CONDITION);
+ }
+ return null;
+ }
+
+ /**
+ * @param condition the condition to set
+ */
+ public void setCondition(String condition) {
+ if(this.attributes == null) {
+ this.attributes = new HashMap();
+ }
+ if(condition != null) {
+ this.attributes.put(Attributes.CONDITION, condition);
+ }
+ else {
+ this.attributes.remove(Attributes.CONDITION);
+ }
+ }
+
+ /**
+ * @return the enabled
+ */
+ public boolean isEnabled() {
+ if(this.attributes != null) {
+ Boolean bool = (Boolean) this.attributes.get(Attributes.ENABLED);
+ if(bool != null) {
+ return bool.booleanValue();
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ if(this.attributes == null) {
+ this.attributes = new HashMap();
+ }
+ this.attributes.put(Attributes.ENABLED, Boolean.valueOf(enabled));
+ }
+
+ /**
+ * @return the kind
+ */
+ public String getKind() {
+ return kind;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object o) {
+ if(o instanceof RemoteBreakpoint) {
+ RemoteBreakpoint bp = (RemoteBreakpoint) o;
+ return handle.equals(bp.handle) && mapsEqual(location, bp.location) && mapsEqual(attributes, bp.attributes) && kind.equals(bp.kind);
+ }
+ return false;
+ }
+
+ /**
+ * Returns if the given maps are equal.
+ * null
true
if the maps are equal false
otherwise
+ */
+ boolean mapsEqual(Map m1, Map m2) {
+ if(m1 == null && m2 == null) {
+ return true;
+ }
+ if(m1 == null ^ m2 == null) {
+ return false;
+ }
+ if(m1.size() != m2.size()) {
+ return false;
+ }
+ Entry entry = null;
+ for (Iterator i = m1.entrySet().iterator(); i.hasNext();) {
+ entry = (Entry) i.next();
+ Object val = m2.get(entry.getKey());
+ if(val == null) {
+ return false;
+ }
+ if(!val.equals(entry.getValue())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return handle.hashCode() + mapHashCode(location) + mapHashCode(attributes) + kind.hashCode();
+ }
+
+ /**
+ * Computes the hash code for the given map
+ * @param m
+ * @return the hash code to use for the given map
+ */
+ int mapHashCode(Map m) {
+ int hashcode = 0;
+ for (Iterator i = m.values().iterator(); i.hasNext();) {
+ hashcode += i.next().hashCode();
+ }
+ return hashcode;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object o) {
+ if(o instanceof RemoteBreakpoint) {
+ RemoteBreakpoint bp = (RemoteBreakpoint) o;
+ return this.kind.compareTo(bp.kind);
+ }
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buff = new StringBuffer("RemoteBreakpoint\n"); //$NON-NLS-1$
+ buff.append("\t[handle: ").append(handle.toString()).append("]\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return super.toString();
+ }
+
+ /**
+ * Helper method to get the {@link Attributes#ENABLED} value from the breakpoint JSON
+ *
+ * @param json the JSON for the breakpoint
+ * @return true
if the attribute is found and true
, false
otherwise
+ */
+ public static boolean getEnabled(Map json) {
+ Object val = json.get(Attributes.ATTRIBUTES);
+ if(val instanceof Map) {
+ Map map = (Map) val;
+ val = map.get(Attributes.ENABLED);
+ if(val instanceof Boolean) {
+ return ((Boolean)val).booleanValue();
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Helper method to get the condition from the breakpoint JSON
+ *
+ * @param json the JSON for the breakpoint
+ * @return the condition or null
+ */
+ public static final String getCondition(Map json) {
+ Object val = json.get(Attributes.ATTRIBUTES);
+ if(val instanceof Map) {
+ Map map = (Map) val;
+ return (String)map.get(Attributes.CONDITION);
+ }
+ return null;
+ }
+
+ /**
+ * Helper method to get the 'set' value from the breakpoint JSON
+ *
+ * @param json the JSON for the breakpoint
+ * @return true
if the attribute is present and true
, false
otherwise
+ */
+ public static final boolean isSet(Map json) {
+ Object val = json.get(Attributes.SET);
+ if(val instanceof Boolean) {
+ return ((Boolean)val).booleanValue();
+ }
+ return false;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/messages.properties
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/messages.properties
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/messages.properties
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/messages.properties 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2010 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+crossfire_vm=Crossfire VM
+thread_name={0} - {1}
+vm_name=CrossFire VM
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFBreakpointRequest.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFBreakpointRequest.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFBreakpointRequest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFBreakpointRequest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFScriptReference;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFVirtualMachine;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFRequestPacket;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFResponsePacket;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Commands;
+
+/**
+ * Default implementation of {@link BreakpointRequest} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFBreakpointRequest extends CFThreadEventRequest implements BreakpointRequest {
+
+ private String condition = null;
+ private int hitcount = 0;
+ private Location location = null;
+ private Long bpHandle = null;
+
+ /**
+ * Constructor
+ * @param vm
+ * @param location
+ */
+ public CFBreakpointRequest(VirtualMachine vm, Location location) {
+ super(vm);
+ this.location = location;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Locatable#location()
+ */
+ public Location location() {
+ return location;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest#addThreadFilter(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
+ */
+ public void addThreadFilter(ThreadReference thread) {
+ setThread(thread);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest#addConditionFilter(java.lang.String)
+ */
+ public void addConditionFilter(String condition) {
+ this.condition = condition;
+ }
+
+ /**
+ * Returns the {@link String} condition set for this request using {@link #addConditionFilter(String)} or null
+ *
+ * @return the condition filter or null
+ */
+ public String getConditionFilter() {
+ return condition;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest#addHitCountFilter(int)
+ */
+ public void addHitCountFilter(int hitcount) {
+ this.hitcount = hitcount;
+ }
+
+ /**
+ * Returns the hit count set using {@link #addHitCountFilter(int)} or 0
+ *
+ * @return the specified hit count or 0
+ */
+ public int getHitCount() {
+ return hitcount;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFEventRequest#setEnabled(boolean)
+ */
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ if(enabled) {
+ //send setbreakpoint request
+ CFScriptReference script = (CFScriptReference) location.scriptReference();
+ CFRequestPacket request = new CFRequestPacket(Commands.SET_BREAKPOINTS, null);
+ Map bp = new HashMap();
+ bp.put(Attributes.TYPE, Attributes.LINE);
+ Map loc = new HashMap();
+ loc.put(Attributes.LINE, new Integer(location.lineNumber()));
+ loc.put(Attributes.URL, script.url());
+ bp.put(Attributes.LOCATION, loc);
+ Map attribs = new HashMap();
+ if (condition != null) {
+ attribs.put(Attributes.CONDITION, condition);
+ }
+ if (hitcount > 0) {
+ attribs.put(Attributes.HIT_COUNT, new Long(hitcount));
+ }
+ attribs.put(Attributes.ENABLED, Boolean.TRUE);
+ bp.put(Attributes.ATTRIBUTES, attribs);
+ request.setArgument(Attributes.BREAKPOINTS, Arrays.asList(new Object[] {bp}));
+ CFResponsePacket response = ((CFVirtualMachine)virtualMachine()).sendRequest(request);
+ if(response.isSuccess()) {
+ //process the response to get the handle of the breakpoint
+ List list = (List)response.getBody().get(Attributes.BREAKPOINTS);
+ if (list != null && list.size() > 0) {
+ bp = (Map)list.get(0);
+ if (bp != null) {
+ Number handle = (Number) bp.get(Attributes.HANDLE);
+ bpHandle = new Long(handle.longValue());
+ }
+ }
+ else {
+ //TODO create a dummy breakpoint whose details can be filled in when an onToggleBreakpoint event is received
+ }
+ }
+ }
+ else if(bpHandle != null) {
+ //send deletebreakpoint request
+ CFRequestPacket request = new CFRequestPacket(Commands.DELETE_BREAKPOINTS, null);
+ request.getArguments().put(Attributes.HANDLES, Arrays.asList(new Number[] {bpHandle}));
+ CFResponsePacket response = ((CFVirtualMachine)virtualMachine()).sendRequest(request);
+ if(response.isSuccess()) {
+ bpHandle = null;
+ }
+ }
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDeathRequest.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDeathRequest.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDeathRequest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDeathRequest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.VMDeathRequest;
+
+/**
+ * Default implementation of {@link VMDeathRequest} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFDeathRequest extends CFEventRequest implements VMDeathRequest {
+
+ /**
+ * Constructor
+ * @param vm
+ */
+ public CFDeathRequest(VirtualMachine vm) {
+ super(vm);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDebuggerRequest.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDebuggerRequest.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDebuggerRequest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDebuggerRequest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.DebuggerStatementRequest;
+
+/**
+ * Default implementation of {@link DebuggerStatementRequest} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFDebuggerRequest extends CFThreadEventRequest implements DebuggerStatementRequest {
+
+ /**
+ * Constructor
+ * @param vm
+ */
+ public CFDebuggerRequest(VirtualMachine vm) {
+ super(vm);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.DebuggerStatementRequest#addThreadFilter(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
+ */
+ public void addThreadFilter(ThreadReference thread) {
+ setThread(thread);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDisconnectRequest.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDisconnectRequest.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDisconnectRequest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDisconnectRequest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.VMDisconnectRequest;
+
+/**
+ * Default implementation of {@link VMDisconnectRequest} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFDisconnectRequest extends CFEventRequest implements VMDisconnectRequest {
+
+ /**
+ * Constructor
+ * @param vm
+ */
+ public CFDisconnectRequest(VirtualMachine vm) {
+ super(vm);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFEventRequest.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFEventRequest.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFEventRequest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFEventRequest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
+
+/**
+ * Default {@link EventRequest} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFEventRequest implements EventRequest {
+
+ private boolean enabled = false;
+ private VirtualMachine vm = null;
+
+ /**
+ * Constructor
+ */
+ public CFEventRequest(VirtualMachine vm) {
+ this.vm = vm;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.Mirror#virtualMachine()
+ */
+ public VirtualMachine virtualMachine() {
+ return vm;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#isEnabled()
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#setEnabled(boolean)
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFExceptionRequest.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFExceptionRequest.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFExceptionRequest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFExceptionRequest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ExceptionRequest;
+
+/**
+ * Default implementation of {@link ExceptionRequest} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFExceptionRequest extends CFThreadEventRequest implements ExceptionRequest {
+
+ /**
+ * Constructor
+ * @param vm
+ */
+ public CFExceptionRequest(VirtualMachine vm) {
+ super(vm);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.ExceptionRequest#addThreadFilter(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
+ */
+ public void addThreadFilter(ThreadReference thread) {
+ setThread(thread);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFResumeRequest.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFResumeRequest.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFResumeRequest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFResumeRequest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ResumeRequest;
+
+/**
+ * Crossfire implementation of {@link ResumeRequest}
+ *
+ * @since 1.0
+ */
+public class CFResumeRequest extends CFThreadEventRequest implements ResumeRequest {
+
+ /**
+ * Constructor
+ * @param vm
+ * @param thread
+ */
+ public CFResumeRequest(VirtualMachine vm, ThreadReference thread) {
+ super(vm);
+ setThread(thread);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFScriptLoadRequest.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFScriptLoadRequest.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFScriptLoadRequest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFScriptLoadRequest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ScriptLoadRequest;
+
+/**
+ * Default implementation of {@link ScriptLoadRequest} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFScriptLoadRequest extends CFEventRequest implements ScriptLoadRequest {
+
+ /**
+ * Constructor
+ * @param vm
+ */
+ public CFScriptLoadRequest(VirtualMachine vm) {
+ super(vm);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFStepRequest.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFStepRequest.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFStepRequest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFStepRequest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFThreadReference;
+
+/**
+ * Default implementation of {@link StepRequest} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFStepRequest extends CFThreadEventRequest implements StepRequest {
+
+ private int stepkind = 0;
+
+ /**
+ * Constructor
+ * @param vm
+ */
+ public CFStepRequest(VirtualMachine vm, ThreadReference thread, int step) {
+ super(vm);
+ setThread(thread);
+ this.stepkind = step;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest#step()
+ */
+ public int step() {
+ return stepkind;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFEventRequest#setEnabled(boolean)
+ */
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ ((CFThreadReference)thread()).setStep((enabled ? stepkind : -1));
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFSuspendRequest.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFSuspendRequest.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFSuspendRequest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFSuspendRequest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.SuspendRequest;
+
+/**
+ * Default implementation of {@link SuspendRequest} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFSuspendRequest extends CFThreadEventRequest implements SuspendRequest {
+
+ /**
+ * Constructor
+ * @param vm
+ */
+ public CFSuspendRequest(VirtualMachine vm, ThreadReference thread) {
+ super(vm);
+ setThread(thread);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadEnterRequest.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadEnterRequest.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadEnterRequest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadEnterRequest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadEnterRequest;
+
+/**
+ * Default implementation of {@link ThreadEnterRequest} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFThreadEnterRequest extends CFThreadEventRequest implements ThreadEnterRequest {
+
+ /**
+ * Constructor
+ * @param vm
+ */
+ public CFThreadEnterRequest(VirtualMachine vm) {
+ super(vm);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadEnterRequest#addThreadFilter(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
+ */
+ public void addThreadFilter(ThreadReference thread) {
+ setThread(thread);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadEventRequest.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadEventRequest.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadEventRequest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadEventRequest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+
+/**
+ * Abstract notion of an event that knows about a thread
+ *
+ * @since 1.0
+ */
+public class CFThreadEventRequest extends CFEventRequest {
+
+ private ThreadReference thread = null;
+
+ /**
+ * Constructor
+ * @param vm
+ */
+ public CFThreadEventRequest(VirtualMachine vm) {
+ super(vm);
+ }
+
+ /**
+ * Sets the backing {@link ThreadReference} for the request
+ * @param thread
+ */
+ public void setThread(ThreadReference thread) {
+ this.thread = thread;
+ }
+
+ /**
+ * Returns the underlying {@link ThreadReference} this request is filtered to.
+ * @return the thread filter
+ */
+ public ThreadReference thread() {
+ return this.thread;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadExitRequest.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadExitRequest.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadExitRequest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadExitRequest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
+
+import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
+import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
+import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadExitRequest;
+
+/**
+ * Default implementation of {@link ThreadExitRequest} for Crossfire
+ *
+ * @since 1.0
+ */
+public class CFThreadExitRequest extends CFThreadEventRequest implements ThreadExitRequest {
+
+ /**
+ * Constructor
+ * @param vm
+ */
+ public CFThreadExitRequest(VirtualMachine vm) {
+ super(vm);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadExitRequest#addThreadFilter(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
+ */
+ public void addThreadFilter(ThreadReference thread) {
+ setThread(thread);
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/Attributes.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/Attributes.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/Attributes.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/Attributes.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,356 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
+
+/**
+ * Interface for all the attribute constants
+ *
+ * @since 1.0
+ */
+public interface Attributes {
+
+ /**
+ * The "arguments" attribute
+ */
+ public static final String ARGUMENTS = "arguments"; //$NON-NLS-1$
+ /**
+ * The "attributes" attribute
+ */
+ public static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
+ /**
+ * The "body" attribute
+ */
+ public static final String BODY = "body"; //$NON-NLS-1$
+ /**
+ * The type "boolean"
+ */
+ public static final String BOOLEAN = "boolean"; //$NON-NLS-1$
+ /**
+ * The "breakpoint" attribute
+ */
+ public static final String BREAKPOINT = "breakpoint"; //$NON-NLS-1$
+ /**
+ * The "breakpoints" attribute
+ */
+ public static final String BREAKPOINTS = "breakpoints"; //$NON-NLS-1$
+ /**
+ * The "category" attribute
+ */
+ public static final String CATEGORY = "category"; //$NON-NLS-1$
+ /**
+ * The "callee attribute"
+ */
+ public static final String CALLEE = "callee"; //$NON-NLS-1$
+ /**
+ * The "callingFrame" attribute
+ */
+ public static final String CALLING_FRAME = "callingFrame"; //$NON-NLS-1$
+ /**
+ * The code attribute for this packet
+ */
+ public static final String CODE = "code"; //$NON-NLS-1$
+ /**
+ * The "columnNumber" attribute
+ */
+ public static final String COLUMN_NUMBER = "columnNumber"; //$NON-NLS-1$
+ /**
+ * The "columnOffset" attribute
+ */
+ public static final String COLUMN_OFFSET = "columnOffset"; //$NON-NLS-1$
+ /**
+ * The "command" attribute
+ */
+ public static final String COMMAND = "command"; //$NON-NLS-1$
+ /**
+ * The "condition" argument
+ */
+ public static final String CONDITION = "condition"; //$NON-NLS-1$
+ /**
+ * the "constructor" attribute
+ */
+ public static final String CONSTRUCTOR = "constructor"; //$NON-NLS-1$
+ /**
+ * the "context_href" attribute
+ */
+ public static final String CONTEXT_HREF = "context_href"; //$NON-NLS-1$
+ /**
+ * The "contextId" attribute
+ */
+ public static final String CONTEXT_ID = "contextId"; //$NON-NLS-1$
+ /**
+ * The "contexts" attribute
+ */
+ public static final String CONTEXTS = "contexts"; //$NON-NLS-1$
+ /**
+ * the "current" attribute
+ */
+ public static final String CURRENT = "current"; //$NON-NLS-1$
+ /**
+ * The "data" attribute
+ */
+ public static final String DATA = "data"; //$NON-NLS-1$
+ /**
+ * The "enabled" argument
+ */
+ public static final String ENABLED = "enabled"; //$NON-NLS-1$
+ /**
+ * The "error" attribute for an onError event
+ */
+ public static final String ERROR = "error"; //$NON-NLS-1$
+ /**
+ * The "errorMessage" attribute
+ */
+ public static final String ERROR_MESSAGE = "errorMessage"; //$NON-NLS-1$
+ /**
+ * The "executionContext" attribute
+ */
+ public static final String EXECUTION_CONTEXT = "executionContext"; //$NON-NLS-1$
+ /**
+ * The "expression" attribute
+ */
+ public static final String EXPRESSION = "expression"; //$NON-NLS-1$
+ /**
+ * The "fileName" attribute
+ */
+ public static final String FILE_NAME = "fileName"; //$NON-NLS-1$
+ /**
+ * The "flags" attributes
+ */
+ public static final String FLAGS = "flags"; //$NON-NLS-1$
+ /**
+ * The "frame" argument
+ */
+ public static final String FRAME = "frame"; //$NON-NLS-1$
+ /**
+ * The "frameIndex" argument
+ */
+ public static final String FRAME_INDEX = "frameIndex"; //$NON-NLS-1$
+ /**
+ * The "frameNumber" argument
+ */
+ public static final String FRAME_NUMBER = "frameNumber"; //$NON-NLS-1$
+ /**
+ * The "frames" attribute
+ */
+ public static final String FRAMES = "frames"; //$NON-NLS-1$
+ /**
+ * The "fromFrame" attribute
+ */
+ public static final String FROM_FRAME = "fromFrame"; //$NON-NLS-1$
+ /**
+ * The "functionName" attribute
+ */
+ public static final String FUNCTION_NAME = "functionName"; //$NON-NLS-1$
+ /**
+ * The type "function"
+ */
+ public static final String FUNCTION = "function"; //$NON-NLS-1$
+ /**
+ * The "handle" attribute
+ */
+ public static final String HANDLE = "handle"; //$NON-NLS-1$
+ /**
+ * The "handles" attribute
+ */
+ public static final String HANDLES = "handles"; //$NON-NLS-1$
+ /**
+ * The "handshake" attribute
+ */
+ public static final String HANDSHAKE = "handshake"; //$NON-NLS-1$
+ /**
+ * The "hitCount" attribute
+ */
+ public static final String HIT_COUNT = "hitCount"; //$NON-NLS-1$
+ /**
+ * The "href" attribute
+ */
+ public static final String HREF = "href"; //$NON-NLS-1$
+ /**
+ * The "includeScopes" attribute
+ */
+ public static final String INCLUDE_SCOPES = "includeScopes"; //$NON-NLS-1$
+ /**
+ * The "includeSource" attribute
+ */
+ public static final String INCLUDE_SOURCE = "includeSource"; //$NON-NLS-1$
+ /**
+ * The "index" attribute
+ */
+ public static final String INDEX = "index"; //$NON-NLS-1$
+ /**
+ * The "isConstructing" attribute
+ */
+ public static final String IS_CONSTRUCTING = "isConstructing"; //$NON-NLS-1$
+ /**
+ * the "isDebugger" attribute
+ */
+ public static final String IS_DEBUGGER = "isDebugger"; //$NON-NLS-1$
+ /**
+ * the "isValid" attribute
+ */
+ public static final String IS_VALID = "isValid"; //$NON-NLS-1$
+ /**
+ * The "line" attribute
+ */
+ public static final String LINE = "line"; //$NON-NLS-1$
+ /**
+ * The "lineCount" attribute
+ */
+ public static final String LINE_COUNT = "lineCount"; //$NON-NLS-1$
+ /**
+ * The "lineNumber" attribute
+ */
+ public static final String LINE_NUMBER = "lineNumber"; //$NON-NLS-1$
+ /**
+ * The "lineNo" attribute
+ */
+ public static final String LINE_NO = "lineNo"; //$NON-NLS-1$
+ /**
+ * The "lineOffset" attribute
+ */
+ public static final String LINE_OFFSET = "lineOffset"; //$NON-NLS-1$
+ /**
+ * The "locals" attribute
+ */
+ public static final String LOCALS = "locals"; //$NON-NLS-1$
+ /**
+ * The "location" attribute
+ */
+ public static final String LOCATION = "location"; //$NON-NLS-1$
+ /**
+ * The message attribute for this packet
+ */
+ public static final String MESSAGE = "message"; //$NON-NLS-1$
+ /**
+ * The "newContextId" attribute
+ */
+ public static final String NEW_CONTEXT_ID = "newContextId"; //$NON-NLS-1$
+ /**
+ * The type "number"
+ */
+ public static final String NUMBER = "number"; //$NON-NLS-1$
+ /**
+ * The type "object"
+ */
+ public static final String OBJECT = "object"; //$NON-NLS-1$
+ /**
+ * The type "proto"
+ */
+ public static final String PROTO = "proto"; //$NON-NLS-1$
+ /**
+ * The "ref" attribute / type
+ */
+ public static final String REF = "ref"; //$NON-NLS-1$
+ /**
+ * The "requestSeq" attribute
+ */
+ public static final String REQUEST_SEQ = "requestSeq"; //$NON-NLS-1$
+ /**
+ * The "result" attribute
+ */
+ public static final String RESULT = "result"; //$NON-NLS-1$
+ /**
+ * The running attribute for this packet
+ */
+ public static final String RUNNING = "running"; //$NON-NLS-1$
+ /**
+ * The "scope" attribute
+ */
+ public static final String SCOPE = "scope"; //$NON-NLS-1$
+ /**
+ * The "scopes" attribute
+ */
+ public static final String SCOPES = "scopes"; //$NON-NLS-1$
+ /**
+ * The "scopeIndexes" attribute
+ */
+ public static final String SCOPE_INDEXES = "scopeIndexes"; //$NON-NLS-1$
+ /**
+ * The "script" attribute
+ */
+ public static final String SCRIPT = "script"; //$NON-NLS-1$
+ /**
+ * The "scripts" attribute
+ */
+ public static final String SCRIPTS = "scripts"; //$NON-NLS-1$
+ /**
+ * The "seq" attribute
+ */
+ public static final String SEQ = "seq"; //$NON-NLS-1$
+ /**
+ * The "set" attribute
+ */
+ public static final String SET = "set"; //$NON-NLS-1$
+ /**
+ * The "source" attribute
+ */
+ public static final String SOURCE = "source"; //$NON-NLS-1$
+ /**
+ * The "sourceLength" attribute
+ */
+ public static final String SOURCE_LENGTH = "sourceLength"; //$NON-NLS-1$
+ /**
+ * The "sourceName" attribute
+ */
+ public static final String SOURCE_NAME = "sourceName"; //$NON-NLS-1$
+ /**
+ * The "stacktrace" attribute
+ */
+ public static final String STACKTRACE = "stackTrace"; //$NON-NLS-1$
+ /**
+ * The "status" attribute
+ */
+ public static final String STATUS = "status"; //$NON-NLS-1$
+ /**
+ * The "stepaction" attribute
+ */
+ public static final String STEPACTION = "stepAction"; //$NON-NLS-1$
+ /**
+ * The type "string"
+ */
+ public static final String STRING = "string"; //$NON-NLS-1$
+ /**
+ * The "this" attribute
+ */
+ public static final String THIS = "this"; //$NON-NLS-1$
+ /**
+ * The thisValue" attribute
+ */
+ public static final String THIS_VALUE = "thisValue"; //$NON-NLS-1$
+ /**
+ * the "toFrame" attribute
+ */
+ public static final String TO_FRAME = "toFrame"; //$NON-NLS-1$
+ /**
+ * The "tools" attribute
+ */
+ public static final String TOOLS = "tools"; //$NON-NLS-1$
+ /**
+ * The "type" attribute
+ */
+ public static final String TYPE = "type"; //$NON-NLS-1$
+ /**
+ * The "url" attribute
+ */
+ public static final String URL = "url"; //$NON-NLS-1$
+ /**
+ * The "urls" attribute
+ */
+ public static final String URLS = "urls"; //$NON-NLS-1$
+ /**
+ * The "value" attribute
+ */
+ public static final String VALUE = "value"; //$NON-NLS-1$
+ /**
+ * The "values" attribute
+ */
+ public static final String VALUES = "values"; //$NON-NLS-1$
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFEventPacket.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFEventPacket.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFEventPacket.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFEventPacket.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.wst.jsdt.debug.transport.packet.Event;
+
+
+/**
+ * An {@link CFEventPacket} is a specialized {@link CFPacket}
+ * that only handles event
data.
+ *
+ * @since 1.0
+ */
+public class CFEventPacket extends CFPacket implements Event {
+
+ /**
+ * The type of this packet
+ */
+ public static final String EVENT = "event"; //$NON-NLS-1$
+ /**
+ * The "closed" event kind
+ */
+ public static final String CLOSED = "closed"; //$NON-NLS-1$
+ /**
+ * The "onScript" event kind
+ */
+ public static final String ON_SCRIPT = "onScript"; //$NON-NLS-1$
+ /**
+ * The "onBreak" event kind
+ */
+ public static final String ON_BREAK = "onBreak"; //$NON-NLS-1$
+ /**
+ * The "onConsoleDebug" event kind
+ */
+ public static final String ON_CONSOLE_DEBUG = "onConsoleDebug"; //$NON-NLS-1$
+ /**
+ * The "onConsoleError" event kind
+ */
+ public static final String ON_CONSOLE_ERROR = "onConsoleError"; //$NON-NLS-1$
+ /**
+ * The "onConsoleInfo" event kind
+ */
+ public static final String ON_CONSOLE_INFO = "onConsoleInfo"; //$NON-NLS-1$
+ /**
+ * The "onConsoleLog" event kind
+ */
+ public static final String ON_CONSOLE_LOG = "onConsoleLog"; //$NON-NLS-1$
+ /**
+ * The "onConsoleWarn" event kind
+ */
+ public static final String ON_CONSOLE_WARN = "onConsoleWarn"; //$NON-NLS-1$
+ /**
+ * The "onError" event kind
+ */
+ public static final String ON_ERROR = "onError"; //$NON-NLS-1$
+ /**
+ * The "onInspectNode" event kind
+ */
+ public static final String ON_INSPECT_NODE = "onInspectNode"; //$NON-NLS-1$
+ /**
+ * The "onResume" event kind
+ */
+ public static final String ON_RESUME = "onResume"; //$NON-NLS-1$
+ /**
+ * The "onToggleBreakpoint" event kind
+ */
+ public static final String ON_TOGGLE_BREAKPOINT = "onToggleBreakpoint"; //$NON-NLS-1$
+ /**
+ * The "onContextSelected" event kind
+ */
+ public static final String ON_CONTEXT_SELECTED = "onContextSelected"; //$NON-NLS-1$
+ /**
+ * The "onContextDestroyed" event kind
+ */
+ public static final String ON_CONTEXT_DESTROYED = "onContextDestroyed"; //$NON-NLS-1$
+ /**
+ * The "onContextCreated" event kind
+ */
+ public static final String ON_CONTEXT_CREATED = "onContextCreated"; //$NON-NLS-1$
+ /**
+ * The "onContextLoaded" event kind
+ */
+ public static final String ON_CONTEXT_LOADED = "onContextLoaded"; //$NON-NLS-1$
+
+ private final String event;
+ private final Map body = Collections.synchronizedMap(new HashMap());
+
+ /**
+ * Constructor
+ * @param event
+ */
+ public CFEventPacket(String event) {
+ super(EVENT, null);
+ this.event = event.intern();
+ }
+
+ /**
+ * Constructor
+ * @param json
+ */
+ public CFEventPacket(Map json) {
+ super(json);
+ String packetEvent = (String) json.get(EVENT);
+ event = packetEvent.intern();
+ Object data = json.get(Attributes.BODY);
+ if(data instanceof Map) {
+ body.putAll((Map) data);
+ }
+ else if(data instanceof String ||
+ data instanceof List) {
+ body.put(Attributes.BODY, data);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket#getContextId()
+ */
+ public String getContextId() {
+ String id = super.getContextId();
+ if(id == null) {
+ id = (String) body.get(Attributes.CONTEXT_ID);
+ }
+ return id;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.packet.Event#getEvent()
+ */
+ public String getEvent() {
+ return event;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.packet.Event#getBody()
+ */
+ public Map getBody() {
+ return body;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket#toJSON()
+ */
+ public Map toJSON() {
+ Map json = super.toJSON();
+ json.put(EVENT, event);
+ if(body.size() > 0) {
+ json.put(Attributes.BODY, body);
+ }
+ return json;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ Object json = toJSON();
+ buffer.append("CFEventPacket: "); //$NON-NLS-1$
+ JSON.writeValue(json, buffer);
+ return buffer.toString();
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFPacket.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFPacket.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFPacket.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFPacket.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Abstract description of a packet for sending / receiving information to the debug client
+ * using JSON
+ *
+ * @since 1.0
+ */
+public abstract class CFPacket implements org.eclipse.wst.jsdt.debug.transport.packet.Packet {
+
+ /**
+ * Debugging flag
+ */
+ public static boolean TRACE = false;
+
+ private final String type;
+ private final String context_id;
+
+ /**
+ * Constructor
+ *
+ * @param type the type for the {@link CFPacket} null
is not accepted
+ */
+ protected CFPacket(String type, String context_id) {
+ if(type == null) {
+ throw new IllegalArgumentException("The type for a packet cannot be null"); //$NON-NLS-1$
+ }
+ this.type = type.intern();
+ this.context_id = context_id;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param json the pre-composed map of attributes for the packet, null
is not accepted
+ */
+ protected CFPacket(Map json) {
+ if(json == null) {
+ throw new IllegalArgumentException("The JSON map for a packet cannot be null"); //$NON-NLS-1$
+ }
+ String packetType = (String) json.get(Attributes.TYPE);
+ this.type = packetType.intern();
+ this.context_id = (String) json.get(Attributes.CONTEXT_ID);
+ }
+
+ /**
+ * @return the context id or null
+ */
+ public String getContextId() {
+ return context_id;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.packet.Packet#getType()
+ */
+ public String getType() {
+ return type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.packet.Packet#toJSON()
+ */
+ public Map toJSON() {
+ Map json = new HashMap();
+ json.put(Attributes.TYPE, type);
+ if(context_id != null) {
+ json.put(Attributes.CONTEXT_ID, context_id);
+ }
+ return json;
+ }
+
+ /**
+ * Returns the type from the given JSON map.null
if the map is not correctly
+ * formed.
+ *
+ * @param json the JSON map, null
is not accepted
+ * @return the type from the JSON map or null
+ */
+ public static String getType(Map json) {
+ if(json == null) {
+ throw new IllegalArgumentException("A null JSON map is not allowed when trying to get the packet type"); //$NON-NLS-1$
+ }
+ return (String) json.get(Attributes.TYPE);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ Object json = toJSON();
+ buffer.append("CFPacket: "); //$NON-NLS-1$
+ JSON.writeValue(json, buffer);
+ return buffer.toString();
+ }
+
+ /**
+ * Sets if packet transfer should be traced
+ * @param tracing
+ */
+ public static void setTracing(boolean tracing) {
+ TRACE = tracing;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFRequestPacket.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFRequestPacket.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFRequestPacket.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFRequestPacket.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.wst.jsdt.debug.transport.packet.Request;
+
+/**
+ * Default request implementation using JSON
+ *
+ * @since 1.0
+ */
+public class CFRequestPacket extends CFPacket implements Request {
+
+ /**
+ * The type of this packet
+ */
+ public static final String REQUEST = "request"; //$NON-NLS-1$
+
+ private final String command;
+ private final Map arguments = Collections.synchronizedMap(new HashMap());
+ private final Map params = Collections.synchronizedMap(new HashMap());
+ private static int currentSequence = 0;
+ private final int sequence;
+
+ /**
+ * Constructor
+ *
+ * @param command the command, null
is not accepted
+ * @param context_id the id of the context to scope the request to
+ * @see http://getfirebug.com/wiki/index.php/Crossfire_Protocol_Reference for
+ * requests that do not require a context id.
+ */
+ public CFRequestPacket(String command, String context_id) {
+ super(REQUEST, context_id);
+ if(command == null) {
+ throw new IllegalArgumentException("The request command kind cannot be null"); //$NON-NLS-1$
+ }
+ this.sequence = nextSequence();
+ this.command = command.intern();
+ }
+
+ /**
+ * Constructor
+ *
+ * @param json map of JSON attributes, null
is not accepted
+ */
+ public CFRequestPacket(Map json) {
+ super(json);
+ if(json == null) {
+ throw new IllegalArgumentException("The JSON map for a request packet cannot be null"); //$NON-NLS-1$
+ }
+ String value = (String) json.get(Attributes.COMMAND);
+ this.command = value.intern();
+ Map packetArguments = (Map) json.get(Attributes.ARGUMENTS);
+ arguments.putAll(packetArguments);
+ Number packetSeq = (Number) json.get(Attributes.SEQ);
+ this.sequence = packetSeq.intValue();
+ }
+
+ /**
+ * @return a next value for the sequence
+ */
+ private static synchronized int nextSequence() {
+ return ++currentSequence;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.packet.Request#getSequence()
+ */
+ public int getSequence() {
+ return sequence;
+ }
+
+ /**
+ * Allows additional parameters to be added to the request
+ *
+ * @param key
+ * @param value
+ */
+ public void addAdditionalParam(String key, Object value) {
+ params.put(key, value);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.packet.Request#getCommand()
+ */
+ public String getCommand() {
+ return command;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.packet.Request#getArguments()
+ */
+ public Map getArguments() {
+ return arguments;
+ }
+
+ /**
+ * Sets the given argument in the JSON map.
+ *
+ * @param key the key for the attribute, null
is not accepted
+ * @param argument the value for the argument
+ */
+ public void setArgument(String key, Object argument) {
+ if(key == null) {
+ throw new IllegalArgumentException("The argument key cannot be null"); //$NON-NLS-1$
+ }
+ arguments.put(key, argument);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket#toJSON()
+ */
+ public Map toJSON() {
+ Map json = super.toJSON();
+ json.put(Attributes.SEQ, new Integer(sequence));
+ json.put(Attributes.COMMAND, command);
+ if(!arguments.isEmpty()) {
+ json.put(Attributes.ARGUMENTS, arguments);
+ }
+ Entry entry = null;
+ for(Iterator iter = params.entrySet().iterator(); iter.hasNext();) {
+ entry = (Entry) iter.next();
+ json.put(entry.getKey(), entry.getValue());
+ }
+ return json;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ Object json = toJSON();
+ buffer.append("CFRequestPacket: "); //$NON-NLS-1$
+ JSON.writeValue(json, buffer);
+ return buffer.toString();
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFResponsePacket.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFResponsePacket.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFResponsePacket.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFResponsePacket.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.wst.jsdt.debug.transport.packet.Response;
+
+/**
+ * Default {@link CFResponsePacket} implementation using JSON
+ *
+ * @since 1.0
+ */
+public class CFResponsePacket extends CFPacket implements Response {
+
+ /**
+ * The type of this packet
+ */
+ public static final String RESPONSE = "response"; //$NON-NLS-1$
+
+ /**
+ * Response codes
+ */
+ public static final int CODE_OK = 0;
+ public static final int CODE_MALFORMED_PACKET = 1;
+ public static final int CODE_MALFORMED_REQUEST = 2;
+ public static final int CODE_COMMAND_NOT_IMPLEMENTED = 3;
+ public static final int CODE_INVALID_ARGUMENTS = 4;
+ public static final int CODE_UNEXPECTED_EXCEPTION = 5;
+ public static final int CODE_COMMAND_FAILED = 6;
+ public static final int CODE_INVALID_STATE = 7;
+
+ static final Map failed_attributes;
+ static {
+ failed_attributes = new HashMap();
+ Integer value = new Integer(-1);
+ failed_attributes.put(Attributes.SEQ, value);
+ failed_attributes.put(Attributes.TYPE, RESPONSE);
+ failed_attributes.put(Attributes.REQUEST_SEQ, value);
+ failed_attributes.put(Attributes.COMMAND, "failed"); //$NON-NLS-1$
+ Map status = new HashMap();
+ failed_attributes.put(Attributes.STATUS, status);
+ status.put(Attributes.CODE, new Integer(CODE_UNEXPECTED_EXCEPTION));
+ status.put(Attributes.RUNNING, Boolean.FALSE);
+ status.put(Attributes.MESSAGE, "failed"); //$NON-NLS-1$
+ }
+
+ public static final CFResponsePacket FAILED = new CFResponsePacket(failed_attributes);
+
+ private String command;
+ private int requestSequence;
+ private Map body = Collections.synchronizedMap(new HashMap());
+ private volatile int code = 0;
+ private volatile boolean running = true;
+ private volatile String message;
+ private Map stackTrace = Collections.synchronizedMap(new HashMap());
+
+ /**
+ * Constructor
+ *
+ * @param requestSequence the sequence
+ * @param command the command, null
is not accepted
+ */
+ public CFResponsePacket(int requestSequence, String command) {
+ super(RESPONSE, null);
+ if(command == null) {
+ throw new IllegalArgumentException("The command string for a response packet cannot be null"); //$NON-NLS-1$
+ }
+ this.requestSequence = requestSequence;
+ this.command = command.intern();
+ }
+
+ /**
+ * Constructor
+ *
+ * @param json the JSON map for a response, null
is not accepted
+ */
+ public CFResponsePacket(Map json) {
+ super(json);
+ Number packetRequestSeq = (Number) json.get(Attributes.REQUEST_SEQ);
+ requestSequence = packetRequestSeq.intValue();
+
+ String packetCommand = (String) json.get(Attributes.COMMAND);
+ command = packetCommand.intern();
+
+ Object bdy = json.get(Attributes.BODY);
+ if(bdy instanceof Map) {
+ Map packetBody = (Map)bdy;
+ body.putAll(packetBody);
+ }
+
+ Object status = json.get(Attributes.STATUS);
+ if (status != null && status instanceof Map) {
+ Map packetStatus = (Map)status;
+ Object codeObj = packetStatus.get(Attributes.CODE);
+ if (codeObj != null) {
+ code = ((Number)codeObj).intValue();
+ }
+ Boolean runningObj = (Boolean)packetStatus.get(Attributes.RUNNING);
+ if (runningObj != null) {
+ running = runningObj.booleanValue();
+ }
+ message = (String)packetStatus.get(Attributes.MESSAGE);
+ stackTrace = (Map)packetStatus.get(Attributes.STACKTRACE);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.packet.Response#getRequestSequence()
+ */
+ public int getRequestSequence() {
+ return requestSequence;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.packet.Response#getCommand()
+ */
+ public String getCommand() {
+ return command;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.packet.Response#getBody()
+ */
+ public Map getBody() {
+ return body;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.packet.Response#isSuccess()
+ */
+ public boolean isSuccess() {
+ return code == CODE_OK;
+ }
+
+ /**
+ * Set the success code for the response
+ *
+ * @param code the new success code
+ */
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ /**
+ * Get the success code for the response
+ *
+ * return the success code
+ */
+ public int getCode() {
+ return code;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.packet.Response#isRunning()
+ */
+ public boolean isRunning() {
+ return running;
+ }
+
+ /**
+ * Sets the running state of the underlying command
+ *
+ * @param running the new running state for the underlying command
+ */
+ public void setRunning(boolean running) {
+ this.running = running;
+ }
+
+ /**
+ * Returns the status message for this {@link CFResponsePacket}.null
+ *
+ * @return the status message for this {@link CFResponsePacket} or null
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Set the status message for this {@link CFResponsePacket}
+ *
+ * @param message the new message, null
is accepted
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ /**
+ * Returns the stack trace for this {@link CFResponsePacket}.null
+ *
+ * @return the stack trace for this {@link CFResponsePacket} or null
+ */
+ public Map getStackTrace() {
+ return stackTrace;
+ }
+
+ /**
+ * Set the stack trace for this {@link CFResponsePacket}
+ *
+ * @param stackTrace the new stack trace, null
is accepted
+ */
+ public void setStackTrace(Map stackTrace) {
+ this.stackTrace = stackTrace;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket#toJSON()
+ */
+ public Map toJSON() {
+ Map json = super.toJSON();
+ json.put(Attributes.REQUEST_SEQ, new Integer(requestSequence));
+ json.put(Attributes.COMMAND, command);
+ if(body != null && body.size() > 0) {
+ json.put(Attributes.BODY, body);
+ }
+ Map status = new HashMap();
+ json.put(Attributes.STATUS, status);
+ status.put(Attributes.RUNNING, new Boolean(running));
+ status.put(Attributes.CODE, new Integer(code));
+ if (message != null) {
+ status.put(Attributes.MESSAGE, message);
+ }
+ if (stackTrace != null) {
+ status.put(Attributes.STACKTRACE, stackTrace);
+ }
+ return json;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ Object json = toJSON();
+ buffer.append("CFResponsePacket: "); //$NON-NLS-1$
+ JSON.writeValue(json, buffer);
+ return buffer.toString();
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFSocketConnection.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFSocketConnection.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFSocketConnection.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFSocketConnection.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.Socket;
+import java.util.Map;
+
+import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
+import org.eclipse.wst.jsdt.debug.transport.Connection;
+import org.eclipse.wst.jsdt.debug.transport.packet.Packet;
+import org.eclipse.wst.jsdt.debug.transport.socket.SocketConnection;
+
+/**
+ * A specialized {@link Connection} that communicates using {@link Socket}s
+ *
+ * @since 1.0
+ */
+public class CFSocketConnection extends SocketConnection {
+
+ /**
+ * Constructor
+ *
+ * @param socket the underlying {@link Socket}, null
is not accepted
+ *
+ * @throws IOException
+ */
+ public CFSocketConnection(Socket socket) throws IOException {
+ super(socket);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.socket.SocketConnection#writePacket(org.eclipse.wst.jsdt.debug.transport.packet.Packet)
+ */
+ public void writePacket(Packet packet) throws IOException {
+ String serialized = JSON.serialize((CFPacket) packet);
+ if(CFPacket.TRACE) {
+ Tracing.writeString("WRITE PACKET: "+serialized); //$NON-NLS-1$
+ }
+ Writer writer = getWriter();
+ writer.write(serialized);
+ writer.flush();
+ }
+
+ /**
+ * Writes the standard handshake packet to connect
+ *
+ * @param tools the {@link String} array of tools to enable by default
+ * @throws IOException
+ */
+ public void writeHandShake(String[] tools) throws IOException {
+ if(CFPacket.TRACE) {
+ Tracing.writeString("WRITE HANDSHAKE: "+HandShakePacket.getHandshake(tools)); //$NON-NLS-1$
+ }
+ Writer writer = getWriter();
+ writer.write(HandShakePacket.getHandshake(tools));
+ writer.flush();
+ }
+
+ /**
+ * Reads the {@link HandShakePacket} packet from the the stream
+ *
+ * @return the {@link HandShakePacket}, never null
+ * @throws IOException
+ */
+ public CFPacket readHandShake() throws IOException {
+ StringBuffer buffer = new StringBuffer();
+ //read the header first
+ int c = 0;
+ boolean r = false;
+ Reader reader = getReader();
+ while((c = reader.read()) > -1) {
+ buffer.append((char)c);
+ if(r) {
+ if(c == '\n') {
+ break;
+ }
+ }
+ r = c == '\r';
+ }
+ //chew up the tool heading if there is one
+ r = false;
+ while(reader.ready() && (c = reader.read()) > -1) {
+ if(r) {
+ if(c == '\n') {
+ buffer.append((char)c);
+ break;
+ }
+ }
+ r = c == '\r';
+ if(r) {
+ buffer.append((char)c);
+ }
+ }
+ //XXX hack, we should be properly parsing and accounting for the tool header
+ if(buffer.toString().equals(HandShakePacket.getHandshake(null))) {
+ HandShakePacket ack = new HandShakePacket();
+ if(CFPacket.TRACE) {
+ Tracing.writeString("ACK HANDSHAKE: "+buffer.toString()); //$NON-NLS-1$
+ }
+ return ack;
+ }
+ if(CFPacket.TRACE) {
+ Tracing.writeString("Did not get correct CrossFire handshake: "+buffer.toString()); //$NON-NLS-1$
+ }
+ throw new IOException("Did not get correct CrossFire handshake: "+buffer.toString()); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.socket.SocketConnection#readPacket()
+ */
+ public Packet readPacket() throws IOException {
+ StringBuffer buffer = new StringBuffer();
+ StringBuffer raw = new StringBuffer();
+ int c = -1;
+ boolean r = false;
+ String len = null;
+ Reader reader = getReader();
+ while((c = reader.read()) > -1) {
+ if(CFPacket.TRACE) {
+ raw.append((char)c);
+ }
+ if(r) {
+ if(c == '\n') {
+ String str = buffer.toString();
+ if(str.startsWith(JSON.CONTENT_LENGTH)) {
+ len = grabAttrib(str);
+ }
+ else if(str.equals("\r")) { //$NON-NLS-1$
+ break;
+ }
+ buffer = new StringBuffer();
+ r = false;
+ }
+ continue;
+ }
+ buffer.append((char)c);
+ r = c == '\r';
+ }
+ int length = 0;
+ try {
+ length = Integer.parseInt(len);
+ } catch (NumberFormatException e) {
+ if(CFPacket.TRACE) {
+ Tracing.writeString("[SOCKET] failed to read content length: "+raw.toString()); //$NON-NLS-1$
+ }
+ throw new IOException("Failed to parse content length: " + raw.toString()); //$NON-NLS-1$
+ }
+ char[] message = new char[length];
+ int n = 0;
+ int off = 0;
+ while (n < length) {
+ int count = reader.read(message, off + n, length - n);
+ if (count < 0) {
+ throw new EOFException();
+ }
+ n += count;
+ }
+ if(CFPacket.TRACE) {
+ raw.append(message);
+ Tracing.writeString("READ PACKET: " + raw.toString()); //$NON-NLS-1$
+ }
+ Map json = (Map) JSON.read(new String(message));
+ String type = CFPacket.getType(json);
+ if (CFEventPacket.EVENT.equals(type)) {
+ return new CFEventPacket(json);
+ }
+ if (CFRequestPacket.REQUEST.equals(type)) {
+ return new CFRequestPacket(json);
+ }
+ if (CFResponsePacket.RESPONSE.equals(type)) {
+ return new CFResponsePacket(json);
+ }
+ throw new IOException("Unknown packet type: " + type); //$NON-NLS-1$
+ }
+
+ /**
+ * Grabs the attribute from the RHS of the header. Where all headers
+ * have the form [name]:[value]
.
+ *
+ * @param str the string to parse
+ * @return the [value]
from the header
+ */
+ String grabAttrib(String str) {
+ if(str != null) {
+ int idx = str.indexOf(':');
+ if(idx > -1) {
+ return str.substring(idx+1, str.length()-1);
+ }
+ }
+ return null;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFTransportService.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFTransportService.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFTransportService.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFTransportService.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.wst.jsdt.debug.transport.Connection;
+import org.eclipse.wst.jsdt.debug.transport.ListenerKey;
+import org.eclipse.wst.jsdt.debug.transport.packet.Packet;
+import org.eclipse.wst.jsdt.debug.transport.socket.SocketConnection;
+import org.eclipse.wst.jsdt.debug.transport.socket.SocketTransportService;
+
+
+/**
+ * Implementation of a transport service that using a {@link Socket} for communication
+ *
+ * @since 1.0
+ */
+public class CFTransportService extends SocketTransportService {
+
+ static final Class serverSocketClass = ServerSocket.class; // temporary used to pre-load the ServerSocket.class
+
+ /**
+ * Map of {@link ListenerKey} to {@link ServerSocket}s
+ */
+ Map listeners = new HashMap();
+
+ String[] tools = null;
+
+ /**
+ * Constructor
+ */
+ public CFTransportService(String[] tools) {
+ this.tools = tools;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.socket.SocketTransportService#getConnection(java.net.Socket)
+ */
+ public SocketConnection getConnection(Socket socket) throws IOException {
+ return new CFSocketConnection(socket);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.socket.SocketTransportService#handleAccept(org.eclipse.wst.jsdt.debug.transport.Connection)
+ */
+ public void handleAccept(Connection connection) throws IOException {
+ if(connection instanceof CFSocketConnection) {
+ CFSocketConnection cfconn = (CFSocketConnection) connection;
+ Packet packet = cfconn.readHandShake();
+ if (!(packet instanceof HandShakePacket)) {
+ throw new IOException("failure establishing connection"); //$NON-NLS-1$
+ }
+ cfconn.writeHandShake(this.tools);
+ return;
+ }
+ throw new IOException("failure establishing connection"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.transport.socket.SocketTransportService#handleAttach(org.eclipse.wst.jsdt.debug.transport.Connection)
+ */
+ public void handleAttach(Connection connection) throws IOException {
+ if(connection instanceof CFSocketConnection) {
+ CFSocketConnection cfconn = (CFSocketConnection) connection;
+ cfconn.writeHandShake(this.tools);
+ Packet packet = cfconn.readHandShake();
+ if (!(packet instanceof HandShakePacket)) {
+ throw new IOException("failure establishing connection"); //$NON-NLS-1$
+ }
+ return;
+ }
+ throw new IOException("failure establishing connection"); //$NON-NLS-1$
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/Commands.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/Commands.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/Commands.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/Commands.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
+
+/**
+ * Interface for all the command constants
+ *
+ * @since 1.0
+ */
+public interface Commands {
+
+ /**
+ * The "backtrace" command
+ */
+ public static final String BACKTRACE = "backtrace"; //$NON-NLS-1$
+ /**
+ * The "changebreakpoint" command
+ */
+ public static final String CHANGE_BREAKPOINTS = "changeBreakpoints"; //$NON-NLS-1$
+ /**
+ * The "deletebreakpoint" command
+ */
+ public static final String DELETE_BREAKPOINTS = "deleteBreakpoints"; //$NON-NLS-1$
+ /**
+ * The "continue" command
+ */
+ public static final String CONTINUE = "continue"; //$NON-NLS-1$
+ /**
+ * The "disabletools" command
+ */
+ public static final String DISABLE_TOOLS = "disableTools"; //$NON-NLS-1$
+ /**
+ * The "enabletools" command
+ */
+ public static final String ENABLE_TOOLS = "enableTools"; //$NON-NLS-1$
+ /**
+ * The "evaluate" command
+ */
+ public static final String EVALUATE = "evaluate"; //$NON-NLS-1$
+ /**
+ * The "frame" command
+ */
+ public static final String FRAME = "frame"; //$NON-NLS-1$
+ /**
+ * The "getbreakpoints" command
+ */
+ public static final String GET_BREAKPOINTS = "getBreakpoints"; //$NON-NLS-1$
+ /**
+ * The "gettools" command
+ */
+ public static final String GET_TOOLS = "getTools"; //$NON-NLS-1$
+ /**
+ * The "inspect" command
+ */
+ public static final String INSPECT = "inspect"; //$NON-NLS-1$
+ /**
+ * The "listcontexts" command
+ */
+ public static final String LISTCONTEXTS = "listContexts"; //$NON-NLS-1$
+ /**
+ * The "lookup" command
+ */
+ public static final String LOOKUP = "lookup"; //$NON-NLS-1$
+ /**
+ * The "scopes" command
+ */
+ public static final String SCOPES = "scopes"; //$NON-NLS-1$
+ /**
+ * The "scripts" command
+ */
+ public static final String SCRIPTS = "scripts"; //$NON-NLS-1$
+ /**
+ * The "setbreakpoint" command
+ */
+ public static final String SET_BREAKPOINTS = "setBreakpoints"; //$NON-NLS-1$
+ /**
+ * The "in" step action
+ */
+ public static final String STEP_IN = "in"; //$NON-NLS-1$
+ /**
+ * The "next" step action
+ */
+ public static final String STEP_NEXT = "next"; //$NON-NLS-1$
+ /**
+ * The "out" step action
+ */
+ public static final String STEP_OUT = "out"; //$NON-NLS-1$
+ /**
+ * The "source" command
+ */
+ public static final String SOURCE = "source"; //$NON-NLS-1$
+ /**
+ * The "suspend" command
+ */
+ public static final String SUSPEND = "suspend"; //$NON-NLS-1$
+ /**
+ * The "createcontext" command
+ */
+ public static final String CREATE_CONTEXT = "createContext"; //$NON-NLS-1$
+ /**
+ * The "version" command
+ */
+ public static final String VERSION = "version"; //$NON-NLS-1$
+
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/HandShakePacket.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/HandShakePacket.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/HandShakePacket.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/HandShakePacket.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * {@link CFPacket} for replying to the Crossfire handshake request
+ *
+ * @since 1.0
+ */
+public class HandShakePacket extends CFPacket {
+
+ /**
+ * handshake String
+ */
+ private static String CROSSFIRE_HANDSHAKE = "CrossfireHandshake\r\n"; //$NON-NLS-1$
+
+
+ /**
+ * Constructor
+ * @param type
+ */
+ protected HandShakePacket() {
+ super(CFResponsePacket.RESPONSE, null);
+ }
+
+ /**
+ * Creates a handshake object with the given set of tools
+ *
+ * @param tools the {@link String} array of tools to enable
+ * @return the handshake
+ */
+ public static String getHandshake(String[] tools) {
+ StringBuffer buffer = new StringBuffer(CROSSFIRE_HANDSHAKE);
+ if(tools != null) {
+ for (int i = 0; i < tools.length; i++) {
+ if(tools[i] != null) {
+ buffer.append(tools[i]);
+ }
+ if(i < tools.length -1) {
+ buffer.append(',');
+ }
+ }
+ }
+ return buffer.append(JSON.LINE_FEED).toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket#toString()
+ */
+ public String toString() {
+ return CROSSFIRE_HANDSHAKE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket#toJSON()
+ */
+ public Map toJSON() {
+ Map json = new HashMap(1);
+ json.put(Attributes.HANDSHAKE, CROSSFIRE_HANDSHAKE);
+ return json;
+ }
+}
Index: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/JSON.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/JSON.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/JSON.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/JSON.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,540 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
+
+import java.math.BigDecimal;
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFNullValue;
+import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFUndefinedValue;
+
+/**
+ * Class for reading / writing JSON objects
+ * Content-Length:
preamble
+ */
+ public static final String CONTENT_LENGTH = "Content-Length:"; //$NON-NLS-1$
+ /**
+ * Enables / Disables tracing in the all of the JSDI implementations
+ *
+ * @param trace
+ */
+ public static void setTracing(boolean trace) {
+ TRACE = trace;
+ }
+
+ /**
+ * Constructor
+ *
+ * No instantiation
+ */
+ private JSON() {}
+
+ /**
+ * Writes the given key / value pair to the buffer in the form: "key":["]value["]
+ *
+ * @param key
+ * @param value
+ * @param buffer
+ */
+ public static void writeKeyValue(String key, Object value, StringBuffer buffer) {
+ writeString(key, buffer);
+ buffer.append(':');
+ writeValue(value, buffer);
+ }
+
+ /**
+ * Writes out the given value to the buffer. value.toString()
"value"
null
+ * [{@link #writeValue(Object, StringBuffer)},...]
{"key":{@link #writeValue(Object, StringBuffer)},...}
[{@link #writeValue(Object, StringBuffer)},...]
+ *
+ * @param collection
+ * @param buffer
+ */
+ static void writeArray(Collection collection, StringBuffer buffer) {
+ buffer.append('[');
+ for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
+ writeValue(iterator.next(), buffer);
+ if(iterator.hasNext()) {
+ buffer.append(',');
+ }
+ }
+ buffer.append(']');
+ }
+
+ /**
+ * Writes an object mapping to the given buffer in the form: {"key":{@link #writeValue(Object, StringBuffer)},...}
+ *
+ * @param map
+ * @param buffer
+ */
+ public static void writeObject(Map map, StringBuffer buffer) {
+ buffer.append('{');
+ for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();) {
+ String key = (String) iterator.next();
+ writeString(key, buffer);
+ buffer.append(':');
+ writeValue(map.get(key), buffer);
+ if(iterator.hasNext()) {
+ buffer.append(',');
+ }
+ }
+ buffer.append('}');
+ }
+
+ /**
+ * Writes the Content-Length:N
preamble to the head of the given buffer
+ *
+ * @param buffer
+ * @param length
+ */
+ public static void writeContentLength(StringBuffer buffer, int length) {
+ StringBuffer buff = new StringBuffer(18);
+ buff.append(CONTENT_LENGTH).append(length).append(LINE_FEED).append(LINE_FEED);
+ buffer.insert(0, buff.toString());
+ }
+
+ /**
+ * Serializes the given {@link CFPacket} to a {@link String}
+ *
+ * @param packet the packet to serialize
+ *
+ * @return the serialized {@link String}, never null
+ */
+ public static String serialize(CFPacket packet) {
+ Object json = packet.toJSON();
+ StringBuffer buffer = new StringBuffer();
+ writeValue(json, buffer);
+ int length = buffer.length();
+ writeContentLength(buffer, length);
+ buffer.append(LINE_FEED);
+ if(TRACE) {
+ Tracing.writeString("SERIALIZE: " + packet.getType() +" packet as "+buffer.toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Reads and returns a new object from the given JSON {@link String}. This method
+ * will throw an {@link IllegalStateException} if parsing fails.
+ *
+ * @param jsonString
+ * @return the object, never null
+ */
+ public static Object read(String jsonString) {
+ return parse(new StringCharacterIterator(jsonString));
+ }
+
+ /**
+ * Reads and returns a new object form the given {@link CharacterIterator} that corresponds to
+ * a properly formatted JSON string. This method will throw an {@link IllegalStateException} if
+ * parsing fails.
+ *
+ * @param it the {@link CharacterIterator} to parse
+ * @return the object, never null
+ */
+ public static Object parse(CharacterIterator it) {
+ parseWhitespace(it);
+ Object result = parseValue(it);
+ parseWhitespace(it);
+ if (it.current() != CharacterIterator.DONE) {
+ throw error("should be done", it); //$NON-NLS-1$
+ }
+ return result;
+ }
+
+ /**
+ * Creates an {@link IllegalStateException} for the given message and iterator
+ *
+ * @param message the message for the exception
+ * @param it the {@link CharacterIterator} to parse
+ *
+ * @return a new {@link IllegalStateException}
+ */
+ private static RuntimeException error(String message, CharacterIterator it) {
+ return new IllegalStateException("[" + it.getIndex() + "] " + message); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ /**
+ * Chews up whitespace from the iterator
+ *
+ * @param it the {@link CharacterIterator} to parse
+ */
+ private static void parseWhitespace(CharacterIterator it) {
+ char c = it.current();
+ while (Character.isWhitespace(c)) {
+ c = it.next();
+ }
+ }
+
+ /**
+ * Parses the {@link Object} from the {@link CharacterIterator}. This method
+ * delegates to the proper parsing method depending on the current iterator context.
+ * This method will throw an {@link IllegalStateException} if parsing fails.
+ *
+ * @param it the {@link CharacterIterator} to parse
+ *
+ * @return the new object, never null
+ * @see #parseString(CharacterIterator)
+ * @see #parseNumber(CharacterIterator)
+ * @see #parseArray(CharacterIterator)
+ * @see #parseObject(CharacterIterator)
+ */
+ private static Object parseValue(CharacterIterator it) {
+ switch (it.current()) {
+ case '{' : {
+ return parseObject(it);
+ }
+ case '[' : {
+ return parseArray(it);
+ }
+ case '"' : {
+ return parseString(it);
+ }
+ case '-' :
+ case '0' :
+ case '1' :
+ case '2' :
+ case '3' :
+ case '4' :
+ case '5' :
+ case '6' :
+ case '7' :
+ case '8' :
+ case '9' : {
+ return parseNumber(it);
+ }
+ case 't' : {
+ parseText(Boolean.TRUE.toString(), it);
+ return Boolean.TRUE;
+ }
+ case 'f' : {
+ parseText(Boolean.FALSE.toString(), it);
+ return Boolean.FALSE;
+ }
+ case 'n' : {
+ parseText(CFNullValue.NULL, it);
+ return null;
+ }
+ case 'u': {
+ parseText(CFUndefinedValue.UNDEFINED, it);
+ return null;
+ }
+ }
+ throw error("Bad JSON starting character '" + it.current() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$;
+ }
+
+ /**
+ * Parses the JSON string from the {@link CharacterIterator}
+ *
+ * @param it the {@link CharacterIterator} to parse
+ * @return the JSON {@link String}, never null
+ */
+ private static String parseString(CharacterIterator it) {
+ char c = it.next();
+ if (c == '"') {
+ it.next();
+ return ""; //$NON-NLS-1$
+ }
+ StringBuffer buffer = new StringBuffer();
+ while (c != CharacterIterator.DONE && c != '"') {
+ if (Character.isISOControl(c)) {
+ //ignore it and continue
+ c = it.next();
+ continue;
+ //throw error("illegal ISO control character: '" + Integer.toHexString(c) + "'", it); //$NON-NLS-1$ //$NON-NLS-2$);
+ }
+ if (c == '\\') {
+ c = it.next();
+ switch (c) {
+ case '"' :
+ case '\\' :
+ case '/' : {
+ buffer.append(c);
+ break;
+ }
+ case 'b' : {
+ buffer.append('\b');
+ break;
+ }
+ case 'f' : {
+ buffer.append('\f');
+ break;
+ }
+ case 'n' : {
+ buffer.append('\n');
+ break;
+ }
+ case 'r' : {
+ buffer.append('\r');
+ break;
+ }
+ case 't' : {
+ buffer.append('\t');
+ break;
+ }
+ case 'u' : {
+ StringBuffer unicode = new StringBuffer(4);
+ for (int i = 0; i < 4; i++) {
+ unicode.append(it.next());
+ }
+ try {
+ buffer.append((char) Integer.parseInt(unicode.toString(), 16));
+ } catch (NumberFormatException e) {
+ throw error("expected a unicode hex number but was '" + unicode.toString() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$););
+ }
+ break;
+ }
+ default : {
+ throw error("illegal escape character '" + c + "'", it); //$NON-NLS-1$ //$NON-NLS-2$););
+ }
+ }
+ } else {
+ buffer.append(c);
+ }
+ c = it.next();
+ }
+ c = it.next();
+ return buffer.toString();
+ }
+
+ /**
+ * Parses an {@link Map} object from the iterator or throws an
+ * {@link IllegalStateException} if parsing fails.
+ *
+ * @param it the {@link CharacterIterator} to parse
+ * @return a new {@link Map} object, never null
+ */
+ private static Map parseObject(CharacterIterator it) {
+ it.next();
+ parseWhitespace(it);
+ if (it.current() == '}') {
+ it.next();
+ return Collections.EMPTY_MAP;
+ }
+
+ Map map = new HashMap();
+ while (it.current() != CharacterIterator.DONE) {
+ if (it.current() != '"') {
+ throw error("expected a string start '\"' but was '" + it.current() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ String key = parseString(it);
+ if (map.containsKey(key)) {
+ throw error("' already defined" + "key '" + key, it); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ parseWhitespace(it);
+ if (it.current() != ':') {
+ throw error("expected a pair separator ':' but was '" + it.current() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ it.next();
+ parseWhitespace(it);
+ Object value = parseValue(it);
+ map.put(key, value);
+ parseWhitespace(it);
+ if (it.current() == ',') {
+ it.next();
+ parseWhitespace(it);
+ continue;
+ }
+ if (it.current() != '}') {
+ throw error("expected an object close '}' but was '" + it.current() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ break;
+ }
+ it.next();
+ return map;
+ }
+
+ /**
+ * Parses an {@link ArrayList} from the given iterator or throws an
+ * {@link IllegalStateException} if parsing fails
+ *
+ * @param it the {@link CharacterIterator} to parse
+ * @return a new {@link ArrayList} object never null
+ */
+ private static List parseArray(CharacterIterator it) {
+ it.next();
+ parseWhitespace(it);
+ if (it.current() == ']') {
+ it.next();
+ return Collections.EMPTY_LIST;
+ }
+
+ List list = new ArrayList();
+ while (it.current() != CharacterIterator.DONE) {
+ Object value = parseValue(it);
+ list.add(value);
+ parseWhitespace(it);
+ if (it.current() == ',') {
+ it.next();
+ parseWhitespace(it);
+ continue;
+ }
+ if (it.current() != ']') {
+ throw error("expected an array close ']' but was '" + it.current() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ break;
+ }
+ it.next();
+ return list;
+ }
+
+ /**
+ * @param string
+ * @param it
+ */
+ private static void parseText(String string, CharacterIterator it) {
+ int length = string.length();
+ char c = it.current();
+ for (int i = 0; i < length; i++) {
+ if (c != string.charAt(i)) {
+ throw error("expected to parse '" + string + "' but character " + (i + 1) + " was '" + c + "'", it); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$;
+ }
+ c = it.next();
+ }
+ }
+
+ /**
+ * Parses a {@link Number} object from the given {@link CharacterIterator}
+ *
+ * @param it
+ * @return a new {@link Number}, never null
+ */
+ private static Object parseNumber(CharacterIterator it) {
+ StringBuffer buffer = new StringBuffer();
+ char c = it.current();
+ while (Character.isDigit(c) || c == '-' || c == '+' || c == '.' || c == 'e' || c == 'E') {
+ buffer.append(c);
+ c = it.next();
+ }
+ try {
+ return new BigDecimal(buffer.toString());
+ } catch (NumberFormatException e) {
+ throw error("expected a number but was '" + buffer.toString() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$;
+ }
+ }
+}
#P org.eclipse.wst.jsdt.debug.rhino
Index: build.properties
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.rhino/build.properties,v
retrieving revision 1.3
diff -u -r1.3 build.properties
--- build.properties 1 Apr 2010 18:37:15 -0000 1.3
+++ build.properties 4 Jan 2012 20:13:17 -0000
@@ -1,8 +1,19 @@
+###############################################################################
+# Copyright (c) 2010, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
about.html,\
- OSGI-INF/l10n/bundle.properties
+ OSGI-INF/l10n/bundle.properties,\
+ OSGI-INF/
src.includes = about.html
Index: src/org/eclipse/wst/jsdt/debug/internal/rhino/RhinoPreferenceInitializer.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.rhino/src/org/eclipse/wst/jsdt/debug/internal/rhino/RhinoPreferenceInitializer.java,v
retrieving revision 1.1
diff -u -r1.1 RhinoPreferenceInitializer.java
--- src/org/eclipse/wst/jsdt/debug/internal/rhino/RhinoPreferenceInitializer.java 17 Mar 2010 18:08:46 -0000 1.1
+++ src/org/eclipse/wst/jsdt/debug/internal/rhino/RhinoPreferenceInitializer.java 4 Jan 2012 20:13:17 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,7 +31,7 @@
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() {
- IEclipsePreferences defaultscope = new DefaultScope().getNode(RhinoDebugPlugin.PLUGIN_ID);
+ IEclipsePreferences defaultscope = DefaultScope.INSTANCE.getNode(RhinoDebugPlugin.PLUGIN_ID);
defaultscope.putBoolean(Constants.SUSPEND_ON_STDIN_LOAD, false);
try {
defaultscope.flush();
Index: src/org/eclipse/wst/jsdt/debug/internal/rhino/RhinoPreferencesManager.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.rhino/src/org/eclipse/wst/jsdt/debug/internal/rhino/RhinoPreferencesManager.java,v
retrieving revision 1.1
diff -u -r1.1 RhinoPreferencesManager.java
--- src/org/eclipse/wst/jsdt/debug/internal/rhino/RhinoPreferencesManager.java 17 Mar 2010 18:08:46 -0000 1.1
+++ src/org/eclipse/wst/jsdt/debug/internal/rhino/RhinoPreferencesManager.java 4 Jan 2012 20:13:17 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,7 +28,7 @@
* Starts the manager
*/
public void start() {
- IEclipsePreferences node = new InstanceScope().getNode(RhinoDebugPlugin.PLUGIN_ID);
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(RhinoDebugPlugin.PLUGIN_ID);
if(node != null) {
node.addPreferenceChangeListener(this);
}
@@ -42,7 +42,7 @@
* Stops the manager and frees any resources held
*/
public void stop() {
- IEclipsePreferences node = new InstanceScope().getNode(RhinoDebugPlugin.PLUGIN_ID);
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(RhinoDebugPlugin.PLUGIN_ID);
if(node != null) {
node.removePreferenceChangeListener(this);
}
Index: src/org/eclipse/wst/jsdt/debug/internal/rhino/jsdi/VirtualMachineImpl.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.rhino/src/org/eclipse/wst/jsdt/debug/internal/rhino/jsdi/VirtualMachineImpl.java,v
retrieving revision 1.14
diff -u -r1.14 VirtualMachineImpl.java
--- src/org/eclipse/wst/jsdt/debug/internal/rhino/jsdi/VirtualMachineImpl.java 25 Feb 2011 20:02:19 -0000 1.14
+++ src/org/eclipse/wst/jsdt/debug/internal/rhino/jsdi/VirtualMachineImpl.java 4 Jan 2012 20:13:17 -0000
@@ -91,6 +91,14 @@
}
/**
+ * Called via reflection to determine if the vm supports suspend on script loads
+ * @return true
if this VM can suspend when a script loads false
otherwise
+ */
+ public boolean supportsSuspendOnScriptLoads() {
+ return true;
+ }
+
+ /**
* Creates a new {@link ScriptReferenceImpl} for the given ID
* @param scriptId
* @return the new {@link ScriptReferenceImpl} or null
Index: src/org/eclipse/wst/jsdt/debug/internal/rhino/jsdi/messages.properties
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.rhino/src/org/eclipse/wst/jsdt/debug/internal/rhino/jsdi/messages.properties,v
retrieving revision 1.3
diff -u -r1.3 messages.properties
--- src/org/eclipse/wst/jsdt/debug/internal/rhino/jsdi/messages.properties 17 Mar 2010 18:08:47 -0000 1.3
+++ src/org/eclipse/wst/jsdt/debug/internal/rhino/jsdi/messages.properties 4 Jan 2012 20:13:17 -0000
@@ -1 +1,11 @@
+###############################################################################
+# Copyright (c) 2010, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
ArrayReferenceImpl_array_count_=Array [{0}]
#P org.eclipse.wst.jsdt.debug.rhino.debugger
Index: build.properties
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.rhino.debugger/build.properties,v
retrieving revision 1.3
diff -u -r1.3 build.properties
--- build.properties 1 Apr 2010 18:37:23 -0000 1.3
+++ build.properties 4 Jan 2012 20:13:18 -0000
@@ -1,7 +1,19 @@
+###############################################################################
+# Copyright (c) 2010, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
about.html,\
- OSGI-INF/l10n/bundle.properties
+ OSGI-INF/l10n/bundle.properties,\
+ OSGI-INF/,\
+ OSGI-INF/l10n/
src.includes = about.html
Index: src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/ScriptSource.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/ScriptSource.java,v
retrieving revision 1.6
diff -u -r1.6 ScriptSource.java
--- src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/ScriptSource.java 25 Feb 2011 20:02:25 -0000 1.6
+++ src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/ScriptSource.java 4 Jan 2012 20:13:18 -0000
@@ -182,9 +182,11 @@
void clearBreakpoints(RhinoDebuggerImpl debugger) {
if(this.lines != null) {
for (int i = 0; i < this.lines.length; i++) {
- Breakpoint bp = lines[i].breakpoint;
- if(bp != null) {
- debugger.clearBreakpoint(bp.breakpointId);
+ if(lines[i] != null) {
+ Breakpoint bp = lines[i].breakpoint;
+ if(bp != null) {
+ debugger.clearBreakpoint(bp.breakpointId);
+ }
}
}
}
@@ -277,13 +279,13 @@
result.put(JSONConstants.SOURCE, source);
result.put(JSONConstants.GENERATED, Boolean.valueOf(generated));
if(lines != null) {
- HashSet lineNumbers = new HashSet();
- for (int i = 0; i < lines.length; i++) {
- if(lines[i] != null) {
- lineNumbers.add(new Integer(i));
+ HashSet lineNumbers = new HashSet();
+ for (int i = 0; i < lines.length; i++) {
+ if(lines[i] != null) {
+ lineNumbers.add(new Integer(i));
+ }
}
- }
- result.put(JSONConstants.LINES, (lineNumbers == null ? Collections.EMPTY_SET : lineNumbers));
+ result.put(JSONConstants.LINES, (lineNumbers == null ? Collections.EMPTY_SET : lineNumbers));
}
else {
result.put(JSONConstants.LINES, Collections.EMPTY_SET);
#P org.eclipse.wst.jsdt.debug.rhino.ui
Index: build.properties
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.rhino.ui/build.properties,v
retrieving revision 1.2
diff -u -r1.2 build.properties
--- build.properties 17 Aug 2010 17:01:40 -0000 1.2
+++ build.properties 4 Jan 2012 20:13:19 -0000
@@ -1,3 +1,13 @@
+###############################################################################
+# Copyright (c) 2010, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
@@ -5,4 +15,5 @@
plugin.xml,\
OSGI-INF/l10n/bundle.properties,\
icons/,\
- about.html
+ about.html,\
+ OSGI-INF/
Index: plugin.xml
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.rhino.ui/plugin.xml,v
retrieving revision 1.2
diff -u -r1.2 plugin.xml
--- plugin.xml 19 Oct 2010 19:55:17 -0000 1.2
+++ plugin.xml 4 Jan 2012 20:13:19 -0000
@@ -152,6 +152,14 @@
thino.main.tab
+ * Value is: rhino.main.tab
*/
public static final String TAB_ID = "rhino.main.tab"; //$NON-NLS-1$
public static final String[] VERSIONS = {"100", "110", "120", "130", "140", "150", "160", "170"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
@@ -127,6 +127,10 @@
setControl(comp);
}
+ public String getHelpContextId() {
+ return IHelpConstants.MAIN_TAB_CONTEXT;
+ };
+
/**
* Allows users to select a script from either a project context, if there is one or the workspace
*
Index: src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/preferences/RhinoDebugPreferencePage.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.rhino.ui/src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/preferences/RhinoDebugPreferencePage.java,v
retrieving revision 1.1
diff -u -r1.1 RhinoDebugPreferencePage.java
--- src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/preferences/RhinoDebugPreferencePage.java 19 Oct 2010 19:55:17 -0000 1.1
+++ src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/preferences/RhinoDebugPreferencePage.java 4 Jan 2012 20:13:19 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -42,7 +42,7 @@
public RhinoDebugPreferencePage() {
super(GRID);
setDescription(Messages.rhino_pref_page_desc);
- setPreferenceStore(RhinoUIPlugin.getDefault().getPreferenceStore());
+ setPreferenceStore(RhinoUIPlugin.getCorePreferenceStore());
}
/* (non-Javadoc)
Index: src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/refactoring/ProjectChange.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.rhino.ui/src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/refactoring/ProjectChange.java,v
retrieving revision 1.2
diff -u -r1.2 ProjectChange.java
--- src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/refactoring/ProjectChange.java 2 Sep 2010 16:50:39 -0000 1.2
+++ src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/refactoring/ProjectChange.java 4 Jan 2012 20:13:19 -0000
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package org.eclipse.wst.jsdt.debug.internal.rhino.ui.refactoring;
import org.eclipse.core.resources.IContainer;
Index: src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/source/RhinoSourceDirector.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.rhino.ui/src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/source/RhinoSourceDirector.java,v
retrieving revision 1.1
diff -u -r1.1 RhinoSourceDirector.java
--- src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/source/RhinoSourceDirector.java 17 Aug 2010 15:59:43 -0000 1.1
+++ src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/source/RhinoSourceDirector.java 4 Jan 2012 20:13:19 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -26,4 +26,11 @@
public void initializeParticipants() {
addParticipants(new ISourceLookupParticipant[] {new RhinoSourceLookupParticipant()});
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#isFindDuplicates()
+ */
+ public boolean isFindDuplicates() {
+ return true;
+ }
}
Index: src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/source/RhinoSourceLookupParticipant.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.rhino.ui/src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/source/RhinoSourceLookupParticipant.java,v
retrieving revision 1.1
diff -u -r1.1 RhinoSourceLookupParticipant.java
--- src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/source/RhinoSourceLookupParticipant.java 17 Aug 2010 15:59:43 -0000 1.1
+++ src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/source/RhinoSourceLookupParticipant.java 4 Jan 2012 20:13:19 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,10 +14,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.URIUtil;
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
-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.launching.SourceLookup;
/**
@@ -31,15 +28,7 @@
* @see org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant#getSourceName(java.lang.Object)
*/
public String getSourceName(Object object) throws CoreException {
- if(object instanceof IJavaScriptStackFrame) {
- IJavaScriptStackFrame frame = (IJavaScriptStackFrame) object;
- return frame.getSourceName();
- }
- if(object instanceof IScript) {
- IScript script = (IScript) object;
- return URIUtil.lastSegment(script.sourceURI());
- }
- return null;
+ return SourceLookup.getSourceName(object);
}
/* (non-Javadoc)
#P org.eclipse.wst.jsdt.debug.transport
Index: build.properties
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.transport/build.properties,v
retrieving revision 1.2
diff -u -r1.2 build.properties
--- build.properties 10 Aug 2010 12:09:40 -0000 1.2
+++ build.properties 4 Jan 2012 20:13:19 -0000
@@ -1,6 +1,18 @@
+###############################################################################
+# Copyright (c) 2010, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/l10n/bundle.properties,\
- about.html
+ about.html,\
+ OSGI-INF/,\
+ OSGI-INF/l10n/
Index: src/org/eclipse/wst/jsdt/debug/transport/ListenerKey.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/ListenerKey.java,v
retrieving revision 1.1
diff -u -r1.1 ListenerKey.java
--- src/org/eclipse/wst/jsdt/debug/transport/ListenerKey.java 20 Jul 2010 19:18:42 -0000 1.1
+++ src/org/eclipse/wst/jsdt/debug/transport/ListenerKey.java 4 Jan 2012 20:13:19 -0000
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package org.eclipse.wst.jsdt.debug.transport;
import java.net.Socket;
Index: src/org/eclipse/wst/jsdt/debug/transport/socket/SocketListenerKey.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/socket/SocketListenerKey.java,v
retrieving revision 1.1
diff -u -r1.1 SocketListenerKey.java
--- src/org/eclipse/wst/jsdt/debug/transport/socket/SocketListenerKey.java 20 Jul 2010 19:18:41 -0000 1.1
+++ src/org/eclipse/wst/jsdt/debug/transport/socket/SocketListenerKey.java 4 Jan 2012 20:13:19 -0000
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package org.eclipse.wst.jsdt.debug.transport.socket;
import org.eclipse.wst.jsdt.debug.transport.ListenerKey;
#P org.eclipse.wst.jsdt.debug.ui
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/META-INF/MANIFEST.MF,v
retrieving revision 1.7
diff -u -r1.7 MANIFEST.MF
--- META-INF/MANIFEST.MF 19 Oct 2010 19:55:21 -0000 1.7
+++ META-INF/MANIFEST.MF 4 Jan 2012 20:13:20 -0000
@@ -16,19 +16,19 @@
org.eclipse.ui.workbench.texteditor,
org.eclipse.wst.jsdt.ui,
org.eclipse.ui.editors,
- org.eclipse.core.expressions
+ org.eclipse.core.expressions,
+ org.eclipse.wst.sse.ui;bundle-version="1.3.1"
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.wst.jsdt.debug.internal.ui.filters"
-Export-Package: org.eclipse.wst.jsdt.debug.internal.ui;x-internal:=true,
+Export-Package: org.eclipse.wst.jsdt.debug.internal.ui;x-friends:="org.eclipse.wst.jsdt.debug.rhino.ui",
org.eclipse.wst.jsdt.debug.internal.ui.actions;x-internal:=true,
org.eclipse.wst.jsdt.debug.internal.ui.adapters;x-internal:=true,
org.eclipse.wst.jsdt.debug.internal.ui.breakpoints;x-internal:=true,
org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.details;x-internal:=true,
org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.editors;x-internal:=true,
- org.eclipse.wst.jsdt.debug.internal.ui.dialogs;x-internal:=true,
+ org.eclipse.wst.jsdt.debug.internal.ui.dialogs;x-friends:="org.eclipse.wst.jsdt.debug.rhino.ui",
org.eclipse.wst.jsdt.debug.internal.ui.display;x-internal:=true,
org.eclipse.wst.jsdt.debug.internal.ui.eval;x-internal:=true,
- org.eclipse.wst.jsdt.debug.internal.ui.filters;x-internal:=true,
org.eclipse.wst.jsdt.debug.internal.ui.launching;x-internal:=true,
org.eclipse.wst.jsdt.debug.internal.ui.preferences;x-internal:=true,
org.eclipse.wst.jsdt.debug.internal.ui.source;x-internal:=true,
Index: OSGI-INF/l10n/bundle.properties
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/OSGI-INF/l10n/bundle.properties,v
retrieving revision 1.16
diff -u -r1.16 bundle.properties
--- OSGI-INF/l10n/bundle.properties 23 Mar 2011 19:46:56 -0000 1.16
+++ OSGI-INF/l10n/bundle.properties 4 Jan 2012 20:13:20 -0000
@@ -42,10 +42,6 @@
openSourceObjectAction.tooltip = Shows the JavaScript source for the selected script element
commandCategory.description = Tooling for debugging JavaScript
commandCategory.name = JavaScript Debug
-jsdtProjectFilter.description = Filters the External JavaScript Source project, which is used in the workspace to hold temporary JavaScript sources
-jsdtProjectFilter.name = External JavaScript Source
-jdtProjectFilter.description = Filters the External JavaScript Source project, which is used in the workspace to hold temporary JavaScript sources
-jdtProjectFilter.name = External JavaScript Source
showFunctionVarAction.label = Show function variables
showFunctionVarAction.tooltip = Show or hide function variables
Index: build.properties
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/build.properties,v
retrieving revision 1.6
diff -u -r1.6 build.properties
--- build.properties 1 Apr 2010 18:37:29 -0000 1.6
+++ build.properties 4 Jan 2012 20:13:20 -0000
@@ -1,3 +1,13 @@
+###############################################################################
+# Copyright (c) 2010, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
Index: plugin.xml
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/plugin.xml,v
retrieving revision 1.30
diff -u -r1.30 plugin.xml
--- plugin.xml 23 Mar 2011 19:17:00 -0000 1.30
+++ plugin.xml 4 Jan 2012 20:13:20 -0000
@@ -89,6 +89,16 @@
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider">
+ null
if it could not be computed
+ *
+ * @param doc
+ * @param offset
+ * @return the {@link JavaScriptUnit} for the region from the document or null
+ */
+ JavaScriptUnit parse(IDocument doc, int offset) {
+ try {
+ ITypedRegion region = doc.getPartition(offset);
+ if(region != null) {
+ ASTParser parser = ASTParser.newParser(AST.JLS3);
+ //parser.setKind(ASTParser.K_STATEMENTS);
+ parser.setSource(doc.get(offset, region.getLength()).toCharArray());
+ return (JavaScriptUnit)parser.createAST(null);
+ }
+ }
+ catch(BadLocationException ble) {
+ //do nothing, return null
+ }
+ return null;
+ }
+
+ /**
* Returns the resource on which a breakpoint marker should
* be created for the given member. The resource returned is the
* associated file, or workspace root in the case of a binary in
Index: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/messages.properties
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/eval/messages.properties,v
retrieving revision 1.1
diff -u -r1.1 messages.properties
--- src/org/eclipse/wst/jsdt/debug/internal/ui/eval/messages.properties 14 Oct 2010 18:29:38 -0000 1.1
+++ src/org/eclipse/wst/jsdt/debug/internal/ui/eval/messages.properties 4 Jan 2012 20:13:21 -0000
@@ -1,3 +1,13 @@
+###############################################################################
+# Copyright (c) 201o IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
cannot_find_debug_target=Unable to locate debug target
cursor_position_not_valid=Cursor position is not a valid location to run to
empty_editor=Empty editor
Index: src/org/eclipse/wst/jsdt/debug/internal/ui/filters/ExternalSourceProjectFilter.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/filters/ExternalSourceProjectFilter.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/filters/ExternalSourceProjectFilter.java
--- src/org/eclipse/wst/jsdt/debug/internal/ui/filters/ExternalSourceProjectFilter.java 26 Jul 2010 14:51:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.debug.internal.ui.filters;
-
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-
-/**
- * Viewer filter for the 'JavaScript External Source' project
- *
- * @since 1.1
- */
-public class ExternalSourceProjectFilter extends ViewerFilter {
-
- /**
- * Constructor
- */
- public ExternalSourceProjectFilter() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if(element instanceof IProject) {
- return !((IProject)element).getName().equals(Messages.external_javascript_source);
- }
- return true;
- }
-
-}
Index: src/org/eclipse/wst/jsdt/debug/internal/ui/filters/Messages.java
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/filters/Messages.java
diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/filters/Messages.java
--- src/org/eclipse/wst/jsdt/debug/internal/ui/filters/Messages.java 26 Jul 2010 14:51:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.debug.internal.ui.filters;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- *
- */
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.ui.filters.messages"; //$NON-NLS-1$
- public static String external_javascript_source;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
Index: src/org/eclipse/wst/jsdt/debug/internal/ui/filters/messages.properties
===================================================================
RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/filters/messages.properties
diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/filters/messages.properties
--- src/org/eclipse/wst/jsdt/debug/internal/ui/filters/messages.properties 26 Jul 2010 14:51:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,11 +0,0 @@
-###############################################################################
-# Copyright (c) 2010 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-external_javascript_source=External JavaScript Source
\ No newline at end of file
Index: src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptConnectTab.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptConnectTab.java,v
retrieving revision 1.6
diff -u -r1.6 JavaScriptConnectTab.java
--- src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptConnectTab.java 26 Oct 2010 19:25:38 -0000 1.6
+++ src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptConnectTab.java 4 Jan 2012 20:13:21 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -154,10 +154,17 @@
this.argumentsgroup = SWTFactory.createGroup(comp, Messages.connector_properties, 2, 1, GridData.FILL_HORIZONTAL);
this.argumentsgroup.setVisible(false);
- setControl(comp);
PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IHelpContextIds.CONNECT_TAB);
+ setControl(comp);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getHelpContextId()
+ */
+ public String getHelpContextId() {
+ return IHelpContextIds.CONNECT_TAB;
+ };
+
/**
* Returns the {@link Connector} based on the selection of the combo
* @return the selected combo
@@ -276,6 +283,27 @@
return false;
}
}
+ else if (editor instanceof BooleanFieldEditor) {
+ boolean value = ((BooleanFieldEditor)editor).getBooleanValue();
+ if (!arg.isValid(String.valueOf(value))) {
+ setErrorMessage(NLS.bind(Messages.the_argument_0_is_not_valid, new String[] {arg.name()}));
+ return false;
+ }
+ }
+ else if (editor instanceof IntegerFieldEditor) {
+ int value = ((IntegerFieldEditor)editor).getIntValue();
+ if (!arg.isValid(String.valueOf(value))) {
+ setErrorMessage(NLS.bind(Messages.the_argument_0_is_not_valid, new String[] {arg.name()}));
+ return false;
+ }
+ }
+ else if(editor instanceof ComboFieldEditor) {
+ editor.store();
+ if (!arg.isValid(editor.getPreferenceStore().getString(key))) {
+ setErrorMessage(NLS.bind(Messages.the_argument_0_is_not_valid, new String[] {arg.name()}));
+ return false;
+ }
+ }
}
return true;
}
Index: src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavascriptTabGroup.java
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavascriptTabGroup.java,v
retrieving revision 1.2
diff -u -r1.2 JavascriptTabGroup.java
--- src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavascriptTabGroup.java 24 Feb 2010 21:49:42 -0000 1.2
+++ src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavascriptTabGroup.java 4 Jan 2012 20:13:21 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,9 +16,10 @@
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
+import org.eclipse.wst.jsdt.debug.internal.ui.IHelpContextIds;
/**
- * Default tab group for Javascript debugging
+ * Default tab group for JavaScript debugging
*
* @since 1.0
*/
@@ -28,11 +29,17 @@
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
*/
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ SourceLookupTab slt = new SourceLookupTab();
+ slt.setHelpContextId(IHelpContextIds.SOURCE_LOOKUP_TAB);
+ EnvironmentTab et = new EnvironmentTab();
+ et.setHelpContextId(IHelpContextIds.ENVIRONMENT_TAB);
+ CommonTab ct = new CommonTab();
+ ct.setHelpContextId(IHelpContextIds.COMMON_TAB);
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
new JavaScriptConnectTab(),
- new SourceLookupTab(),
- new EnvironmentTab(),
- new CommonTab()
+ slt,
+ et,
+ ct
};
setTabs(tabs);
}
Index: src/org/eclipse/wst/jsdt/debug/internal/ui/messages.properties
===================================================================
RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/messages.properties,v
retrieving revision 1.8
diff -u -r1.8 messages.properties
--- src/org/eclipse/wst/jsdt/debug/internal/ui/messages.properties 28 Feb 2011 18:05:08 -0000 1.8
+++ src/org/eclipse/wst/jsdt/debug/internal/ui/messages.properties 4 Jan 2012 20:13:21 -0000
@@ -28,13 +28,14 @@
evald_script=