diff options
author | mrennie | 2010-07-20 19:36:58 +0000 |
---|---|---|
committer | mrennie | 2010-07-20 19:36:58 +0000 |
commit | 9521c8daf0947ec52b6b93b5a2acc1ff1129e463 (patch) | |
tree | fdba3ec8aea596db71ddc91cf889175e81576a4e /development/org.eclipse.wst.jsdt.debug.chrome/src/org | |
parent | 6446e7a6eaf0cae143365bddcd80bc547d74ba8f (diff) | |
download | webtools.jsdt.debug-9521c8daf0947ec52b6b93b5a2acc1ff1129e463.tar.gz webtools.jsdt.debug-9521c8daf0947ec52b6b93b5a2acc1ff1129e463.tar.xz webtools.jsdt.debug-9521c8daf0947ec52b6b93b5a2acc1ff1129e463.zip |
sharing Google Chrome work for experimenting with
Diffstat (limited to 'development/org.eclipse.wst.jsdt.debug.chrome/src/org')
64 files changed, 4588 insertions, 0 deletions
diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/ChromePlugin.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/ChromePlugin.java new file mode 100644 index 0000000..d1eb3a0 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/ChromePlugin.java @@ -0,0 +1,137 @@ +package org.eclipse.wst.jsdt.debug.internal.chrome; + +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.chrome.event.EventQueueImpl; +import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.MirrorImpl; +import org.eclipse.wst.jsdt.debug.internal.chrome.transport.PacketImpl; +import org.eclipse.wst.jsdt.debug.internal.chrome.transport.JSON; +import org.osgi.framework.BundleContext; + +public class ChromePlugin extends Plugin { + + /** + * Id of the bundle + */ + public static final String PLUGIN_ID = "org.eclipse.wst.jsdt.debug.internal.chrome"; //$NON-NLS-1$ + /** + * PacketImpl tracing option name + */ + public static final String TRC_PACKETS = PLUGIN_ID + "/packets"; //$NON-NLS-1$ + /** + * ChromeEvent 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; + + /** + * Singleton instance + */ + private static ChromePlugin plugin = null; + + /** + * @return the singleton plugin instance + */ + public static ChromePlugin getDefault() { + return plugin; + } + + /* + * (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); + } + } + + /** + * 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 <code>null</code> 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(ChromePlugin.getDefault().isDebugging()) { + String option = Platform.getDebugOption(TRC_PACKETS); + if(option != null) { + PacketImpl.setTracing(Boolean.valueOf(option).booleanValue()); + } + option = Platform.getDebugOption(TRC_EVENTQUEUE); + if(option != null) { + EventQueueImpl.setTracing(Boolean.valueOf(option).booleanValue()); + } + option = Platform.getDebugOption(TRC_JSDI); + if(option != null) { + MirrorImpl.setTracing(Boolean.valueOf(option).booleanValue()); + } + option = Platform.getDebugOption(TRC_JSON); + if(option != null) { + JSON.setTracing(Boolean.valueOf(option).booleanValue()); + } + } + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/Tracing.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/Tracing.java new file mode 100644 index 0000000..6d2e4ec --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/Tracing.java @@ -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.chrome; + +import org.eclipse.wst.jsdt.debug.internal.chrome.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) { + System.out.println(string.replaceAll(JSON.LINE_FEED, PRINTABLE_LINE_FEED)); + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/BrowserArgument.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/BrowserArgument.java new file mode 100644 index 0000000..00924a4 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/BrowserArgument.java @@ -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.chrome.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.browser_arg_desc; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label() + */ + public String label() { + return Messages.browser_arg_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; + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/ChromeAttachingConnector.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/ChromeAttachingConnector.java new file mode 100644 index 0000000..a7a3bf2 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/ChromeAttachingConnector.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * 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.chrome.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.AttachingConnector; +import org.eclipse.wst.jsdt.debug.internal.chrome.ChromePlugin; +import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.VMImpl; +import org.eclipse.wst.jsdt.debug.internal.chrome.transport.ChromeTransportService; +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 attaching connector + * + * @since 1.0 + */ +public class ChromeAttachingConnector implements AttachingConnector { + + public static final String ID = "org.eclipse.wst.jsdt.debug.chrome.connector.attach"; //$NON-NLS-1$ + + /** + * Constructor + */ + public ChromeAttachingConnector() { + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#defaultArguments() + */ + public Map defaultArguments() { + Map args = new HashMap(); + args.put(HostArgument.HOST, new HostArgument(null)); + args.put(PortArgument.PORT, new PortArgument(5000)); + 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_to_google_chrome; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#name() + */ + public String name() { + return Messages.google_chrome_attach; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#id() + */ + public String id() { + return 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); + boolean browser = Boolean.valueOf(str).booleanValue(); + TransportService service = new ChromeTransportService(); + String host = (String) arguments.get(HostArgument.HOST); + String port = (String) arguments.get(PortArgument.PORT); + if(browser) { + launchBrowser(host, port); + } + Connection c = service.attach(host + ":" + Integer.parseInt(port), 10000, 10000); //$NON-NLS-1$ + DebugSession session = new DebugSession(c); + return new VMImpl(session); + } + + /** + * Launch the browser on the given host / port + * @param host + * @param port + * @throws IOException + */ + void launchBrowser(final String host, final String port) throws IOException { + Thread thread = new Thread() { + public void run() { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + ChromePlugin.log(e); + } + StringBuffer buffer = new StringBuffer("/opt/google/chrome/chrome --remote-shell-port= "); //$NON-NLS-1$ + buffer.append(port); + try { + Runtime.getRuntime().exec(buffer.toString()); + } catch (IOException e) { + ChromePlugin.log(e); + } + }; + }; + thread.start(); + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/HostArgument.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/HostArgument.java new file mode 100644 index 0000000..607ba3d --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/HostArgument.java @@ -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.chrome.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_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 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 <code>localhost</code> or <code>127.0.0.1</code> + * @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 diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/Messages.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/Messages.java new file mode 100644 index 0000000..e68037e --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/Messages.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.chrome.connect; + +import org.eclipse.osgi.util.NLS; + +/** + * + */ +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.chrome.connect.messages"; //$NON-NLS-1$ + public static String attach_to_google_chrome; + public static String browser_arg_desc; + public static String browser_arg_label; + public static String google_chrome_attach; + public static String host_arg_desc; + public static String host_arg_label; + public static String port_arg_desc; + public static String port_arg_label; + public static String timeout_arg_desc; + public static String timeout_arg_label; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/PortArgument.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/PortArgument.java new file mode 100644 index 0000000..7e6fe05 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/PortArgument.java @@ -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.chrome.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_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 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 diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/TimeoutArgument.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/TimeoutArgument.java new file mode 100644 index 0000000..2d84a7a --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/TimeoutArgument.java @@ -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.chrome.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_arg_desc; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label() + */ + public String label() { + return Messages.timeout_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 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; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/messages.properties b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/messages.properties new file mode 100644 index 0000000..f6d0aa0 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/connect/messages.properties @@ -0,0 +1,10 @@ +attach_to_google_chrome=Allows you to connect to the Google Chrome browser +browser_arg_desc=Automatically launch Chrome and attach to it +browser_arg_label=Auto&matically launch Chrome and attach to it (extremely experimental) +google_chrome_attach=Google Chrome - Attach +host_arg_desc=The name of the host address to try and attach to +host_arg_label=&Host: +port_arg_desc=The port on the host machine to try connecting on +port_arg_label=&Port: +timeout_arg_desc=A timeout value in milliseconds to wait for the debugger to connect +timeout_arg_label=&Timeout: diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/BreakpointEventImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/BreakpointEventImpl.java new file mode 100644 index 0000000..51fb72a --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/BreakpointEventImpl.java @@ -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.chrome.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.event.BreakpointEvent; + +/** + * + */ +public class BreakpointEventImpl extends LocatableEventImpl implements BreakpointEvent { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.LocatableEvent#thread() + */ + public ThreadReference thread() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Locatable#location() + */ + public Location location() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/DebuggerStatementEventImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/DebuggerStatementEventImpl.java new file mode 100644 index 0000000..6cec32b --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/DebuggerStatementEventImpl.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.chrome.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.event.DebuggerStatementEvent; + +/** + * + */ +public class DebuggerStatementEventImpl extends LocatableEventImpl implements + DebuggerStatementEvent { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.LocatableEvent#thread() + */ + public ThreadReference thread() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Locatable#location() + */ + public Location location() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/EventImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/EventImpl.java new file mode 100644 index 0000000..1381fbb --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/EventImpl.java @@ -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.chrome.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; + +/** + * + */ +public class EventImpl implements Event { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Mirror#virtualMachine() + */ + public VirtualMachine virtualMachine() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.Event#request() + */ + public EventRequest request() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/EventQueueImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/EventQueueImpl.java new file mode 100644 index 0000000..f60133d --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/EventQueueImpl.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * 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.chrome.event; + +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.event.EventSet; +import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager; +import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.MirrorImpl; +import org.eclipse.wst.jsdt.debug.internal.chrome.transport.Commands; +import org.eclipse.wst.jsdt.debug.transport.exception.DisconnectedException; +import org.eclipse.wst.jsdt.debug.transport.exception.TimeoutException; +import org.eclipse.wst.jsdt.debug.transport.packet.Event; + +/** + * EVent queue for Chrome + * + * @since 1.0 + */ +public class EventQueueImpl extends MirrorImpl implements EventQueue { + + private EventRequestManager ermanager = null; + + static boolean TRACE = false; + + /** + * Constructor + * + * @param vm the underlying {@link VirtualMachine} + * @param manager the {@link EventRequestManager} to ask about pending requests + */ + public EventQueueImpl(VirtualMachine vm, EventRequestManager manager) { + super(vm); + this.ermanager = 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 { + //loop until disconnected - exception breaks loop + while(true) { + Event event = chromeVM().receiveEvent(); + if(event != null) { + //TODO + if(event.getEvent().equals(Commands.INSPECT)) { + ermanager.breakpointRequests(); + } + } + } + } + catch(DisconnectedException de) { + + } + catch(TimeoutException te) { + + } + return null; + } + + /** + * Enables / Disables tracing in the all of the JSDI implementations + * + * @param trace + */ + public static void setTracing(boolean trace) { + TRACE = trace; + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/EventSetImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/EventSetImpl.java new file mode 100644 index 0000000..fe6bb54 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/EventSetImpl.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * 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.chrome.event; + +import java.util.HashSet; + +import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine; +import org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet; + +/** + * + */ +public class EventSetImpl extends HashSet implements EventSet { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Mirror#virtualMachine() + */ + public VirtualMachine virtualMachine() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet#suspended() + */ + public boolean suspended() { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet#resume() + */ + public void resume() { + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/ExceptionEventImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/ExceptionEventImpl.java new file mode 100644 index 0000000..9e5122e --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/ExceptionEventImpl.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * 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.chrome.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.event.ExceptionEvent; + +/** + * + */ +public class ExceptionEventImpl extends LocatableEventImpl implements ExceptionEvent { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.LocatableEvent#thread() + */ + public ThreadReference thread() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Locatable#location() + */ + public Location location() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.ExceptionEvent#message() + */ + public String message() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/LocatableEventImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/LocatableEventImpl.java new file mode 100644 index 0000000..03aa31e --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/LocatableEventImpl.java @@ -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.chrome.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.event.LocatableEvent; + +/** + * + */ +public class LocatableEventImpl extends EventImpl implements LocatableEvent { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Locatable#location() + */ + public Location location() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.LocatableEvent#thread() + */ + public ThreadReference thread() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/ScriptEventImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/ScriptEventImpl.java new file mode 100644 index 0000000..f024602 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/ScriptEventImpl.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * 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.chrome.event; + +import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference; +import org.eclipse.wst.jsdt.debug.core.jsdi.event.ScriptLoadEvent; + +/** + * + */ +public class ScriptEventImpl extends LocatableEventImpl implements + ScriptLoadEvent { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.ScriptLoadEvent#script() + */ + public ScriptReference script() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/StepEventImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/StepEventImpl.java new file mode 100644 index 0000000..aa6e37e --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/StepEventImpl.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.chrome.event; + +import org.eclipse.wst.jsdt.debug.core.jsdi.event.StepEvent; + +/** + * + */ +public class StepEventImpl extends LocatableEventImpl implements StepEvent { + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/SuspendEventImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/SuspendEventImpl.java new file mode 100644 index 0000000..e6193aa --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/SuspendEventImpl.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * 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.chrome.event; + +import org.eclipse.wst.jsdt.debug.core.jsdi.event.SuspendEvent; + +/** + * + */ +public class SuspendEventImpl extends LocatableEventImpl implements + SuspendEvent { + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/ThreadEnterEventImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/ThreadEnterEventImpl.java new file mode 100644 index 0000000..018db56 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/ThreadEnterEventImpl.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.chrome.event; + +import org.eclipse.wst.jsdt.debug.core.jsdi.event.ThreadEnterEvent; + +/** + * + */ +public class ThreadEnterEventImpl extends LocatableEventImpl implements ThreadEnterEvent { + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/ThreadExitEventImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/ThreadExitEventImpl.java new file mode 100644 index 0000000..4719d44 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/ThreadExitEventImpl.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * 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.chrome.event; + +import org.eclipse.wst.jsdt.debug.core.jsdi.event.ThreadExitEvent; + +/** + * + */ +public class ThreadExitEventImpl extends LocatableEventImpl implements + ThreadExitEvent { + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/VMDeathEventImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/VMDeathEventImpl.java new file mode 100644 index 0000000..034bef6 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/VMDeathEventImpl.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * 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.chrome.event; + +import org.eclipse.wst.jsdt.debug.core.jsdi.event.VMDeathEvent; + +/** + * + */ +public class VMDeathEventImpl extends LocatableEventImpl implements + VMDeathEvent { + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/VMDisconnectEventImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/VMDisconnectEventImpl.java new file mode 100644 index 0000000..c433cac --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/event/VMDisconnectEventImpl.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * 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.chrome.event; + +import org.eclipse.wst.jsdt.debug.core.jsdi.event.VMDisconnectEvent; + +/** + * + */ +public class VMDisconnectEventImpl extends LocatableEventImpl implements + VMDisconnectEvent { + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ArrayImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ArrayImpl.java new file mode 100644 index 0000000..af907e9 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ArrayImpl.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * 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.chrome.jsdi; + +import java.util.List; + +import org.eclipse.wst.jsdt.debug.core.jsdi.ArrayReference; +import org.eclipse.wst.jsdt.debug.core.jsdi.Value; + +/** + * + */ +public class ArrayImpl extends ObjectImpl implements ArrayReference { + + /* (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; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/BooleanImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/BooleanImpl.java new file mode 100644 index 0000000..4294644 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/BooleanImpl.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * 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.chrome.jsdi; + +import org.eclipse.wst.jsdt.debug.core.jsdi.BooleanValue; +import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine; + +/** + * Default implementation of {@link BooleanValue} for Chrome + * + * @since 1.0 + */ +public class BooleanImpl extends MirrorImpl implements BooleanValue { + + private boolean value = false; + + /** + * Constructor + * + * @param vm the underlying {@link VirtualMachine} + * @param bool the boolean value + */ + public BooleanImpl(VirtualMachine vm, boolean bool) { + super(vm); + value = bool; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#intValue() + */ + public int intValue() { + if(value) { + return 1; + } + return 0; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#doubleValue() + */ + public double doubleValue() { + return intValue(); + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#booleanValue() + */ + public boolean booleanValue() { + return value; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#stringValue() + */ + public String stringValue() { + return Boolean.toString(value); + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString() + */ + public String valueString() { + return stringValue(); + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/FunctionImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/FunctionImpl.java new file mode 100644 index 0000000..076e97a --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/FunctionImpl.java @@ -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.chrome.jsdi; + +import org.eclipse.wst.jsdt.debug.core.jsdi.FunctionReference; + +/** + * + */ +public class FunctionImpl extends ObjectImpl implements FunctionReference { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.FunctionReference#functionName() + */ + public String functionName() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.FunctionReference#functionBody() + */ + public String functionBody() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/Messages.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/Messages.java new file mode 100644 index 0000000..6795014 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/Messages.java @@ -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.chrome.jsdi; + +import org.eclipse.osgi.util.NLS; + +/** + * + */ +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.messages"; //$NON-NLS-1$ + public static String cannot_mirror_null_number; + public static String chrome_vm; + public static String vm_description; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/MirrorImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/MirrorImpl.java new file mode 100644 index 0000000..4ebc132 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/MirrorImpl.java @@ -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.chrome.jsdi; + +import org.eclipse.wst.jsdt.debug.core.jsdi.Mirror; +import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine; + +/** + * Default impl for Chrome v8. + * + * @since 1.0 + */ +public class MirrorImpl implements Mirror { + + /** + * Flag for tracing + */ + static boolean TRACE = false; + + private VirtualMachine vm = null; + + /** + * Constructor + * + * @param vm the underlying {@link VirtualMachine} + */ + public MirrorImpl(VirtualMachine vm) { + this.vm = vm; + } + + /** + * Constructor + * + * Used for the {@link VMImpl} instantiation case + */ + protected MirrorImpl() { + this.vm = (VirtualMachine) this; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Mirror#virtualMachine() + */ + public VirtualMachine virtualMachine() { + return vm; + } + + /** + * Returns the {@link VMImpl} backing this {@link Mirror} object + * + * @return the backing {@link VMImpl} + */ + protected VMImpl chromeVM() { + return (VMImpl)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); + } + + /** + * Enables / Disables tracing in the all of the JSDI implementations + * + * @param trace + */ + public static void setTracing(boolean trace) { + TRACE = trace; + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/NullImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/NullImpl.java new file mode 100644 index 0000000..8bfc9d7 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/NullImpl.java @@ -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.chrome.jsdi; + +import org.eclipse.wst.jsdt.debug.core.jsdi.NullValue; +import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine; + +/** + * Chrome impl of {@link NullValue} + * + * @since 1.0 + */ +public class NullImpl extends MirrorImpl implements NullValue { + + /** + * String representation of the value<br><br> + * Value is: <code>null</code> + */ + public static final String NULL = "null"; //$NON-NLS-1$ + + /** + * Constructor + * + * @param vm the underlying {@link VirtualMachine} + */ + public NullImpl(VirtualMachine vm) { + super(vm); + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString() + */ + public String valueString() { + return NULL; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() { + return valueString(); + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/NumberImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/NumberImpl.java new file mode 100644 index 0000000..13f9794 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/NumberImpl.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * 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.chrome.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 Chrome + * + * @since 1.0 + */ +public class NumberImpl extends MirrorImpl implements NumberValue { + + private Number number = null; + + /** + * Constructor + * + * @param vm the underlying {@link VirtualMachine} + * @param number the number + */ + public NumberImpl(VirtualMachine vm, Number number) { + super(vm); + if(number == null) { + throw new IllegalArgumentException(Messages.cannot_mirror_null_number); + } + this.number = number; + } + + /* (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() { + if(number.intValue() < 1) { + return false; + } + return true; + } + + /* (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 false; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() { + return valueString(); + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ObjectImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ObjectImpl.java new file mode 100644 index 0000000..393a6e3 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ObjectImpl.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * 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.chrome.jsdi; + +import java.util.List; + +import org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference; +import org.eclipse.wst.jsdt.debug.core.jsdi.Value; + +/** + * + */ +public class ObjectImpl extends MirrorImpl implements ObjectReference { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString() + */ + public String valueString() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#className() + */ + public String className() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#constructor() + */ + public Value constructor() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#prototype() + */ + public Value prototype() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#properties() + */ + public List properties() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#id() + */ + public Number id() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/PropertyImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/PropertyImpl.java new file mode 100644 index 0000000..05625a8 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/PropertyImpl.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * 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.chrome.jsdi; + +import org.eclipse.wst.jsdt.debug.core.jsdi.Property; +import org.eclipse.wst.jsdt.debug.core.jsdi.Value; + +/** + * + */ +public class PropertyImpl extends MirrorImpl implements Property { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Property#name() + */ + public String name() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Property#value() + */ + public Value value() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ScriptImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ScriptImpl.java new file mode 100644 index 0000000..ca48acf --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ScriptImpl.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * 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.chrome.jsdi; + +import java.net.URI; +import java.util.List; + +import org.eclipse.wst.jsdt.debug.core.jsdi.Location; +import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference; + +/** + * + */ +public class ScriptImpl extends MirrorImpl implements ScriptReference { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#allLineLocations() + */ + public List allLineLocations() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#lineLocation(int) + */ + public Location lineLocation(int lineNumber) { + 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; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#source() + */ + public String source() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#sourceURI() + */ + public URI sourceURI() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/StackFrameImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/StackFrameImpl.java new file mode 100644 index 0000000..c9dbcb9 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/StackFrameImpl.java @@ -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.chrome.jsdi; + +import java.util.List; + +import org.eclipse.wst.jsdt.debug.core.jsdi.Location; +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; + +/** + * + */ +public class StackFrameImpl extends MirrorImpl implements StackFrame { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame#thisObject() + */ + public Variable thisObject() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame#variables() + */ + public List variables() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame#location() + */ + public Location location() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame#evaluate(java.lang.String) + */ + public Value evaluate(String expression) { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/StringImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/StringImpl.java new file mode 100644 index 0000000..dfbe67e --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/StringImpl.java @@ -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.chrome.jsdi; + +import org.eclipse.wst.jsdt.debug.core.jsdi.StringValue; +import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine; + +/** + * + */ +public class StringImpl extends MirrorImpl implements StringValue { + + private String string = null; + + /** + * Constructor + * + * @param vm + * @param string + */ + StringImpl(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; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ThreadImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ThreadImpl.java new file mode 100644 index 0000000..701f9e9 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ThreadImpl.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * 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.chrome.jsdi; + +import java.util.List; + +import org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame; +import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference; + +/** + * + */ +public class ThreadImpl extends MirrorImpl implements ThreadReference { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#frameCount() + */ + public int frameCount() { + return 0; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#frame(int) + */ + public StackFrame frame(int index) { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#frames() + */ + public List frames() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#interrupt() + */ + public void interrupt() { + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#resume() + */ + public void resume() { + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#suspend() + */ + public void suspend() { + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#status() + */ + public int status() { + return 0; + } + + /* (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 false; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#name() + */ + public String name() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/UndefinedImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/UndefinedImpl.java new file mode 100644 index 0000000..99d5044 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/UndefinedImpl.java @@ -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.chrome.jsdi; + +import org.eclipse.wst.jsdt.debug.core.jsdi.UndefinedValue; +import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine; + +/** + * Default implementation of {@link UndefinedValue} for Chrome. + * + * @since 1.0 + */ +public class UndefinedImpl extends MirrorImpl implements UndefinedValue { + + /** + * Textual representation of undefined<br><br> + * value is: <code>undefined</code> + */ + public static final String UNDEFINED = "undefined"; //$NON-NLS-1$ + + /** + * Constructor + * + * @param vm the underlying {@link VirtualMachine} + */ + public UndefinedImpl(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(); + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/VMImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/VMImpl.java new file mode 100644 index 0000000..a32df55 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/VMImpl.java @@ -0,0 +1,302 @@ +/******************************************************************************* + * 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.chrome.jsdi; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.osgi.util.NLS; +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.internal.chrome.ChromePlugin; +import org.eclipse.wst.jsdt.debug.internal.chrome.Tracing; +import org.eclipse.wst.jsdt.debug.internal.chrome.event.EventQueueImpl; +import org.eclipse.wst.jsdt.debug.internal.chrome.transport.EventPacketImpl; +import org.eclipse.wst.jsdt.debug.internal.chrome.transport.RequestPacketImpl; +import org.eclipse.wst.jsdt.debug.internal.chrome.transport.Commands; +import org.eclipse.wst.jsdt.debug.internal.chrome.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; +import org.eclipse.wst.jsdt.debug.transport.packet.Event; +import org.eclipse.wst.jsdt.debug.transport.packet.Request; +import org.eclipse.wst.jsdt.debug.transport.packet.Response; + +/** + * Default implementation of a {@link VirtualMachine} for Chrome + * + * @since 1.0 + */ +public class VMImpl extends MirrorImpl implements VirtualMachine { + + public static int RUNNING = 1; + public static int SUSPENDED = 2; + public static int TERMINATED = 3; + public static int DISPOSED = 4; + public static int DISCONNECTED = 5; + + /** + * The current state + */ + private int state = 0; + /** + * The singleton {@link NullValue} + */ + private static NullValue nullValue = null; + /** + * The singleton {@link UndefinedValue} + */ + private static UndefinedValue undefinedValue = null; + + private EventRequestManager ermanager = null; + private EventQueue queue = new EventQueueImpl(this, ermanager); + private final DebugSession session; + + private Map threads = Collections.synchronizedMap(new HashMap(4)); + private Map scripts = Collections.synchronizedMap(new HashMap(4)); + + /** + * Constructor + * + * @param session the backing {@link DebugSession} + */ + public VMImpl(DebugSession session) { + super(); + this.session = session; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#resume() + */ + public synchronized void resume() { + if(state == SUSPENDED) { + //TODO + state = RUNNING; + } + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#suspend() + */ + public synchronized void suspend() { + if(state == RUNNING) { + //TODO + state = SUSPENDED; + } + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#terminate() + */ + public synchronized void terminate() { + if(state != TERMINATED) { + //TODO + state = TERMINATED; + } + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#name() + */ + public String name() { + return NLS.bind(Messages.chrome_vm, version()); + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#description() + */ + public String description() { + return Messages.vm_description; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#version() + */ + public String version() { + Request request = new RequestPacketImpl(Commands.VERSION); + Response response = sendRequest(request); + if(response != null && response.isSuccess()) { + return (String) response.getBody().get(Commands.VERSION); + } + Tracing.writeString("VM [failed version request]" + JSON.serialize(request)); //$NON-NLS-1$ + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#allThreads() + */ + public List allThreads() { + if(threads.isEmpty()) { + return Collections.EMPTY_LIST; + } + return new ArrayList(threads.values()); + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#allScripts() + */ + public List allScripts() { + if(scripts.isEmpty()) { + return Collections.EMPTY_LIST; + } + return new ArrayList(scripts.values()); + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#dispose() + */ + public synchronized void dispose() { + if(state != DISPOSED) { + //TODO + state = DISPOSED; + } + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOfUndefined() + */ + public UndefinedValue mirrorOfUndefined() { + synchronized (this) { + if(undefinedValue == null) { + undefinedValue = new UndefinedImpl(this); + } + } + return undefinedValue; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOfNull() + */ + public NullValue mirrorOfNull() { + synchronized (this) { + if(nullValue == null) { + nullValue = new NullImpl(this); + } + } + return nullValue; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOf(boolean) + */ + public BooleanValue mirrorOf(boolean bool) { + return new BooleanImpl(this, bool); + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOf(java.lang.Number) + */ + public NumberValue mirrorOf(Number number) { + return new NumberImpl(this, number); + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOf(java.lang.String) + */ + public StringValue mirrorOf(String string) { + return new StringImpl(this, string); + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#eventRequestManager() + */ + public EventRequestManager eventRequestManager() { + return ermanager; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#eventQueue() + */ + public EventQueue eventQueue() { + return queue; + } + + /** + * Sends a request to the underlying {@link DebugSession}, waiting + * for the {@link VirtualMachine#DEFAULT_TIMEOUT}. + * + * @param request + * @return the {@link CFResponse} for the request + */ + public Response sendRequest(Request request) { + try { + session.send(request); + return session.receiveResponse(request.getSequence(), 3000); + } + catch(DisconnectedException de) { + disconnectVM(); + handleException(de.getMessage(), de); + } + catch(TimeoutException te) { + ChromePlugin.log(te); + } + return null; + } + + /** + * Receives an {@link CFEvent} from the underlying {@link DebugSession}, + * waiting for the {@link VirtualMachine#DEFAULT_TIMEOUT}. + * + * @return the next {@link CFEvent} never <code>null</code> + * @throws TimeoutException + * @throws DisconnectedException + */ + public Event receiveEvent() throws TimeoutException, DisconnectedException { + return (Event) session.receive(EventPacketImpl.EVENT, DEFAULT_TIMEOUT); + } + + /** + * Receives an {@link CFEvent} from the underlying {@link DebugSession}, + * waiting for the {@link VirtualMachine#DEFAULT_TIMEOUT}. + * @param timeout + * @return the next {@link CFEvent} never <code>null</code> + * @throws TimeoutException + * @throws DisconnectedException + */ + public Event receiveEvent(int timeout) throws TimeoutException, DisconnectedException { + return (Event) session.receive(EventPacketImpl.EVENT, timeout); + } + + /** + * disconnects the VM + */ + public synchronized void disconnectVM() { + if (state == 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.session.dispose(); + } finally { + state = DISCONNECTED; + } + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ValueImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ValueImpl.java new file mode 100644 index 0000000..37350fc --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/ValueImpl.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * 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.chrome.jsdi; + +import org.eclipse.wst.jsdt.debug.core.jsdi.Value; + +/** + * + */ +public class ValueImpl extends MirrorImpl implements Value { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString() + */ + public String valueString() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/VarImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/VarImpl.java new file mode 100644 index 0000000..958297e --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/VarImpl.java @@ -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.chrome.jsdi; + +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; + +/** + * + */ +public class VarImpl extends MirrorImpl implements Variable { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Property#name() + */ + public String name() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Property#value() + */ + public Value value() { + return null; + } + + /* (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) { + return false; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/messages.properties b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/messages.properties new file mode 100644 index 0000000..e4d4ca2 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/jsdi/messages.properties @@ -0,0 +1,3 @@ +cannot_mirror_null_number=You cannot mirror a null Number +chrome_vm=Chrome VM [{0}] +vm_description=The virtual machine for communication with Google Chrome for debugging JavaScript in v8 diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/BreakpointReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/BreakpointReqImpl.java new file mode 100644 index 0000000..d6948a7 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/BreakpointReqImpl.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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.chrome.request; + +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.request.BreakpointRequest; + +/** + * + */ +public class BreakpointReqImpl extends EventReqImpl implements BreakpointRequest { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#isEnabled() + */ + public boolean isEnabled() { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#setEnabled(boolean) + */ + public void setEnabled(boolean enabled) { + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.Locatable#location() + */ + public Location location() { + return null; + } + + /* (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) { + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest#addConditionFilter(java.lang.String) + */ + public void addConditionFilter(String condition) { + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest#addHitCountFilter(int) + */ + public void addHitCountFilter(int hitcount) { + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/DebuggerStatementReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/DebuggerStatementReqImpl.java new file mode 100644 index 0000000..7a97b77 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/DebuggerStatementReqImpl.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * 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.chrome.request; + +import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference; +import org.eclipse.wst.jsdt.debug.core.jsdi.request.DebuggerStatementRequest; + +/** + * + */ +public class DebuggerStatementReqImpl extends EventReqImpl implements + DebuggerStatementRequest { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#isEnabled() + */ + public boolean isEnabled() { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#setEnabled(boolean) + */ + public void setEnabled(boolean enabled) { + } + + /* (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) { + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqImpl.java new file mode 100644 index 0000000..6635e45 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqImpl.java @@ -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.chrome.request; + +import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest; +import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.MirrorImpl; + +/** + * + */ +public class EventReqImpl extends MirrorImpl implements EventRequest { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#isEnabled() + */ + public boolean isEnabled() { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#setEnabled(boolean) + */ + public void setEnabled(boolean enabled) { + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqManager.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqManager.java new file mode 100644 index 0000000..bd27542 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/EventReqManager.java @@ -0,0 +1,234 @@ +/******************************************************************************* + * 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.chrome.request; + +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.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.chrome.jsdi.MirrorImpl; + +/** + * {@link EventRequestManager} for Chrome + * + * @since 1.0 + */ +public class EventReqManager extends MirrorImpl 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 disconnects = Collections.synchronizedList(new ArrayList(4)); + private List deaths = Collections.synchronizedList(new ArrayList(4)); + + private HashMap kind = new HashMap(10); + + /** + * Constructor + * + * @param vm the underlying virtual machine + */ + public EventReqManager(VirtualMachine vm) { + super(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(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) { + return null; + } + + /* (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() { + return null; + } + + /* (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() { + return null; + } + + /* (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() { + return null; + } + + /* (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) { + return null; + } + + /* (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) { + return null; + } + + /* (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#createThreadEnterRequest() + */ + public ThreadEnterRequest createThreadEnterRequest() { + return null; + } + + /* (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() { + return null; + } + + /* (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() { + return null; + } + + /* (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() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#vmDisconnectRequests() + */ + public List vmDisconnectRequests() { + return Collections.unmodifiableList(disconnects); + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ExceptionReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ExceptionReqImpl.java new file mode 100644 index 0000000..d715326 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ExceptionReqImpl.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * 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.chrome.request; + +import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference; +import org.eclipse.wst.jsdt.debug.core.jsdi.request.ExceptionRequest; + +/** + * + */ +public class ExceptionReqImpl extends EventReqImpl implements ExceptionRequest { + + /* (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) { + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ScritpLoadReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ScritpLoadReqImpl.java new file mode 100644 index 0000000..0b949e1 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ScritpLoadReqImpl.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * 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.chrome.request; + +import org.eclipse.wst.jsdt.debug.core.jsdi.request.ScriptLoadRequest; + +/** + * + */ +public class ScritpLoadReqImpl extends EventReqImpl implements + ScriptLoadRequest { + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/StepReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/StepReqImpl.java new file mode 100644 index 0000000..9864e7a --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/StepReqImpl.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * 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.chrome.request; + +import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference; +import org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest; + +/** + * + */ +public class StepReqImpl extends EventReqImpl implements StepRequest { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest#step() + */ + public int step() { + return 0; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest#thread() + */ + public ThreadReference thread() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/SuspendReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/SuspendReqImpl.java new file mode 100644 index 0000000..f2f14b4 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/SuspendReqImpl.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.chrome.request; + +import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference; +import org.eclipse.wst.jsdt.debug.core.jsdi.request.SuspendRequest; + +/** + * + */ +public class SuspendReqImpl extends EventReqImpl implements SuspendRequest { + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.SuspendRequest#thread() + */ + public ThreadReference thread() { + return null; + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ThreadEnterReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ThreadEnterReqImpl.java new file mode 100644 index 0000000..709a231 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ThreadEnterReqImpl.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.chrome.request; + +import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference; +import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadEnterRequest; + +/** + * + */ +public class ThreadEnterReqImpl extends EventReqImpl implements + ThreadEnterRequest { + + /* (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) { + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ThreadExitReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ThreadExitReqImpl.java new file mode 100644 index 0000000..32fff48 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/ThreadExitReqImpl.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.chrome.request; + +import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference; +import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadExitRequest; + +/** + * + */ +public class ThreadExitReqImpl extends EventReqImpl implements + ThreadExitRequest { + + /* (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) { + } + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/VMDeathReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/VMDeathReqImpl.java new file mode 100644 index 0000000..d183f28 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/VMDeathReqImpl.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.chrome.request; + +import org.eclipse.wst.jsdt.debug.core.jsdi.request.VMDeathRequest; + +/** + * + */ +public class VMDeathReqImpl extends EventReqImpl implements VMDeathRequest { + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/VMDisconnectReqImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/VMDisconnectReqImpl.java new file mode 100644 index 0000000..c5b9c2a --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/request/VMDisconnectReqImpl.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * 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.chrome.request; + +import org.eclipse.wst.jsdt.debug.core.jsdi.request.VMDisconnectRequest; + +/** + * + */ +public class VMDisconnectReqImpl extends EventReqImpl implements + VMDisconnectRequest { + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Attributes.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Attributes.java new file mode 100644 index 0000000..75126db --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Attributes.java @@ -0,0 +1,172 @@ +/******************************************************************************* + * 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.chrome.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 "body" attribute + */ + public static final String BODY = "body"; //$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 "context_href" attribute + */ + public static final String CONTEXT_HREF = "context_href"; //$NON-NLS-1$ + /** + * The "context_id" attribute + */ + public static final String CONTEXT_ID = "context_id"; //$NON-NLS-1$ + /** + * The "contexts" attribute + */ + public static final String CONTEXTS = "contexts"; //$NON-NLS-1$ + /** + * The "crossfire_id" attribute + */ + public static final String CROSSFIRE_ID = "crossfire_id"; //$NON-NLS-1$ + /** + * The "data" attribute + */ + public static final String DATA = "data"; //$NON-NLS-1$ + /** + * The "expression" attribute + */ + public static final String EXPRESSION = "expression"; //$NON-NLS-1$ + /** + * The "frame" attribute + */ + public static final String FRAME = "frame"; //$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 "func" attribute + */ + public static final String FUNC = "func"; //$NON-NLS-1$ + /** + * The "handle" attribute + */ + public static final String HANDLE = "handle"; //$NON-NLS-1$ + /** + * The "handshake" attribute + */ + public static final String HANDSHAKE = "handshake"; //$NON-NLS-1$ + /** + * The "href" attribute + */ + public static final String HREF = "href"; //$NON-NLS-1$ + /** + * The "id" attribute + */ + public static final String ID = "id"; //$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 "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 "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 message attribute for this packet + */ + public static final String MESSAGE = "message"; //$NON-NLS-1$ + /** + * The "ref" attribute + */ + public static final String REF = "ref"; //$NON-NLS-1$ + /** + * The "request_seq" attribute + */ + public static final String REQUEST_SEQ = "request_seq"; //$NON-NLS-1$ + /** + * The running attribute for this packet + */ + public static final String RUNNING = "running"; //$NON-NLS-1$ + /** + * The "script" attribute + */ + public static final String SCRIPT = "script"; //$NON-NLS-1$ + /** + * The "seq" attribute + */ + public static final String SEQ = "seq"; //$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 success attribute for this packet + */ + public static final String SUCCESS = "success"; //$NON-NLS-1$ + /** + * The "this" attribute + */ + public static final String THIS = "this"; //$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 "value" attribute + */ + public static final String VALUE = "value"; //$NON-NLS-1$ +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ChromeSocketConnection.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ChromeSocketConnection.java new file mode 100644 index 0000000..b7c7869 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ChromeSocketConnection.java @@ -0,0 +1,176 @@ +/******************************************************************************* + * 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.chrome.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.chrome.ChromePlugin; +import org.eclipse.wst.jsdt.debug.internal.chrome.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 ChromeSocketConnection extends SocketConnection { + + public static final String HANDSHAKE = "ChromeDevToolsHandshake\r\n"; //$NON-NLS-1$ + + /** + * Constructor + * + * @param socket the underlying {@link Socket}, <code>null</code> is not accepted + * + * @throws IOException + */ + public ChromeSocketConnection(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(packet); + if(PacketImpl.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 packet + * @throws IOException + */ + public void writeHandShake() throws IOException { + if(PacketImpl.TRACE) { + Tracing.writeString("WRITE HANDSHAKE: "+HANDSHAKE); //$NON-NLS-1$ + } + Writer writer = getWriter(); + writer.write(HANDSHAKE); + writer.flush(); + //waitForReadyRead(); + } + + /** + * Method to wait for the socket reader to become ready after the handshake + * + * @throws IOException + */ + void waitForReadyRead() throws IOException { + long timeout = System.currentTimeMillis() + 1000; + boolean timedout = System.currentTimeMillis() > timeout; + Reader reader = getReader(); + while(!reader.ready() && !timedout) { + try { + Thread.sleep(100); + timedout = System.currentTimeMillis() > timeout; + } catch (InterruptedException e) { + ChromePlugin.log(e); + } + } + if(timedout) { + if(PacketImpl.TRACE) { + Tracing.writeString("HANDSHAKE: Timed out waiting for ready read from handshake"); //$NON-NLS-1$ + } + //throw new IOException("Waiting for the socket to become available after receiving handshake timed out."); //$NON-NLS-1$ + } + } + + /** + * Reads the {@link HandShakePacket} packet from the the stream + * + * @return the {@link HandShakePacket}, never <code>null</code> + * @throws IOException + */ + public boolean 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'; + } + return buffer.toString().equals(HANDSHAKE); + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.transport.socket.SocketConnection#readPacket() + */ + public Packet readPacket() throws IOException { + StringBuffer buffer = new StringBuffer(); + int c = -1; + boolean len = false; + Reader reader = getReader(); + while((c = reader.read()) > -1) { + if(c == '\r') { + break; + } + if(len) { + buffer.append((char)c); + continue; + } + len = c == ':'; + } + int length = 0; + try { + length = Integer.parseInt(buffer.toString()); + } catch (NumberFormatException e) { + throw new IOException("Failed to parse content length: " + buffer.toString()); //$NON-NLS-1$ + } + c = reader.read(); + if(c != '\n') { + throw new IOException("Failed to parse content length: " + buffer.toString() + "next char was not '\n'" + (char)c); //$NON-NLS-1$ //$NON-NLS-2$ + } + 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(PacketImpl.TRACE) { + Tracing.writeString("READ PACKET: [length - "+length+"]"+new String(message)); //$NON-NLS-1$ //$NON-NLS-2$ + } + Map json = (Map) JSON.read(new String(message)); + String type = (String) json.get(Attributes.TYPE); + if (EventPacketImpl.EVENT.equals(type)) { + return new EventPacketImpl(json); + } + if (RequestPacketImpl.REQUEST.equals(type)) { + return new RequestPacketImpl(json); + } + if (ResponsePacketImpl.RESPONSE.equals(type)) { + return new ResponsePacketImpl(json); + } + throw new IOException("Unknown packet type: " + type); //$NON-NLS-1$ + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ChromeTransportService.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ChromeTransportService.java new file mode 100644 index 0000000..2b45905 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ChromeTransportService.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * 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.chrome.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.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 ChromeTransportService 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(); + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.transport.socket.SocketTransportService#getConnection(java.net.Socket) + */ + public SocketConnection getConnection(Socket socket) throws IOException { + return new ChromeSocketConnection(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 ChromeSocketConnection) { + ChromeSocketConnection cfconn = (ChromeSocketConnection) connection; + if (cfconn.readHandShake()) { + cfconn.writeHandShake(); + } + 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 ChromeSocketConnection) { + ChromeSocketConnection cfconn = (ChromeSocketConnection) connection; + cfconn.writeHandShake(); + if (!cfconn.readHandShake()) { + throw new IOException("failure establishing connection"); //$NON-NLS-1$ + } + return; + } + throw new IOException("failure establishing connection"); //$NON-NLS-1$ + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Commands.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Commands.java new file mode 100644 index 0000000..79a9f03 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Commands.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * 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.chrome.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_BREAKPOINT = "changebreakpoint"; //$NON-NLS-1$ + /** + * The "clearbreakpoint" command + */ + public static final String CLEAR_BREAKPOINT = "clearbreakpoint"; //$NON-NLS-1$ + /** + * The "continue" command + */ + public static final String CONTINUE = "continue"; //$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 "getbreakpoint" command + */ + public static final String GET_BREAKPOINT = "getbreakpoint"; //$NON-NLS-1$ + /** + * The "getbreakpoints" command + */ + public static final String GET_BREAKPOINTS = "getbreakpoints"; //$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 "script" command + */ + public static final String SCRIPT = "script"; //$NON-NLS-1$ + /** + * The "scripts" command + */ + public static final String SCRIPTS = "scripts"; //$NON-NLS-1$ + /** + * The "setbreakpoint" command + */ + public static final String SET_BREAKPOINT = "setbreakpoint"; //$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 "version" command + */ + public static final String VERSION = "version"; //$NON-NLS-1$ + +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/EventPacketImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/EventPacketImpl.java new file mode 100644 index 0000000..64a2a74 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/EventPacketImpl.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * 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.chrome.transport; + +import java.util.Collections; +import java.util.Map; + +import org.eclipse.wst.jsdt.debug.transport.packet.Event; + +/** + * Event packet + * + * @since 1.0 + */ +public class EventPacketImpl extends PacketImpl implements Event { + + /** + * The type of this packet + */ + public static final String EVENT = "event"; //$NON-NLS-1$ + + private String event = null; + private Map body = null; + + /** + * Constructor + * @param event + */ + public EventPacketImpl(String event) { + super(EVENT); + if(event == null) { + throw new IllegalArgumentException(Messages.cannot_create_packet_with_no_event); + } + this.event = event; + } + + /** + * Constructor + * + * @param json + */ + public EventPacketImpl(Map json) { + super(json); + this.event = (String) json.get(EVENT); + if(event == null) { + throw new IllegalArgumentException(Messages.no_event_found_in_json); + } + } + + /* (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() { + if(body == null) { + return Collections.EMPTY_MAP; + } + return body; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.internal.chrome.transport.PacketImpl#toJSON() + */ + public Map toJSON() { + Map json = super.toJSON(); + json.put(Attributes.COMMAND, event); + if(body != null) { + 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("EventPacketImpl: "); //$NON-NLS-1$ + JSON.writeValue(json, buffer); + return buffer.toString(); + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/JSON.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/JSON.java new file mode 100644 index 0000000..515632c --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/JSON.java @@ -0,0 +1,539 @@ +/******************************************************************************* + * 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.chrome.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.chrome.Tracing; +import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.NullImpl; +import org.eclipse.wst.jsdt.debug.internal.chrome.jsdi.UndefinedImpl; +import org.eclipse.wst.jsdt.debug.transport.packet.Packet; + +/** + * Class for reading / writing JSON objects + * <br><br> + * Chrome has the following types: + * <ul> + * <li>object</li> + * <li>function</li> + * <li>boolean</li> + * <li>number</li> + * <li>string</li> + * <li>undefined</li> + * <li>ref</li> + * </ul> + * @since 1.0 + */ +public final class JSON { + + static boolean TRACE = false; + + /** + * Standard line feed / control feed terminus for Crossfire packets + */ + public static final String LINE_FEED = "\r\n"; //$NON-NLS-1$ + /** + * The default <code>Content-Length:</code> pre-amble + */ + 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: <code>"key":["]value["]</code> + * + * @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. <br><br> + * Values are written out as: + * <ul> + * <li>Boolean / Number: <code>value.toString()</code></li> + * <li>String: <code>"value"</code></li> + * <li>null: <code>null</code> + * <li>Collection: <code>[{@link #writeValue(Object, StringBuffer)},...]</code></li> + * <li>Map: <code>{"key":{@link #writeValue(Object, StringBuffer)},...}</code></li> + * </ul> + * + * @param value + * @param buffer + */ + public static void writeValue(Object value, StringBuffer buffer) { + if (value == null) { + buffer.append(NullImpl.NULL); + } + else if (value instanceof Boolean || value instanceof Number) { + buffer.append(value.toString()); + } + else if (value instanceof String) { + writeString((String) value, buffer); + } + else if(value instanceof Collection) { + writeArray((Collection) value, buffer); + } + else if(value instanceof Map) { + writeObject((Map) value, buffer); + } + } + + /** + * Writes the given {@link String} into the given {@link StringBuffer} properly escaping + * all control characters + * + * @param string + * @param buffer + */ + public static void writeString(String string, StringBuffer buffer) { + buffer.append('"'); + int length = string.length(); + for (int i = 0; i < length; i++) { + char c = string.charAt(i); + switch (c) { + case '"' : + case '\\' : + case '/' : { + buffer.append('\\'); + buffer.append(c); + break; + } + case '\b' : { + buffer.append("\\b"); //$NON-NLS-1$ + break; + } + case '\f' : { + buffer.append("\\f"); //$NON-NLS-1$ + break; + } + case '\n' : { + buffer.append("\\n"); //$NON-NLS-1$ + break; + } + case '\r' : { + buffer.append("\\r"); //$NON-NLS-1$ + break; + } + case '\t' : { + buffer.append("\\t"); //$NON-NLS-1$ + break; + } + default : + if (Character.isISOControl(c)) { + buffer.append("\\u"); //$NON-NLS-1$ + String hexString = Integer.toHexString(c); + for (int j = hexString.length(); j < 4; j++) { + buffer.append('0'); + } + buffer.append(hexString); + } else { + buffer.append(c); + } + } + } + buffer.append('"'); + } + + /** + * Writes the given collection into an array string of the form: <code>[{@link #writeValue(Object, StringBuffer)},...]</code> + * + * @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: <code>{"key":{@link #writeValue(Object, StringBuffer)},...}</code> + * + * @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 <code>Content-Length:N</code> pre-amble 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); + buffer.insert(0, buff); + } + + /** + * Serializes the given {@link CFPacket} to a {@link String} + * + * @param packet the packet to serialize + * + * @return the serialized {@link String}, never <code>null</code> + */ + public static String serialize(Packet packet) { + Object json = packet.toJSON(); + StringBuffer buffer = new StringBuffer(); + writeValue(json, buffer); + int length = buffer.length(); + buffer.append(LINE_FEED); + writeContentLength(buffer, length); + 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 <code>null</code> + */ + 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 <code>null</code> + */ + 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 <code>null</code> + * @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(NullImpl.NULL, it); + return null; + } + case 'u': { + parseText(UndefinedImpl.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 <code>null</code> + */ + private static String parseString(CharacterIterator it) { + char c = it.next(); + if (c == '"') { + it.next(); + return ""; //$NON-NLS-1$ + } + StringBuffer buffer = new StringBuffer(); + while (c != '"') { + if (Character.isISOControl(c)) { + 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 <code>null</code> + */ + private static Map parseObject(CharacterIterator it) { + it.next(); + parseWhitespace(it); + if (it.current() == '}') { + it.next(); + return Collections.EMPTY_MAP; + } + + Map map = new HashMap(); + while (true) { + 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 <code>null</code> + */ + private static List parseArray(CharacterIterator it) { + it.next(); + parseWhitespace(it); + if (it.current() == ']') { + it.next(); + return Collections.EMPTY_LIST; + } + + List list = new ArrayList(); + while (true) { + 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 <code>null</code> + */ + 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$; + } + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Messages.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Messages.java new file mode 100644 index 0000000..1352db9 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/Messages.java @@ -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.chrome.transport; + +import org.eclipse.osgi.util.NLS; + +/** + * + */ +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.chrome.transport.messages"; //$NON-NLS-1$ + public static String cannot_create_packet_with_no_event; + public static String cannot_create_pakcet_null_json; + public static String cannot_create_request_null_command; + public static String cannot_create_response_null_command; + public static String no_command_in_json_response; + public static String no_command_in_request_json; + public static String no_event_found_in_json; + public static String no_packet_type_in_json; + public static String packet_type_cannot_be_null; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/PacketImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/PacketImpl.java new file mode 100644 index 0000000..4853963 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/PacketImpl.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * 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.chrome.transport; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.wst.jsdt.debug.transport.packet.Packet; + +/** + * Basic packet + * + * @since 1.0 + */ +public class PacketImpl implements Packet { + + /** + * Debugging flag + */ + public static boolean TRACE = false; + + private String type = null; + + /** + * Constructor + * + * @param type + */ + public PacketImpl(String type) { + if(type == null) { + throw new IllegalArgumentException(Messages.packet_type_cannot_be_null); + } + this.type = type; + } + + /** + * Constructor + * + * @param existing JSON map to create a packet from + */ + public PacketImpl(Map json) { + if(json == null) { + throw new IllegalArgumentException(Messages.cannot_create_pakcet_null_json); + } + type = (String) json.get(Attributes.TYPE); + if(type == null) { + throw new IllegalArgumentException(Messages.no_packet_type_in_json); + } + } + + /** + * Sets if packet transfer should be traced + * @param tracing + */ + public static void setTracing(boolean tracing) { + TRACE = tracing; + } + + /* (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); + return json; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() { + StringBuffer buffer = new StringBuffer(); + Object json = toJSON(); + buffer.append("PacketImpl: "); //$NON-NLS-1$ + JSON.writeValue(json, buffer); + return buffer.toString(); + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/RequestPacketImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/RequestPacketImpl.java new file mode 100644 index 0000000..5b2e8b3 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/RequestPacketImpl.java @@ -0,0 +1,126 @@ +/******************************************************************************* + * 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.chrome.transport; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.wst.jsdt.debug.transport.packet.Request; + +/** + * Request packet + * + * @since 1.0 + */ +public class RequestPacketImpl extends PacketImpl implements Request { + + /** + * The type of this packet + */ + public static final String REQUEST = "request"; //$NON-NLS-1$ + private static int next_seq = 0; + private final String command; + private final int seq; + private Map args = Collections.synchronizedMap(new HashMap(4)); + + /** + * Constructor + * + * @param command + */ + public RequestPacketImpl(String command) { + super(REQUEST); + if(command == null) { + throw new IllegalArgumentException(Messages.cannot_create_request_null_command); + } + this.command = command; + this.seq = ++next_seq; + } + + /** + * Constructor + * @param json + */ + public RequestPacketImpl(Map json) { + super(json); + this.command = (String) json.get(Attributes.COMMAND); + if(command == null) { + throw new IllegalArgumentException(Messages.no_command_in_request_json); + } + this.seq = ((Number)json.get(Attributes.SEQ)).intValue(); + Map pargs = (Map) json.get(Attributes.ARGUMENTS); + if(pargs != null) { + args.putAll(pargs); + } + } + + /** + * Sets the given argument in the JSON map. + * + * @param key the key for the attribute, <code>null</code> is not accepted + * @param argument the value for the argument, <code>null</code> is not accepted + */ + public void setArgument(String key, Object argument) { + if(key == null) { + throw new IllegalArgumentException("The argument key cannot be null"); //$NON-NLS-1$ + } + if(argument == null) { + throw new IllegalArgumentException("A null argument is not allowed"); //$NON-NLS-1$ + } + args.put(key, argument); + } + + /* (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#getSequence() + */ + public int getSequence() { + return seq; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.transport.packet.Request#getArguments() + */ + public Map getArguments() { + return args; + } + + /* (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(seq)); + json.put(Attributes.COMMAND, command); + if(!args.isEmpty()) { + json.put(Attributes.ARGUMENTS, args); + } + return json; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() { + StringBuffer buffer = new StringBuffer(); + Object json = toJSON(); + buffer.append("RequestPacketImpl: "); //$NON-NLS-1$ + JSON.writeValue(json, buffer); + return buffer.toString(); + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ResponsePacketImpl.java b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ResponsePacketImpl.java new file mode 100644 index 0000000..daabdae --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/ResponsePacketImpl.java @@ -0,0 +1,129 @@ +/******************************************************************************* + * 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.chrome.transport; + +import java.util.Collections; +import java.util.Map; + +import org.eclipse.wst.jsdt.debug.transport.packet.Response; + +/** + * Response packet + * + * @since 1.0 + */ +public class ResponsePacketImpl extends PacketImpl implements Response { + + /** + * The type of this packet + */ + public static final String RESPONSE = "response"; //$NON-NLS-1$ + + private int rseq = 0; + private String command = null; + private Map body = null; + private boolean success = false; + private boolean running = false; + + /** + * Constructor + * @param requestSequence + * @param command + */ + public ResponsePacketImpl(int requestSequence, String command) { + super(RESPONSE); + if(command == null) { + throw new IllegalArgumentException(Messages.cannot_create_response_null_command); + } + this.rseq = requestSequence; + this.command = command; + } + + /** + * Constructor + * @param json + */ + public ResponsePacketImpl(Map json) { + super(json); + this.rseq = ((Integer)json.get(Attributes.REQUEST_SEQ)).intValue(); + this.command = (String) json.get(Attributes.COMMAND); + if(command == null) { + throw new IllegalArgumentException(Messages.no_command_in_json_response); + } + this.body = (Map) json.get(Attributes.BODY); + this.success = ((Boolean)json.get(Attributes.SUCCESS)).booleanValue(); + this.running = ((Boolean)json.get(Attributes.RUNNING)).booleanValue(); + } + + /* (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#getRequestSequence() + */ + public int getRequestSequence() { + return rseq; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.transport.packet.Response#getBody() + */ + public Map getBody() { + if(body == null) { + return Collections.EMPTY_MAP; + } + return body; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.transport.packet.Response#isSuccess() + */ + public boolean isSuccess() { + return success; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.transport.packet.Response#isRunning() + */ + public boolean isRunning() { + return running; + } + + /* (non-Javadoc) + * @see org.eclipse.wst.jsdt.debug.internal.chrome.transport.PacketImpl#toJSON() + */ + public Map toJSON() { + Map json = super.toJSON(); + json.put(Attributes.COMMAND, command); + json.put(Attributes.REQUEST_SEQ, new Integer(rseq)); + if(body != null) { + json.put(Attributes.BODY, body); + } + json.put(Attributes.SUCCESS, Boolean.valueOf(success)); + json.put(Attributes.RUNNING, Boolean.valueOf(running)); + return json; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() { + StringBuffer buffer = new StringBuffer(); + Object json = toJSON(); + buffer.append("ResponsePacketImpl: "); //$NON-NLS-1$ + JSON.writeValue(json, buffer); + return buffer.toString(); + } +} diff --git a/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/messages.properties b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/messages.properties new file mode 100644 index 0000000..6cd72e2 --- /dev/null +++ b/development/org.eclipse.wst.jsdt.debug.chrome/src/org/eclipse/wst/jsdt/debug/internal/chrome/transport/messages.properties @@ -0,0 +1,9 @@ +cannot_create_packet_with_no_event=You cannot create an event packet with no event +cannot_create_pakcet_null_json=You cannot create a packet from a null JSON mapping +cannot_create_request_null_command=You cannot create a request packet with a null command +cannot_create_response_null_command=A response packet cannot be created for a null command +no_command_in_json_response=There was no command found in the initializing JSON map to create a response packet from +no_command_in_request_json=There was no command found in the initializing JSON map to create a request packet from +no_event_found_in_json=There was no event found in the initializing JSON map to create an event packet from +no_packet_type_in_json=There was no type found in the initializing JSON map to create a packet from +packet_type_cannot_be_null=The type of a packet cannot be null |