View | Details | Raw Unified | Return to bug 356862 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-2 / +2 lines)
Lines 17-24 Link Here
17
 org.eclipse.wst.jsdt.debug.core.model,
17
 org.eclipse.wst.jsdt.debug.core.model,
18
 org.eclipse.wst.jsdt.debug.internal.core;x-friends:="org.eclipse.wst.jsdt.debug.ui",
18
 org.eclipse.wst.jsdt.debug.internal.core;x-friends:="org.eclipse.wst.jsdt.debug.ui",
19
 org.eclipse.wst.jsdt.debug.internal.core.breakpoints;x-friends:="org.eclipse.wst.jsdt.debug.ui",
19
 org.eclipse.wst.jsdt.debug.internal.core.breakpoints;x-friends:="org.eclipse.wst.jsdt.debug.ui",
20
 org.eclipse.wst.jsdt.debug.internal.core.launching;x-friends:="org.eclipse.wst.jsdt.debug.ui",
20
 org.eclipse.wst.jsdt.debug.internal.core.launching;x-friends:="org.eclipse.wst.jsdt.debug.ui,org.eclipse.wst.jsdt.debug.rhino.ui",
21
 org.eclipse.wst.jsdt.debug.internal.core.model;x-friends:="org.eclipse.wst.jsdt.debug.ui"
21
 org.eclipse.wst.jsdt.debug.internal.core.model;x-friends:="org.eclipse.wst.jsdt.debug.ui,org.eclipse.wst.jsdt.debug.rhino.ui"
22
Import-Package: org.eclipse.jface.text,
22
Import-Package: org.eclipse.jface.text,
23
 org.eclipse.text.edits,
23
 org.eclipse.text.edits,
24
 org.eclipse.wst.jsdt.core,
24
 org.eclipse.wst.jsdt.core,
(-)build.properties (+10 lines)
Lines 1-3 Link Here
1
###############################################################################
2
# Copyright (c) 2010, 2011 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
1
source.. = src/
11
source.. = src/
2
output.. = bin/
12
output.. = bin/
3
bin.includes = META-INF/,\
13
bin.includes = META-INF/,\
(-)plugin.xml (+1 lines)
Lines 13-18 Link Here
13
<plugin>
13
<plugin>
14
   <extension-point id="launchingConnectors" name="%connectorsExtPoint.name" schema="schema/launchingConnectors.exsd"/>
14
   <extension-point id="launchingConnectors" name="%connectorsExtPoint.name" schema="schema/launchingConnectors.exsd"/>
15
   <extension-point id="breakpointParticipants" name="%breakpointParticipantsExt.name" schema="schema/breakpointParticipants.exsd"/>
15
   <extension-point id="breakpointParticipants" name="%breakpointParticipantsExt.name" schema="schema/breakpointParticipants.exsd"/>
16
   <extension-point id="scriptResolvers" name="scriptResolvers" schema="schema/scriptResolvers.exsd"/>
16
   <extension
17
   <extension
17
         point="org.eclipse.debug.core.launchConfigurationTypes">
18
         point="org.eclipse.debug.core.launchConfigurationTypes">
18
      <launchConfigurationType
19
      <launchConfigurationType
(-)schema/scriptResolvers.exsd (+128 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.wst.jsdt.debug.core" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appinfo>
6
         <meta.schema plugin="org.eclipse.wst.jsdt.debug.core" id="scriptResolvers" name="scriptResolvers"/>
7
      </appinfo>
8
      <documentation>
9
         This extension point is used to contribute a script solver that is consulted any place in JSDT where a &lt;code&gt;ScriptReference&lt;/code&gt; must be resolved to a workspace-local &lt;code&gt;IFile&lt;/code&gt;.
10
&lt;br&gt;&lt;br&gt;
11
An example of typical usage is resolving if a breakpoint&apos;s workspace path matches that of a given &lt;code&gt;ScriptReference&lt;/code&gt;
12
      </documentation>
13
   </annotation>
14
15
   <element name="extension">
16
      <annotation>
17
         <appinfo>
18
            <meta.element />
19
         </appinfo>
20
      </annotation>
21
      <complexType>
22
         <sequence minOccurs="1" maxOccurs="unbounded">
23
            <element ref="scriptResolver"/>
24
         </sequence>
25
         <attribute name="point" type="string" use="required">
26
            <annotation>
27
               <documentation>
28
                  
29
               </documentation>
30
            </annotation>
31
         </attribute>
32
         <attribute name="id" type="string">
33
            <annotation>
34
               <documentation>
35
                  
36
               </documentation>
37
            </annotation>
38
         </attribute>
39
         <attribute name="name" type="string">
40
            <annotation>
41
               <documentation>
42
                  
43
               </documentation>
44
               <appinfo>
45
                  <meta.attribute translatable="true"/>
46
               </appinfo>
47
            </annotation>
48
         </attribute>
49
      </complexType>
50
   </element>
51
52
   <element name="scriptResolver">
53
      <annotation>
54
         <documentation>
55
            A resolver that can help determine equality between workspace-local IFiles and JavaScript ScriptReferences
56
         </documentation>
57
      </annotation>
58
      <complexType>
59
         <attribute name="class" type="string" use="required">
60
            <annotation>
61
               <documentation>
62
                  The fully qualified name of the Java class that implements org.eclipse.wst.jsdt.debug.core.model.ScriptResolver
63
               </documentation>
64
               <appinfo>
65
                  <meta.attribute kind="java" basedOn="org.eclipse.wst.jsdt.debug.core.model.ScriptResolver:"/>
66
               </appinfo>
67
            </annotation>
68
         </attribute>
69
      </complexType>
70
   </element>
71
72
   <annotation>
73
      <appinfo>
74
         <meta.section type="since"/>
75
      </appinfo>
76
      <documentation>
77
         3.4
78
      </documentation>
79
   </annotation>
80
81
   <annotation>
82
      <appinfo>
83
         <meta.section type="examples"/>
84
      </appinfo>
85
      <documentation>
86
         The following is an example of the default script resolver:
87
&lt;pre&gt;
88
   &lt;extension point=&quot;org.eclipse.wst.jsdt.debug.core.scriptResolvers&quot;&gt;
89
      &lt;scriptResolver
90
            class=&quot;org.eclipse.wst.jsdt.debug.internal.core.model.DefaultScriptResolver&quot;&gt;
91
      &lt;/scriptResolver&gt;
92
   &lt;/extension&gt;
93
&lt;/pre&gt;
94
      </documentation>
95
   </annotation>
96
97
   <annotation>
98
      <appinfo>
99
         <meta.section type="apiinfo"/>
100
      </appinfo>
101
      <documentation>
102
         The class field must specify the fully qualified name of the the class the extends &lt;code&gt;org.eclipse.wst.jsdt.debug.core.model.AbstractScriptResolver&lt;/code&gt;.
103
      </documentation>
104
   </annotation>
105
106
   <annotation>
107
      <appinfo>
108
         <meta.section type="implementation"/>
109
      </appinfo>
110
      <documentation>
111
         [Enter information about supplied implementation of this extension point.]
112
      </documentation>
113
   </annotation>
114
115
   <annotation>
116
      <appinfo>
117
         <meta.section type="copyright"/>
118
      </appinfo>
119
      <documentation>
120
         Copyright (c) 2011 IBM Corporation and others.&lt;br&gt;
121
All rights reserved. This program and the accompanying materials are made 
122
available under the terms of the Eclipse Public License v1.0 which 
123
accompanies this distribution, and is available at 
124
&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
125
      </documentation>
126
   </annotation>
127
128
</schema>
(-)src/org/eclipse/wst/jsdt/debug/core/model/IScriptResolver.java (+51 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.core.model;
12
13
import java.net.URI;
14
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
18
19
/**
20
 * This resolver allows contributors to plug-in to the process of resolving a {@link ScriptReference}'s 
21
 * {@link URI} to a workspace-local {@link IFile}.
22
 * <br><br>
23
 * This interface is not intended to be directly implemented. Instead clients must extend the base class {@link ScriptResolver}
24
 * 
25
 * @see ScriptResolver
26
 * @noextend This interface is not intended to be extended by clients.
27
 * @noimplement This interface is not intended to be implemented by clients.
28
 * @since 3.4
29
 */
30
public interface IScriptResolver {
31
32
	/**
33
	 * This method determines if the given {@link IPath} matches the {@link URI} from {@link ScriptReference#sourceURI()}.
34
35
	 * @param script the {@link ScriptReference} to compare the source {@link URI} from - never <code>null</code>
36
	 * @param path the path to match against the source {@link URI} - never <code>null</code>
37
	 * 
38
	 * @return <code>true</code> if the source {@link URI} of the given {@link ScriptReference} is considered to match the given {@link IPath}, <code>false</code> otherwise.
39
	 */
40
	public boolean matches(ScriptReference script, IPath path);
41
	
42
	/**
43
	 * This method is used to find the workspace {@link IFile} that corresponds to the source {@link URI} from the given {@link ScriptReference}.
44
	 * <br><br>
45
	 * If no file can be determined the method must return <code>null</code>. The result will be checked for existence.
46
	 * 
47
	 * @param script the {@link ScriptReference} to find the {@link IFile} for
48
	 * @return the {@link IFile} for the {@link ScriptReference} or <code>null</code>
49
	 */
50
	public IFile getFile(ScriptReference script);
51
}
(-)src/org/eclipse/wst/jsdt/debug/core/model/ScriptResolver.java (+39 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.core.model;
12
13
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.runtime.IPath;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
16
17
/**
18
 * This is the default base class for all {@link IScriptResolver}s
19
 * <br><br>
20
 * Clients must extend this class and not directly implement the interface {@link IScriptResolver}
21
 * 
22
 * @since 3.4
23
 */
24
public abstract class ScriptResolver implements IScriptResolver {
25
26
	/* (non-Javadoc)
27
	 * @see org.eclipse.wst.jsdt.debug.core.model.IScriptResolver#matches(org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference, org.eclipse.core.runtime.IPath)
28
	 */
29
	public boolean matches(ScriptReference script, IPath path) {
30
		return false;
31
	}
32
33
	/* (non-Javadoc)
34
	 * @see org.eclipse.wst.jsdt.debug.core.model.IScriptResolver#getFile(org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference)
35
	 */
36
	public IFile getFile(ScriptReference script) {
37
		return null;
38
	}
39
}
(-)src/org/eclipse/wst/jsdt/debug/internal/core/Constants.java (+5 lines)
Lines 73-78 Link Here
73
	 * The name of the launching connectors extension point
73
	 * The name of the launching connectors extension point
74
	 */
74
	 */
75
	static final String LAUNCHING_CONNECTORS = "launchingConnectors"; //$NON-NLS-1$
75
	static final String LAUNCHING_CONNECTORS = "launchingConnectors"; //$NON-NLS-1$
76
	/**
77
	 * The name of the script resolvers extension point
78
	 * @since 3.4
79
	 */
80
	static final String SCRIPT_RESOLVERS = "scriptResolvers"; //$NON-NLS-1$
76
	
81
	
77
//#########  PREFERENCES  ############
82
//#########  PREFERENCES  ############
78
	/**
83
	/**
(-)src/org/eclipse/wst/jsdt/debug/internal/core/JavaScriptDebugPlugin.java (-2 / +19 lines)
Lines 27-32 Link Here
27
import org.eclipse.core.runtime.preferences.InstanceScope;
27
import org.eclipse.core.runtime.preferences.InstanceScope;
28
import org.eclipse.wst.jsdt.debug.internal.core.launching.ConnectorsManager;
28
import org.eclipse.wst.jsdt.debug.internal.core.launching.ConnectorsManager;
29
import org.eclipse.wst.jsdt.debug.internal.core.model.BreakpointParticipantManager;
29
import org.eclipse.wst.jsdt.debug.internal.core.model.BreakpointParticipantManager;
30
import org.eclipse.wst.jsdt.debug.internal.core.model.ScriptResolutionManager;
30
import org.osgi.framework.BundleContext;
31
import org.osgi.framework.BundleContext;
31
32
32
/**
33
/**
Lines 64-69 Link Here
64
	 */
65
	 */
65
	private static JavaScriptPreferencesManager prefmanager = null;
66
	private static JavaScriptPreferencesManager prefmanager = null;
66
	/**
67
	/**
68
	 * Singleton {@link ScriptResolutionManager}
69
	 */
70
	private static ScriptResolutionManager resolutionmanager = null;
71
	/**
67
	 * Handle to the 'External JavaScript Source' project
72
	 * Handle to the 'External JavaScript Source' project
68
	 */
73
	 */
69
	private static IProject extSrcProject = null;
74
	private static IProject extSrcProject = null;
Lines 94-99 Link Here
94
	}
99
	}
95
	
100
	
96
	/**
101
	/**
102
	 * Returns the singleton {@link ScriptResolutionManager}
103
	 * @return the {@link ScriptResolutionManager}
104
	 * @since 3.4
105
	 */
106
	public static synchronized ScriptResolutionManager getResolutionManager() {
107
		if(resolutionmanager == null) {
108
			resolutionmanager = new ScriptResolutionManager();
109
		}
110
		return resolutionmanager;
111
	}
112
	
113
	/**
97
	 * Returns the current handle to the 'External JavaScript Source' project or <code>null</code>. If the project
114
	 * Returns the current handle to the 'External JavaScript Source' project or <code>null</code>. If the project
98
	 * is not accessible it can be created by passing <code>true</code> in for the create parameter.
115
	 * is not accessible it can be created by passing <code>true</code> in for the create parameter.
99
	 * 
116
	 * 
Lines 130-136 Link Here
130
	 * @return <code>true</code> if the path is in the external source project, <code>false</code> otherwise
147
	 * @return <code>true</code> if the path is in the external source project, <code>false</code> otherwise
131
	 */
148
	 */
132
	public static boolean isExternalSource(IPath path) {
149
	public static boolean isExternalSource(IPath path) {
133
		if(path.segment(0).equals(Messages.external_javascript_source)) {
150
		if(Messages.external_javascript_source.equals(path.segment(0))) {
134
			return true;
151
			return true;
135
		}
152
		}
136
		//try to look it up. The name might not have the project name in it
153
		//try to look it up. The name might not have the project name in it
Lines 169-175 Link Here
169
			if(prefmanager != null) {
186
			if(prefmanager != null) {
170
				prefmanager.stop();
187
				prefmanager.stop();
171
			}
188
			}
172
			if(new InstanceScope().getNode(PLUGIN_ID).getBoolean(Constants.DELETE_EXT_PROJECT_ON_EXIT, false)) {
189
			if(InstanceScope.INSTANCE.getNode(PLUGIN_ID).getBoolean(Constants.DELETE_EXT_PROJECT_ON_EXIT, false)) {
173
				if(extSrcProject != null && extSrcProject.exists()) {
190
				if(extSrcProject != null && extSrcProject.exists()) {
174
					extSrcProject.delete(true, null);
191
					extSrcProject.delete(true, null);
175
				}
192
				}
(-)src/org/eclipse/wst/jsdt/debug/internal/core/JavaScriptDebugPreferenceInitializer.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 32-38 Link Here
32
	 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
32
	 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
33
	 */
33
	 */
34
	public void initializeDefaultPreferences() {
34
	public void initializeDefaultPreferences() {
35
		IEclipsePreferences prefs = new DefaultScope().getNode(JavaScriptDebugPlugin.PLUGIN_ID);
35
		IEclipsePreferences prefs = DefaultScope.INSTANCE.getNode(JavaScriptDebugPlugin.PLUGIN_ID);
36
		if(prefs != null) {
36
		if(prefs != null) {
37
			prefs.putBoolean(Constants.SUSPEND_ON_ALL_SCRIPT_LOADS, false);
37
			prefs.putBoolean(Constants.SUSPEND_ON_ALL_SCRIPT_LOADS, false);
38
			prefs.putBoolean(Constants.SUSPEND_ON_THROWN_EXCEPTION, true);
38
			prefs.putBoolean(Constants.SUSPEND_ON_THROWN_EXCEPTION, true);
(-)src/org/eclipse/wst/jsdt/debug/internal/core/JavaScriptPreferencesManager.java (-2 / +2 lines)
Lines 88-94 Link Here
88
	 * Starts the manager
88
	 * Starts the manager
89
	 */
89
	 */
90
	public void start() {
90
	public void start() {
91
		IEclipsePreferences node = new InstanceScope().getNode(JavaScriptDebugPlugin.PLUGIN_ID);
91
		IEclipsePreferences node = InstanceScope.INSTANCE.getNode(JavaScriptDebugPlugin.PLUGIN_ID);
92
		node.addPreferenceChangeListener(this);
92
		node.addPreferenceChangeListener(this);
93
		StartJob job = new StartJob(node.getBoolean(Constants.SUSPEND_ON_ALL_SCRIPT_LOADS, false), 
93
		StartJob job = new StartJob(node.getBoolean(Constants.SUSPEND_ON_ALL_SCRIPT_LOADS, false), 
94
				node.getBoolean(Constants.SUSPEND_ON_THROWN_EXCEPTION, true));
94
				node.getBoolean(Constants.SUSPEND_ON_THROWN_EXCEPTION, true));
Lines 101-107 Link Here
101
	 * Stops the manager and clean up
101
	 * Stops the manager and clean up
102
	 */
102
	 */
103
	public void stop() {
103
	public void stop() {
104
		IEclipsePreferences node = new InstanceScope().getNode(JavaScriptDebugPlugin.PLUGIN_ID);
104
		IEclipsePreferences node = InstanceScope.INSTANCE.getNode(JavaScriptDebugPlugin.PLUGIN_ID);
105
		if(node != null) {
105
		if(node != null) {
106
			node.removePreferenceChangeListener(this);
106
			node.removePreferenceChangeListener(this);
107
		}
107
		}
(-)src/org/eclipse/wst/jsdt/debug/internal/core/TextUtils.java (-3 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 31-40 Link Here
31
	 */
31
	 */
32
	public static String shortenText(String string, int threshold) {
32
	public static String shortenText(String string, int threshold) {
33
		int length = string.length(); 
33
		int length = string.length(); 
34
		if(length > threshold) {
34
		if (length > threshold) {
35
			int chomp = length - threshold + 3;
35
			int chomp = length - threshold + 3;
36
			int begin = Math.round(threshold/2)-1;
36
			int begin = Math.round(threshold/2)-1;
37
			return string.replaceAll(string.substring(begin, begin+chomp), "..."); //$NON-NLS-1$
37
			StringBuffer buff = new StringBuffer();
38
			buff.append(string.substring(0, begin)).append("...").append(string.substring(begin+chomp)); //$NON-NLS-1$
39
			return buff.toString();
38
		}
40
		}
39
		return string;
41
		return string;
40
	}
42
	}
(-)src/org/eclipse/wst/jsdt/debug/internal/core/breakpoints/JavaScriptBreakpoint.java (-26 / +5 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.core.breakpoints;
11
package org.eclipse.wst.jsdt.debug.internal.core.breakpoints;
12
12
13
import java.net.URI;
14
import java.net.URISyntaxException;
13
import java.net.URISyntaxException;
15
import java.util.ArrayList;
14
import java.util.ArrayList;
16
import java.util.HashMap;
15
import java.util.HashMap;
Lines 20-26 Link Here
20
19
21
import org.eclipse.core.resources.IMarker;
20
import org.eclipse.core.resources.IMarker;
22
import org.eclipse.core.resources.IWorkspace;
21
import org.eclipse.core.resources.IWorkspace;
23
import org.eclipse.core.resources.IWorkspaceRoot;
24
import org.eclipse.core.resources.IWorkspaceRunnable;
22
import org.eclipse.core.resources.IWorkspaceRunnable;
25
import org.eclipse.core.resources.ResourcesPlugin;
23
import org.eclipse.core.resources.ResourcesPlugin;
26
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.CoreException;
Lines 43-49 Link Here
43
import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel;
41
import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel;
44
import org.eclipse.wst.jsdt.debug.internal.core.Constants;
42
import org.eclipse.wst.jsdt.debug.internal.core.Constants;
45
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
43
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
46
import org.eclipse.wst.jsdt.debug.internal.core.Messages;
47
import org.eclipse.wst.jsdt.debug.internal.core.launching.SourceLookup;
44
import org.eclipse.wst.jsdt.debug.internal.core.launching.SourceLookup;
48
import org.eclipse.wst.jsdt.debug.internal.core.model.IJavaScriptEventListener;
45
import org.eclipse.wst.jsdt.debug.internal.core.model.IJavaScriptEventListener;
49
import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptDebugTarget;
46
import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptDebugTarget;
Lines 61-67 Link Here
61
	 * The total count of all of the targets this breakpoint is installed in
58
	 * The total count of all of the targets this breakpoint is installed in
62
	 */
59
	 */
63
	public static final String INSTALL_COUNT = JavaScriptDebugPlugin.PLUGIN_ID + ".install_count"; //$NON-NLS-1$
60
	public static final String INSTALL_COUNT = JavaScriptDebugPlugin.PLUGIN_ID + ".install_count"; //$NON-NLS-1$
64
61
	
65
	private HashSet targets = null;
62
	private HashSet targets = null;
66
	private HashMap requestspertarget = new HashMap(4);
63
	private HashMap requestspertarget = new HashMap(4);
67
64
Lines 165-172 Link Here
165
			boolean success = true;
162
			boolean success = true;
166
			for (Iterator iter = scripts.iterator(); iter.hasNext();) {
163
			for (Iterator iter = scripts.iterator(); iter.hasNext();) {
167
				ScriptReference script = (ScriptReference) iter.next();
164
				ScriptReference script = (ScriptReference) iter.next();
168
				if (scriptPathMatches(script))
165
				if (JavaScriptDebugPlugin.getResolutionManager().matches(script, new Path(getScriptPath()))) {
169
					success &= createRequest(target, script);
166
					success &= createRequest(target, script);
167
				}
170
			}
168
			}
171
			if (success) {
169
			if (success) {
172
				if (this.targets == null) {
170
				if (this.targets == null) {
Lines 437-444 Link Here
437
			ScriptReference script = sevent.script();
435
			ScriptReference script = sevent.script();
438
			
436
			
439
			try {
437
			try {
440
				if (scriptPathMatches(script)) 
438
				if (JavaScriptDebugPlugin.getResolutionManager().matches(script, new Path(getScriptPath()))) {
441
					createRequest(target, script);
439
					createRequest(target, script);
440
				}
442
			} catch (CoreException ce) {
441
			} catch (CoreException ce) {
443
				JavaScriptDebugPlugin.log(ce);
442
				JavaScriptDebugPlugin.log(ce);
444
			}
443
			}
Lines 446-471 Link Here
446
		return true;
445
		return true;
447
	}
446
	}
448
447
449
	protected boolean scriptPathMatches(ScriptReference script) throws CoreException {
450
		URI sourceURI = script.sourceURI();
451
		if ("file".equals(sourceURI.getScheme())) {//$NON-NLS-1$			
452
			IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
453
			URI workspaceURI = workspaceRoot.getRawLocationURI();			
454
			sourceURI = workspaceURI.relativize(sourceURI);
455
		}
456
		String path = getScriptPath();
457
		IPath spath = new Path(path);
458
		if(spath.segment(0).equals(Messages.external_javascript_source)) {
459
			spath = spath.removeFirstSegments(1).makeAbsolute();
460
		}
461
		//XXX use the same algorithm we use to save the source to 'encode' the source URI for comparison
462
		IPath uripath = SourceLookup.getSourcePath(sourceURI);
463
		if(uripath != null) {
464
			uripath = uripath.makeAbsolute();
465
		}
466
		return spath.equals(uripath);
467
	}
468
469
	/**
448
	/**
470
	 * Returns if the type names for the breakpoint are equal or not. Two <code>null</code> type names are considered to be equal.
449
	 * Returns if the type names for the breakpoint are equal or not. Two <code>null</code> type names are considered to be equal.
471
	 * 
450
	 * 
(-)src/org/eclipse/wst/jsdt/debug/internal/core/breakpoints/JavaScriptLoadBreakpoint.java (-1 / +27 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.core.breakpoints;
11
package org.eclipse.wst.jsdt.debug.internal.core.breakpoints;
12
12
13
import java.lang.reflect.Method;
13
import java.util.ArrayList;
14
import java.util.ArrayList;
14
import java.util.Map;
15
import java.util.Map;
15
16
Lines 19-29 Link Here
19
import org.eclipse.core.resources.ResourcesPlugin;
20
import org.eclipse.core.resources.ResourcesPlugin;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.core.runtime.Path;
22
import org.eclipse.debug.core.DebugException;
24
import org.eclipse.debug.core.DebugException;
23
import org.eclipse.debug.core.model.IBreakpoint;
25
import org.eclipse.debug.core.model.IBreakpoint;
24
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpointParticipant;
26
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpointParticipant;
25
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLoadBreakpoint;
27
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLoadBreakpoint;
26
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
28
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
29
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
27
import org.eclipse.wst.jsdt.debug.core.jsdi.event.Event;
30
import org.eclipse.wst.jsdt.debug.core.jsdi.event.Event;
28
import org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet;
31
import org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet;
29
import org.eclipse.wst.jsdt.debug.core.jsdi.event.ScriptLoadEvent;
32
import org.eclipse.wst.jsdt.debug.core.jsdi.event.ScriptLoadEvent;
Lines 101-106 Link Here
101
			JavaScriptThread thread = target.findThread((sevent).thread());
104
			JavaScriptThread thread = target.findThread((sevent).thread());
102
			if (thread != null) {
105
			if (thread != null) {
103
				if(isGlobalLoadSuspend()) {
106
				if(isGlobalLoadSuspend()) {
107
					if(!supportsGlobalSuspend(target.getVM())) {
108
						return true;
109
					}
104
					JavaScriptPreferencesManager.setGlobalSuspendOn(script.sourceURI().toString());
110
					JavaScriptPreferencesManager.setGlobalSuspendOn(script.sourceURI().toString());
105
					thread.addBreakpoint(this);
111
					thread.addBreakpoint(this);
106
					return false;
112
					return false;
Lines 124-130 Link Here
124
	 */
130
	 */
125
	private boolean isMatchedScriptLoadSuspend(ScriptReference script, JavaScriptThread thread, boolean suspendVote) {
131
	private boolean isMatchedScriptLoadSuspend(ScriptReference script, JavaScriptThread thread, boolean suspendVote) {
126
		try {
132
		try {
127
			if (scriptPathMatches(script)) {
133
			if (JavaScriptDebugPlugin.getResolutionManager().matches(script, new Path(getScriptPath()))) {
128
				int vote = thread.suspendForScriptLoad(this, script, suspendVote);
134
				int vote = thread.suspendForScriptLoad(this, script, suspendVote);
129
				return (vote & IJavaScriptBreakpointParticipant.SUSPEND) > 0 || vote == IJavaScriptBreakpointParticipant.DONT_CARE;
135
				return (vote & IJavaScriptBreakpointParticipant.SUSPEND) > 0 || vote == IJavaScriptBreakpointParticipant.DONT_CARE;
130
			}
136
			}
Lines 136-141 Link Here
136
	}
142
	}
137
	
143
	
138
	/**
144
	/**
145
	 * Use reflection hack to opt-out of global suspend
146
	 * 
147
	 * @param vm
148
	 * @return <code>true</code> if the backing {@link VirtualMachine} supports global suspend
149
	 */
150
	boolean supportsGlobalSuspend(VirtualMachine vm) {
151
		boolean supports = true;
152
		try {
153
			//TODO consider supportsSuspendOnScriptLoads for future VirtualMachine extensions
154
			Method m = vm.getClass().getMethod("supportsSuspendOnScriptLoads", new Class[0]); //$NON-NLS-1$
155
			Boolean b = (Boolean) m.invoke(vm, null);
156
			supports = b.booleanValue();
157
		} catch (Exception e) {
158
			//assume the method is not there / problematic
159
			supports = true;
160
		}
161
		return supports;
162
	}
163
	
164
	/**
139
	 * Returns if this breakpoint supports global suspend
165
	 * Returns if this breakpoint supports global suspend
140
	 * 
166
	 * 
141
	 * @return <code>true</code> if we should suspend on all script loads <code>false</code> otherwise
167
	 * @return <code>true</code> if we should suspend on all script loads <code>false</code> otherwise
(-)src/org/eclipse/wst/jsdt/debug/internal/core/launching/JavaScriptSourceLookupParticipant.java (-2 / +49 lines)
Lines 12-24 Link Here
12
12
13
import java.net.URI;
13
import java.net.URI;
14
import java.util.HashMap;
14
import java.util.HashMap;
15
import java.util.Iterator;
16
import java.util.List;
15
17
16
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.core.runtime.IPath;
19
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
21
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
20
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
22
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
23
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
24
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame;
25
import org.eclipse.wst.jsdt.debug.core.model.IScript;
21
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
26
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
27
import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptDebugTarget;
28
import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptStackFrame;
29
import org.eclipse.wst.jsdt.debug.internal.core.model.Script;
22
30
23
/**
31
/**
24
 * Default source lookup participant
32
 * Default source lookup participant
Lines 45-50 Link Here
45
	 * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant#findSourceElements(java.lang.Object)
53
	 * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant#findSourceElements(java.lang.Object)
46
	 */
54
	 */
47
	public Object[] findSourceElements(Object object) throws CoreException {
55
	public Object[] findSourceElements(Object object) throws CoreException {
56
		IFile file = resolveFile(object);
57
		if(file != null && file.exists()) {
58
			return new IFile[] {file};
59
		}
48
		ISourceContainer[] containers = getSourceContainers();
60
		ISourceContainer[] containers = getSourceContainers();
49
		if(containers != null && containers.length > 0) {
61
		if(containers != null && containers.length > 0) {
50
			String name = getSourceName(object);
62
			String name = getSourceName(object);
Lines 61-67 Link Here
61
			//in the external source project and show it
73
			//in the external source project and show it
62
			URI sourceURI = SourceLookup.getSourceURI(object);
74
			URI sourceURI = SourceLookup.getSourceURI(object);
63
			if (sourceURI != null) {
75
			if (sourceURI != null) {
64
				IFile file = (IFile) sourcemap.get(sourceURI);
76
				file = (IFile) sourcemap.get(sourceURI);
65
				if(file != null && file.exists()) {
77
				if(file != null && file.exists()) {
66
					return new IFile[] { file };
78
					return new IFile[] { file };
67
				}
79
				}
Lines 72-77 Link Here
72
	}
84
	}
73
85
74
	/**
86
	/**
87
	 * Tries to resolve the workspace local {@link IFile}(s) that match the underlying {@link ScriptReference}
88
	 * for either an {@link IJavaScriptStackFrame} or an {@link IScript}
89
	 * 
90
	 * @param object the object to try and resolve the {@link IFile} from
91
	 * @return the corresponding {@link IFile} for the object or <code>null</code> if one could not be determined
92
	 * @since 1.4
93
	 */
94
	IFile resolveFile(Object object) {
95
		String uri = null;
96
		JavaScriptDebugTarget target = null;
97
		if(object instanceof JavaScriptStackFrame) {
98
			JavaScriptStackFrame frame = (JavaScriptStackFrame) object;
99
			uri = frame.getSourcePath();
100
			target = (JavaScriptDebugTarget) frame.getDebugTarget();
101
		}
102
		if(object instanceof Script) {
103
			Script script = (Script) object;
104
			uri = script.sourceURI().toString();
105
			target = (JavaScriptDebugTarget) script.getDebugTarget();
106
		}
107
		if(uri != null && target != null) {
108
			List scripts = target.getVM().allScripts();
109
			for (Iterator i = scripts.iterator(); i.hasNext();) {
110
				ScriptReference ref = (ScriptReference) i.next();
111
				if(uri.equals(ref.sourceURI().toString())) {
112
					return JavaScriptDebugPlugin.getResolutionManager().getFile(ref);
113
				}
114
			}
115
		}
116
		return null;
117
	}
118
	
119
	
120
	
121
	/**
75
	 * Shows the source in an external editor
122
	 * Shows the source in an external editor
76
	 * 
123
	 * 
77
	 * @param sourceuri
124
	 * @param sourceuri
Lines 106-109 Link Here
106
	public boolean isFindDuplicates() {
153
	public boolean isFindDuplicates() {
107
		return true;
154
		return true;
108
	}
155
	}
109
}
156
}
(-)src/org/eclipse/wst/jsdt/debug/internal/core/launching/SourceLookup.java (-6 / +16 lines)
Lines 40-46 Link Here
40
public final class SourceLookup {
40
public final class SourceLookup {
41
41
42
	public static final QualifiedName SCRIPT_URL = new QualifiedName(JavaScriptCore.PLUGIN_ID, "scriptURL"); //$NON-NLS-1$
42
	public static final QualifiedName SCRIPT_URL = new QualifiedName(JavaScriptCore.PLUGIN_ID, "scriptURL"); //$NON-NLS-1$
43
	
43
	public static final IPath TOP_LEVEL_PATH = new Path("/"); //$NON-NLS-1$
44
	/**
44
	/**
45
	 * Returns the name of the source object to lookup or <code>null</code>
45
	 * Returns the name of the source object to lookup or <code>null</code>
46
	 * if the object is not a {@link IJavaScriptStackFrame} or an {@link IScript}
46
	 * if the object is not a {@link IJavaScriptStackFrame} or an {@link IScript}
Lines 50-60 Link Here
50
	 * @since 1.1
50
	 * @since 1.1
51
	 */
51
	 */
52
	public static String getSourceName(Object object) {
52
	public static String getSourceName(Object object) {
53
		String name = null;
53
		if (object instanceof IJavaScriptStackFrame) {
54
		if (object instanceof IJavaScriptStackFrame) {
54
			return ((IJavaScriptStackFrame) object).getSourceName();
55
			name = ((IJavaScriptStackFrame) object).getSourceName();
55
		}
56
		}
56
		if(object instanceof IScript) {
57
		if(object instanceof IScript) {
57
			return URIUtil.lastSegment(((IScript)object).sourceURI());
58
			name = URIUtil.lastSegment(((IScript)object).sourceURI());
59
		}
60
		if(name != null) {
61
			if(new Path(name).getFileExtension() == null) {
62
				//append .js, there is no case where we would look up a file with no extension from a script node
63
				StringBuffer buf = new StringBuffer(name.length()+3);
64
				buf.append(name).append('.').append(Constants.JS_EXTENSION);
65
				return buf.toString();
66
			}
67
			return name;
58
		}
68
		}
59
		return null;
69
		return null;
60
	}
70
	}
Lines 133-139 Link Here
133
			else {
143
			else {
134
				file = doFormat(file, source);
144
				file = doFormat(file, source);
135
			}
145
			}
136
			file.setPersistentProperty(SCRIPT_URL, sourceuri.getPath());
146
			file.setPersistentProperty(SCRIPT_URL, sourceuri.toString());
137
			return file;
147
			return file;
138
		}
148
		}
139
		return null;
149
		return null;
Lines 158-164 Link Here
158
			return null;
168
			return null;
159
		}
169
		}
160
		if(uripath.trim().equals("/")) { //$NON-NLS-1$
170
		if(uripath.trim().equals("/")) { //$NON-NLS-1$
161
			uripath = "page.js"; //$NON-NLS-1$
171
			uripath = "index.htm"; //$NON-NLS-1$
162
		}
172
		}
163
		String host = sourceuri.getHost();
173
		String host = sourceuri.getHost();
164
		IPath path = null;
174
		IPath path = null;
Lines 237-243 Link Here
237
			newpath = newpath.append((String) segments.get(i));
247
			newpath = newpath.append((String) segments.get(i));
238
		}
248
		}
239
		String ext = newpath.getFileExtension(); 
249
		String ext = newpath.getFileExtension(); 
240
		if(ext == null || !Constants.JS_EXTENSION.equals(ext)) {
250
		if(ext == null && !Constants.JS_EXTENSION.equals(ext)) {
241
			newpath = newpath.addFileExtension(Constants.JS_EXTENSION);
251
			newpath = newpath.addFileExtension(Constants.JS_EXTENSION);
242
		}
252
		}
243
		return newpath; 
253
		return newpath; 
(-)src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptStackFrame.java (-1 / +1 lines)
Lines 102-108 Link Here
102
	 * @see org.eclipse.debug.core.model.IStackFrame#getName()
102
	 * @see org.eclipse.debug.core.model.IStackFrame#getName()
103
	 */
103
	 */
104
	public String getName() throws DebugException {
104
	public String getName() throws DebugException {
105
		return this.stackFrame.location().scriptReference().sourceURI().toString();
105
		return this.stackFrame.location().functionName();
106
	}
106
	}
107
107
108
	/*
108
	/*
(-)src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptThread.java (-1 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 848-853 Link Here
848
		if(event instanceof SuspendEvent) {
848
		if(event instanceof SuspendEvent) {
849
			if(canSuspend()) {
849
			if(canSuspend()) {
850
				if(this.thread.equals(((SuspendEvent)event).thread())) {
850
				if(this.thread.equals(((SuspendEvent)event).thread())) {
851
					if(pendingstep != null) {
852
						pendingstep.abort();
853
					}
851
					markSuspended();
854
					markSuspended();
852
					fireSuspendEvent(DebugEvent.UNSPECIFIED);
855
					fireSuspendEvent(DebugEvent.UNSPECIFIED);
853
					return false;
856
					return false;
Lines 868-873 Link Here
868
			if(pendingstep != null) {
871
			if(pendingstep != null) {
869
				//we need to handle the case where a step has caused a resume and no StepEvent has been sent
872
				//we need to handle the case where a step has caused a resume and no StepEvent has been sent
870
				pendingstep.abort();
873
				pendingstep.abort();
874
				//send an event as we have stepped to resume
875
				fireResumeEvent(DebugEvent.UNSPECIFIED);
871
			}
876
			}
872
		}
877
		}
873
		return true;
878
		return true;
(-)src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptValue.java (-2 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 46-51 Link Here
46
 */
46
 */
47
public class JavaScriptValue extends JavaScriptDebugElement implements IJavaScriptValue {
47
public class JavaScriptValue extends JavaScriptDebugElement implements IJavaScriptValue {
48
48
49
	public static final IVariable[] NO_VARIABLES = new IVariable[0];
50
	
49
	/**
51
	/**
50
	 * the '[proto]' value
52
	 * the '[proto]' value
51
	 */
53
	 */
Lines 206-212 Link Here
206
	 */
208
	 */
207
	public synchronized IVariable[] getVariables() throws DebugException {
209
	public synchronized IVariable[] getVariables() throws DebugException {
208
		if (!hasVariables()) {
210
		if (!hasVariables()) {
209
			return null;
211
			return NO_VARIABLES;
210
		}
212
		}
211
		if (this.properties == null) {
213
		if (this.properties == null) {
212
			final ObjectReference reference = (ObjectReference) this.value;
214
			final ObjectReference reference = (ObjectReference) this.value;
(-)src/org/eclipse/wst/jsdt/debug/internal/core/model/ModelMessages.java (-1 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
(-)src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolutionManager.java (+195 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.core.model;
12
13
import java.net.URI;
14
import java.util.ArrayList;
15
import java.util.Arrays;
16
import java.util.List;
17
18
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IResource;
20
import org.eclipse.core.resources.IWorkspaceRoot;
21
import org.eclipse.core.resources.ResourcesPlugin;
22
import org.eclipse.core.runtime.IConfigurationElement;
23
import org.eclipse.core.runtime.IExtensionPoint;
24
import org.eclipse.core.runtime.IPath;
25
import org.eclipse.core.runtime.ListenerList;
26
import org.eclipse.core.runtime.Path;
27
import org.eclipse.core.runtime.Platform;
28
import org.eclipse.core.runtime.URIUtil;
29
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
30
import org.eclipse.wst.jsdt.debug.core.model.IScriptResolver;
31
import org.eclipse.wst.jsdt.debug.internal.core.Constants;
32
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
33
import org.eclipse.wst.jsdt.debug.internal.core.Messages;
34
import org.eclipse.wst.jsdt.debug.internal.core.launching.SourceLookup;
35
36
/**
37
 * Handles the collection of {@link ScriptResolverExtension}s and provide useful utilities for path / script handling
38
 * @since 3.4
39
 */
40
public final class ScriptResolutionManager {
41
42
	static IScriptResolver[] NO_RESOLVERS = new IScriptResolver[0];
43
	ListenerList resolvers = null;
44
	
45
	/**
46
	 * This is a convenience method that consults all of the registered {@link IScriptResolver}s.
47
	 * <br><br>
48
	 * This method will return <code>true</code> iff any one (or all) of the {@link IScriptResolver}s returns <code>true</code> or
49
	 * the default matching algorithm returns <code>true</code> - which is consulted after all extensions have been asked.
50
	 * @param script the script to check
51
	 * @param path the path to compare against
52
	 * @return <code>true</code> if any one (or all) of the {@link IScriptResolver}s return <code>true</code>, <code>false</code> otherwise
53
	 */
54
	public boolean matches(ScriptReference script, IPath path) {
55
		IScriptResolver[] res = getResolvers();
56
		for (int i = 0; i < res.length; i++) {
57
			if(res[i].matches(script, path)) {
58
				return true;
59
			}
60
		}
61
		//no extensions matched, fall-back to the old way
62
		return isMatch(script, path);
63
	}
64
	
65
	boolean isMatch(ScriptReference script, IPath path) {
66
		if(guessScriptMatches(script, path)) {
67
			return true;
68
		}
69
		//no luck, try an exact match
70
		URI sourceURI = script.sourceURI();
71
		if (URIUtil.isFileURI(sourceURI)) {
72
			IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
73
			URI workspaceURI = workspaceRoot.getRawLocationURI();			
74
			sourceURI = workspaceURI.relativize(sourceURI);
75
		}
76
		IPath spath = path;
77
		if(spath.segmentCount() > 0 && spath.segment(0).equals(Messages.external_javascript_source)) {
78
			spath = spath.removeFirstSegments(1).makeAbsolute();
79
		}
80
		IPath uripath = SourceLookup.getSourcePath(sourceURI);
81
		if(uripath != null) {
82
			uripath = uripath.makeAbsolute();
83
		}
84
		return spath.equals(uripath);
85
	}
86
87
	/**
88
	 * Guesses if the paths are considered equal by walking backward from the last segment of the paths and counting the matching segments. 
89
	 * The paths are guessed to be equal iff any two or more segments match in order.
90
	 * 
91
	 * @param script the {@link ScriptReference}
92
	 * @param path the path to compare
93
	 * @return <code>true</code> if the paths 'match', <code>false</code> otherwise
94
	 */
95
	boolean guessScriptMatches(ScriptReference script, IPath path) {
96
		IPath newpath = path.makeAbsolute();
97
		IPath uri = new Path(script.sourceURI().getPath());
98
		if(SourceLookup.TOP_LEVEL_PATH.equals(newpath) && SourceLookup.TOP_LEVEL_PATH.equals(uri)) {
99
			return true;
100
		}
101
		uri = uri.makeAbsolute();
102
		int matched_segments = 0;
103
		int last = uri.segmentCount()-1;
104
		for(int i  = newpath.segmentCount()-1; i > -1; i--) {
105
			if(last < 0) {
106
				break;
107
			}
108
			if(newpath.segment(i).equals(uri.segment(last))) {
109
				matched_segments++;
110
				last--;
111
			}
112
		}
113
		return matched_segments > 1;
114
	}
115
	
116
	/**
117
	 * Convenience method to consult all of the registered {@link IScriptResolver}s for the matching {@link IFile}.
118
	 * <br><br>
119
	 * This method will vote on the file to return, and return the {@link IFile} that has the most votes as follows:
120
	 * <ul>
121
	 * <li>If there is one contributor and it returns an {@link IFile} that one is chosen</li>
122
	 * <li>If there is &gt; one contributor the greatest number of matching {@link IFile}s returned is chosen. If there is a tie, the {@link IFile}
123
	 * that matches the one selected from the default algorithm will be chosen. In the event the default algorithm returns <code>null</code> the first {@link IFile}
124
	 * will be selected.</li>
125
	 * <li>If there are no contributors the default algorithm is consulted</li>
126
	 * </ul>
127
	 * @param script
128
	 * @return the matching {@link IFile} or <code>null</code>
129
	 */
130
	public IFile getFile(ScriptReference script) {
131
		IScriptResolver[] resolvers = getResolvers();
132
		ArrayList files = new ArrayList();
133
		IFile file = null;
134
		for (int i = 0; i < resolvers.length; i++) {
135
			file = resolvers[i].getFile(script);
136
			if(file != null) {
137
				if(files.contains(file)) {
138
					return file;
139
				}
140
				files.add(file);
141
			}
142
		}
143
		file = null;
144
		IPath p = SourceLookup.getSourcePath(script.sourceURI());
145
		IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(p);
146
		if(res != null && res.getType() == IResource.FILE) {
147
			file = (IFile) res;
148
		}
149
		if(files.size() > 0) {
150
			if(files.contains(file)) {
151
				return file;
152
			}
153
			return (IFile) files.get(0);
154
		}
155
		return file;
156
	}
157
	
158
	/**
159
	 * Returns the complete listing of {@link IScriptResolver}s or an empty array, never <code>null</code>
160
	 * 
161
	 * @return the complete listing of {@link IScriptResolver}s
162
	 */
163
	public IScriptResolver[] getResolvers() {
164
		loadResolvers();
165
		if(resolvers.size() < 1) {
166
			return NO_RESOLVERS;
167
		}
168
		List res = Arrays.asList(resolvers.getListeners());
169
		return (IScriptResolver[]) res.toArray(new IScriptResolver[res.size()]);
170
	}
171
	
172
	/**
173
	 * load up all the extension points to the delegate listeners
174
	 */
175
	void loadResolvers() {
176
		if(resolvers == null) {
177
			resolvers = new ListenerList();
178
			IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(JavaScriptDebugPlugin.PLUGIN_ID, Constants.SCRIPT_RESOLVERS);
179
			IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
180
			for (int i = 0; i < elements.length; i++) {
181
				resolvers.add(new ScriptResolverExtension(elements[i]));
182
			}
183
		}
184
	}
185
	
186
	/**
187
	 * Clean up
188
	 */
189
	public void dispose() {
190
		if(resolvers != null) {
191
			resolvers.clear();
192
			resolvers = null;
193
		}
194
	}
195
}
(-)src/org/eclipse/wst/jsdt/debug/internal/core/model/ScriptResolverExtension.java (+75 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.core.model;
12
13
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.IConfigurationElement;
16
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
18
import org.eclipse.wst.jsdt.debug.core.model.IScriptResolver;
19
import org.eclipse.wst.jsdt.debug.internal.core.Constants;
20
21
/**
22
 * Default implementation of the delegate class for all {@link IScriptResolver}s
23
 * 
24
 * @since 3.4
25
 */
26
public class ScriptResolverExtension implements IScriptResolver {
27
28
	private IConfigurationElement element = null;
29
	private IScriptResolver delegate = null;
30
	
31
	/**
32
	 * Constructor
33
	 * @param element the backing {@link IConfigurationElement} to lazily load and delegate to
34
	 */
35
	public ScriptResolverExtension(IConfigurationElement element) {
36
		this.element = element;
37
	}
38
	
39
	/**
40
	 * Returns the delegate {@link IScriptResolver} from the backing {@link IConfigurationElement}
41
	 * 
42
	 * @return the delegate {@link IScriptResolver}
43
	 * @throws CoreException thrown if the delegate class fails to be created
44
	 */
45
	synchronized IScriptResolver getDelegate() throws CoreException {
46
		if(delegate == null) {
47
			delegate = (IScriptResolver) element.createExecutableExtension(Constants.CLASS);
48
		}
49
		return delegate;
50
	}
51
	
52
	/* (non-Javadoc)
53
	 * @see org.eclipse.wst.jsdt.debug.core.model.IScriptPathResolver#matches(org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference, org.eclipse.core.runtime.IPath)
54
	 */
55
	public boolean matches(ScriptReference script, IPath path) {
56
		try {
57
			return getDelegate().matches(script, path);
58
		}
59
		catch(CoreException ce) {
60
			return false;
61
		}
62
	}
63
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.wst.jsdt.debug.core.model.IScriptPathResolver#getFile(org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference)
66
	 */
67
	public IFile getFile(ScriptReference script) {
68
		try {
69
			return getDelegate().getFile(script);
70
		}
71
		catch(CoreException ce) {
72
			return null;
73
		}
74
	}
75
}
(-)src/org/eclipse/wst/jsdt/debug/internal/core/model/modelmessages.properties (-1 / +1 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2010 IBM Corporation and others.
2
# Copyright (c) 2010, 2011 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
(-).classpath (+7 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
(-).options (+25 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2010 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
#option file for tracing options for Crossfire debugger port
13
org.eclipse.wst.jsdt.debug.crossfire/debug=true
14
15
#option to trace packets being sent / received
16
org.eclipse.wst.jsdt.debug.crossfire/packets=false
17
18
#option to trace the event queue
19
org.eclipse.wst.jsdt.debug.crossfire/eventqueue=false
20
21
#option to trace the jsdi impl* elements
22
org.eclipse.wst.jsdt.debug.crossfire/jsdi=false
23
24
#option to trace the JSON parser
25
org.eclipse.wst.jsdt.debug.crossfire/json=false
(-).project (+34 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.eclipse.wst.jsdt.debug.internal.crossfire</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
		<buildCommand>
24
			<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
25
			<arguments>
26
			</arguments>
27
		</buildCommand>
28
	</buildSpec>
29
	<natures>
30
		<nature>org.eclipse.pde.PluginNature</nature>
31
		<nature>org.eclipse.jdt.core.javanature</nature>
32
		<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
33
	</natures>
34
</projectDescription>
(-).settings/org.eclipse.jdt.core.prefs (+90 lines)
Added Link Here
1
#Fri Apr 30 10:04:28 CDT 2010
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6
org.eclipse.jdt.core.compiler.compliance=1.4
7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8
org.eclipse.jdt.core.compiler.debug.localVariable=generate
9
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
11
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
12
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
13
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
14
org.eclipse.jdt.core.compiler.problem.comparingIdentical=error
15
org.eclipse.jdt.core.compiler.problem.deadCode=error
16
org.eclipse.jdt.core.compiler.problem.deprecation=warning
17
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
18
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
19
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
20
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
21
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
22
org.eclipse.jdt.core.compiler.problem.fallthroughCase=error
23
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
24
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
25
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
26
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
27
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
28
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
29
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
30
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
31
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
32
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
33
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled
34
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
35
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
36
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
37
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
38
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
39
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
40
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error
41
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
42
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
43
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
44
org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
45
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
46
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
47
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
48
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
49
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
50
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
51
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
52
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
53
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
54
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=error
55
org.eclipse.jdt.core.compiler.problem.nullReference=warning
56
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
57
org.eclipse.jdt.core.compiler.problem.parameterAssignment=error
58
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
59
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
60
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
61
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
62
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error
63
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
64
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
65
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
66
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
67
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
68
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
69
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
70
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
71
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
72
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=error
73
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
74
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
75
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
76
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
77
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
78
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
79
org.eclipse.jdt.core.compiler.problem.unusedImport=error
80
org.eclipse.jdt.core.compiler.problem.unusedLabel=error
81
org.eclipse.jdt.core.compiler.problem.unusedLocal=error
82
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=error
83
org.eclipse.jdt.core.compiler.problem.unusedParameter=error
84
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
85
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
86
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
87
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
88
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
89
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
90
org.eclipse.jdt.core.compiler.source=1.3
(-)META-INF/MANIFEST.MF (+20 lines)
Added Link Here
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Bundle-Name
4
Bundle-SymbolicName: org.eclipse.wst.jsdt.debug.crossfire;singleton:=true
5
Bundle-Version: 1.0.100.qualifier
6
Bundle-Activator: org.eclipse.wst.jsdt.debug.internal.crossfire.CrossFirePlugin
7
Bundle-Vendor: %Bundle-Vendor
8
Require-Bundle: org.eclipse.core.runtime,
9
 org.eclipse.wst.jsdt.debug.core;bundle-version="1.0.0",
10
 org.eclipse.wst.jsdt.debug.transport;bundle-version="1.0.0",
11
 org.eclipse.wst.jsdt.core;bundle-version="1.0.0",
12
 org.eclipse.debug.core
13
Bundle-RequiredExecutionEnvironment: J2SE-1.4
14
Bundle-ActivationPolicy: lazy
15
Export-Package: org.eclipse.wst.jsdt.debug.internal.crossfire;x-internal:=true,
16
 org.eclipse.wst.jsdt.debug.internal.crossfire.connect;x-internal:=true,
17
 org.eclipse.wst.jsdt.debug.internal.crossfire.event;x-internal:=true,
18
 org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;x-internal:=true,
19
 org.eclipse.wst.jsdt.debug.internal.crossfire.request;x-internal:=true,
20
 org.eclipse.wst.jsdt.debug.internal.crossfire.transport;x-internal:=true
(-)OSGI-INF/l10n/bundle.properties (+12 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2010 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
Bundle-Vendor = Eclipse Web Tools Platform
12
Bundle-Name = Crossfire JavaScript Debug
(-)about.html (+87 lines)
Added Link Here
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
6
<title>About</title>
7
</head>
8
<body lang="EN-US">
9
<h2>About This Content</h2>
10
 
11
<p>April 20, 2007</p>	
12
<h3>License</h3>
13
14
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise 
15
indicated below, the Content is provided to you under the terms and conditions of the
16
Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available 
17
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
18
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
19
20
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
21
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
22
apply to your use of any object code in the Content.  Check the Redistributor's license that was 
23
provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
24
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
25
and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
26
27
<h3>Third Party Content</h3>
28
29
<p>The Content includes items that have been sourced from third parties as set out below. If you 
30
did not receive this Content directly from the Eclipse Foundation, the following is provided 
31
for informational purposes only, and you should look to the Redistributor&rsquo;s license for 
32
terms and conditions of use.</p>
33
34
<h4>Ispell 3.1.20</h4>
35
36
<p>The plug-in is accompanied by software developed by Geoff Kuenning.  The following files:</p>
37
<ul>
38
	<li>dictionaries/en_US.dictionary</li>
39
	<li>dictionaries/en_GB.dictionary</li>
40
</ul>
41
42
<p>are based on Ispell 3.1.20.  The home page for Ispell is located at <a href="http://lasr.cs.ucla.edu/geoff/ispell.html" target="_blank">http://lasr.cs.ucla.edu/geoff/ispell.html</a>.</p>
43
44
<p>Your use of Ispell 3.1.20 in the plug-in is subject to the terms and conditions of the Ispell license.  A copy of the Ispell license is included in
45
<a href="about_files/ispell-license.txt" target="_blank">about_files/ispell-license.txt</a> and is also reproduced below:</p>
46
47
<blockquote>
48
  Copyright 1993, Geoff Kuenning, Granada Hills, CA<br />
49
  All rights reserved.<br />
50
<br />
51
  Redistribution and use in source and binary forms, with or without<br />
52
  modification, are permitted provided that the following conditions<br />
53
  are met:<br />
54
<br />
55
  1. Redistributions of source code must retain the above copyright<br />
56
     notice, this list of conditions and the following disclaimer.<br />
57
  2. Redistributions in binary form must reproduce the above copyright<br />
58
     notice, this list of conditions and the following disclaimer in the<br />
59
     documentation and/or other materials provided with the distribution.<br />
60
  3. All modifications to the source code must be clearly marked as<br />
61
     such.  Binary redistributions based on modified source code<br />
62
     must be clearly marked as modified versions in the documentation<br />
63
     and/or other materials provided with the distribution.<br />
64
  4. All advertising materials mentioning features or use of this software<br />
65
     must display the following acknowledgment:<br />
66
     This product includes software developed by Geoff Kuenning and<br />
67
     other unpaid contributors.<br />
68
  5. The name of Geoff Kuenning may not be used to endorse or promote<br />
69
     products derived from this software without specific prior<br />
70
     written permission.<br />
71
<br />
72
  THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS<br />
73
  IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT<br />
74
  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS<br />
75
  FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GEOFF<br />
76
  KUENNING OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,<br />
77
  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,<br />
78
  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;<br />
79
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER<br />
80
  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br />
81
  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN<br />
82
  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br />
83
  POSSIBILITY OF SUCH DAMAGE.<br />
84
</blockquote>
85
86
</body>
87
</html>
(-)build.properties (+18 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2011 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
source.. = src/
12
output.. = bin/
13
bin.includes = META-INF/,\
14
               .,\
15
               plugin.xml,\
16
               OSGI-INF/,\
17
               about.html,\
18
               .options
(-)plugin.xml (+19 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.eclipse.wst.jsdt.debug.core.launchingConnectors">
6
      <connector
7
            class="org.eclipse.wst.jsdt.debug.internal.crossfire.connect.CrossfireListeningConnector"
8
            id="crossfire.remote.listen.connector">
9
      </connector>
10
   </extension>
11
   <extension
12
         point="org.eclipse.wst.jsdt.debug.core.launchingConnectors">
13
      <connector
14
            class="org.eclipse.wst.jsdt.debug.internal.crossfire.connect.CrossfireAttachingConnector"
15
            id="crossfire.remote.attach.connector">
16
      </connector>
17
   </extension>
18
19
</plugin>
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/CFObject.java (+50 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire;
12
13
/**
14
 * Place-holding class for objects
15
 * 
16
 * @since 1.0
17
 */
18
public class CFObject {
19
20
	private String type = null;
21
	private String name = null;
22
	private Number handle = null;
23
	
24
	public CFObject(String name, String type, Number handle) {
25
		this.name = name;
26
		this.type = type;
27
		this.handle = handle;
28
	}
29
	
30
	/**
31
	 * @return the handle
32
	 */
33
	public Number getHandle() {
34
		return this.handle;
35
	}
36
	
37
	/**
38
	 * @return the type
39
	 */
40
	public String getType() {
41
		return this.type;
42
	}
43
	
44
	/**
45
	 * @return the name
46
	 */
47
	public String getName() {
48
		return this.name;
49
	}
50
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/CFThrowable.java (+256 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire;
12
13
import java.io.PrintStream;
14
import java.io.PrintWriter;
15
import java.util.HashMap;
16
import java.util.Map;
17
18
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
19
20
/**
21
 * Class to hold information about an onError event so it can be re-thrown, etc
22
 * 
23
 * @since 1.0
24
 */
25
public class CFThrowable extends Throwable {
26
27
	private Map frame = null;
28
	private Map error = null;
29
	private Map objects = null;
30
	
31
	/**
32
	 * Constructor
33
	 * @param json
34
	 */
35
	public CFThrowable(Map json) {
36
		super();
37
		if(json != null) {
38
			frame = (Map) json.get(Attributes.FRAME);
39
			if(frame != null) {
40
				processFrame();
41
			}
42
			else {
43
				Map map = (Map) json.get(Attributes.STACKTRACE);
44
				if(map != null) {
45
					//TODO process any frame infos we get
46
				}
47
			}
48
			error = (Map) json.get(Attributes.ERROR);
49
		}
50
	}
51
52
	void processFrame() {
53
		if(frame != null) {
54
			objects = new HashMap(frame.size());
55
			Map vals = (Map) frame.remove(Attributes.VALUE);
56
			if(vals != null) {
57
				vals = (Map) vals.remove(Attributes.SCRIPT);
58
				objects.put(Attributes.SCRIPT, new CFObject(Attributes.SCRIPT, (String)vals.get(Attributes.TYPE), (Number)vals.get(Attributes.HANDLE)));
59
			}
60
			vals = (Map) frame.remove(Attributes.SCOPE);
61
			if(vals != null) {
62
				objects.put(Attributes.SCOPE, new CFObject(Attributes.SCOPE, (String)vals.get(Attributes.TYPE), (Number)vals.get(Attributes.HANDLE)));
63
			}
64
			vals = (Map) frame.remove(Attributes.CALLING_FRAME);
65
			if(vals != null) {
66
				objects.put(Attributes.CALLING_FRAME, new CFObject(Attributes.CALLING_FRAME, (String)vals.get(Attributes.TYPE), (Number) vals.get(Attributes.HANDLE)));
67
			}
68
			vals = (Map) frame.remove(Attributes.EXECUTION_CONTEXT);
69
			if(vals != null) {
70
				objects.put(Attributes.EXECUTION_CONTEXT, new CFObject(Attributes.EXECUTION_CONTEXT, (String)vals.get(Attributes.TYPE), (Number) vals.get(Attributes.HANDLE)));
71
			}
72
			vals = (Map) frame.remove(Attributes.CALLEE);
73
			if(vals != null) {
74
				objects.put(Attributes.CALLEE, new CFObject(Attributes.CALLEE, (String)vals.get(Attributes.TYPE), (Number) vals.get(Attributes.HANDLE)));
75
			}
76
			vals = (Map) frame.remove(Attributes.THIS_VALUE);
77
			if(vals != null) {
78
				objects.put(Attributes.THIS_VALUE, new CFObject(Attributes.THIS_VALUE, (String)vals.get(Attributes.TYPE), (Number) vals.get(Attributes.HANDLE)));
79
			}
80
		}
81
	}
82
	
83
	/**
84
	 * Returns if the error was caused by the debugger or not
85
	 * 
86
	 * @return if the debugger caused the error or not
87
	 */
88
	public boolean isDebugger() {
89
		if(frame != null) {
90
			Boolean bool = (Boolean) error.get(Attributes.IS_DEBUGGER);
91
			if(bool != null) {
92
				return bool.booleanValue();
93
			}
94
		}
95
		return false;
96
	}
97
	
98
	/**
99
	 * Returns if the error is valid wrt the state of the Firebug debugger
100
	 * 
101
	 * @return if the error is valid
102
	 */
103
	public boolean isValid() {
104
		if(frame != null) {
105
			Boolean bool = (Boolean) error.get(Attributes.IS_VALID);
106
			if(bool != null) {
107
				return bool.booleanValue();
108
			}
109
		}
110
		return false;
111
	}
112
	
113
	/**
114
	 * Returns the line number the error originated from or -1 if it could not be determined
115
	 * 
116
	 * @return the line number of the error or -1.
117
	 */
118
	public int lineNumber() {
119
		if(error != null) {
120
			Number val = (Number) error.get(Attributes.LINE_NUMBER);
121
			if(val == null) {
122
				//try lineNo
123
				val = (Number) error.get(Attributes.LINE_NO);
124
			}
125
			if(val != null) {
126
				return val.intValue();
127
			}
128
		}
129
		return -1;
130
	}
131
	
132
	/* (non-Javadoc)
133
	 * @see java.lang.Throwable#getLocalizedMessage()
134
	 */
135
	public String getLocalizedMessage() {
136
		return getMessage();
137
	}
138
	
139
	/* (non-Javadoc)
140
	 * @see java.lang.Throwable#getMessage()
141
	 */
142
	public String getMessage() {
143
		if(error != null) {
144
			String val = (String) error.get(Attributes.MESSAGE);
145
			if(val == null) {
146
				//try errorMessage
147
				val = (String) error.get(Attributes.ERROR_MESSAGE);
148
			}
149
			return val;
150
		}
151
		return null;
152
	}
153
	
154
	/**
155
	 * Returns the column number the error originated from or -1 if it could not be determined
156
	 * 
157
	 * @return the column number or -1
158
	 */
159
	public int columnNumber() {
160
		if(error != null) {
161
			Number val = (Number) error.get(Attributes.COLUMN_NUMBER);
162
			if(val != null) {
163
				return val.intValue();
164
			}
165
		}
166
		return -1;
167
	}
168
	
169
	/**
170
	 * Returns the flags from the event or -1 if they could not be determined
171
	 * 
172
	 * @return the flags or -1
173
	 */
174
	public int getFlags() {
175
		if(error != null) {
176
			Number val = (Number) error.get(Attributes.FLAGS);
177
			if(val != null) {
178
				return val.intValue();
179
			}
180
		}
181
		return -1;
182
	}
183
	
184
	/**
185
	 * Return the category for the error or <code>null</code>
186
	 * 
187
	 * @return the error category or <code>null</code>
188
	 */
189
	public String getCategory() {
190
		if(error != null) {
191
			String val = (String) error.get(Attributes.CATEGORY);
192
			return val;
193
		}
194
		return null;
195
	}
196
	
197
	/**
198
	 * Returns the name of the script the error occurred in or <code>null</code> if it could not be determined
199
	 *  
200
	 * @return the name of the script or <code>null</code>
201
	 */
202
	public String scriptName() {
203
		if(error != null) {
204
			String val = (String) error.get(Attributes.FILE_NAME);
205
			if(val == null) {
206
				//try the source attribute
207
				val = (String) error.get(Attributes.SOURCE_NAME);
208
			}
209
			return val;
210
		}
211
		return null;
212
	}
213
	
214
	/**
215
	 * Returns the name of the function the error originated from or <code>null</code> if it could not be determined
216
	 * 
217
	 * @return the name of the function or <code>null</code>
218
	 */
219
	public String functionName() {
220
		if(frame != null) {
221
			String val = (String) frame.get(Attributes.FUNCTION_NAME);
222
			return val;
223
		}
224
		return null;
225
	}
226
	
227
	/* (non-Javadoc)
228
	 * @see java.lang.Throwable#printStackTrace()
229
	 */
230
	public void printStackTrace() {
231
		if(frame != null) {
232
			return;
233
		}
234
		super.printStackTrace();
235
	}
236
	
237
	/* (non-Javadoc)
238
	 * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
239
	 */
240
	public void printStackTrace(PrintStream s) {
241
		if(frame != null) {
242
			return;
243
		}
244
		super.printStackTrace(s);
245
	}
246
	
247
	/* (non-Javadoc)
248
	 * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
249
	 */
250
	public void printStackTrace(PrintWriter s) {
251
		if(frame != null) {
252
			return;
253
		}
254
		super.printStackTrace(s);
255
	}
256
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/Constants.java (+42 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire;
12
13
/**
14
 * Constants for the bundle
15
 * 
16
 * @since 1.0
17
 */
18
public interface Constants {
19
20
	/**
21
	 * Constant representing a space
22
	 */
23
	public static final String SPACE = " "; //$NON-NLS-1$
24
	/**
25
	 * Constant representing a colon.<br>
26
	 * <br>
27
	 * Value is: <code>:</code>
28
	 */
29
	public static final String COLON = ":"; //$NON-NLS-1$
30
	/**
31
	 * Constant representing the empty string
32
	 */
33
	public static final String EMPTY_STRING = ""; //$NON-NLS-1$
34
	/**
35
	 * UTF-8 encoding constant <br>
36
	 * <br>
37
	 * Value is: <code>UTF-8</code>
38
	 */
39
	public static final String UTF_8 = "UTF-8"; //$NON-NLS-1$
40
	public static String URI_FILE_SCHEME = "file"; //$NON-NLS-1$
41
	public static final String UNKNOWN = "unknown"; //$NON-NLS-1$
42
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/CrossFirePlugin.java (+164 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire;
12
13
import java.net.URI;
14
import java.net.URISyntaxException;
15
16
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Platform;
19
import org.eclipse.core.runtime.Plugin;
20
import org.eclipse.core.runtime.Status;
21
import org.eclipse.wst.jsdt.debug.internal.crossfire.event.CFEventQueue;
22
import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFMirror;
23
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
24
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket;
25
import org.osgi.framework.BundleActivator;
26
import org.osgi.framework.BundleContext;
27
28
/**
29
 * Crossfire {@link BundleActivator}
30
 * 
31
 * @since 1.0
32
 */
33
public class CrossFirePlugin extends Plugin {
34
35
	/**
36
	 * Id of the bundle
37
	 */
38
	public static final String PLUGIN_ID = "org.eclipse.wst.jsdt.debug.crossfire"; //$NON-NLS-1$
39
	/**
40
	 * CFPacket tracing option name
41
	 */
42
	public static final String TRC_PACKETS = PLUGIN_ID + "/packets"; //$NON-NLS-1$
43
	/**
44
	 * CFEventPacket queue tracing option name
45
	 */
46
	public static final String TRC_EVENTQUEUE = PLUGIN_ID + "/eventqueue"; //$NON-NLS-1$
47
	/**
48
	 * JSDI implementation tracing option name
49
	 */
50
	public static final String TRC_JSDI = PLUGIN_ID + "/jsdi"; //$NON-NLS-1$
51
	/**
52
	 * JSON parser tracing option
53
	 */
54
	public static final String TRC_JSON = PLUGIN_ID + "/json"; //$NON-NLS-1$
55
	
56
	/**
57
	 * Status code indicating an unexpected internal error.
58
	 */
59
	public static final int INTERNAL_ERROR = 120;
60
	
61
	private static CrossFirePlugin plugin = null;
62
63
	/*
64
	 * (non-Javadoc)
65
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
66
	 */
67
	public void start(BundleContext bundleContext) throws Exception {
68
		super.start(bundleContext);
69
		plugin = this;
70
		configureTracing();
71
	}
72
73
	/* (non-Javadoc)
74
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
75
	 */
76
	public void stop(BundleContext bundleContext) throws Exception {
77
		try {
78
			plugin = null;
79
		}
80
		finally {
81
			super.stop(bundleContext);
82
		}
83
	}
84
	
85
	/**
86
	 * @return the singleton instance
87
	 */
88
	public static CrossFirePlugin getDefault() {
89
		return plugin;
90
	}
91
	
92
	/**
93
	 * Logs the specified status with this plug-in's log.
94
	 * 
95
	 * @param status status to log
96
	 */
97
	public static void log(IStatus status) {
98
		if (plugin != null) {
99
			plugin.getLog().log(status);
100
		}
101
	}
102
103
	/**
104
	 * Logs the specified throwable with this plug-in's log.
105
	 * 
106
	 * @param t throwable to log 
107
	 */
108
	public static void log(Throwable t) {
109
		log(newErrorStatus("Error logged from Crossfire Debug: ", t)); //$NON-NLS-1$
110
	}
111
	
112
	/**
113
	 * Logs an internal error with the specified message.
114
	 * 
115
	 * @param message the error message to log
116
	 */
117
	public static void logErrorMessage(String message) {
118
		log(newErrorStatus("Internal message logged from Crossfire Debug: " + message, null)); //$NON-NLS-1$	
119
	}
120
	
121
	/**
122
	 * Returns a new error status for this plug-in with the given message
123
	 * @param message the message to be included in the status
124
	 * @param exception the exception to be included in the status or <code>null</code> if none
125
	 * @return a new error status
126
	 */
127
	public static IStatus newErrorStatus(String message, Throwable exception) {
128
		return new Status(IStatus.ERROR, PLUGIN_ID, INTERNAL_ERROR, message, exception);
129
	}
130
131
	/**
132
	 * Turns on / off any tracing options
133
	 */
134
	public void configureTracing() {
135
		if(CrossFirePlugin.getDefault().isDebugging()) {
136
			String option = Platform.getDebugOption(TRC_PACKETS);
137
			if(option != null) {
138
				CFPacket.setTracing(Boolean.valueOf(option).booleanValue());
139
			}
140
			option = Platform.getDebugOption(TRC_EVENTQUEUE);
141
			if(option != null) {
142
				CFEventQueue.setTracing(Boolean.valueOf(option).booleanValue());
143
			}
144
			option = Platform.getDebugOption(TRC_JSDI);
145
			if(option != null) {
146
				CFMirror.setTracing(Boolean.valueOf(option).booleanValue());
147
			}
148
			option = Platform.getDebugOption(TRC_JSON);
149
			if(option != null) {
150
				JSON.setTracing(Boolean.valueOf(option).booleanValue());
151
			}
152
		}
153
	}
154
	
155
	/**
156
	 * Creates a new {@link URI} with the <code>file</code> scheme
157
	 * @param path
158
	 * @return a new {@link URI}
159
	 * @throws URISyntaxException
160
	 */
161
	public static URI fileURI(IPath path) throws URISyntaxException {
162
		return new URI(Constants.URI_FILE_SCHEME, null, path.makeAbsolute().toString(), null);
163
	}
164
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/LaunchHelper.java (+109 lines)
Added Link Here
1
package org.eclipse.wst.jsdt.debug.internal.crossfire;
2
3
4
import java.util.HashMap;
5
import java.util.Iterator;
6
import java.util.Map;
7
import java.util.Map.Entry;
8
9
import org.eclipse.core.resources.IProject;
10
import org.eclipse.core.resources.ResourcesPlugin;
11
import org.eclipse.core.runtime.CoreException;
12
import org.eclipse.core.runtime.IProgressMonitor;
13
import org.eclipse.core.runtime.SubMonitor;
14
import org.eclipse.debug.core.DebugPlugin;
15
import org.eclipse.debug.core.ILaunch;
16
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.core.ILaunchConfigurationType;
18
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
19
import org.eclipse.debug.core.ILaunchManager;
20
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate2;
21
import org.eclipse.debug.core.model.ISourceLocator;
22
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
23
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
24
import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
25
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector;
26
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument;
27
import org.eclipse.wst.jsdt.debug.internal.core.launching.ILaunchConstants;
28
import org.eclipse.wst.jsdt.debug.internal.core.launching.RemoteJavaScriptLaunchDelegate;
29
import org.eclipse.wst.jsdt.debug.internal.crossfire.connect.CrossfireAttachingConnector;
30
import org.eclipse.wst.jsdt.debug.internal.crossfire.connect.CrossfireListeningConnector;
31
32
/**
33
 * 
34
 */
35
public class LaunchHelper {
36
37
	public static final String REMOTE_LAUNCH_CONFIG_TYPE_ID = "org.eclipse.wst.jsdt.debug.core.launchConfigurationType"; //$NON-NLS-1$
38
	
39
	public static ILaunchConfiguration newRemoteConfiguration(String name, boolean attach) throws CoreException {
40
		ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager();
41
		ILaunchConfigurationType type = mgr.getLaunchConfigurationType(REMOTE_LAUNCH_CONFIG_TYPE_ID);
42
		if(type != null) {
43
			ILaunchConfigurationWorkingCopy copy = type.newInstance(null, mgr.generateLaunchConfigurationName(name));
44
			Connector connector = null;
45
			if(attach) {
46
				connector = new CrossfireAttachingConnector();
47
				copy.setAttribute(ILaunchConstants.CONNECTOR_ID, CrossfireAttachingConnector.CROSSFIRE_REMOTE_ATTACH_CONNECTOR_ID);
48
			}
49
			else {
50
				connector = new CrossfireListeningConnector();
51
				copy.setAttribute(ILaunchConstants.CONNECTOR_ID, CrossfireListeningConnector.CROSSFIRE_REMOTE_ATTACH_CONNECTOR_ID);	
52
			}
53
			Map args = connector.defaultArguments();
54
			Map newargs = new HashMap();
55
			Entry entry = null;
56
			Argument arg = null;
57
			for(Iterator i = args.entrySet().iterator(); i.hasNext();) {
58
				entry = (Entry) i.next();
59
				arg = (Argument) entry.getValue();
60
				newargs.put(entry.getKey(), arg.toString());
61
			}
62
			copy.setAttribute(ILaunchConstants.ARGUMENT_MAP, newargs);
63
			return copy.doSave();
64
		}
65
		return null;
66
	}
67
	
68
	public static void doLaunch(ILaunchConfigurationDelegate2 delegate, ILaunch launch, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException {
69
		SubMonitor localmonitor = SubMonitor.convert(monitor, "launch both", 6); //$NON-NLS-1$
70
		try {
71
			delegate.launch(config, "debug", launch, localmonitor); //$NON-NLS-1$
72
			if(!localmonitor.isCanceled()) {
73
				localmonitor.worked(2);
74
			}
75
			ILaunchConfiguration cfg = newRemoteConfiguration("foo", true); //$NON-NLS-1$
76
			if(!localmonitor.isCanceled()) {
77
				localmonitor.worked(2);
78
			}
79
			if(cfg != null) {
80
				RemoteJavaScriptLaunchDelegate del = new RemoteJavaScriptLaunchDelegate();
81
				del.launch(cfg, "debug", launch, localmonitor); //$NON-NLS-1$
82
			}
83
			if(!localmonitor.isCanceled()) {
84
				localmonitor.worked(2);
85
			}
86
		}
87
		finally {
88
			if(!localmonitor.isCanceled()) {
89
				localmonitor.done();
90
			}
91
		}
92
	}
93
	
94
	public static void appendProjectContainer(ILaunch launch, String pname) {
95
		ISourceLocator loc = launch.getSourceLocator();
96
		if(loc instanceof ISourceLookupDirector) {
97
			ISourceLookupDirector director = (ISourceLookupDirector) loc;
98
			IProject pj = ResourcesPlugin.getWorkspace().getRoot().getProject(pname);
99
			if(pj.exists()) {
100
				ProjectSourceContainer container = new ProjectSourceContainer(pj, false);
101
				ISourceContainer[] containers = director.getSourceContainers();
102
				ISourceContainer[] newcontainers = new ISourceContainer[containers.length+1];
103
				newcontainers[0] = container;
104
				System.arraycopy(containers, 0, newcontainers, 1, containers.length);
105
				director.setSourceContainers(newcontainers);
106
			}
107
		}
108
	}
109
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/Tracing.java (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire;
12
13
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
14
15
/**
16
 * Helper class for common tracing functions
17
 * 
18
 * @since 1.0
19
 */
20
public class Tracing {
21
22
	public static final String PRINTABLE_LINE_FEED = "\\\\r\\\\n"; //$NON-NLS-1$
23
	
24
	/**
25
	 * Writes the string to system out cleaning it of control chars before printing it
26
	 * 
27
	 * @param string
28
	 */
29
	public static void writeString(String string) {
30
		String s = string.replaceAll(JSON.LINE_FEED, PRINTABLE_LINE_FEED);
31
		s = s.replaceAll("\r", "\\\\r");  //$NON-NLS-1$//$NON-NLS-2$
32
		s = s.replaceAll("\n", "\\\\n");  //$NON-NLS-1$//$NON-NLS-2$
33
		System.out.println("[CROSSFIRE]" + s); //$NON-NLS-1$
34
	}
35
	
36
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/BrowserArgument.java (+91 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument;
14
15
/**
16
 * Option to automatically launch the browser and connect to it
17
 * 
18
 * @since 1.0
19
 */
20
public class BrowserArgument implements BooleanArgument {
21
22
	/**
23
	 * name of the argument
24
	 */
25
	public static final String BROWSER = "browser"; //$NON-NLS-1$
26
	
27
	private boolean doit = false; 
28
	
29
	/* (non-Javadoc)
30
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
31
	 */
32
	public String description() {
33
		return Messages.auto_attach_desc;
34
	}
35
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
38
	 */
39
	public String label() {
40
		return Messages.auto_attach_label;
41
	}
42
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
45
	 */
46
	public boolean mustSpecify() {
47
		return false;
48
	}
49
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
52
	 */
53
	public String name() {
54
		return BROWSER;
55
	}
56
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
59
	 */
60
	public void setValue(String value) {
61
		doit = Boolean.valueOf(value).booleanValue();
62
	}
63
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
66
	 */
67
	public String value() {
68
		return Boolean.toString(doit);
69
	}
70
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#booleanValue()
73
	 */
74
	public boolean booleanValue() {
75
		return doit;
76
	}
77
78
	/* (non-Javadoc)
79
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#isValid(java.lang.String)
80
	 */
81
	public boolean isValid(String value) {
82
		return true;
83
	}
84
85
	/* (non-Javadoc)
86
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#setValue(boolean)
87
	 */
88
	public void setValue(boolean booleanValue) {
89
		doit = booleanValue;
90
	}
91
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/ConsoleArgument.java (+89 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument;
15
16
/**
17
 * An {@link Argument} to enable the <code>console</code> tool
18
 * 
19
 * @since 1.0
20
 */
21
public class ConsoleArgument implements BooleanArgument {
22
23
	public static final String CONSOLE = "console"; //$NON-NLS-1$
24
	
25
	private boolean fValue = true;
26
	
27
	/* (non-Javadoc)
28
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
29
	 */
30
	public String description() {
31
		return Messages.console_arg_description;
32
	}
33
34
	/* (non-Javadoc)
35
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
36
	 */
37
	public String label() {
38
		return Messages.console_arg_label;
39
	}
40
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
43
	 */
44
	public boolean mustSpecify() {
45
		return true;
46
	}
47
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
50
	 */
51
	public String name() {
52
		return CONSOLE;
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
57
	 */
58
	public void setValue(String value) {
59
		fValue = Boolean.valueOf(value).booleanValue();
60
	}
61
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
64
	 */
65
	public String value() {
66
		return Boolean.toString(fValue);
67
	}
68
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#booleanValue()
71
	 */
72
	public boolean booleanValue() {
73
		return fValue;
74
	}
75
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#isValid(java.lang.String)
78
	 */
79
	public boolean isValid(String value) {
80
		return value != null;
81
	}
82
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#setValue(boolean)
85
	 */
86
	public void setValue(boolean booleanValue) {
87
		fValue = booleanValue;
88
	}
89
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/CrossfireAttachingConnector.java (+194 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
12
13
import java.io.IOException;
14
import java.util.ArrayList;
15
import java.util.HashMap;
16
import java.util.Map;
17
18
import org.eclipse.core.runtime.Platform;
19
import org.eclipse.osgi.util.NLS;
20
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
21
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.AttachingConnector;
22
import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFVirtualMachine;
23
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFTransportService;
24
import org.eclipse.wst.jsdt.debug.transport.Connection;
25
import org.eclipse.wst.jsdt.debug.transport.DebugSession;
26
import org.eclipse.wst.jsdt.debug.transport.TransportService;
27
28
/**
29
 * Attaching connector for Crossfire
30
 * 
31
 * @since 1.0
32
 */
33
public class CrossfireAttachingConnector implements AttachingConnector {
34
35
	public static final String CROSSFIRE_REMOTE_ATTACH_CONNECTOR_ID = "crossfire.remote.attach.connector"; //$NON-NLS-1$
36
37
	/**
38
	 * Constructor
39
	 */
40
	public CrossfireAttachingConnector() {
41
	}
42
43
	/*
44
	 * (non-Javadoc)
45
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#defaultArguments()
46
	 */
47
	public Map defaultArguments() {
48
		HashMap args = new HashMap(5);
49
		args.put(HostArgument.HOST, new HostArgument(null));
50
		args.put(PortArgument.PORT, new PortArgument(5000));
51
		args.put(TimeoutArgument.TIMEOUT, new TimeoutArgument());
52
		args.put(ConsoleArgument.CONSOLE, new ConsoleArgument());
53
		args.put(DOMArgument.DOM, new DOMArgument());
54
		args.put(InspectorArgument.INSPECTOR, new InspectorArgument());
55
		args.put(NetArgument.NET, new NetArgument());
56
		args.put(TraceArgument.TRACE, new TraceArgument());
57
		//XXX hack because there is no good way to find the Firefox executable on Win
58
		if(!Platform.OS_WIN32.equals(Platform.getOS())) {
59
			args.put(BrowserArgument.BROWSER, new BrowserArgument());
60
		}
61
		return args;
62
	}
63
64
	/*
65
	 * (non-Javadoc)
66
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#description()
67
	 */
68
	public String description() {
69
		return Messages.attach_connector_desc;
70
	}
71
72
	/*
73
	 * (non-Javadoc)
74
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#name()
75
	 */
76
	public String name() {
77
		return Messages.crossfire_remote_attach;
78
	}
79
80
	/*
81
	 * (non-Javadoc)
82
	 * 
83
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#id()
84
	 */
85
	public String id() {
86
		return CROSSFIRE_REMOTE_ATTACH_CONNECTOR_ID;
87
	}
88
89
	/*
90
	 * (non-Javadoc)
91
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.AttachingConnector#attach
92
	 * (java.util.Map)
93
	 */
94
	public VirtualMachine attach(Map arguments) throws IOException {
95
		String str = (String) arguments.get(BrowserArgument.BROWSER);
96
		//XXX hack because there is no good way to find the Firefox executable on Win
97
		boolean browser = Boolean.valueOf(str).booleanValue() && !Platform.OS_WIN32.equals(Platform.getOS());
98
		if (browser && !HostArgument.isLocalhost((String) arguments.get(HostArgument.HOST))) {
99
			// we cannot auto launch the browser on a different host
100
			throw new IOException(Messages.cannot_launch_browser_not_localhost);
101
		}
102
		Connection c = null;
103
		if (browser) {
104
			c = launchForBrowser(arguments);
105
		} else {
106
			c = launch(arguments);
107
		}
108
		DebugSession session = new DebugSession(c);
109
		return new CFVirtualMachine(session);
110
	}
111
112
	/**
113
	 * Launches the browser and connects to it. This method will poll for the
114
	 * browser to be launched but only for a fixed timeout.
115
	 * 
116
	 * @param arguments
117
	 * @return the created connection or <code>null</code> if the attempt to
118
	 *         connect times out, the browser process terminates before we can
119
	 *         connect
120
	 * @throws IOException
121
	 */
122
	Connection launchForBrowser(final Map arguments) throws IOException {
123
		String host = (String) arguments.get(HostArgument.HOST);
124
		String port = (String) arguments.get(PortArgument.PORT);
125
		StringBuffer buffer = new StringBuffer("firefox -ProfileManager -load-fb-modules -crossfire-server-port ").append(port); //$NON-NLS-1$
126
		Process p = Runtime.getRuntime().exec(buffer.toString());
127
		TransportService service = new CFTransportService(getToolArgs(arguments));
128
		String timeoutstr = (String) arguments.get(TimeoutArgument.TIMEOUT);
129
		int timeout = Integer.parseInt(timeoutstr);
130
		buffer = new StringBuffer();
131
		buffer.append(host).append(':').append(Integer.parseInt(port));
132
		long timer = System.currentTimeMillis() + 20000;
133
		Connection c = null;
134
		while (p != null && System.currentTimeMillis() < timer && c == null) {
135
			try {
136
				c = service.attach(buffer.toString(), timeout,timeout);
137
			} catch (IOException ioe) {
138
				// ignore while pinging to connect
139
				try {
140
					Thread.sleep(200);
141
				} catch (InterruptedException e) {
142
					//do nothing
143
				}
144
			}
145
		}
146
		if (c == null) {
147
			throw new IOException(NLS.bind(Messages.failed_to_attach_to_auto_browser, new String[] {host, port }));
148
		}
149
		return c;
150
	}
151
152
	/**
153
	 * Tries to connect to the given
154
	 * 
155
	 * @param arguments
156
	 * @return the {@link Connection} or throws an exception
157
	 * @throws IOException
158
	 */
159
	Connection launch(Map arguments) throws IOException {
160
		TransportService service = new CFTransportService(getToolArgs(arguments));
161
		String host = (String) arguments.get(HostArgument.HOST);
162
		String port = (String) arguments.get(PortArgument.PORT);
163
		String timeoutstr = (String) arguments.get(TimeoutArgument.TIMEOUT);
164
		int timeout = Integer.parseInt(timeoutstr);
165
		StringBuffer buffer = new StringBuffer();
166
		buffer.append(host).append(':').append(Integer.parseInt(port));
167
		return service.attach(buffer.toString(), timeout, timeout);
168
	}
169
	
170
	String[] getToolArgs(Map arguments) {
171
		ArrayList tools = new ArrayList();
172
		String value = (String) arguments.get(ConsoleArgument.CONSOLE);
173
		if(Boolean.valueOf(value).booleanValue()) {
174
			tools.add(ConsoleArgument.CONSOLE);
175
		}
176
		value = (String) arguments.get(DOMArgument.DOM);
177
		if(Boolean.valueOf(value).booleanValue()) {
178
			tools.add(DOMArgument.DOM);
179
		}
180
		value = (String) arguments.get(InspectorArgument.INSPECTOR);
181
		if(Boolean.valueOf(value).booleanValue()) {
182
			tools.add(InspectorArgument.INSPECTOR);
183
		}
184
		value = (String) arguments.get(NetArgument.NET);
185
		if(Boolean.valueOf(value).booleanValue()) {
186
			tools.add(NetArgument.NET);
187
		}
188
		value = (String) arguments.get(TraceArgument.TRACE);
189
		if(Boolean.valueOf(value).booleanValue()) {
190
			tools.add(TraceArgument.TRACE);
191
		}
192
		return (String[]) tools.toArray(new String[tools.size()]);
193
	}
194
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/CrossfireListeningConnector.java (+91 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
12
13
import java.io.IOException;
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
18
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.ListeningConnector;
19
import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFVirtualMachine;
20
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFTransportService;
21
import org.eclipse.wst.jsdt.debug.transport.Connection;
22
import org.eclipse.wst.jsdt.debug.transport.DebugSession;
23
import org.eclipse.wst.jsdt.debug.transport.TransportService;
24
25
/**
26
 * Default launching connector for CrossFire
27
 * 
28
 * @since 1.0
29
 */
30
public class CrossfireListeningConnector implements ListeningConnector {
31
	
32
	/**
33
	 * The id of the connector
34
	 */
35
	public static final String CROSSFIRE_REMOTE_ATTACH_CONNECTOR_ID = "crossfire.remote.listen.connector"; //$NON-NLS-1$
36
37
	/**
38
	 * Constructor
39
	 */
40
	public CrossfireListeningConnector() {
41
	}
42
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#defaultArguments()
45
	 */
46
	public Map defaultArguments() {
47
		HashMap args = new HashMap(5);
48
		args.put(HostArgument.HOST, new HostArgument(null));
49
		args.put(PortArgument.PORT, new PortArgument(5000));
50
		args.put(TimeoutArgument.TIMEOUT, new TimeoutArgument());
51
		args.put(ConsoleArgument.CONSOLE, new ConsoleArgument());
52
		return args;
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#description()
57
	 */
58
	public String description() {
59
		return Messages.attach_connector_desc;
60
	}
61
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#name()
64
	 */
65
	public String name() {
66
		return Messages.attach_connector_name;
67
	}
68
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector#id()
71
	 */
72
	public String id() {
73
		return CROSSFIRE_REMOTE_ATTACH_CONNECTOR_ID;
74
	}
75
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.ListeningConnector#accept(java.util.Map)
78
	 */
79
	public VirtualMachine accept(Map arguments) throws IOException {
80
		TransportService service = new CFTransportService(null);
81
		String host = (String) arguments.get(HostArgument.HOST);
82
		String port = (String) arguments.get(PortArgument.PORT);
83
		String timeoutstr = (String) arguments.get(TimeoutArgument.TIMEOUT);
84
		int timeout = Integer.parseInt(timeoutstr);
85
		StringBuffer buffer = new StringBuffer();
86
		buffer.append(host).append(':').append(Integer.parseInt(port));
87
		Connection c = service.accept(service.startListening(buffer.toString()), timeout, timeout);
88
		DebugSession session = new DebugSession(c);
89
		return new CFVirtualMachine(session);
90
	}
91
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/DOMArgument.java (+89 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument;
15
16
/**
17
 * An {@link Argument} to enable DOM tooling support in the crossfire server
18
 * 
19
 * @since 1.0
20
 */
21
public class DOMArgument implements BooleanArgument {
22
23
	public static final String DOM = "dom"; //$NON-NLS-1$
24
	
25
	private boolean fValue = true;
26
	
27
	/* (non-Javadoc)
28
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
29
	 */
30
	public String description() {
31
		return Messages.dom_arg_description;
32
	}
33
34
	/* (non-Javadoc)
35
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
36
	 */
37
	public String label() {
38
		return Messages.dom_arg_label;
39
	}
40
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
43
	 */
44
	public boolean mustSpecify() {
45
		return true;
46
	}
47
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
50
	 */
51
	public String name() {
52
		return DOM;
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
57
	 */
58
	public void setValue(String value) {
59
		fValue = Boolean.valueOf(value).booleanValue();
60
	}
61
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
64
	 */
65
	public String value() {
66
		return Boolean.toString(fValue);
67
	}
68
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#booleanValue()
71
	 */
72
	public boolean booleanValue() {
73
		return fValue;
74
	}
75
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#isValid(java.lang.String)
78
	 */
79
	public boolean isValid(String value) {
80
		return value != null;
81
	}
82
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#setValue(boolean)
85
	 */
86
	public void setValue(boolean booleanValue) {
87
		fValue = booleanValue;
88
	}
89
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/HostArgument.java (+105 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.StringArgument;
14
import org.eclipse.wst.jsdt.debug.transport.Constants;
15
16
/**
17
 * Implementation of a string argument that describes the host argument
18
 * 
19
 * @since 1.0
20
 */
21
public class HostArgument implements StringArgument {
22
23
	private static final long serialVersionUID = 3057403815318177030L;
24
	private String host;
25
26
	/**
27
	 * Host attribute name
28
	 */
29
	public static final String HOST = "host"; //$NON-NLS-1$
30
31
	/**
32
	 * Constructor
33
	 * 
34
	 * @param host
35
	 */
36
	public HostArgument(String host) {
37
		setValue(host);
38
	}
39
40
	/* (non-Javadoc)
41
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
42
	 */
43
	public String description() {
44
		return Messages.host_arg_desc;
45
	}
46
47
	/* (non-Javadoc)
48
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.StringArgument#isValid(java.lang.String)
49
	 */
50
	public boolean isValid(String value) {
51
		return value != null;
52
	}
53
54
	/* (non-Javadoc)
55
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
56
	 */
57
	public String label() {
58
		return Messages.host_arg_name;
59
	}
60
61
	/* (non-Javadoc)
62
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
63
	 */
64
	public boolean mustSpecify() {
65
		return true;
66
	}
67
	
68
	/* (non-Javadoc)
69
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
70
	 */
71
	public String name() {
72
		return HOST;
73
	}
74
75
	/* (non-Javadoc)
76
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
77
	 */
78
	public void setValue(String host) {
79
		if(host == null) {
80
			this.host = Constants.LOCALHOST;
81
		}
82
		else {
83
			if (!isValid(host)) {
84
				throw new IllegalArgumentException();
85
			}
86
			this.host = host;
87
		}
88
	}
89
90
	/* (non-Javadoc)
91
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
92
	 */
93
	public String value() {
94
		return host;
95
	}
96
97
	/**
98
	 * Returns if the given host is <code>localhost</code> or <code>127.0.0.1</code>
99
	 * @param host
100
	 * @return true if the given host it localhost (127.0.0.1) false otherwise
101
	 */
102
	public static boolean isLocalhost(String host) {
103
		return host.equals(Constants.LOCALHOST) || host.equals(Constants.LOCALHOST_IP);
104
	}
105
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/InspectorArgument.java (+89 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument;
15
16
/**
17
 * An {@link Argument} to allow the page inspector tooling to be enabled in the 
18
 * Crossfire server
19
 * 
20
 * @since 1.0
21
 */
22
public class InspectorArgument implements BooleanArgument {
23
24
	public static final String INSPECTOR = "inspector"; //$NON-NLS-1$
25
	private boolean fValue = true;
26
	
27
	/* (non-Javadoc)
28
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
29
	 */
30
	public String description() {
31
		return Messages.inspector_arg_description;
32
	}
33
34
	/* (non-Javadoc)
35
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
36
	 */
37
	public String label() {
38
		return Messages.inspector_arg_label;
39
	}
40
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
43
	 */
44
	public boolean mustSpecify() {
45
		return true;
46
	}
47
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
50
	 */
51
	public String name() {
52
		return INSPECTOR;
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
57
	 */
58
	public void setValue(String value) {
59
		fValue = Boolean.valueOf(value).booleanValue();
60
	}
61
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
64
	 */
65
	public String value() {
66
		return Boolean.toString(fValue);
67
	}
68
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#booleanValue()
71
	 */
72
	public boolean booleanValue() {
73
		return fValue;
74
	}
75
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#isValid(java.lang.String)
78
	 */
79
	public boolean isValid(String value) {
80
		return value != null;
81
	}
82
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#setValue(boolean)
85
	 */
86
	public void setValue(boolean booleanValue) {
87
		fValue = booleanValue;
88
	}
89
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/Messages.java (+50 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
12
13
import org.eclipse.osgi.util.NLS;
14
15
/**
16
 *
17
 */
18
public class Messages extends NLS {
19
	private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.crossfire.connect.messages"; //$NON-NLS-1$
20
	public static String attach_connector_desc;
21
	public static String attach_connector_name;
22
	public static String auto_attach_desc;
23
	public static String auto_attach_label;
24
	public static String cannot_launch_browser_not_localhost;
25
	public static String console_arg_description;
26
	public static String console_arg_label;
27
	public static String crossfire_remote_attach;
28
	public static String dom_arg_description;
29
	public static String dom_arg_label;
30
	public static String failed_to_attach_to_auto_browser;
31
	public static String host_arg_desc;
32
	public static String host_arg_name;
33
	public static String inspector_arg_description;
34
	public static String inspector_arg_label;
35
	public static String net_arg_description;
36
	public static String net_arg_label;
37
	public static String port_arg_desc;
38
	public static String port_arg_name;
39
	public static String timeout;
40
	public static String timeout_desc;
41
	public static String trace_arg_description;
42
	public static String trace_arg_label;
43
	static {
44
		// initialize resource bundle
45
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
46
	}
47
48
	private Messages() {
49
	}
50
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/NetArgument.java (+89 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument;
15
16
/**
17
 * An {@link Argument} to allow the the Net panel and support to be enabled in the Crossfire server
18
 * 
19
 * @since 1.0
20
 */
21
public class NetArgument implements BooleanArgument {
22
23
	public static final String NET = "net"; //$NON-NLS-1$
24
	
25
	private boolean fValue = true;
26
	
27
	/* (non-Javadoc)
28
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
29
	 */
30
	public String description() {
31
		return Messages.net_arg_description;
32
	}
33
34
	/* (non-Javadoc)
35
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
36
	 */
37
	public String label() {
38
		return Messages.net_arg_label;
39
	}
40
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
43
	 */
44
	public boolean mustSpecify() {
45
		return true;
46
	}
47
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
50
	 */
51
	public String name() {
52
		return NET;
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
57
	 */
58
	public void setValue(String value) {
59
		fValue = Boolean.valueOf(value).booleanValue();
60
	}
61
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
64
	 */
65
	public String value() {
66
		return Boolean.toString(fValue);
67
	}
68
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#booleanValue()
71
	 */
72
	public boolean booleanValue() {
73
		return fValue;
74
	}
75
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#isValid(java.lang.String)
78
	 */
79
	public boolean isValid(String value) {
80
		return value != null;
81
	}
82
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#setValue(boolean)
85
	 */
86
	public void setValue(boolean booleanValue) {
87
		fValue = booleanValue;
88
	}
89
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/PortArgument.java (+133 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument;
14
15
/**
16
 * Implementation of an {@link IntegerArgument} that describes the port to try connecting to
17
 * 
18
 * @since 1.0
19
 */
20
public class PortArgument implements IntegerArgument {
21
22
	private static final long serialVersionUID = -1954469572907116388L;
23
	private int port;
24
25
	/**
26
	 * The port attribute name
27
	 */
28
	public static final String PORT = "port"; //$NON-NLS-1$
29
30
	/**
31
	 * Constructor
32
	 * 
33
	 * @param port
34
	 */
35
	public PortArgument(int port) {
36
		setValue(port);
37
	}
38
39
	/* (non-Javadoc)
40
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#intValue()
41
	 */
42
	public int intValue() {
43
		return port;
44
	}
45
46
	/* (non-Javadoc)
47
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#isValid(int)
48
	 */
49
	public boolean isValid(int intValue) {
50
		return intValue > 0;
51
	}
52
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#max()
55
	 */
56
	public int max() {
57
		return Integer.MAX_VALUE;
58
	}
59
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#min()
62
	 */
63
	public int min() {
64
		return 1;
65
	}
66
67
	/* (non-Javadoc)
68
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#setValue(int)
69
	 */
70
	public void setValue(int port) {
71
		this.port = port;
72
	}
73
74
	/* (non-Javadoc)
75
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
76
	 */
77
	public String description() {
78
		return Messages.port_arg_desc;
79
	}
80
81
	/* (non-Javadoc)
82
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#isValid(java.lang.String)
83
	 */
84
	public boolean isValid(String value) {
85
		try {
86
			int intValue = Integer.parseInt(value);
87
			return isValid(intValue);
88
		} catch (NumberFormatException e) {
89
			return false;
90
		}
91
	}
92
93
	/* (non-Javadoc)
94
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
95
	 */
96
	public String label() {
97
		return Messages.port_arg_name;
98
	}
99
100
	/* (non-Javadoc)
101
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
102
	 */
103
	public boolean mustSpecify() {
104
		return true;
105
	}
106
107
	/* (non-Javadoc)
108
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
109
	 */
110
	public String name() {
111
		return PORT;
112
	}
113
114
	/* (non-Javadoc)
115
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
116
	 */
117
	public void setValue(String value) {
118
		try {
119
			int intValue = Integer.parseInt(value);
120
			setValue(intValue);
121
		} catch (NumberFormatException nfe) {
122
			// re-throw IllegalArgumentException
123
			throw new IllegalArgumentException(nfe.getMessage());
124
		}
125
	}
126
127
	/* (non-Javadoc)
128
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
129
	 */
130
	public String value() {
131
		return Integer.toString(port);
132
	}
133
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/TimeoutArgument.java (+138 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument;
14
15
/**
16
 * Argument used to specify a timeout (in ms)
17
 * 
18
 * @since 1.1
19
 */
20
public class TimeoutArgument implements IntegerArgument {
21
	
22
	/**
23
	 * Argument to specify a timeout
24
	 */
25
	public static final String TIMEOUT = "timeout"; //$NON-NLS-1$
26
	/**
27
	 * default connecting timeout
28
	 */
29
	public static final Integer CONNECT_TIMEOUT = new Integer(30000);
30
	
31
	/**
32
	 * The timeout
33
	 */
34
	private int timeout = 0;
35
	
36
	/**
37
	 * Constructor
38
	 */
39
	public TimeoutArgument() {
40
		setValue(CONNECT_TIMEOUT.intValue());
41
	}
42
	
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
45
	 */
46
	public String description() {
47
		return Messages.timeout_desc;
48
	}
49
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
52
	 */
53
	public String label() {
54
		return Messages.timeout;
55
	}
56
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
59
	 */
60
	public boolean mustSpecify() {
61
		return true;
62
	}
63
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
66
	 */
67
	public String name() {
68
		return TIMEOUT;
69
	}
70
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
73
	 */
74
	public void setValue(String value) {
75
		try {
76
			timeout = Integer.parseInt(value);
77
		}
78
		catch(NumberFormatException nfe) {
79
			//do nothing the new value will not be set
80
		}
81
	}
82
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
85
	 */
86
	public String value() {
87
		return Integer.toString(timeout);
88
	}
89
90
	/* (non-Javadoc)
91
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#intValue()
92
	 */
93
	public int intValue() {
94
		return timeout;
95
	}
96
97
	/* (non-Javadoc)
98
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#isValid(int)
99
	 */
100
	public boolean isValid(int intValue) {
101
		return intValue > 0;
102
	}
103
104
	/* (non-Javadoc)
105
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#isValid(java.lang.String)
106
	 */
107
	public boolean isValid(String value) {
108
		try {
109
			return Integer.parseInt(value) > 0;
110
		}
111
		catch(NumberFormatException bfe) {
112
			//do nothing, just not valid
113
		}
114
		return false;
115
	}
116
117
	/* (non-Javadoc)
118
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#max()
119
	 */
120
	public int max() {
121
		return Integer.MAX_VALUE;
122
	}
123
124
	/* (non-Javadoc)
125
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#min()
126
	 */
127
	public int min() {
128
		return 0;
129
	}
130
131
	/* (non-Javadoc)
132
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.IntegerArgument#setValue(int)
133
	 */
134
	public void setValue(int intValue) {
135
		timeout = intValue;
136
	}
137
138
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/TraceArgument.java (+89 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.connect;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument;
15
16
/**
17
 * An {@link Argument} to allow server error tracing to be reported back to the client
18
 * 
19
 * @since 1.0
20
 */
21
public class TraceArgument implements BooleanArgument {
22
23
	public static final String TRACE = "trace"; //$NON-NLS-1$
24
	
25
	private boolean fValue = false;
26
	
27
	/* (non-Javadoc)
28
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#description()
29
	 */
30
	public String description() {
31
		return Messages.trace_arg_description;
32
	}
33
34
	/* (non-Javadoc)
35
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#label()
36
	 */
37
	public String label() {
38
		return Messages.trace_arg_label;
39
	}
40
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#mustSpecify()
43
	 */
44
	public boolean mustSpecify() {
45
		return true;
46
	}
47
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#name()
50
	 */
51
	public String name() {
52
		return TRACE;
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#setValue(java.lang.String)
57
	 */
58
	public void setValue(String value) {
59
		fValue = Boolean.valueOf(value).booleanValue();
60
	}
61
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.Argument#value()
64
	 */
65
	public String value() {
66
		return Boolean.toString(fValue);
67
	}
68
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#booleanValue()
71
	 */
72
	public boolean booleanValue() {
73
		return fValue;
74
	}
75
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#isValid(java.lang.String)
78
	 */
79
	public boolean isValid(String value) {
80
		return value != null;
81
	}
82
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.connect.Connector.BooleanArgument#setValue(boolean)
85
	 */
86
	public void setValue(boolean booleanValue) {
87
		fValue = booleanValue;
88
	}
89
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/connect/messages.properties (+33 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2010, 2011 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
attach_connector_desc=Allows you to connect to a Mozilla-based browser with the CrossFire extension installed
12
attach_connector_name=CrossFire - Remote Listen
13
auto_attach_desc=Automatically launch Firefox and attach to it
14
auto_attach_label=Auto&matically launch Firefox and attach to it (extremely experimental)
15
cannot_launch_browser_not_localhost=You cannot launch a browser on a different host than localhost (127.0.0.1)
16
console_arg_description=Allows Crossfire to forward messages logged in the Firebug console to the Eclipse Error Log.
17
console_arg_label=Enable Firebug console message logging in the Error &Log
18
crossfire_remote_attach=Crossfire - Remote Attach
19
dom_arg_description=Allows the client to take part in DOM inspections
20
dom_arg_label=Enable DO&M inspection support
21
failed_to_attach_to_auto_browser=Failed to attach to debugger at {0} on port {1}
22
host_arg_desc=The name of the host address to try attaching to.
23
host_arg_name=&Host:
24
inspector_arg_description=Allows the client to enable page inspections in the Crossfire server
25
inspector_arg_label=Enable pa&ge inspections
26
net_arg_description=Allows network traffic inspections to be enabled in the Crossfire server
27
net_arg_label=Enable network tra&ffic inspections
28
port_arg_desc=The port on the host machine to try attaching to.
29
port_arg_name=&Port:
30
timeout=&Timeout (ms):
31
timeout_desc=A timeout value in milliseconds to wait for a debugger to connect
32
trace_arg_description=Allows server error tracing to be enabled. When enabled exception messages and stack traces are returned with failure error codes.
33
trace_arg_label=Enable server error tr&acing
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFBreakpointEvent.java (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
16
import org.eclipse.wst.jsdt.debug.core.jsdi.event.BreakpointEvent;
17
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
18
19
/**
20
 * Default implementation of {@link BreakpointEvent} for Crossfire
21
 * 
22
 * @since 1.0
23
 */
24
public class CFBreakpointEvent extends CFLocatableEvent implements BreakpointEvent {
25
26
	/**
27
	 * Constructor
28
	 * @param vm
29
	 * @param request
30
	 * @param thread
31
	 * @param location
32
	 */
33
	public CFBreakpointEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, Location location) {
34
		super(vm, request, thread, location);
35
	}
36
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFDebuggerStatementEvent.java (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
16
import org.eclipse.wst.jsdt.debug.core.jsdi.event.DebuggerStatementEvent;
17
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
18
19
/**
20
 * Default implementation of {@link DebuggerStatementEvent} for Crossfire
21
 * 
22
 * @since 1.0
23
 */
24
public class CFDebuggerStatementEvent extends CFLocatableEvent implements DebuggerStatementEvent {
25
26
	/**
27
	 * Constructor
28
	 * @param vm
29
	 * @param request
30
	 * @param thread
31
	 * @param location
32
	 */
33
	public CFDebuggerStatementEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, Location location) {
34
		super(vm, request, thread, location);
35
	}
36
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEvent.java (+51 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.event.Event;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
16
17
/**
18
 * Default implementation of an {@link CFEvent} for Crossfire
19
 * 
20
 * @since 1.0
21
 */
22
public class CFEvent implements Event {
23
24
	private VirtualMachine vm = null;
25
	private EventRequest request = null;
26
	
27
	/**
28
	 * Constructor
29
	 * 
30
	 * @param vm
31
	 * @param request
32
	 */
33
	public CFEvent(VirtualMachine vm, EventRequest request) {
34
		this.vm = vm;
35
		this.request = request;
36
	}
37
	
38
	/* (non-Javadoc)
39
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Mirror#virtualMachine()
40
	 */
41
	public VirtualMachine virtualMachine() {
42
		return vm;
43
	}
44
45
	/* (non-Javadoc)
46
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.Event#request()
47
	 */
48
	public EventRequest request() {
49
		return request;
50
	}
51
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEventQueue.java (+391 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
12
13
import java.util.Iterator;
14
import java.util.List;
15
import java.util.Map;
16
import java.util.Map.Entry;
17
18
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.MultiStatus;
20
import org.eclipse.core.runtime.Status;
21
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
22
import org.eclipse.wst.jsdt.debug.core.jsdi.event.EventQueue;
23
import org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet;
24
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager;
25
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ResumeRequest;
26
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ScriptLoadRequest;
27
import org.eclipse.wst.jsdt.debug.core.jsdi.request.SuspendRequest;
28
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadEnterRequest;
29
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadExitRequest;
30
import org.eclipse.wst.jsdt.debug.core.jsdi.request.VMDeathRequest;
31
import org.eclipse.wst.jsdt.debug.internal.crossfire.CFThrowable;
32
import org.eclipse.wst.jsdt.debug.internal.crossfire.CrossFirePlugin;
33
import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
34
import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFLocation;
35
import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFMirror;
36
import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFScriptReference;
37
import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFThreadReference;
38
import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFVirtualMachine;
39
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
40
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFEventPacket;
41
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
42
import org.eclipse.wst.jsdt.debug.transport.exception.DisconnectedException;
43
import org.eclipse.wst.jsdt.debug.transport.exception.TimeoutException;
44
45
/**
46
 * Default {@link EventQueue} for Crossfire
47
 * 
48
 * @since 1.0
49
 */
50
public class CFEventQueue extends CFMirror implements EventQueue {
51
52
	private static boolean TRACE = false;
53
	
54
	private EventRequestManager eventmgr = null;
55
	private boolean disposed = false;
56
	
57
	/**
58
	 * Constructor
59
	 * 
60
	 * @param vm
61
	 * @param manager
62
	 */
63
	public CFEventQueue(CFVirtualMachine vm, EventRequestManager manager) {
64
		super(vm);
65
		this.eventmgr = manager;
66
	}
67
	
68
	/* (non-Javadoc)
69
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.EventQueue#remove()
70
	 */
71
	public EventSet remove() {
72
		return remove(-1);
73
	}
74
75
	/* (non-Javadoc)
76
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.EventQueue#remove(int)
77
	 */
78
	public EventSet remove(int timeout) {
79
		try {
80
			while(true && !disposed) {
81
				CFEventPacket event = crossfire().receiveEvent(timeout);
82
				String name = event.getEvent();
83
				CFEventSet set = new CFEventSet(crossfire());
84
				if(CFEventPacket.CLOSED.equals(name)) {
85
					List deaths = eventmgr.vmDeathRequests();
86
					for (Iterator iter = deaths.iterator(); iter.hasNext();) {
87
						VMDeathRequest request = (VMDeathRequest) iter.next();
88
						set.add(new CFVMDeathEvent(crossfire(), request));
89
					}
90
					if(TRACE) {
91
						Tracing.writeString("QUEUE [event - "+CFEventPacket.CLOSED+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
92
					}
93
				}
94
				else if(CFEventPacket.ON_BREAK.equals(name)) {
95
					if(TRACE) {
96
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_BREAK+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
97
					}
98
					String threadid = event.getContextId();
99
					if(threadid != null) {
100
						CFThreadReference thread = crossfire().findThread(threadid);
101
						set.setThread(thread);
102
						if(thread != null && !thread.isSuspended()) {
103
							List suspends = eventmgr.suspendRequests();
104
							for (Iterator iter = suspends.iterator(); iter.hasNext();) {
105
								SuspendRequest request = (SuspendRequest) iter.next();
106
								Map locaction = (Map) event.getBody().get(Attributes.LOCATION);
107
								if(locaction == null) {
108
									continue;
109
								}
110
								String url = (String) locaction.get(Attributes.URL);
111
								Number line = (Number) locaction.get(Attributes.LINE);
112
								CFScriptReference script = crossfire().findScript(url);
113
								if(script != null) {
114
									CFLocation loc = new CFLocation(crossfire(), script, null, line.intValue());
115
									set.add(new CFSuspendEvent(crossfire(), request, thread, loc));
116
								}
117
							}
118
							thread.markSuspended(true);
119
						}
120
						else {
121
							return null;
122
						}
123
					}
124
					else {
125
						return null;
126
					}
127
				}
128
				else if(CFEventPacket.ON_RESUME.equals(name)) {
129
					if(TRACE) {
130
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_RESUME+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
131
					}
132
					String threadid = event.getContextId();
133
					if(threadid != null) {
134
						CFThreadReference thread = crossfire().findThread(threadid);
135
						if(thread != null) {
136
							set.setThread(thread);
137
							List resumes = eventmgr.resumeRequests();
138
							for (Iterator iter = resumes.iterator(); iter.hasNext();) {
139
								ResumeRequest request = (ResumeRequest) iter.next();
140
								if(request.thread().equals(thread)) {
141
									CFLocation loc = new CFLocation(crossfire(), null, null, 0);
142
									set.add(new CFResumeEvent(crossfire(), request, thread, loc));
143
								}
144
							}
145
							thread.eventResume();
146
						}
147
						else {
148
							return null;
149
						}
150
					}
151
					else {
152
						return null;
153
					}
154
				}
155
				else if(CFEventPacket.ON_SCRIPT.equals(name)) {
156
					ThreadReference thread = crossfire().findThread(event.getContextId());
157
					if(thread != null) {
158
						set.setThread(thread);
159
						Map json = (Map) event.getBody().get(Attributes.SCRIPT);
160
						if(json != null) {
161
							CFScriptReference script = crossfire().addScript(event.getContextId(), json);
162
							List scripts = eventmgr.scriptLoadRequests();
163
							for (Iterator iter = scripts.iterator(); iter.hasNext();) {
164
								ScriptLoadRequest request = (ScriptLoadRequest) iter.next();
165
								set.add(new CFScriptLoadEvent(crossfire(), request, thread, script));
166
							}
167
						}
168
						else {
169
							return null;
170
						}
171
					}
172
					else {
173
						return null;
174
					}
175
					if(TRACE) {
176
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_SCRIPT+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
177
					}
178
				}
179
				else if(CFEventPacket.ON_CONTEXT_SELECTED.equals(name)) {
180
					handleContext(set, event, true);
181
					if(TRACE) {
182
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONTEXT_SELECTED+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
183
					}
184
				}
185
				else if(CFEventPacket.ON_CONTEXT_CREATED.equals(name)) {
186
					handleContext(set, event, true);
187
					if(TRACE) {
188
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONTEXT_CREATED+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
189
					}
190
				}
191
				else if(CFEventPacket.ON_CONTEXT_LOADED.equals(name)) {
192
					handleContext(set, event, true);
193
					if(TRACE) {
194
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONTEXT_LOADED+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
195
					}
196
				}
197
				else if(CFEventPacket.ON_CONTEXT_DESTROYED.equals(name)) {
198
					ThreadReference thread = crossfire().findThread(event.getContextId());
199
					crossfire().removeThread(event.getContextId());
200
					crossfire().removeScriptsForContext(event.getContextId());
201
					if(thread != null) {
202
						List threads = eventmgr.threadExitRequests();
203
						for (Iterator iter = threads.iterator(); iter.hasNext();) {
204
							ThreadExitRequest request = (ThreadExitRequest) iter.next();
205
							set.add(new CFThreadExitEvent(crossfire(), request, thread));
206
						}
207
					}
208
					else {
209
						return null;
210
					}
211
					if(TRACE) {
212
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONTEXT_DESTROYED+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
213
					}
214
				}
215
				else if(CFEventPacket.ON_CONSOLE_DEBUG.equals(name)) {
216
					Map info = (Map) event.getBody().get(Attributes.VALUE);
217
					if(info != null) {
218
						log(IStatus.INFO, info);
219
					}
220
					if(TRACE) {
221
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONSOLE_DEBUG+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
222
					}
223
					return null;
224
				}
225
				else if(CFEventPacket.ON_CONSOLE_ERROR.equals(name)) {
226
					logError(event.getBody());
227
					if(TRACE) {
228
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONSOLE_ERROR+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
229
					}
230
					return null;
231
				}
232
				else if(CFEventPacket.ON_CONSOLE_INFO.equals(name)) {
233
					Map info = (Map) event.getBody().get(Attributes.VALUE);
234
					if(info != null) {
235
						log(IStatus.INFO, info);
236
					}
237
					if(TRACE) {
238
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONSOLE_INFO+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
239
					}
240
					return null;
241
				}
242
				else if(CFEventPacket.ON_CONSOLE_LOG.equals(name)) {
243
					Map info = (Map) event.getBody().get(Attributes.VALUE);
244
					if(info != null) {
245
						log(IStatus.INFO, info);
246
					}
247
					if(TRACE) {
248
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONSOLE_LOG+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
249
					}
250
					return null;
251
				}
252
				else if(CFEventPacket.ON_CONSOLE_WARN.equals(name)) {
253
					Map info = (Map) event.getBody().get(Attributes.VALUE);
254
					if(info != null) {
255
						log(IStatus.WARNING, info);
256
					}
257
					if(TRACE) {
258
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_CONSOLE_WARN+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
259
					}
260
					return null;
261
				}
262
				else if(CFEventPacket.ON_ERROR.equals(name)) {
263
					Map body = event.getBody();
264
					if(body != null) {
265
						Throwable thro = new CFThrowable(body);
266
						Status status = new Status(IStatus.ERROR, CrossFirePlugin.PLUGIN_ID, thro.getMessage(), thro);
267
						CrossFirePlugin.log(status);
268
					}
269
				}
270
				else if(CFEventPacket.ON_INSPECT_NODE.equals(name)) {
271
					if(TRACE) {
272
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_INSPECT_NODE+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
273
					}
274
					return null;
275
				}
276
				else if(CFEventPacket.ON_TOGGLE_BREAKPOINT.equals(name)) {
277
					crossfire().toggleBreakpoint(event.getBody());
278
					if(TRACE) {
279
						Tracing.writeString("QUEUE [event - "+CFEventPacket.ON_TOGGLE_BREAKPOINT+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
280
					}
281
					return null;
282
				}
283
				else {
284
					if(TRACE) {
285
						Tracing.writeString("QUEUE [unknown event - "+name+"] "+JSON.serialize(event)); //$NON-NLS-1$ //$NON-NLS-2$
286
					}
287
				}
288
				if (set.isEmpty()) {
289
					set.resume();
290
					continue;
291
				}
292
				return set;
293
			}
294
		}
295
		catch(DisconnectedException de) {
296
			if(TRACE) {
297
				Tracing.writeString("QUEUE [disconnect exception]: "+de.getMessage()); //$NON-NLS-1$
298
			}
299
			crossfire().disconnectVM();
300
			handleException(de.getMessage(), (de.getCause() == null ? de : de.getCause()));
301
		}
302
		catch(TimeoutException te) {
303
			CrossFirePlugin.log(te);
304
		}
305
		return null;
306
	}
307
	
308
	void logError(Map info) {
309
		if(info != null) {
310
			MultiStatus mstatus = new MultiStatus(CrossFirePlugin.PLUGIN_ID, IStatus.ERROR, "Error message logged in Firebug console", null); //$NON-NLS-1$
311
			String message = (String) info.get(Attributes.MESSAGE);
312
			CFThrowable thrw = new CFThrowable((Map) info.get(Attributes.STACKTRACE));
313
			if(message != null) {
314
				IStatus status = new Status(IStatus.ERROR, CrossFirePlugin.PLUGIN_ID, message, thrw);
315
				mstatus.add(status);
316
			}
317
			if(mstatus.getChildren().length > 0) {
318
				CrossFirePlugin.log(mstatus);
319
			}
320
		}
321
	}
322
	
323
	/**
324
	 * Logs the entry from the queue
325
	 * 
326
	 * @param kind
327
	 * @param objects
328
	 */
329
	void log(int kind, Map objects) {
330
		IStatus status = null;
331
		if(objects.size() > 1) {
332
			MultiStatus mstatus = new MultiStatus(CrossFirePlugin.PLUGIN_ID, kind, "Messages logged from Firebug console", null); //$NON-NLS-1$
333
			Entry entry = null;
334
			for (Iterator i = objects.entrySet().iterator(); i.hasNext();) {
335
				entry = (Entry) i.next();
336
				Object value = entry.getValue();
337
				if(value instanceof Map) {
338
					Map map = (Map) entry.getValue();
339
					if(!map.containsKey(Attributes.HANDLE)) {
340
						Object val = map.get(Attributes.VALUE);
341
						if(val != null) {
342
							mstatus.add(new Status(kind, CrossFirePlugin.PLUGIN_ID, val.toString()));
343
						}
344
					}
345
				}
346
			}
347
			status = mstatus;
348
		}
349
		if(status != null) {
350
			CrossFirePlugin.log(status);
351
		}
352
	}
353
	
354
	/**
355
	 * Handles a context created, loaded, and changed event
356
	 * @param set the {@link EventSet} to add to
357
	 * @param event the {@link CFEventPacket} received
358
	 * @param lookup if we should try to lookup the {@link ThreadReference} before creating a new one
359
	 */
360
	void handleContext(CFEventSet set, CFEventPacket event, boolean lookup) {
361
		List threads = eventmgr.threadEnterRequests();
362
		CFThreadReference thread = null;
363
		String context = event.getContextId();
364
		if(lookup) {
365
			thread = crossfire().findThread(context);
366
		}
367
		if(thread == null) {
368
			thread = crossfire().addThread(context, (String) event.getBody().get(Attributes.URL));
369
		}
370
		set.setThread(thread);
371
		for (Iterator iter = threads.iterator(); iter.hasNext();) {
372
			ThreadEnterRequest request = (ThreadEnterRequest) iter.next();
373
			set.add(new CFThreadEnterEvent(crossfire(), request, thread));
374
		}
375
	}
376
	
377
	/**
378
	 * Flushes and cleans up the queue
379
	 */
380
	public void dispose() {
381
		disposed = true;
382
	}
383
	
384
	/**
385
	 * Turns on / off tracing in the event queue
386
	 * @param tracing
387
	 */
388
	public static void setTracing(boolean tracing) {
389
		TRACE = tracing;
390
	}
391
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFEventSet.java (+70 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
12
13
import java.util.ArrayList;
14
15
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
16
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
17
import org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet;
18
19
/**
20
 * Default implementation of {@link EventSet} for Crossfire
21
 *  
22
 *  @since 1.0
23
 */
24
public class CFEventSet extends ArrayList implements EventSet {
25
26
	private VirtualMachine vm = null;
27
	private ThreadReference thread = null;
28
	
29
	/**
30
	 * Constructor
31
	 * @param vm
32
	 */
33
	public CFEventSet(VirtualMachine vm) {
34
		this.vm = vm;
35
	}
36
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet#suspended()
39
	 */
40
	public boolean suspended() {
41
		return true;
42
	}
43
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.EventSet#resume()
46
	 */
47
	public void resume() {
48
		if(thread != null) {
49
			thread.resume();
50
		}
51
		else {
52
			vm.resume();
53
		}
54
	}
55
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Mirror#virtualMachine()
58
	 */
59
	public VirtualMachine virtualMachine() {
60
		return vm;
61
	}
62
	 
63
	/**
64
	 * Sets the thread context for the set
65
	 * @param thread
66
	 */
67
	public void setThread(ThreadReference thread) {
68
		this.thread = thread;
69
	}
70
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFExceptionEvent.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
16
import org.eclipse.wst.jsdt.debug.core.jsdi.event.ExceptionEvent;
17
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
18
19
/**
20
 * Default implementation of {@link ExceptionEvent} for Crossfire
21
 * 
22
 * @since 1.0
23
 */
24
public class CFExceptionEvent extends CFLocatableEvent implements ExceptionEvent {
25
26
	private String message = null;
27
	
28
	/**
29
	 * Constructor
30
	 * @param vm
31
	 * @param request
32
	 * @param thread
33
	 * @param location
34
	 * @param message
35
	 */
36
	public CFExceptionEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, Location location, String message) {
37
		super(vm, request, thread, location);
38
		this.message = message;
39
	}
40
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.ExceptionEvent#message()
43
	 */
44
	public String message() {
45
		return message;
46
	}
47
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFLocatableEvent.java (+53 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
16
import org.eclipse.wst.jsdt.debug.core.jsdi.event.LocatableEvent;
17
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
18
19
/**
20
 * Default implementation of {@link LocatableEvent} for Crossfire
21
 * 
22
 * @sicne 1.0
23
 */
24
public class CFLocatableEvent extends CFEvent implements LocatableEvent {
25
26
	private ThreadReference thread = null;
27
	private Location location = null;
28
	
29
	/**
30
	 * Constructor
31
	 * @param vm
32
	 * @param request
33
	 */
34
	public CFLocatableEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, Location location) {
35
		super(vm, request);
36
		this.thread = thread;
37
		this.location = location;
38
	}
39
40
	/* (non-Javadoc)
41
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Locatable#location()
42
	 */
43
	public Location location() {
44
		return location;
45
	}
46
47
	/* (non-Javadoc)
48
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.LocatableEvent#thread()
49
	 */
50
	public ThreadReference thread() {
51
		return thread;
52
	}
53
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFResumeEvent.java (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
16
import org.eclipse.wst.jsdt.debug.core.jsdi.event.ResumeEvent;
17
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
18
19
/**
20
 * Crossfire implementation of {@link ResumeEvent}
21
 * 
22
 * @since 1.0
23
 */
24
public class CFResumeEvent extends CFLocatableEvent implements ResumeEvent {
25
26
	/**
27
	 * Constructor
28
	 * @param vm
29
	 * @param request
30
	 * @param thread
31
	 * @param location
32
	 */
33
	public CFResumeEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, Location location) {
34
		super(vm, request, thread, location);
35
	}
36
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFScriptLoadEvent.java (+45 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
16
import org.eclipse.wst.jsdt.debug.core.jsdi.event.ScriptLoadEvent;
17
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
18
19
/**
20
 * Default implementation of {@link ScriptLoadEvent} for Crossfire
21
 * 
22
 * @since 1.0
23
 */
24
public class CFScriptLoadEvent extends CFLocatableEvent implements ScriptLoadEvent {
25
26
	private ScriptReference script = null;
27
	
28
	/**
29
	 * Constructor
30
	 * @param vm
31
	 * @param request
32
	 */
33
	public CFScriptLoadEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, ScriptReference script) {
34
		super(vm, request, thread, null);
35
		this.script = script;
36
	}
37
38
	/* (non-Javadoc)
39
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.event.ScriptLoadEvent#script()
40
	 */
41
	public ScriptReference script() {
42
		return script;
43
	}
44
45
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFSuspendEvent.java (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
16
import org.eclipse.wst.jsdt.debug.core.jsdi.event.SuspendEvent;
17
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
18
19
/**
20
 * Default implementation of {@link SuspendEvent} for Crossfire
21
 * 
22
 * @since 1.0
23
 */
24
public class CFSuspendEvent extends CFLocatableEvent implements SuspendEvent {
25
26
	/**
27
	 * Constructor
28
	 * @param vm
29
	 * @param request
30
	 * @param thread
31
	 * @param location
32
	 */
33
	public CFSuspendEvent(VirtualMachine vm, EventRequest request, ThreadReference thread, Location location) {
34
		super(vm, request, thread, location);
35
	}
36
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFThreadEnterEvent.java (+34 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.event.ThreadEnterEvent;
16
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
17
18
/**
19
 * Default implementation of {@link ThreadEnterEvent} for Crossfire
20
 * 
21
 * @since 1.0
22
 */
23
public class CFThreadEnterEvent extends CFLocatableEvent implements ThreadEnterEvent {
24
25
	/**
26
	 * Constructor
27
	 * @param vm
28
	 * @param request
29
	 * @param thread
30
	 */
31
	public CFThreadEnterEvent(VirtualMachine vm, EventRequest request, ThreadReference thread) {
32
		super(vm, request, thread, null);
33
	}
34
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFThreadExitEvent.java (+34 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.event.ThreadExitEvent;
16
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
17
18
/**
19
 * Default implementation of {@link ThreadExitEvent} for Crossfire
20
 * 
21
 * @since 1.0
22
 */
23
public class CFThreadExitEvent extends CFLocatableEvent implements ThreadExitEvent {
24
25
	/**
26
	 * Constructor
27
	 * @param vm
28
	 * @param request
29
	 * @param thread
30
	 */
31
	public CFThreadExitEvent(VirtualMachine vm, EventRequest request, ThreadReference thread) {
32
		super(vm, request, thread, null);
33
	}
34
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/event/CFVMDeathEvent.java (+32 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.event;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.event.VMDeathEvent;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
16
17
/**
18
 * Default implementation of a {@link VMDeathEvent} for Crossfire
19
 * 
20
 * @since 1.0
21
 */
22
public class CFVMDeathEvent extends CFEvent implements VMDeathEvent {
23
24
	/**
25
	 * Constructor
26
	 * @param vm
27
	 * @param request
28
	 */
29
	public CFVMDeathEvent(VirtualMachine vm, EventRequest request) {
30
		super(vm, request);
31
	}
32
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFArrayReference.java (+61 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import java.util.List;
14
import java.util.Map;
15
16
import org.eclipse.wst.jsdt.debug.core.jsdi.ArrayReference;
17
import org.eclipse.wst.jsdt.debug.core.jsdi.Value;
18
19
/**
20
 * Default implementation of {@link ArrayReference} for Crossfire
21
 * 
22
 * @since 1.0
23
 */
24
public class CFArrayReference extends CFObjectReference implements ArrayReference {
25
26
	/**
27
	 * The "array" value type
28
	 */
29
	public static final String ARRAY = "array"; //$NON-NLS-1$
30
	
31
	/**
32
	 * Constructor
33
	 * @param vm
34
	 * @param frame
35
	 * @param body
36
	 */
37
	public CFArrayReference(CFVirtualMachine vm, CFStackFrame frame, Map body) {
38
		super(vm, frame, body);
39
	}
40
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ArrayReference#length()
43
	 */
44
	public int length() {
45
		return 0;
46
	}
47
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ArrayReference#getValue(int)
50
	 */
51
	public Value getValue(int index) throws IndexOutOfBoundsException {
52
		return null;
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ArrayReference#getValues()
57
	 */
58
	public List getValues() {
59
		return null;
60
	}
61
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFBooleanValue.java (+77 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.BooleanValue;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
16
/**
17
 * Default implementation of a {@link BooleanValue} for Crossfire
18
 * 
19
 * @since 1.0
20
 */
21
public class CFBooleanValue extends CFMirror implements BooleanValue {
22
23
	private boolean bool = false;
24
	
25
	/**
26
	 * Constructor
27
	 * 
28
	 * @param vm
29
	 * @param bool the underlying boolean value
30
	 */
31
	public CFBooleanValue(VirtualMachine vm, boolean bool) {
32
		super(vm);
33
		this.bool = bool;
34
	}
35
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#intValue()
38
	 */
39
	public int intValue() {
40
		return (bool ? 1 : 0);
41
	}
42
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#doubleValue()
45
	 */
46
	public double doubleValue() {
47
		return (bool ? 1 : 0);
48
	}
49
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#booleanValue()
52
	 */
53
	public boolean booleanValue() {
54
		return bool;
55
	}
56
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#stringValue()
59
	 */
60
	public String stringValue() {
61
		return Boolean.toString(bool);
62
	}
63
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString()
66
	 */
67
	public String valueString() {
68
		return stringValue();
69
	}
70
71
	/* (non-Javadoc)
72
	 * @see java.lang.Object#toString()
73
	 */
74
	public String toString() {
75
		return stringValue();
76
	}
77
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFEventRequestManager.java (+296 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import java.util.ArrayList;
14
import java.util.Collections;
15
import java.util.HashMap;
16
import java.util.Iterator;
17
import java.util.List;
18
19
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
20
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
21
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
22
import org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest;
23
import org.eclipse.wst.jsdt.debug.core.jsdi.request.DebuggerStatementRequest;
24
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
25
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager;
26
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ExceptionRequest;
27
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ResumeRequest;
28
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ScriptLoadRequest;
29
import org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest;
30
import org.eclipse.wst.jsdt.debug.core.jsdi.request.SuspendRequest;
31
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadEnterRequest;
32
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadExitRequest;
33
import org.eclipse.wst.jsdt.debug.core.jsdi.request.VMDeathRequest;
34
import org.eclipse.wst.jsdt.debug.core.jsdi.request.VMDisconnectRequest;
35
import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFBreakpointRequest;
36
import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFDeathRequest;
37
import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFDebuggerRequest;
38
import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFDisconnectRequest;
39
import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFExceptionRequest;
40
import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFResumeRequest;
41
import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFScriptLoadRequest;
42
import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFStepRequest;
43
import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFSuspendRequest;
44
import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFThreadEnterRequest;
45
import org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFThreadExitRequest;
46
47
/**
48
 * Default {@link EventRequestManager} for Crossfire
49
 * 
50
 * @since 1.0
51
 */
52
public class CFEventRequestManager implements EventRequestManager {
53
54
	private List threadexits = Collections.synchronizedList(new ArrayList(4));
55
	private List threadenters = Collections.synchronizedList(new ArrayList(4));
56
	private List breakpoints = Collections.synchronizedList(new ArrayList(4));
57
	private List debuggers = Collections.synchronizedList(new ArrayList(4));
58
	private List exceptions = Collections.synchronizedList(new ArrayList(4));
59
	private List loads = Collections.synchronizedList(new ArrayList(4));
60
	private List steps = Collections.synchronizedList(new ArrayList(4));
61
	private List suspends = Collections.synchronizedList(new ArrayList(4));
62
	private List resumes = Collections.synchronizedList(new ArrayList(4));
63
	private List disconnects = Collections.synchronizedList(new ArrayList(4));
64
	private List deaths = Collections.synchronizedList(new ArrayList(4));
65
	
66
	private HashMap kind = new HashMap(10);
67
	
68
	private VirtualMachine vm = null;
69
	
70
	/**
71
	 * Constructor
72
	 * 
73
	 * @param vm
74
	 */
75
	public CFEventRequestManager(VirtualMachine vm) {
76
		this.vm = vm;
77
		kind.put(CFBreakpointRequest.class, breakpoints);
78
		kind.put(CFDebuggerRequest.class, debuggers);
79
		kind.put(CFExceptionRequest.class, exceptions);
80
		kind.put(CFScriptLoadRequest.class, loads);
81
		kind.put(CFStepRequest.class, steps);
82
		kind.put(CFSuspendRequest.class, suspends);
83
		kind.put(CFResumeRequest.class, resumes);
84
		kind.put(CFThreadEnterRequest.class, threadenters);
85
		kind.put(CFThreadExitRequest.class, threadexits);
86
		kind.put(CFDisconnectRequest.class, disconnects);
87
		kind.put(CFDeathRequest.class, deaths);
88
	}
89
	
90
	/* (non-Javadoc)
91
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createBreakpointRequest(org.eclipse.wst.jsdt.debug.core.jsdi.Location)
92
	 */
93
	public BreakpointRequest createBreakpointRequest(Location location) {
94
		CFBreakpointRequest request = new CFBreakpointRequest(vm, location);
95
		breakpoints.add(request);
96
		return request;
97
	}
98
99
	/* (non-Javadoc)
100
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#breakpointRequests()
101
	 */
102
	public List breakpointRequests() {
103
		return Collections.unmodifiableList(breakpoints);
104
	}
105
106
	/* (non-Javadoc)
107
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createDebuggerStatementRequest()
108
	 */
109
	public DebuggerStatementRequest createDebuggerStatementRequest() {
110
		CFDebuggerRequest request = new CFDebuggerRequest(vm);
111
		debuggers.add(request);
112
		return request;
113
	}
114
115
	/* (non-Javadoc)
116
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#debuggerStatementRequests()
117
	 */
118
	public List debuggerStatementRequests() {
119
		return Collections.unmodifiableList(debuggers);
120
	}
121
122
	/* (non-Javadoc)
123
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createExceptionRequest()
124
	 */
125
	public ExceptionRequest createExceptionRequest() {
126
		CFExceptionRequest request = new CFExceptionRequest(vm);
127
		exceptions.add(request);
128
		return request;
129
	}
130
131
	/* (non-Javadoc)
132
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#exceptionRequests()
133
	 */
134
	public List exceptionRequests() {
135
		return Collections.unmodifiableList(exceptions);
136
	}
137
138
	/* (non-Javadoc)
139
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createScriptLoadRequest()
140
	 */
141
	public ScriptLoadRequest createScriptLoadRequest() {
142
		CFScriptLoadRequest request = new CFScriptLoadRequest(vm);
143
		loads.add(request);
144
		return request;
145
	}
146
147
	/* (non-Javadoc)
148
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#scriptLoadRequests()
149
	 */
150
	public List scriptLoadRequests() {
151
		return Collections.unmodifiableList(loads);
152
	}
153
154
	/* (non-Javadoc)
155
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createStepRequest(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference, int)
156
	 */
157
	public StepRequest createStepRequest(ThreadReference thread, int step) {
158
		CFStepRequest request = new CFStepRequest(vm, thread, step);
159
		steps.add(request);
160
		return request; 
161
	}
162
	
163
164
	/* (non-Javadoc)
165
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#stepRequests()
166
	 */
167
	public List stepRequests() {
168
		return Collections.unmodifiableList(steps);
169
	}
170
171
	/* (non-Javadoc)
172
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createSuspendRequest(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
173
	 */
174
	public SuspendRequest createSuspendRequest(ThreadReference thread) {
175
		CFSuspendRequest request = new CFSuspendRequest(vm, thread);
176
		suspends.add(request);
177
		return request;
178
	}
179
180
	/* (non-Javadoc)
181
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#suspendRequests()
182
	 */
183
	public List suspendRequests() {
184
		return Collections.unmodifiableList(suspends);
185
	}
186
187
	/* (non-Javadoc)
188
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createResumeRequest(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
189
	 */
190
	public ResumeRequest createResumeRequest(ThreadReference thread) {
191
		CFResumeRequest request = new CFResumeRequest(vm, thread);
192
		resumes.add(request);
193
		return request;
194
	}
195
	
196
	/* (non-Javadoc)
197
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#resumeRequests()
198
	 */
199
	public List resumeRequests() {
200
		return Collections.unmodifiableList(resumes);
201
	}
202
	
203
	/* (non-Javadoc)
204
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createThreadEnterRequest()
205
	 */
206
	public ThreadEnterRequest createThreadEnterRequest() {
207
		CFThreadEnterRequest request = new CFThreadEnterRequest(vm);
208
		threadenters.add(request);
209
		return request;
210
	}
211
212
	/* (non-Javadoc)
213
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#threadEnterRequests()
214
	 */
215
	public List threadEnterRequests() {
216
		return Collections.unmodifiableList(threadenters);
217
	}
218
219
	/* (non-Javadoc)
220
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createThreadExitRequest()
221
	 */
222
	public ThreadExitRequest createThreadExitRequest() {
223
		CFThreadExitRequest request = new CFThreadExitRequest(vm);
224
		threadexits.add(request);
225
		return request;
226
	}
227
228
	/* (non-Javadoc)
229
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#threadExitRequests()
230
	 */
231
	public List threadExitRequests() {
232
		return Collections.unmodifiableList(threadexits);
233
	}
234
235
	/* (non-Javadoc)
236
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#deleteEventRequest(org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest)
237
	 */
238
	public void deleteEventRequest(EventRequest eventRequest) {
239
		List requests = (List) kind.get(eventRequest.getClass());
240
		if(requests != null) {
241
			requests.remove(eventRequest);
242
			eventRequest.setEnabled(false);
243
		}
244
	}
245
246
	/* (non-Javadoc)
247
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#deleteEventRequest(java.util.List)
248
	 */
249
	public void deleteEventRequest(List eventRequests) {
250
		for (Iterator iter = eventRequests.iterator(); iter.hasNext();) {
251
			deleteEventRequest((EventRequest) iter.next());
252
		}
253
	}
254
255
	/* (non-Javadoc)
256
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createVMDeathRequest()
257
	 */
258
	public VMDeathRequest createVMDeathRequest() {
259
		CFDeathRequest request = new CFDeathRequest(vm);
260
		deaths.add(request);
261
		return request;
262
	}
263
264
	/* (non-Javadoc)
265
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#vmDeathRequests()
266
	 */
267
	public List vmDeathRequests() {
268
		return Collections.unmodifiableList(deaths);
269
	}
270
271
	/* (non-Javadoc)
272
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#createVMDisconnectRequest()
273
	 */
274
	public VMDisconnectRequest createVMDisconnectRequest() {
275
		CFDisconnectRequest request = new CFDisconnectRequest(vm);
276
		disconnects.add(request);
277
		return request;
278
	}
279
280
	/* (non-Javadoc)
281
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager#vmDisconnectRequests()
282
	 */
283
	public List vmDisconnectRequests() {
284
		return Collections.unmodifiableList(disconnects);
285
	}
286
287
	/**
288
	 * Cleans up all requests
289
	 */
290
	public void dispose() {
291
		for (Iterator iter = kind.keySet().iterator(); iter.hasNext();) {
292
			List list = (List) kind.get(iter.next());
293
			list.clear();
294
		}
295
	}
296
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFFunctionReference.java (+72 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import java.util.Map;
14
15
import org.eclipse.wst.jsdt.debug.core.jsdi.FunctionReference;
16
import org.eclipse.wst.jsdt.debug.core.jsdi.Value;
17
18
/**
19
 * Default implementation of {@link FunctionReference} for Crossfire
20
 * 
21
 * @since 1.0
22
 */
23
public class CFFunctionReference extends CFObjectReference implements FunctionReference {
24
25
	/**
26
	 * The "function" type
27
	 */
28
	public static final String FUNCTION = "function"; //$NON-NLS-1$
29
	
30
	private String funcname = null;
31
	
32
	
33
	/**
34
	 * Constructor
35
	 * @param vm
36
	 * @param frame
37
	 * @param body
38
	 */
39
	public CFFunctionReference(CFVirtualMachine vm, CFStackFrame frame, Map body) {
40
		super(vm, frame, body);
41
	}
42
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.FunctionReference#functionName()
45
	 */
46
	public String functionName() {
47
		synchronized (frame()) {
48
			if(funcname == null) {
49
				Value val = frame().lookup(id());
50
				System.out.println(val);
51
			}
52
		}
53
		return funcname;
54
	}
55
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.FunctionReference#functionBody()
58
	 */
59
	public String functionBody() {
60
		return source();
61
	}
62
	
63
	/* (non-Javadoc)
64
	 * @see org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFObjectReference#valueString()
65
	 */
66
	public String valueString() {
67
		if(source() != null) {
68
			return source();
69
		}
70
		return FUNCTION;
71
	}
72
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFLocation.java (+74 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
16
17
/**
18
 * Default implementation of {@link Location} for Crossfire
19
 * 
20
 * @since 1.0
21
 */
22
public class CFLocation extends CFMirror implements Location {
23
24
	private CFScriptReference script = null;
25
	private String function = null;
26
	private int line = -1;
27
	
28
	/**
29
	 * Constructor
30
	 * @param vm
31
	 * @param script
32
	 * @param function
33
	 * @param line
34
	 */
35
	public CFLocation(VirtualMachine vm, CFScriptReference script, String function, int line) {
36
		super(vm);
37
		this.script = script;
38
		this.function = function;
39
		this.line = line;
40
	}
41
42
	/* (non-Javadoc)
43
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Location#scriptReference()
44
	 */
45
	public ScriptReference scriptReference() {
46
		return script;
47
	}
48
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Location#lineNumber()
51
	 */
52
	public int lineNumber() {
53
		return line;
54
	}
55
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Location#functionName()
58
	 */
59
	public String functionName() {
60
		return function;
61
	}
62
	
63
	/* (non-Javadoc)
64
	 * @see java.lang.Object#toString()
65
	 */
66
	public String toString() {
67
		StringBuffer buffer = new StringBuffer();
68
		buffer.append("LocationImpl: "); //$NON-NLS-1$
69
		buffer.append("[script - ").append(script.sourceURI()).append("] "); //$NON-NLS-1$ //$NON-NLS-2$
70
		buffer.append("[function - ").append(function).append("] "); //$NON-NLS-1$ //$NON-NLS-2$
71
		buffer.append("[line - ").append(line).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
72
		return buffer.toString();
73
	}
74
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFMirror.java (+76 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.Mirror;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
16
/**
17
 * Default implementation for a {@link Mirror} for Crossfire
18
 * 
19
 * @since 1.0
20
 */
21
public class CFMirror implements Mirror {
22
23
	public static boolean TRACE = false;
24
	
25
	private VirtualMachine vm = null;
26
	
27
	/**
28
	 * Constructor
29
	 * For use by the {@link CFVirtualMachine} only
30
	 * @noreference This constructor is not intended to be referenced by clients.
31
	 */
32
	public CFMirror() {
33
		vm = (VirtualMachine) this;
34
	}
35
	
36
	/**
37
	 * Constructor
38
	 */
39
	public CFMirror(VirtualMachine vm) {
40
		this.vm = vm;
41
	}
42
	
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Mirror#virtualMachine()
45
	 */
46
	public VirtualMachine virtualMachine() {
47
		return this.vm;
48
	}
49
	
50
	/**
51
	 * Re-throws the given exception as a {@link RuntimeException} with the given message
52
	 * @param message
53
	 * @param t
54
	 */
55
	protected void handleException(String message, Throwable t) {
56
		throw new RuntimeException(message, t);
57
	}
58
	
59
	/**
60
	 * Returns the handle to the {@link CFVirtualMachine}
61
	 * 
62
	 * @return the {@link CFVirtualMachine} handle
63
	 */
64
	protected CFVirtualMachine crossfire() {
65
		return (CFVirtualMachine) vm;
66
	}
67
	
68
	/**
69
	 * Enables / Disables tracing in the all of the JSDI implementations
70
	 * 
71
	 * @param trace
72
	 */
73
	public static void setTracing(boolean trace) {
74
		TRACE = trace;
75
	}
76
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFNullValue.java (+45 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.NullValue;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
16
/**
17
 * Default implementation of the {@link NullValue} for Crossfire
18
 * 
19
 * @since 1.0
20
 */
21
public class CFNullValue extends CFMirror implements NullValue {
22
23
	public static final String NULL = "null"; //$NON-NLS-1$
24
25
	/**
26
	 * Constructor
27
	 */
28
	public CFNullValue(VirtualMachine vm) {
29
		super(vm);
30
	}
31
	
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString()
34
	 */
35
	public String valueString() {
36
		return CFNullValue.NULL;
37
	}
38
	
39
	/* (non-Javadoc)
40
	 * @see java.lang.Object#toString()
41
	 */
42
	public String toString() {
43
		return valueString();
44
	}
45
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFNumberValue.java (+121 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.NumberValue;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
16
/**
17
 * Default implementation of {@link NumberValue} for Crossfire
18
 * 
19
 * @since 1.0
20
 */
21
public class CFNumberValue extends CFMirror implements NumberValue {
22
	
23
	/**
24
	 * Object representing 'Not a Number'
25
	 */
26
	public static final Double NAN_OBJ = new Double(Double.NaN);
27
	/**
28
	 * Object representing '-Infinity'
29
	 */
30
	public static final Double NEG_INFINITY_OBJ = new Double(Double.NEGATIVE_INFINITY);
31
	/**
32
	 * Object representing 'Infinity'
33
	 */
34
	public static final Double INFINITY_OBJ = new Double(Double.POSITIVE_INFINITY);
35
	
36
	private Number number = null;
37
	
38
	/**
39
	 * Constructor
40
	 * @param vm
41
	 * @param number
42
	 */
43
	public CFNumberValue(VirtualMachine vm, Number number) {
44
		super(vm);
45
		if(number != null) {
46
			this.number = number;
47
		}
48
		else {
49
			this.number = NAN_OBJ;
50
		}
51
	}
52
53
	/**
54
	 * Constructor
55
	 * @param vm the backing {@link VirtualMachine}
56
	 * @param number the name of the number
57
	 * @see #INFINITY
58
	 * @see #NEG_INFINTY
59
	 */
60
	public CFNumberValue(VirtualMachine vm, String number) {
61
		super(vm);
62
		if(INFINITY.equals(number)) {
63
			this.number = INFINITY_OBJ;
64
		}
65
		else if(NEG_INFINITY.equals(number)) {
66
			this.number = NEG_INFINITY_OBJ;
67
		}
68
		if(this.number == null) {
69
			this.number = NAN_OBJ;
70
		}
71
	}
72
	
73
	/* (non-Javadoc)
74
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#intValue()
75
	 */
76
	public int intValue() {
77
		return number.intValue();
78
	}
79
80
	/* (non-Javadoc)
81
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#doubleValue()
82
	 */
83
	public double doubleValue() {
84
		return number.doubleValue();
85
	}
86
87
	/* (non-Javadoc)
88
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#booleanValue()
89
	 */
90
	public boolean booleanValue() {
91
		return number.intValue() > 0 ? true : false;
92
	}
93
94
	/* (non-Javadoc)
95
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.PrimitiveValue#stringValue()
96
	 */
97
	public String stringValue() {
98
		return number.toString();
99
	}
100
101
	/* (non-Javadoc)
102
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString()
103
	 */
104
	public String valueString() {
105
		return stringValue();
106
	}
107
108
	/* (non-Javadoc)
109
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.NumberValue#value()
110
	 */
111
	public Number value() {
112
		return number;
113
	}
114
115
	/* (non-Javadoc)
116
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.NumberValue#isNaN()
117
	 */
118
	public boolean isNaN() {
119
		return Double.isNaN(this.number.doubleValue());
120
	}
121
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFObjectReference.java (+172 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import java.util.ArrayList;
14
import java.util.Iterator;
15
import java.util.List;
16
import java.util.Map;
17
import java.util.Map.Entry;
18
19
import org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference;
20
import org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame;
21
import org.eclipse.wst.jsdt.debug.core.jsdi.Value;
22
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
23
24
/**
25
 * Default implementation of {@link ObjectReference} for Crossfire
26
 * 
27
 * @since 1.0
28
 */
29
public class CFObjectReference extends CFMirror implements ObjectReference {
30
	
31
	/**
32
	 * The "type" of this mirror element
33
	 */
34
	public static final String OBJECT = "object"; //$NON-NLS-1$
35
	
36
	private CFStackFrame frame = null;
37
	private String classname = null;
38
	private Number handle = null;
39
	private Number constref = null;
40
	private Number protoref = null;
41
	private Value constructor = null;
42
	private Value prototype = null;
43
	private List properties = null;
44
	private String source = null;
45
	
46
	/**
47
	 * Constructor
48
	 * @param vm
49
	 * @param frame
50
	 * @param body
51
	 */
52
	public CFObjectReference(CFVirtualMachine vm, CFStackFrame frame, Map body) {
53
		super(vm);
54
		this.frame = frame;
55
		handle = (Number) body.get(Attributes.HANDLE);
56
		source = (String) body.get(Attributes.SOURCE);
57
		//init properties - we are dealing with evaluation results
58
		Map props = (Map) body.get(Attributes.RESULT);
59
		if(props == null) {
60
			Object o = body.get(Attributes.VALUE);
61
			if(o instanceof Map) {
62
				props = (Map) body.get(Attributes.VALUE);
63
			}
64
			else if(this.handle == null) {
65
				props = body;
66
			}
67
		}
68
		if(props != null) {
69
			if(properties == null) {
70
				properties = new ArrayList(props.size());
71
			}
72
			Entry entry = null;
73
			String name = null;
74
			Map json = null;
75
			Number ref = null;
76
			for(Iterator i = props.entrySet().iterator(); i.hasNext();) {
77
				entry = (Entry) i.next();
78
				name = (String)entry.getKey();
79
				if(entry.getValue() instanceof Map) {
80
					json = (Map) entry.getValue();
81
					ref = (Number) json.get(Attributes.HANDLE);
82
					//don't add constructor and proto to the properties heap
83
					//they are requested specially
84
					if(Attributes.CONSTRUCTOR.equals(name)) {
85
						constref = ref;
86
						continue;
87
					}
88
					else if(Attributes.PROTO.equals(name)) {
89
						protoref = ref;
90
						continue;
91
					}
92
				}
93
				properties.add(new CFVariable(crossfire(), frame, name, ref, json));
94
			}
95
		}
96
	}
97
	
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString()
100
	 */
101
	public String valueString() {
102
		if(source != null) {
103
			return source;
104
		}
105
		return OBJECT;
106
	}
107
108
	/* (non-Javadoc)
109
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#className()
110
	 */
111
	public String className() {
112
		return classname;
113
	}
114
115
	/* (non-Javadoc)
116
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#constructor()
117
	 */
118
	public Value constructor() {
119
		synchronized (frame) {
120
			if(constructor == null) {
121
				if(constref == null) {
122
					constructor = crossfire().mirrorOfUndefined();
123
				}
124
				constructor = frame.lookup(constref);
125
			}
126
		}
127
		return constructor;
128
	}
129
130
	/* (non-Javadoc)
131
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#prototype()
132
	 */
133
	public Value prototype() {
134
		synchronized (frame) {
135
			if(prototype == null) {
136
				if(protoref == null) {
137
					prototype = crossfire().mirrorOfUndefined();
138
				}
139
				prototype = frame.lookup(protoref);
140
			}
141
		}
142
		return prototype;
143
	}
144
145
	/* (non-Javadoc)
146
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#properties()
147
	 */
148
	public List properties() {
149
		return properties;
150
	}
151
152
	/* (non-Javadoc)
153
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference#handle()
154
	 */
155
	public Number id() {
156
		return handle;
157
	}
158
	
159
	/**
160
	 * @return the backing {@link StackFrame}
161
	 */
162
	protected CFStackFrame frame() {
163
		return this.frame;
164
	}
165
	
166
	/**
167
	 * @return the source for the body of the object, or <code>null</code>
168
	 */
169
	protected String source() {
170
		return this.source;
171
	}
172
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFProperty.java (+81 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.NullValue;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.Property;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.Value;
16
17
/**
18
 * Default implementation of {@link Property} for Crossfire
19
 * 
20
 * @since 1.0
21
 */
22
public class CFProperty extends CFMirror implements Property {
23
24
	private String name = null;
25
	private Number ref = null;
26
	private CFStackFrame frame = null;
27
	private Value value = null;
28
	
29
	/**
30
	 * Constructor
31
	 * 
32
	 * @param vm
33
	 * @param frame
34
	 * @param name
35
	 * @param ref
36
	 */
37
	public CFProperty(CFVirtualMachine vm, CFStackFrame frame, String name, Number ref) {
38
		super(vm);
39
		this.frame = frame;
40
		this.name = name;
41
		this.ref = ref;
42
	}
43
	
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Property#name()
46
	 */
47
	public String name() {
48
		return this.name;
49
	}
50
	
51
	/**
52
	 * Allows the value to be set. Passing in <code>null</code> for <code>newvalue</code> will result
53
	 * in {@link #value} being set to {@link NullValue}
54
	 * 
55
	 * @param newvalue
56
	 */
57
	protected void setValue(Value newvalue) {
58
		if(newvalue == null) {
59
			this.value = crossfire().mirrorOfNull();
60
		}
61
		else {
62
			this.value = newvalue;
63
		}
64
	}
65
	
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Property#value()
68
	 */
69
	public synchronized Value value() {
70
		if(this.value == null) {
71
			this.value = frame.lookup(this.ref);
72
			if(this.value == null) {
73
				this.value = crossfire().mirrorOfUndefined();
74
			}
75
		}
76
		if(this.value == null) {
77
			return crossfire().mirrorOfUndefined();
78
		}
79
		return this.value;
80
	}
81
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFScriptReference.java (+211 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import java.net.URI;
14
import java.net.URISyntaxException;
15
import java.util.ArrayList;
16
import java.util.Arrays;
17
import java.util.Collections;
18
import java.util.List;
19
import java.util.Map;
20
21
import org.eclipse.core.runtime.Path;
22
import org.eclipse.core.runtime.URIUtil;
23
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
24
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
25
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
26
import org.eclipse.wst.jsdt.debug.internal.crossfire.CrossFirePlugin;
27
import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
28
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
29
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Commands;
30
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
31
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFRequestPacket;
32
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFResponsePacket;
33
34
/**
35
 * Default implementation of {@link ScriptReference} for Crossfire
36
 * 
37
 * @since 1.0
38
 */
39
public class CFScriptReference extends CFMirror implements ScriptReference {
40
	
41
	private String context_id = null;
42
	private String url = null;
43
	private int srclength = 0;
44
	private int linecount = 0;
45
	private int coloffset = 0;
46
	private int lineoffset = 0;
47
	private String source = null;
48
	private URI sourceuri = null;
49
	
50
	private List linelocs = new ArrayList();
51
	
52
	/**
53
	 * Constructor
54
	 * @param vm
55
	 * @param context_id
56
	 * @param json
57
	 */
58
	public CFScriptReference(VirtualMachine vm, String context_id, Map json) {
59
		super(vm);
60
		this.context_id = context_id;
61
		this.url = (String) json.get(Attributes.URL);
62
		initializeScript(json);
63
	}
64
65
	/**
66
	 * Initialize the script from the given JSON map
67
	 * 
68
	 * @param json
69
	 */
70
	void initializeScript(Map json) {
71
		Number value = (Number) json.get(Attributes.SOURCE_LENGTH);
72
		if(value != null) {
73
			this.srclength = value.intValue();
74
		}
75
		value = (Number) json.get(Attributes.LINE_COUNT);
76
		if(value != null) {
77
			this.linecount = value.intValue();
78
		}
79
		value = (Number) json.get(Attributes.LINE_OFFSET);
80
		if(value != null) {
81
			this.lineoffset = value.intValue();
82
		}
83
		value = (Number) json.get(Attributes.COLUMN_OFFSET);
84
		if(value != null) {
85
			this.coloffset = value.intValue();
86
		}
87
		source = (String) json.get(Attributes.SOURCE);
88
		prepareLocations(linecount);
89
	}
90
	
91
	/**
92
	 * Creates the line locations
93
	 * 
94
	 * @param lines
95
	 */
96
	void prepareLocations(int lines) {
97
		linelocs.clear();  //remove old line infos
98
		for (int i = 1; i <= lines; i++) {
99
			linelocs.add(new CFLocation(virtualMachine(), this, null, i));
100
		}
101
	}
102
	
103
	/* (non-Javadoc)
104
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#allLineLocations()
105
	 */
106
	public List allLineLocations() {
107
		return Collections.unmodifiableList(linelocs);
108
	}
109
110
	/* (non-Javadoc)
111
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#lineLocation(int)
112
	 */
113
	public Location lineLocation(int lineNumber) {
114
		if(lineNumber <= linelocs.size()) {
115
			return (Location) linelocs.get(lineNumber-1);
116
		}
117
		return null;
118
	}
119
120
	/* (non-Javadoc)
121
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#allFunctionLocations()
122
	 */
123
	public List allFunctionLocations() {
124
		return null;
125
	}
126
127
	/* (non-Javadoc)
128
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#functionLocation(java.lang.String)
129
	 */
130
	public Location functionLocation(String functionName) {
131
		return null;
132
	}
133
134
	/**
135
	 * The url of the script
136
	 * @return the url
137
	 */
138
	public String url() {
139
		return url;
140
	}
141
	
142
	/**
143
	 * Returns the context id of this script - this represents the id of the owning thread
144
	 * <br><br>
145
	 * This method can return <code>null</code>
146
	 * 
147
	 * @return the context id for the owning thread or <code>null</code>
148
	 */
149
	public String context() {
150
		return context_id;
151
	}
152
	
153
	/* (non-Javadoc)
154
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#source()
155
	 */
156
	public synchronized String source() {
157
		if(source == null) {
158
			CFRequestPacket request = new CFRequestPacket(Commands.SCRIPTS, context_id);
159
			request.setArgument(Attributes.INCLUDE_SOURCE, Boolean.TRUE);
160
			request.setArgument(Attributes.URLS, Arrays.asList(new String[] {url}));
161
			CFResponsePacket response = crossfire().sendRequest(request);
162
			if(response.isSuccess()) {
163
				List list = (List)response.getBody().get(Attributes.SCRIPTS);
164
				if (list != null && list.size() > 0) {
165
					initializeScript((Map)list.get(0));
166
				}
167
			}
168
			else if(TRACE) {
169
				Tracing.writeString("SCRIPTREF [failed source request]: "+JSON.serialize(request)); //$NON-NLS-1$
170
			}
171
		}
172
		return source;
173
	}
174
175
	/* (non-Javadoc)
176
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#sourceURI()
177
	 */
178
	public synchronized URI sourceURI() {
179
		if(sourceuri == null) {
180
			try {
181
				sourceuri = URIUtil.fromString(url);
182
			}
183
			catch(IllegalArgumentException iae) {
184
				try {
185
					sourceuri = CrossFirePlugin.fileURI(new Path(url));
186
				} catch (URISyntaxException e) {
187
					CrossFirePlugin.log(e);
188
				}
189
			}
190
			catch(URISyntaxException urise) {
191
				CrossFirePlugin.log(urise);
192
			}
193
		}
194
		return sourceuri;
195
	}
196
	
197
	/* (non-Javadoc)
198
	 * @see java.lang.Object#toString()
199
	 */
200
	public String toString() {
201
		StringBuffer buffer = new StringBuffer();
202
		buffer.append("Crossfire ScriptReference: [context_id - ").append(context_id).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
203
		buffer.append(" [url - ").append(url).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
204
		buffer.append(" [srclength - ").append(srclength).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
205
		buffer.append(" [linecount - ").append(linecount).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
206
		buffer.append(" [lineoffset - ").append(lineoffset).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
207
		buffer.append(" [coloffset - ").append(coloffset).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
208
		buffer.append("\nSource: \n").append(source); //$NON-NLS-1$
209
		return buffer.toString();
210
	}
211
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFStackFrame.java (+340 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import java.util.ArrayList;
14
import java.util.Arrays;
15
import java.util.Collections;
16
import java.util.HashMap;
17
import java.util.Iterator;
18
import java.util.List;
19
import java.util.Map;
20
import java.util.Map.Entry;
21
22
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
23
import org.eclipse.wst.jsdt.debug.core.jsdi.NullValue;
24
import org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame;
25
import org.eclipse.wst.jsdt.debug.core.jsdi.Value;
26
import org.eclipse.wst.jsdt.debug.core.jsdi.Variable;
27
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
28
import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
29
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
30
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFRequestPacket;
31
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFResponsePacket;
32
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Commands;
33
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
34
35
/**
36
 * Default implementation of {@link StackFrame} for Crossfire
37
 * 
38
 * @since 1.0
39
 */
40
public class CFStackFrame extends CFMirror implements StackFrame {
41
42
	private int index = -1;
43
	private String scriptUrl = null;
44
	private String funcname = null;
45
	private int linenumber = -1;
46
	private List vars = null;
47
	private Variable thisvar = null;
48
	private CFLocation loc = null;
49
	private CFThreadReference thread = null;
50
	
51
	/**
52
	 * Constructor
53
	 * @param vm
54
	 * @param json
55
	 */
56
	public CFStackFrame(VirtualMachine vm, CFThreadReference thread, Map json) {
57
		super(vm);
58
		this.thread = thread;
59
		Number value = (Number) json.get(Attributes.INDEX);
60
		if(value != null) {
61
			index = value.intValue();
62
		}
63
		value = (Number) json.get(Attributes.LINE);
64
		if(value != null) {
65
			linenumber = value.intValue();
66
		}
67
		scriptUrl = (String) json.get(Attributes.URL);
68
		funcname = (String) json.get(Attributes.FUNCTION_NAME);
69
		
70
		parseLocals((Map) json.get(Attributes.LOCALS));
71
		parseScopes((List) json.get(Attributes.SCOPES));
72
	}
73
74
	/**
75
	 * Parses the scopes object node, if there is one
76
	 * 
77
	 * @param list the list of scopes
78
	 */
79
	void parseScopes(List list) {
80
		if(list != null) {
81
			if(vars == null) {
82
				vars = new ArrayList(list.size());
83
			}
84
			for (Iterator i = list.iterator(); i.hasNext();) {
85
				Map map = (Map) i.next();
86
				Map scope = (Map)map.get(Attributes.SCOPE);
87
				if(scope != null) {
88
					vars.add(0, new CFVariable(crossfire(), this, "Enclosing Scope", (Number) scope.get(Attributes.HANDLE), scope)); //$NON-NLS-1$
89
				}
90
			}
91
		}
92
	}
93
	
94
	/**
95
	 * Read the local variable information from the JSON mapping
96
	 * 
97
	 * @param json
98
	 */
99
	void parseLocals(Map json) {
100
		if(json != null) {
101
			Object val = json.get(Attributes.VALUE);
102
			if(val instanceof Map) {
103
				Map locals = (Map) json.get(Attributes.VALUE); 
104
				if(locals != null) {
105
					vars = new ArrayList(locals.size());
106
					parseVariables(locals, vars);
107
				}
108
			}
109
			else {
110
				vars = new ArrayList();
111
			}
112
			Map thismap = (Map) json.get(Attributes.THIS); 
113
			thisvar = new CFVariable(crossfire(), this, Attributes.THIS, null, (thismap == null ? new HashMap(0) : thismap));
114
		}
115
	}
116
	
117
	void parseVariables(Map map, List varcollector) {
118
		Entry entry = null;
119
		for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
120
			entry = (Entry) iter.next();
121
			if(entry.getValue() instanceof Map) {
122
				Map info  = (Map) entry.getValue();
123
				Object obj = info.get(Attributes.HANDLE);
124
				if(obj instanceof Number) {
125
					varcollector.add(
126
							new CFVariable(
127
									crossfire(), 
128
									this, 
129
									(String) entry.getKey(), 
130
									(Number) obj, 
131
									info));
132
				}
133
			}
134
			else {
135
				varcollector.add(
136
						new CFVariable(
137
								crossfire(), 
138
								this, 
139
								(String) entry.getKey(), 
140
								null, 
141
								null));
142
			}
143
		}
144
	}
145
	
146
	/* (non-Javadoc)
147
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame#thisObject()
148
	 */
149
	public Variable thisObject() {
150
		return thisvar;
151
	}
152
153
	/* (non-Javadoc)
154
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame#variables()
155
	 */
156
	public synchronized List variables() {
157
		if(vars != null) {
158
			return vars;
159
		}
160
		return Collections.EMPTY_LIST; 
161
	}
162
163
	/* (non-Javadoc)
164
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame#location()
165
	 */
166
	public synchronized Location location() {
167
		if(loc == null) {
168
			CFScriptReference script = crossfire().findScript(scriptUrl); 
169
			if(script != null) {
170
				loc = new CFLocation(crossfire(), script, funcname, linenumber);
171
			}
172
		}
173
		return loc;
174
	}
175
176
	/* (non-Javadoc)
177
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame#evaluate(java.lang.String)
178
	 */
179
	public Value evaluate(String expression) {
180
		CFRequestPacket request = new CFRequestPacket(Commands.EVALUATE, thread.id());
181
		request.setArgument(Attributes.FRAME_INDEX, new Integer(index));
182
		request.setArgument(Attributes.EXPRESSION, expression);
183
		CFResponsePacket response = crossfire().sendRequest(request);
184
		if(response.isSuccess()) {
185
			return createValue(response.getBody().get(Attributes.RESULT));
186
		}
187
		else if(TRACE) {
188
			Tracing.writeString("STACKFRAME [failed evaluate request]: "+JSON.serialize(request)); //$NON-NLS-1$
189
		}
190
		return virtualMachine().mirrorOfNull();
191
	}
192
	
193
	/**
194
	 * Returns the index of the frame in the stack
195
	 * 
196
	 * @return the frame index
197
	 */
198
	public int frameindex() {
199
		return index;
200
	}
201
	
202
	/**
203
	 * Looks up the value given its handle ref
204
	 * 
205
	 * @param ref
206
	 * @return the {@link Value} or <code>null</code>
207
	 */
208
	public Value lookup(Number ref) {
209
		if(ref != null) {
210
			CFRequestPacket request = new CFRequestPacket(Commands.LOOKUP, thread.id());
211
			request.setArgument(Attributes.HANDLES, Arrays.asList(new Number[] {ref}));
212
			request.setArgument(Attributes.INCLUDE_SOURCE, Boolean.TRUE);
213
			CFResponsePacket response = crossfire().sendRequest(request);
214
			if(response.isSuccess()) {
215
				List list = (List)response.getBody().get(Attributes.VALUES);
216
				if (list != null && list.size() > 0) {
217
					return createValue(list.get(0));
218
				}
219
			}
220
			else if(TRACE) {
221
				Tracing.writeString("STACKFRAME [request for value lookup failed]: "+JSON.serialize(request)); //$NON-NLS-1$
222
			}
223
		}
224
		return crossfire().mirrorOfNull();
225
	}
226
	
227
	/**
228
	 * Creates the correct type if {@link Value} from the given json mapping
229
	 * @param json
230
	 * @return the new {@link Value} or <code>null</code> if one could not be created
231
	 */
232
	Value createValue(Object val) {
233
		//resolve the smallest type from the crossfire insanity
234
		if(val instanceof Map) {
235
			Map values = (Map) val;
236
			String type = (String) values.get(Attributes.TYPE);
237
			if(type != null) {
238
				return createTypeValue(type, values);
239
			}
240
		}
241
		else if(val instanceof String) {
242
			String str = (String) val;
243
			if(CFUndefinedValue.UNDEFINED.equals(str)) {
244
				return crossfire().mirrorOfUndefined();
245
			}
246
			return crossfire().mirrorOf((String) val); 
247
		}
248
		else if(val instanceof Number) {
249
			return crossfire().mirrorOf((Number) val);
250
		}
251
		return crossfire().mirrorOfNull();
252
	}
253
	
254
	/**
255
	 * Create a new {@link Value} based on the given type
256
	 * 
257
	 * @param type the type
258
	 * @param map the map of value information
259
	 * @return the new {@link Value} for the given type or {@link NullValue} if a value cannot be computed
260
	 */
261
	Value createTypeValue(String type, Map map) {
262
		if(CFUndefinedValue.UNDEFINED.equals(type)) {
263
			return crossfire().mirrorOfUndefined();
264
		}
265
		if(Attributes.NUMBER.equals(type)) {
266
			//could be NaN, Infinity or -Infinity, check for strings
267
			Object o = map.get(Attributes.VALUE);
268
			if(o instanceof Number) {
269
				return crossfire().mirrorOf((Number)o);
270
			}
271
			if(o instanceof String) {
272
				return crossfire().mirrorOf((String)o);
273
			}
274
		}
275
		if(CFStringValue.STRING.equals(type)) {
276
			return crossfire().mirrorOf(map.get(Attributes.VALUE).toString());
277
		}
278
		if(CFObjectReference.OBJECT.equals(type) || Attributes.REF.equals(type)) {
279
			return new CFObjectReference(crossfire(), this, map);
280
		}
281
		if(CFArrayReference.ARRAY.equals(type)) {
282
			return new CFArrayReference(crossfire(), this, map);
283
		}
284
		if(CFFunctionReference.FUNCTION.equals(type)) {
285
			return new CFFunctionReference(crossfire(), this, map);
286
		}
287
		return crossfire().mirrorOfNull();
288
	}
289
	
290
	/**
291
	 * Returns if this stack frame is visible
292
	 * 
293
	 * @param variable
294
	 * @return true if this frame is visible, false otherwise
295
	 */
296
	public synchronized boolean isVisible(CFVariable variable) {
297
		return vars != null && (thisvar == variable || vars.contains(variable));
298
	}
299
	
300
	/**
301
	 * Gets all of the scopes from Firebug
302
	 */
303
	void allScopes() {
304
		CFRequestPacket request = new CFRequestPacket(Commands.SCOPES, thread.id());
305
		request.setArgument(Attributes.FRAME_INDEX, new Integer(index));
306
		CFResponsePacket response = crossfire().sendRequest(request);
307
		if(response.isSuccess()) {
308
			List list = (List) response.getBody().get(Attributes.SCOPES);
309
			if(list != null) {
310
				parseScopes(list);
311
			}
312
		}
313
		else if(TRACE) {
314
			Tracing.writeString("VM [failed scopes request]: "+JSON.serialize(request)); //$NON-NLS-1$
315
		}
316
	}
317
	
318
	/**
319
	 * Gets the scope for this frame
320
	 */
321
	void scope(int frameindex, int scopeindex) {
322
		CFRequestPacket request = new CFRequestPacket(Commands.SCOPES, thread.id());
323
		request.setArgument(Attributes.FRAME_INDEX, new Integer(frameindex));
324
		request.setArgument(Attributes.SCOPE_INDEXES, Arrays.asList(new Number[] {new Integer(scopeindex)}));
325
		CFResponsePacket response = crossfire().sendRequest(request);
326
		if(response.isSuccess()) {
327
			if(vars == null) {
328
				vars = new ArrayList();
329
			}
330
			List list = (List)response.getBody().get(Attributes.SCOPES);
331
			if (list != null && list.size() > 0) {
332
				Map scope = ((Map)list.get(0));
333
				vars.add(0, new CFVariable(crossfire(), this, "Enclosing Scope", (Number) scope.get(Attributes.HANDLE), scope)); //$NON-NLS-1$
334
			}
335
		}
336
		else if(TRACE) {
337
			Tracing.writeString("VM [failed scopes request]: "+JSON.serialize(request)); //$NON-NLS-1$
338
		}
339
	}
340
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFStringValue.java (+61 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.StringValue;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
16
/**
17
 * Default implementation of {@link StringValue} for Crossfire
18
 * 
19
 * @since 1.0
20
 */
21
public class CFStringValue extends CFMirror implements StringValue {
22
23
	/**
24
	 * The "type" of this value
25
	 */
26
	public static final String STRING = "string"; //$NON-NLS-1$
27
	
28
	private String string = null;
29
	
30
	/**
31
	 * Constructor
32
	 * 
33
	 * @param vm
34
	 * @param string
35
	 */
36
	public CFStringValue(VirtualMachine vm, String string) {
37
		super(vm);
38
		this.string = string;
39
	}
40
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString()
43
	 */
44
	public String valueString() {
45
		return string;
46
	}
47
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.StringValue#value()
50
	 */
51
	public String value() {
52
		return string;
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see java.lang.Object#toString()
57
	 */
58
	public String toString() {
59
		return string;
60
	}
61
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFThreadReference.java (+326 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import java.util.ArrayList;
14
import java.util.Collections;
15
import java.util.List;
16
import java.util.Map;
17
18
import org.eclipse.osgi.util.NLS;
19
import org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame;
20
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
21
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
22
import org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest;
23
import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
24
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
25
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFRequestPacket;
26
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFResponsePacket;
27
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Commands;
28
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
29
30
/**
31
 * Default implementation of {@link ThreadReference} for Crossfire
32
 * 
33
 * @since 1.0
34
 */
35
public class CFThreadReference extends CFMirror implements ThreadReference {
36
	
37
	static final int RUNNING = 0;
38
	static final int SUSPENDED = 1;
39
	static final int TERMINATED = 2;
40
	static final int EVENT_RESUME = 3;
41
	
42
	private String id = null;
43
	private String url = null;
44
	private boolean current = false;
45
	private int state = RUNNING;
46
	private ArrayList frames = null;
47
	private int stepkind = -1;
48
	
49
	/**
50
	 * Constructor
51
	 * 
52
	 * @param vm
53
	 * @param id
54
	 * @param url
55
	 */
56
	public CFThreadReference(VirtualMachine vm, String id, String url) {
57
		super(vm);
58
		this.id = id;
59
		this.url = url;
60
	}
61
	
62
	/**
63
	 * Constructor
64
	 * @param vm
65
	 * @param json
66
	 */
67
	public CFThreadReference(VirtualMachine vm, Map json) {
68
		super(vm);
69
		this.id = (String) json.get(Attributes.CONTEXT_ID);
70
		this.url = (String) json.get(Attributes.URL);
71
		Boolean bool = (Boolean) json.get(Attributes.CURRENT);
72
		if(bool != null) {
73
			this.current = bool.booleanValue();
74
		}
75
	}
76
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#frameCount()
79
	 */
80
	public int frameCount() {
81
		return frames == null ? 0 : frames.size();
82
	}
83
84
	/* (non-Javadoc)
85
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#frame(int)
86
	 */
87
	public synchronized StackFrame frame(int index) {
88
		if(frames == null || index < 0 || index > frames.size()) {
89
			return null;
90
		}
91
		return (StackFrame) frames.get(index);
92
	}
93
94
	/* (non-Javadoc)
95
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#frames()
96
	 */
97
	public synchronized List frames() {
98
		if(frames == null) {
99
			CFRequestPacket request = new CFRequestPacket(Commands.BACKTRACE, id);
100
			request.setArgument(Attributes.FROM_FRAME, new Integer(0));
101
			request.setArgument(Attributes.INCLUDE_SCOPES, Boolean.TRUE);
102
			CFResponsePacket response = crossfire().sendRequest(request);
103
			if(response.isSuccess()) {
104
				frames = new ArrayList();
105
				List frms = (List) response.getBody().get(Attributes.FRAMES);
106
				if(frms != null) {
107
					Map fmap = null;
108
					for (int i = 0; i < frms.size(); i++) {
109
						fmap = (Map) frms.get(i);
110
						//XXX hack to prevent http://code.google.com/p/fbug/issues/detail?id=4203
111
						if(fmap.containsKey(Attributes.URL)) {
112
							frames.add(new CFStackFrame(virtualMachine(), this, fmap));
113
						}
114
						else if(TRACE) {
115
							Tracing.writeString("STACKFRAME [got bogus stackframe infos]: "+fmap.values().toString()); //$NON-NLS-1$
116
						}
117
					}
118
				}
119
			}
120
			else {
121
				if(TRACE) {
122
					Tracing.writeString("STACKFRAME [backtrace request failed]: "+JSON.serialize(request)); //$NON-NLS-1$
123
				}
124
				if(frames != null) {
125
					frames.clear();
126
				}
127
				return Collections.EMPTY_LIST;
128
			}
129
		}
130
		return frames;
131
	}
132
133
	/* (non-Javadoc)
134
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#interrupt()
135
	 */
136
	public void interrupt() {
137
		try {
138
			resume();
139
		}
140
		finally {
141
			state = TERMINATED;
142
		}
143
	}
144
145
	/**
146
	 * The thread has been resumed by an event
147
	 */
148
	public void eventResume() {
149
		state = EVENT_RESUME;
150
	}
151
	
152
	/* (non-Javadoc)
153
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#resume()
154
	 */
155
	public void resume() {
156
		if(isSuspended()) {
157
			try {
158
				if(state != EVENT_RESUME) {
159
					//XXX only send an request if we were not resumed by an event
160
					CFRequestPacket request = new CFRequestPacket(Commands.CONTINUE, id);
161
					String step = resolveStepKind();
162
					if(step != null) {
163
						request.setArgument(Attributes.STEPACTION, step);
164
					}
165
				
166
					CFResponsePacket response = crossfire().sendRequest(request);
167
					if(response.isSuccess()) {
168
						state = RUNNING;
169
					}
170
					else if(TRACE) {
171
						Tracing.writeString("THREAD [failed continue request] "+JSON.serialize(request)); //$NON-NLS-1$
172
					}
173
				}
174
			}
175
			finally {
176
				clearFrames();
177
				state = RUNNING;
178
			}
179
		}
180
	}
181
182
	/* (non-Javadoc)
183
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#suspend()
184
	 */
185
	public void suspend() {
186
		if(isRunning()) {
187
			CFRequestPacket request = new CFRequestPacket(Commands.SUSPEND, id);
188
			try {
189
				CFResponsePacket response = crossfire().sendRequest(request);
190
				if(response.isSuccess()) {
191
					//XXX catch in case the last resume failed
192
					state = SUSPENDED;
193
				}
194
				else if(TRACE) {
195
					Tracing.writeString("THREAD [failed suspend request]: "+JSON.serialize(request)); //$NON-NLS-1$
196
				}
197
			}
198
			finally {
199
				clearFrames();
200
			}
201
		}
202
	}
203
204
	/**
205
	 * Clears out any stale stack frames
206
	 */
207
	void clearFrames() {
208
		if(frames != null) {
209
			frames.clear();
210
			frames = null;
211
		}
212
	}
213
	
214
	/* (non-Javadoc)
215
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#status()
216
	 */
217
	public int status() {
218
		return THREAD_STATUS_RUNNING;
219
	}
220
221
	/* (non-Javadoc)
222
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#isAtBreakpoint()
223
	 */
224
	public boolean isAtBreakpoint() {
225
		return false;
226
	}
227
228
	/* (non-Javadoc)
229
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#isSuspended()
230
	 */
231
	public boolean isSuspended() {
232
		return state == SUSPENDED;
233
	}
234
235
	/**
236
	 * @return if the thread is in a running state
237
	 */
238
	public boolean isRunning() {
239
		return state == RUNNING;
240
	}
241
	
242
	/* (non-Javadoc)
243
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference#name()
244
	 */
245
	public String name() {
246
		return NLS.bind(Messages.thread_name, new Object[] {id, url});
247
	}
248
	
249
	/* (non-Javadoc)
250
	 * @see java.lang.Object#toString()
251
	 */
252
	public String toString() {
253
		StringBuffer buffer = new StringBuffer();
254
		buffer.append("ThreadReference: [contextId - ").append(id).append("] [url - ").append(url).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
255
		return buffer.toString();
256
	}
257
	
258
	/**
259
	 * Returns the Crossfire id for this thread
260
	 * 
261
	 * @return the id
262
	 */
263
	public String id() {
264
		return id;
265
	}
266
	
267
	/**
268
	 * Returns the URL for this thread
269
	 * 
270
	 * @return the URL
271
	 */
272
	public String url() {
273
		return url;
274
	}
275
	
276
	/**
277
	 * Marks the thread as suspended or not. This is a call-back from the 
278
	 * VM when suspending a VM.
279
	 * 
280
	 * @param suspended
281
	 */
282
	public void markSuspended(boolean suspended) {
283
		//XXX catch - this causes a state change
284
		clearFrames();
285
		state = suspended ? SUSPENDED : RUNNING;
286
	}
287
	
288
	/**
289
	 * Sets the current step kind kind to perform, or -1 to remove the kind
290
	 * @param stepkind
291
	 */
292
	public void setStep(int step) {
293
		this.stepkind = step;
294
	}
295
	
296
	/**
297
	 * @return the step kind to use in the continue request or <code>null</code>
298
	 */
299
	String resolveStepKind() {
300
		if(stepkind != -1) {
301
			switch(stepkind) {
302
				case StepRequest.STEP_INTO: return Commands.STEP_IN;
303
				case StepRequest.STEP_OUT: return Commands.STEP_OUT;
304
				case StepRequest.STEP_OVER: return Commands.STEP_NEXT;
305
			}
306
		}
307
		return null;
308
	}
309
	
310
	/**
311
	 * Returns if the this thread is the current (focus) context in the browser 
312
	 * 
313
	 * @return <code>true</code> if this thread is the current (focus) context
314
	 */
315
	public boolean isCurrent() {
316
		return this.current;
317
	}
318
	
319
	/**
320
	 * Allows the current (focus) status of the thread to be set
321
	 * @param current the new current state
322
	 */
323
	public void setCurrent(boolean current) {
324
		this.current = current;
325
	}
326
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFUndefinedValue.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.UndefinedValue;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
16
/**
17
 * Default implementation for an {@link UndefinedValue} for Crossfire
18
 * 
19
 * @since 1.0
20
 */
21
public class CFUndefinedValue extends CFMirror implements UndefinedValue {
22
23
	public static final String UNDEFINED = "undefined"; //$NON-NLS-1$
24
25
	/**
26
	 * Constructor
27
	 * 
28
	 * @param vm
29
	 */
30
	public CFUndefinedValue(VirtualMachine vm) {
31
		super(vm);
32
	}
33
	
34
	/* (non-Javadoc)
35
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Value#valueString()
36
	 */
37
	public String valueString() {
38
		return UNDEFINED;
39
	}
40
	
41
	/* (non-Javadoc)
42
	 * @see java.lang.Object#toString()
43
	 */
44
	public String toString() {
45
		return valueString();
46
	}
47
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFVariable.java (+96 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import java.util.Map;
14
15
import org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame;
16
import org.eclipse.wst.jsdt.debug.core.jsdi.Value;
17
import org.eclipse.wst.jsdt.debug.core.jsdi.Variable;
18
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
19
20
/**
21
 * Default implementation of a {@link Variable} for Crossfire
22
 * 
23
 * @since 1.0
24
 */
25
public class CFVariable extends CFProperty implements Variable {
26
27
	/**
28
	 * Constructor
29
	 * 
30
	 * @param vm
31
	 * @param frame
32
	 * @param name
33
	 * @param ref
34
	 * @param values
35
	 */
36
	public CFVariable(CFVirtualMachine vm, CFStackFrame frame, String name, Number ref, Map values) {
37
		super(vm, frame, name, ref);
38
		Value value = null;
39
		try {
40
			if(values != null) {
41
				String kind = (String) values.get(Attributes.TYPE);
42
				//if we have a primitive type create it value now
43
				if(kind != null) {
44
					if(kind.equals(Attributes.STRING)) {
45
						value = new CFStringValue(vm, (String) values.get(Attributes.VALUE));
46
					}
47
					else if(kind.equals(Attributes.NUMBER)) {
48
						Object o = values.get(Attributes.VALUE);
49
						if(o instanceof Number) {
50
							value = new CFNumberValue(vm, (Number)o);
51
						}
52
						else if(o instanceof String) {
53
							value = new CFNumberValue(vm, (String)o);
54
						}
55
					}
56
					else if(kind.equals(Attributes.BOOLEAN)) {
57
						value = new CFBooleanValue(vm, ((Boolean)values.get(Attributes.VALUE)).booleanValue());
58
					}
59
					if(Attributes.THIS.equals(name)) {
60
						//special object that has no lookup so we have to pre-populate the properties
61
						value = new CFObjectReference(crossfire(), frame, values);
62
					}
63
					if(CFUndefinedValue.UNDEFINED.equals(kind)) {
64
						value = crossfire().mirrorOfUndefined();
65
					}
66
				}
67
			}
68
			else {
69
				value = crossfire().mirrorOfNull();
70
			}
71
		}
72
		catch(Exception e) {
73
			value = crossfire().mirrorOfUndefined();
74
		}
75
		if(value != null) {
76
			setValue(value);
77
		}
78
	}
79
80
	/* (non-Javadoc)
81
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Variable#isArgument()
82
	 */
83
	public boolean isArgument() {
84
		return false;
85
	}
86
87
	/* (non-Javadoc)
88
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Variable#isVisible(org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame)
89
	 */
90
	public boolean isVisible(StackFrame frame) {
91
		if(frame instanceof CFStackFrame) {
92
			return ((CFStackFrame)frame).isVisible(this);
93
		}
94
		return false;
95
	}
96
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/CFVirtualMachine.java (+839 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import java.util.ArrayList;
14
import java.util.Arrays;
15
import java.util.Collections;
16
import java.util.HashMap;
17
import java.util.Iterator;
18
import java.util.List;
19
import java.util.Map;
20
import java.util.Map.Entry;
21
import java.util.Vector;
22
23
import org.eclipse.core.resources.IMarkerDelta;
24
import org.eclipse.core.resources.IResource;
25
import org.eclipse.core.runtime.CoreException;
26
import org.eclipse.core.runtime.Path;
27
import org.eclipse.core.runtime.QualifiedName;
28
import org.eclipse.debug.core.DebugPlugin;
29
import org.eclipse.debug.core.IBreakpointListener;
30
import org.eclipse.debug.core.IBreakpointManager;
31
import org.eclipse.debug.core.model.IBreakpoint;
32
import org.eclipse.wst.jsdt.core.JavaScriptCore;
33
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLineBreakpoint;
34
import org.eclipse.wst.jsdt.debug.core.jsdi.BooleanValue;
35
import org.eclipse.wst.jsdt.debug.core.jsdi.NullValue;
36
import org.eclipse.wst.jsdt.debug.core.jsdi.NumberValue;
37
import org.eclipse.wst.jsdt.debug.core.jsdi.StringValue;
38
import org.eclipse.wst.jsdt.debug.core.jsdi.UndefinedValue;
39
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
40
import org.eclipse.wst.jsdt.debug.core.jsdi.event.EventQueue;
41
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequestManager;
42
import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel;
43
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
44
import org.eclipse.wst.jsdt.debug.internal.core.breakpoints.JavaScriptLineBreakpoint;
45
import org.eclipse.wst.jsdt.debug.internal.crossfire.Constants;
46
import org.eclipse.wst.jsdt.debug.internal.crossfire.CrossFirePlugin;
47
import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
48
import org.eclipse.wst.jsdt.debug.internal.crossfire.event.CFEventQueue;
49
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
50
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFEventPacket;
51
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFRequestPacket;
52
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFResponsePacket;
53
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Commands;
54
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.JSON;
55
import org.eclipse.wst.jsdt.debug.transport.DebugSession;
56
import org.eclipse.wst.jsdt.debug.transport.exception.DisconnectedException;
57
import org.eclipse.wst.jsdt.debug.transport.exception.TimeoutException;
58
59
/**
60
 * Default CrossFire implementation of {@link VirtualMachine}
61
 * 
62
 * @since 1.0
63
 */
64
public class CFVirtualMachine extends CFMirror implements VirtualMachine, IBreakpointListener {
65
66
	private final NullValue nullvalue = new CFNullValue(this);
67
	private final UndefinedValue undefinedvalue = new CFUndefinedValue(this);
68
	
69
	private final DebugSession session;
70
	private final CFEventRequestManager ermanager = new CFEventRequestManager(this);
71
	private final CFEventQueue queue = new CFEventQueue(this, ermanager);
72
	private boolean disconnected = false;
73
	
74
	private Map threads = null;
75
	private Map scripts = null;
76
	private Map breakpointHandles = new HashMap();
77
	
78
	/**
79
	 * Constructor
80
	 * 
81
	 * @param session
82
	 */
83
	public CFVirtualMachine(DebugSession session) {
84
		super();
85
		this.session = session;
86
		initializeBreakpoints();
87
	}
88
	
89
	/**
90
	 * Synchronizes the set of breakpoints between client and server 
91
	 */
92
	void initializeBreakpoints() {
93
		IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
94
		manager.addBreakpointListener(this);
95
		IBreakpoint[] managerBreakpoints = manager.getBreakpoints(JavaScriptDebugModel.MODEL_ID);
96
		Vector allBps = new Vector();
97
		for (int i = 0; i < managerBreakpoints.length; i++) {
98
			IBreakpoint current = managerBreakpoints[i];
99
			if (current instanceof JavaScriptLineBreakpoint) {
100
				try {
101
					JavaScriptLineBreakpoint breakpoint = (JavaScriptLineBreakpoint)current;
102
103
					IResource resource = breakpoint.getMarker().getResource();
104
					QualifiedName qName = new QualifiedName(JavaScriptCore.PLUGIN_ID, "scriptURL"); //$NON-NLS-1$
105
					String url = resource.getPersistentProperty(qName);
106
					if (url == null) {
107
						String path = breakpoint.getScriptPath();
108
						url = JavaScriptDebugPlugin.getExternalScriptPath(new Path(path));
109
					}
110
					
111
					if (url != null) {
112
						Map location = new HashMap();
113
						location.put(Attributes.LINE, new Integer(breakpoint.getLineNumber()));
114
						location.put(Attributes.URL, url);
115
						Map attributes = new HashMap();
116
						if (breakpoint.isConditionEnabled()) {
117
							String condition = breakpoint.getCondition();
118
							if (condition != null) {
119
								attributes.put(Attributes.CONDITION, condition);
120
							}
121
						}
122
						int hitCount = breakpoint.getHitCount();
123
						if (hitCount != -1) {
124
							attributes.put(Attributes.HIT_COUNT, new Integer(hitCount));
125
						}
126
						Map bpMap = new HashMap();
127
						bpMap.put(Attributes.TYPE, Attributes.LINE);
128
						bpMap.put(Attributes.LOCATION, location);
129
						bpMap.put(Attributes.ATTRIBUTES, attributes);
130
						allBps.add(bpMap);
131
					}
132
				} catch (CoreException e) {
133
					CrossFirePlugin.log(e);
134
				}				
135
			}
136
		}
137
		if (allBps.size() > 0) {
138
			CFRequestPacket request = new CFRequestPacket(Commands.SET_BREAKPOINTS, null);
139
			request.setArgument(Attributes.BREAKPOINTS, Arrays.asList(allBps.toArray()));
140
			CFResponsePacket response = ((CFVirtualMachine)virtualMachine()).sendRequest(request);
141
			if (!response.isSuccess()) {
142
				if(TRACE) {
143
					Tracing.writeString("VM [failed setbreakpoints request]: "+JSON.serialize(request)); //$NON-NLS-1$
144
				}
145
			}
146
		}
147
		
148
		CFRequestPacket request = new CFRequestPacket(Commands.GET_BREAKPOINTS, null);
149
		CFResponsePacket response = sendRequest(request);
150
		if(response.isSuccess()) {
151
			List list = (List) response.getBody().get(Attributes.BREAKPOINTS);
152
			Map bp = null;
153
			for (Iterator i = list.iterator(); i.hasNext();) {
154
				bp = (Map) i.next();
155
				addBreakpoint(bp);
156
			}
157
		}
158
		else if(TRACE) {
159
			Tracing.writeString("VM [failed getbreakpoints request]: "+JSON.serialize(request)); //$NON-NLS-1$
160
		}
161
	}
162
	
163
	/**
164
	 * Sends the <code>getbreakpoint</code> request for the given breakpoint handle
165
	 * @param handle
166
	 * @return the {@link RemoteBreakpoint} representing the request or <code>null</code> if the breakpoint could not be found
167
	 */
168
	public RemoteBreakpoint getBreakpoint(Number handle) {
169
		CFRequestPacket request = new CFRequestPacket(Commands.GET_BREAKPOINTS, null);
170
		request.setArgument(Attributes.HANDLES, Arrays.asList(new Number[] {handle}));
171
		CFResponsePacket response = sendRequest(request);
172
		if(response.isSuccess()) {
173
			List list = (List)response.getBody().get(Attributes.BREAKPOINTS);
174
			if (list != null && list.size() > 0) {
175
				addBreakpoint((Map)list.get(0));
176
			}
177
		}
178
		else if(TRACE) {
179
			Tracing.writeString("VM [failed getbreakpoint request]: "+JSON.serialize(request)); //$NON-NLS-1$
180
		}
181
		return (RemoteBreakpoint) breakpointHandles.get(handle);
182
	}
183
	
184
	/**
185
	 * Sends the <code>changebreakpoint</code> request for the given breakpoint handle to change the given map of attributes
186
	 * @param handle
187
	 * @param attributes
188
	 * @return the changed {@link RemoteBreakpoint} object or <code>null</code> if the request failed
189
	 */
190
	public RemoteBreakpoint changeBreakpoint(Number handle, Map attributes) {
191
		CFRequestPacket request = new CFRequestPacket(Commands.CHANGE_BREAKPOINTS, null);
192
		request.setArgument(Attributes.HANDLES, Arrays.asList(new Number[] {handle}));
193
		request.setArgument(Attributes.ATTRIBUTES, attributes);
194
		CFResponsePacket response = sendRequest(request);
195
		if(response.isSuccess()) {
196
			updateBreakpoint(response.getBody());
197
		}
198
		else if(TRACE) {
199
			Tracing.writeString("VM [failed getbreakpoint request]: "+JSON.serialize(request)); //$NON-NLS-1$
200
		}
201
		return (RemoteBreakpoint) breakpointHandles.get(handle);
202
	}
203
	
204
	/**
205
	 * Called via reflection to determine if the VM supports suspend on script loads
206
	 * @return <code>true</code> if this VM can suspend when a script loads <code>false</code> otherwise
207
	 */
208
	public boolean supportsSuspendOnScriptLoads() {
209
		return false;
210
	}
211
	
212
	/**
213
	 * Add the breakpoint described by the given JSON to the handles list
214
	 * @param json
215
	 */
216
	public void addBreakpoint(Map json) {
217
		if(json != null) {
218
			Number handle = (Number) json.get(Attributes.HANDLE);
219
			if(handle != null) {
220
				RemoteBreakpoint bp = (RemoteBreakpoint) breakpointHandles.get(handle);
221
				if(bp == null) {
222
					bp = new RemoteBreakpoint(this, 
223
						handle,
224
						(Map) json.get(Attributes.LOCATION),
225
						(Map) json.get(Attributes.ATTRIBUTES),
226
						(String)json.get(Attributes.TYPE));
227
				}
228
			}
229
		}
230
	}
231
	
232
	/**
233
	 * Locates the breakpoint for the handle given in the map and updates its attributes
234
	 * 
235
	 * @param json the JSON map, cannot be <code>null</code>
236
	 */
237
	public void updateBreakpoint(Map json) {
238
		if(json != null) {
239
			Number handle = (Number) json.get(Attributes.HANDLE);
240
			if(handle != null) {
241
				RemoteBreakpoint bp = (RemoteBreakpoint) breakpointHandles.get(handle);
242
				if(bp != null) {
243
					bp.setEnabled(RemoteBreakpoint.getEnabled(json));
244
					bp.setCondition(RemoteBreakpoint.getCondition(json));
245
				}
246
			}
247
		}
248
	}
249
	
250
	/**
251
	 * Adds or removes the breakpoint from the cache based on the <code>isset</code> attribute
252
	 * 
253
	 * @param json the JSON map, cannot be <code>null</code>
254
	 */
255
	public void toggleBreakpoint(Map json) {
256
		if(json != null) {
257
			Boolean isset = (Boolean)json.get(Attributes.SET);
258
			if(isset != null && isset.booleanValue()) {
259
				updateBreakpoint(json);
260
			}
261
			else {
262
				Number handle = (Number) json.get(Attributes.HANDLE);
263
				breakpointHandles.remove(handle);
264
			}
265
		}
266
	}
267
	
268
	/**
269
	 * @return the 'readiness' of the VM - i.e. is it in a state to process requests, etc
270
	 */
271
	boolean ready() {
272
		return !disconnected;
273
	}
274
	
275
	/**
276
	 * Sends an <code>createcontext</code> request for the given URL and returns the status of the request.
277
	 * 
278
	 * @param url the URL to open / update in the remote target, <code>null</code> is not accepted
279
	 * @return <code>true</code> if the request was successful, <code>false</code> otherwise
280
	 */
281
	boolean createContext(String url) {
282
		if(url != null && ready()) {
283
			CFRequestPacket request = new CFRequestPacket(Commands.CREATE_CONTEXT, null);
284
			request.getArguments().put(Attributes.URL, url);
285
			CFResponsePacket response = sendRequest(request);
286
			if(response.isSuccess()) {
287
				return true;
288
			}
289
			else if(TRACE) {
290
				Tracing.writeString("VM [failed createcontext request]: "+JSON.serialize(request)); //$NON-NLS-1$
291
			}
292
		}
293
		return false;
294
	}
295
	
296
	/**
297
	 * Sends the frame request
298
	 * @param contextid
299
	 * @param index
300
	 * @param includescopes
301
	 * @return
302
	 */
303
	CFStackFrame getFrame(String contextid, int index, boolean includescopes) {
304
		if(index > -1) {
305
			CFThreadReference thread = findThread(contextid);
306
			if(thread != null) {
307
				CFRequestPacket request = new CFRequestPacket(Commands.FRAME, thread.id());
308
				request.setArgument(Attributes.INDEX, new Integer(index));
309
				request.setArgument(Attributes.INCLUDE_SCOPES, new Boolean(includescopes));
310
				CFResponsePacket response = sendRequest(request);
311
				if(response.isSuccess()) {
312
					return new CFStackFrame(this, thread, response.getBody());
313
				}
314
				else if(TRACE) {
315
					Tracing.writeString("VM [failed frame request]: "+JSON.serialize(request)); //$NON-NLS-1$
316
				}
317
			}
318
		}
319
		return null;
320
		
321
	}
322
	
323
	/**
324
	 * Sends a request to enable the tool with the given name in the remote Crossfire server
325
	 * 
326
	 * @param tools the array of tool names to enable, <code>null</code> is not allowed
327
	 * @return <code>true</code> if the server reports the tool became enabled, <code>false</code> otherwise
328
	 */
329
	boolean enableTools(String[] tools) {
330
		if(tools != null && tools.length > 0 && ready()) {
331
			CFRequestPacket request = new CFRequestPacket(Commands.ENABLE_TOOLS, null);
332
			request.getArguments().put(Attributes.TOOLS, Arrays.asList(tools));
333
			CFResponsePacket response = sendRequest(request);
334
			if(response.isSuccess()) {
335
				//TODO handle the tool being enabled
336
				return true;
337
			}
338
			else if(TRACE) {
339
				Tracing.writeString("VM [failed enabletool request]: "+JSON.serialize(request)); //$NON-NLS-1$
340
			}
341
		}
342
		return false;
343
	}
344
	
345
	/**
346
	 * Sends a request to disable the tool with the given name in the remote Crossfire server
347
	 * 
348
	 * @param tools the array of tool names to disable, <code>null</code> is not allowed
349
	 * @return <code>true</code> if the server reports the tool became disabled, <code>false</code> otherwise
350
	 */
351
	boolean disableTools(String[] tools) {
352
		if(tools != null && tools.length > 0 && ready()) {
353
			CFRequestPacket request = new CFRequestPacket(Commands.DISABLE_TOOLS, null);
354
			request.getArguments().put(Attributes.TOOLS, Arrays.asList(tools));
355
			CFResponsePacket response = sendRequest(request);
356
			if(response.isSuccess()) {
357
				//TODO handle the tool being enabled
358
				return true;
359
			}
360
			else if(TRACE) {
361
				Tracing.writeString("VM [failed disabletool request]: "+JSON.serialize(request)); //$NON-NLS-1$
362
			}
363
		}
364
		return false;
365
	}
366
	
367
	/**
368
	 * Returns the complete listing of tools from Crossfire regardless of their enabled state.
369
	 * 
370
	 * @return the listing of tools or an empty list, never <code>null</code>
371
	 */
372
	List allTools() {
373
		if(ready()) {
374
			CFRequestPacket request = new CFRequestPacket(Commands.GET_TOOLS, null);
375
			CFResponsePacket response = sendRequest(request);
376
			if(response.isSuccess()) {
377
				//TODO do we want to make these first-class objects in our model so we can track state, etc for tools?
378
				List tools = (List) response.getBody().get(Attributes.TOOLS);
379
				if(tools != null) {
380
					return tools;
381
				}
382
			}
383
			else if(TRACE) {
384
				Tracing.writeString("VM [failed alltools request]: "+JSON.serialize(request)); //$NON-NLS-1$
385
			}
386
		}
387
		return Collections.EMPTY_LIST;
388
	}
389
	
390
	/* (non-Javadoc)
391
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#resume()
392
	 */
393
	public void resume() {
394
		if(ready()) {
395
			if(threads != null) {
396
				Entry entry = null;
397
				for (Iterator iter = threads.entrySet().iterator(); iter.hasNext();) {
398
					entry = (Entry) iter.next();
399
					CFThreadReference thread = (CFThreadReference) entry.getValue();
400
					if(thread.isSuspended()) {
401
						CFRequestPacket request = new CFRequestPacket(Commands.CONTINUE, thread.id());
402
						CFResponsePacket response = sendRequest(request);
403
						if(response.isSuccess()) {
404
							if(thread.isSuspended()) {
405
								thread.markSuspended(false);
406
							}
407
						}
408
						else if(TRACE) {
409
							Tracing.writeString("VM [failed continue request][context: "+thread.id()+"]: "+JSON.serialize(request)); //$NON-NLS-1$ //$NON-NLS-2$
410
						}
411
					}
412
				}
413
			}
414
		}
415
	}
416
417
	/* (non-Javadoc)
418
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#suspend()
419
	 */
420
	public void suspend() {
421
		if(ready()) {
422
			if(threads != null) {
423
				Entry entry = null;
424
				for (Iterator iter = threads.entrySet().iterator(); iter.hasNext();) {
425
					entry = (Entry) iter.next();
426
					CFThreadReference thread = (CFThreadReference) entry.getValue();
427
					if(thread.isRunning()) {
428
						CFRequestPacket request = new CFRequestPacket(Commands.SUSPEND, thread.id());
429
						CFResponsePacket response = sendRequest(request);
430
						if(response.isSuccess()) {
431
							if(!thread.isSuspended()) {
432
								thread.markSuspended(true);
433
							}
434
						}
435
						else if(TRACE) {
436
							Tracing.writeString("VM [failed suspend request]: "+JSON.serialize(request)); //$NON-NLS-1$
437
						}
438
					}
439
				}
440
			}
441
		}
442
	}
443
444
	/* (non-Javadoc)
445
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#terminate()
446
	 */
447
	public void terminate() {
448
		if(ready()) {
449
			disconnectVM();
450
		}
451
	}
452
453
	/* (non-Javadoc)
454
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#name()
455
	 */
456
	public String name() {
457
		return Messages.vm_name;
458
	}
459
460
	/* (non-Javadoc)
461
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#description()
462
	 */
463
	public String description() {
464
		return Messages.crossfire_vm;
465
	}
466
467
	/* (non-Javadoc)
468
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#version()
469
	 */
470
	public synchronized String version() {
471
		if(ready()) {
472
			CFRequestPacket request = new CFRequestPacket(Commands.VERSION, null);
473
			CFResponsePacket response = sendRequest(request);
474
			if(response.isSuccess()) {
475
				Map json = response.getBody();
476
				return (String) json.get(Commands.VERSION);
477
			}
478
			if(TRACE) {
479
				Tracing.writeString("VM [failed version request]: "+JSON.serialize(request)); //$NON-NLS-1$
480
			}
481
		}
482
		return Constants.UNKNOWN;
483
	}
484
485
	/* (non-Javadoc)
486
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#allThreads()
487
	 */
488
	public synchronized List allThreads() {
489
		if(threads == null) {
490
			threads = new HashMap();
491
			CFRequestPacket request = new CFRequestPacket(Commands.LISTCONTEXTS, null);
492
			CFResponsePacket response = sendRequest(request);
493
			if(response.isSuccess()) {
494
				List contexts = (List) response.getBody().get(Attributes.CONTEXTS);
495
				for (Iterator iter = contexts.iterator(); iter.hasNext();) {
496
					Map json = (Map) iter.next();
497
					CFThreadReference thread = new CFThreadReference(this, json);
498
					threads.put(thread.id(), thread);
499
				}
500
			}
501
			else if(TRACE) {
502
				Tracing.writeString("VM [failed allthreads request]: "+JSON.serialize(request)); //$NON-NLS-1$
503
			}
504
		}
505
		return new ArrayList(threads.values());
506
	}
507
508
	/**
509
	 * Adds a thread to the listing
510
	 * 
511
	 * @param id
512
	 * @param url
513
	 * @return the new thread
514
	 */
515
	public CFThreadReference addThread(String id, String url) {
516
		if(threads == null) {
517
			allThreads();
518
		}
519
		CFThreadReference thread  = new CFThreadReference(this, id, url);
520
		threads.put(thread.id(), thread);
521
		return thread;
522
	}
523
	
524
	/**
525
	 * Removes the thread with the given id
526
	 * 
527
	 * @param id the id of the thread to remove
528
	 */
529
	public void removeThread(String id) {
530
		if(threads != null) {
531
			Object obj = threads.remove(id);
532
			if(TRACE && obj == null) {
533
				Tracing.writeString("VM [failed to remove thread]: "+id); //$NON-NLS-1$
534
			}
535
		}
536
	}
537
	
538
	/**
539
	 * Returns the thread with the given id or <code>null</code>
540
	 * 
541
	 * @param id
542
	 * @return the thread or <code>null</code>
543
	 */
544
	public synchronized CFThreadReference findThread(String id) {
545
		if(threads == null) {
546
			allThreads();
547
		}
548
		CFThreadReference thread = (CFThreadReference) threads.get(id);
549
		if(TRACE && thread == null) {
550
			Tracing.writeString("VM [failed to find thread]: "+id); //$NON-NLS-1$
551
		}
552
		return thread;
553
	}
554
	
555
	/* (non-Javadoc)
556
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#allScripts()
557
	 */
558
	public synchronized List allScripts() {
559
		if(scripts == null) {
560
			scripts = new HashMap();
561
			List threads = allThreads();
562
			for (Iterator iter = threads.iterator(); iter.hasNext();) {
563
				CFThreadReference thread = (CFThreadReference) iter.next();
564
				CFRequestPacket request = new CFRequestPacket(Commands.SCRIPTS, thread.id());
565
				request.setArgument(Attributes.INCLUDE_SOURCE, Boolean.FALSE);
566
				CFResponsePacket response = sendRequest(request);
567
				if(response.isSuccess()) {
568
					List scriptz = (List) response.getBody().get(Attributes.SCRIPTS);
569
					for (Iterator iter2 = scriptz.iterator(); iter2.hasNext();) {
570
						Map smap = (Map) iter2.next();
571
						if(smap != null) {
572
							CFScriptReference script = new CFScriptReference(this, thread.id(), smap); 
573
							scripts.put(script.url(), script);
574
						}
575
					}
576
				}
577
				else if(TRACE) {
578
					Tracing.writeString("VM [failed scripts request]: "+JSON.serialize(request)); //$NON-NLS-1$
579
				}
580
			}
581
			if(scripts.size() < 1) {
582
				scripts = null;
583
				return Collections.EMPTY_LIST;
584
			}
585
		}
586
		return new ArrayList(scripts.values());
587
	}
588
589
	/**
590
	 * Returns the script with the given url or <code>null</code>
591
	 * 
592
	 * @param url
593
	 * @return the thread or <code>null</code>
594
	 */
595
	public synchronized CFScriptReference findScript(String url) {
596
		if(scripts == null) {
597
			allScripts();
598
		}
599
		CFScriptReference script = null;
600
		if(scripts != null) {
601
			//the scripts collection can be null after a call to allScripts()
602
			//when the remote target had no scripts loaded. In this case
603
			//we do not keep the initialized collection so that any successive 
604
			//calls the this method or allScripts will cause the remote target 
605
			//to be asked for all of its scripts
606
			script = (CFScriptReference) scripts.get(url);
607
		}
608
		//if we find we have a script id that is not cached, we should try a lookup + add in the vm
609
		if(script == null) {
610
			if(TRACE) {
611
				Tracing.writeString("VM [failed to find script]: "+url); //$NON-NLS-1$
612
			}
613
		}
614
		return script;
615
	}
616
	
617
	/**
618
	 * Adds the given script to the listing
619
	 * 
620
	 * @param context_id
621
	 * @param json
622
	 * 
623
	 * @return the new script
624
	 */
625
	public CFScriptReference addScript(String context_id, Map json) {
626
		if(scripts == null) {
627
			allScripts();
628
		}
629
		CFScriptReference script = new CFScriptReference(this, context_id, json);
630
		scripts.put(script.url(), script);
631
		return script;
632
	}
633
	
634
	/**
635
	 * Removes all {@link CFScriptReference}s from the cache when the associated context is destroyed
636
	 * 
637
	 * @param contextid
638
	 */
639
	public void removeScriptsForContext(String contextid) {
640
		if(scripts != null) {
641
			Entry e = null;
642
			for(Iterator i = scripts.entrySet().iterator(); i.hasNext();) {
643
				e = (Entry) i.next();
644
				if(contextid.equals(((CFScriptReference)e.getValue()).context())) {
645
					i.remove();
646
				}
647
			}
648
		}
649
	}
650
	
651
	/**
652
	 * Removes the script with the given url from the listing
653
	 * 
654
	 * @param url the script to remove
655
	 */
656
	public void removeScript(String url) {
657
		if(scripts != null) {
658
			Object obj = scripts.remove(url);
659
			if(TRACE && obj == null) {
660
				Tracing.writeString("VM [failed to remove script]: "+url); //$NON-NLS-1$
661
			}
662
		}
663
	}
664
	
665
	/* (non-Javadoc)
666
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#dispose()
667
	 */
668
	public synchronized void dispose() {
669
		try {
670
			if(TRACE) {
671
				Tracing.writeString("VM [disposing]"); //$NON-NLS-1$
672
			}
673
			queue.dispose();
674
			ermanager.dispose();
675
		}
676
		finally {
677
			//fall-back in case the VM has been disposed but not disconnected
678
			disconnectVM();
679
		}
680
	}
681
682
	/* (non-Javadoc)
683
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOfUndefined()
684
	 */
685
	public UndefinedValue mirrorOfUndefined() {
686
		return undefinedvalue;
687
	}
688
689
	/* (non-Javadoc)
690
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOfNull()
691
	 */
692
	public NullValue mirrorOfNull() {
693
		return nullvalue;
694
	}
695
696
	/* (non-Javadoc)
697
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOf(boolean)
698
	 */
699
	public BooleanValue mirrorOf(boolean bool) {
700
		return new CFBooleanValue(this, bool);
701
	}
702
703
	/* (non-Javadoc)
704
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOf(java.lang.Number)
705
	 */
706
	public NumberValue mirrorOf(Number number) {
707
		return new CFNumberValue(this, number);
708
	}
709
710
	/* (non-Javadoc)
711
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#mirrorOf(java.lang.String)
712
	 */
713
	public StringValue mirrorOf(String string) {
714
		return new CFStringValue(this, string);
715
	}
716
717
	/* (non-Javadoc)
718
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#eventRequestManager()
719
	 */
720
	public synchronized EventRequestManager eventRequestManager() {
721
		return ermanager;
722
	}
723
724
	/* (non-Javadoc)
725
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine#eventQueue()
726
	 */
727
	public synchronized EventQueue eventQueue() {
728
		return queue;
729
	}
730
	
731
	/**
732
	 * Receives an {@link CFEventPacket} from the underlying {@link DebugSession}, 
733
	 * waiting for the {@link VirtualMachine#DEFAULT_TIMEOUT}.
734
	 * 
735
	 * @return the next {@link CFEventPacket} never <code>null</code>
736
	 * @throws TimeoutException
737
	 * @throws DisconnectedException
738
	 */
739
	public CFEventPacket receiveEvent() throws TimeoutException, DisconnectedException {
740
		return (CFEventPacket) session.receive(CFEventPacket.EVENT, DEFAULT_TIMEOUT);
741
	}
742
743
	/**
744
	 * Receives an {@link CFEventPacket} from the underlying {@link DebugSession}, 
745
	 * waiting for the {@link VirtualMachine#DEFAULT_TIMEOUT}.
746
	 * @param timeout
747
	 * @return the next {@link CFEventPacket} never <code>null</code>
748
	 * @throws TimeoutException
749
	 * @throws DisconnectedException
750
	 */
751
	public CFEventPacket receiveEvent(int timeout) throws TimeoutException, DisconnectedException {
752
		return (CFEventPacket) session.receive(CFEventPacket.EVENT, timeout);
753
	}
754
	
755
	/**
756
	 * Sends a request to the underlying {@link DebugSession}, waiting
757
	 * for the {@link VirtualMachine#DEFAULT_TIMEOUT}.
758
	 * 
759
	 * @param request
760
	 * @return the {@link CFResponsePacket} for the request
761
	 */
762
	public CFResponsePacket sendRequest(CFRequestPacket request) {
763
		try {
764
			session.send(request);
765
			return (CFResponsePacket) session.receiveResponse(request.getSequence(), 3000);
766
		}
767
		catch(DisconnectedException de) {
768
			disconnectVM();
769
			handleException(de.getMessage(), (de.getCause() == null ? de : de.getCause()));
770
		}
771
		catch(TimeoutException te) {
772
			CrossFirePlugin.log(te);
773
		}
774
		return CFResponsePacket.FAILED;
775
	}
776
	
777
	/**
778
	 * disconnects the VM
779
	 */
780
	public synchronized void disconnectVM() {
781
		if (disconnected) {
782
			// no-op it is already disconnected
783
			if(TRACE) {
784
				Tracing.writeString("VM [already disconnected]"); //$NON-NLS-1$
785
			}
786
			return;
787
		}
788
		if(TRACE) {
789
			Tracing.writeString("VM [disconnecting]"); //$NON-NLS-1$
790
		}
791
		try {
792
			if(threads != null) {
793
				threads.clear();
794
			}
795
			if(scripts != null) {
796
				scripts.clear();
797
			}
798
			this.queue.dispose();
799
			this.ermanager.dispose();
800
			this.session.dispose();
801
		} finally {
802
			disconnected = true;
803
			DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
804
		}
805
	}
806
807
	/* (non-Javadoc)
808
	 * @see org.eclipse.debug.core.IBreakpointListener#breakpointAdded(org.eclipse.debug.core.model.IBreakpoint)
809
	 */
810
	public void breakpointAdded(IBreakpoint breakpoint) {
811
		if (JavaScriptDebugModel.MODEL_ID.equals(breakpoint.getModelIdentifier())) {
812
			if (breakpoint instanceof IJavaScriptLineBreakpoint) {
813
				//TODO check handle map send request as needed
814
			}
815
	 	}
816
	}
817
818
	/* (non-Javadoc)
819
	 * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
820
	 */
821
	public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
822
		if (JavaScriptDebugModel.MODEL_ID.equals(breakpoint.getModelIdentifier())) {
823
			if (breakpoint instanceof IJavaScriptLineBreakpoint) {
824
				//TODO check handle map send request as needed
825
			}
826
		}
827
	}
828
829
	/* (non-Javadoc)
830
	 * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
831
	 */
832
	public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
833
		if (JavaScriptDebugModel.MODEL_ID.equals(breakpoint.getModelIdentifier())) {
834
			if (breakpoint instanceof IJavaScriptLineBreakpoint) {
835
				//TODO check handle map send request as needed
836
			}
837
		}
838
	}
839
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/Messages.java (+30 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import org.eclipse.osgi.util.NLS;
14
15
/**
16
 *
17
 */
18
public class Messages extends NLS {
19
	private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.messages"; //$NON-NLS-1$
20
	public static String crossfire_vm;
21
	public static String thread_name;
22
	public static String vm_name;
23
	static {
24
		// initialize resource bundle
25
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
26
	}
27
28
	private Messages() {
29
	}
30
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/RemoteBreakpoint.java (+276 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi;
12
13
import java.util.HashMap;
14
import java.util.Iterator;
15
import java.util.Map;
16
import java.util.Map.Entry;
17
18
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
19
20
21
/**
22
 * This class holds the description of a breakpoint from the crossfire server
23
 * 
24
 * @since 1.0
25
 */
26
public class RemoteBreakpoint implements Comparable {
27
28
	public static final String TYPE_LINE = "line"; //$NON-NLS-1$
29
	public static final String TYPE_HTML_ATTRIBUTE_CHANGE = "html_attribute_change"; //$NON-NLS-1$
30
	public static final String TYPE_HTML_CHILD_CHANGE = "html_child_change"; //$NON-NLS-1$
31
	public static final String TYPE_HTML_REMOVE = "html_remove"; //$NON-NLS-1$
32
	public static final String TYPE_HTML_TEXT = "html_text"; //$NON-NLS-1$
33
	public static final String TYPE_HTML_UNKNOWN = "html_unknown_type"; //$NON-NLS-1$
34
	
35
	CFVirtualMachine vm = null;
36
	Number handle = null;
37
	String kind = null;
38
	Map location = null;
39
	Map attributes = null;
40
	
41
	/**
42
	 * Constructor
43
	 * @param vm
44
	 * @param handle
45
	 * @param location
46
	 * @param attributes
47
	 * @param kind
48
	 */
49
	public RemoteBreakpoint(CFVirtualMachine vm, Number handle, Map location, Map attributes, String kind) {
50
		this.vm = vm;
51
		this.handle = handle;
52
		this.location = location;
53
		this.attributes = attributes;
54
		this.kind = kind;
55
	}
56
	
57
	/**
58
	 * @return the handle
59
	 */
60
	public Number getHandle() {
61
		return handle;
62
	}
63
	
64
	/**
65
	 * @return the url
66
	 */
67
	public String getUrl() {
68
		if(this.location != null) {
69
			return (String) this.location.get(Attributes.URL);
70
		}
71
		return null;
72
	}
73
	
74
	/**
75
	 * @return the line
76
	 */
77
	public int getLine() {
78
		if(this.location != null) {
79
			Number line = (Number) this.location.get(Attributes.LINE);
80
			if(line != null) {
81
				return line.intValue();
82
			}
83
		}
84
		return -1;
85
	}
86
	
87
	/**
88
	 * @return the condition
89
	 */
90
	public String getCondition() {
91
		if(this.attributes != null) {
92
			return (String) this.attributes.get(Attributes.CONDITION);
93
		}
94
		return null;
95
	}
96
	
97
	/**
98
	 * @param condition the condition to set
99
	 */
100
	public void setCondition(String condition) {
101
		if(this.attributes == null) {
102
			this.attributes = new HashMap();
103
		}
104
		if(condition != null) {
105
			this.attributes.put(Attributes.CONDITION, condition);
106
		}
107
		else {
108
			this.attributes.remove(Attributes.CONDITION);
109
		}
110
	}
111
	
112
	/**
113
	 * @return the enabled
114
	 */
115
	public boolean isEnabled() {
116
		if(this.attributes != null) {
117
			Boolean bool = (Boolean) this.attributes.get(Attributes.ENABLED);
118
			if(bool != null) {
119
				return bool.booleanValue();
120
			}
121
		}
122
		return false;
123
	}
124
	
125
	/**
126
	 * @param enabled the enabled to set
127
	 */
128
	public void setEnabled(boolean enabled) {
129
		if(this.attributes == null) {
130
			this.attributes = new HashMap();
131
		}
132
		this.attributes.put(Attributes.ENABLED, Boolean.valueOf(enabled));
133
	}
134
	
135
	/**
136
	 * @return the kind
137
	 */
138
	public String getKind() {
139
		return kind;
140
	}
141
	
142
	/* (non-Javadoc)
143
	 * @see java.lang.Object#equals(java.lang.Object)
144
	 */
145
	public boolean equals(Object o) {
146
		if(o instanceof RemoteBreakpoint) {
147
			RemoteBreakpoint bp = (RemoteBreakpoint) o;
148
			return handle.equals(bp.handle) && mapsEqual(location, bp.location) && mapsEqual(attributes, bp.attributes) && kind.equals(bp.kind);
149
		}
150
		return false;
151
	}
152
	
153
	/**
154
	 * Returns if the given maps are equal. 
155
	 * <br><br>
156
	 * They are considered equal iff:
157
	 * <ul>
158
	 * <li>both maps are <code>null</code></li>
159
	 * <li>the maps have the same number of values and the those values are equal using the default {@link #equals(Object)} method</li>
160
	 * </ul>
161
	 * 
162
	 * @param m1
163
	 * @param m2
164
	 * @return <code>true</code> if the maps are equal <code>false</code> otherwise
165
	 */
166
	boolean mapsEqual(Map m1, Map m2) {
167
		if(m1 == null && m2 == null) {
168
			return true;
169
		}
170
		if(m1 == null ^ m2 == null) {
171
			return false;
172
		}
173
		if(m1.size() != m2.size()) {
174
			return false;
175
		}
176
		Entry entry = null;
177
		for (Iterator i = m1.entrySet().iterator(); i.hasNext();) {
178
			entry = (Entry) i.next();
179
			Object val = m2.get(entry.getKey());
180
			if(val == null) {
181
				return false;
182
			}
183
			if(!val.equals(entry.getValue())) {
184
				return false;
185
			}
186
		}
187
		return true;
188
	}
189
	
190
	/* (non-Javadoc)
191
	 * @see java.lang.Object#hashCode()
192
	 */
193
	public int hashCode() {
194
		return handle.hashCode() + mapHashCode(location) + mapHashCode(attributes) + kind.hashCode();
195
	}
196
	
197
	/**
198
	 * Computes the hash code for the given map
199
	 * @param m
200
	 * @return the hash code to use for the given map
201
	 */
202
	int mapHashCode(Map m) {
203
		int hashcode = 0;
204
		for (Iterator i = m.values().iterator(); i.hasNext();) {
205
			hashcode += i.next().hashCode();
206
		}
207
		return hashcode;
208
	}
209
	
210
	/* (non-Javadoc)
211
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
212
	 */
213
	public int compareTo(Object o) {
214
		if(o instanceof RemoteBreakpoint) {
215
			RemoteBreakpoint bp = (RemoteBreakpoint) o;
216
			return this.kind.compareTo(bp.kind);
217
		}
218
		return 0;
219
	}
220
	
221
	/* (non-Javadoc)
222
	 * @see java.lang.Object#toString()
223
	 */
224
	public String toString() {
225
		StringBuffer buff = new StringBuffer("RemoteBreakpoint\n"); //$NON-NLS-1$
226
		buff.append("\t[handle: ").append(handle.toString()).append("]\n"); //$NON-NLS-1$ //$NON-NLS-2$
227
		return super.toString();
228
	}
229
	
230
	/**
231
	 * Helper method to get the {@link Attributes#ENABLED} value from the breakpoint JSON
232
	 * 
233
	 * @param json the JSON for the breakpoint
234
	 * @return <code>true</code> if the attribute is found and <code>true</code>, <code>false</code> otherwise
235
	 */
236
	public static boolean getEnabled(Map json) {
237
		Object val = json.get(Attributes.ATTRIBUTES);
238
		if(val instanceof Map) {
239
			Map map = (Map) val;
240
			val = map.get(Attributes.ENABLED);
241
			if(val instanceof Boolean) {
242
				return ((Boolean)val).booleanValue();
243
			}
244
		}
245
		return false;
246
	}
247
	
248
	/**
249
	 * Helper method to get the condition from the breakpoint JSON
250
	 * 
251
	 * @param json the JSON for the breakpoint
252
	 * @return the condition or <code>null</code>
253
	 */
254
	public static final String getCondition(Map json) {
255
		Object val = json.get(Attributes.ATTRIBUTES);
256
		if(val instanceof Map) {
257
			Map map = (Map) val;
258
			return (String)map.get(Attributes.CONDITION);
259
		}
260
		return null;
261
	}
262
	
263
	/**
264
	 * Helper method to get the 'set' value from the breakpoint JSON
265
	 * 
266
	 * @param json the JSON for the breakpoint
267
	 * @return <code>true</code> if the attribute is present and <code>true</code>, <code>false</code> otherwise
268
	 */
269
	public static final boolean isSet(Map json) {
270
		Object val = json.get(Attributes.SET);
271
		if(val instanceof Boolean) {
272
			return ((Boolean)val).booleanValue();
273
		}
274
		return false;
275
	}
276
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/jsdi/messages.properties (+13 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2010 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
crossfire_vm=Crossfire VM
12
thread_name={0} - {1}
13
vm_name=CrossFire VM
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFBreakpointRequest.java (+148 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
12
13
import java.util.Arrays;
14
import java.util.HashMap;
15
import java.util.List;
16
import java.util.Map;
17
18
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
19
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
20
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
21
import org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest;
22
import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFScriptReference;
23
import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFVirtualMachine;
24
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Attributes;
25
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFRequestPacket;
26
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFResponsePacket;
27
import org.eclipse.wst.jsdt.debug.internal.crossfire.transport.Commands;
28
29
/**
30
 * Default implementation of {@link BreakpointRequest} for Crossfire
31
 * 
32
 * @since 1.0
33
 */
34
public class CFBreakpointRequest extends CFThreadEventRequest implements BreakpointRequest {
35
36
	private String condition = null;
37
	private int hitcount = 0;
38
	private Location location = null;
39
	private Long bpHandle = null;
40
	
41
	/**
42
	 * Constructor
43
	 * @param vm
44
	 * @param location
45
	 */
46
	public CFBreakpointRequest(VirtualMachine vm, Location location) {
47
		super(vm);
48
		this.location = location;
49
	}
50
51
	/* (non-Javadoc)
52
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Locatable#location()
53
	 */
54
	public Location location() {
55
		return location;
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest#addThreadFilter(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
60
	 */
61
	public void addThreadFilter(ThreadReference thread) {
62
		setThread(thread);
63
	}
64
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest#addConditionFilter(java.lang.String)
67
	 */
68
	public void addConditionFilter(String condition) {
69
		this.condition = condition;
70
	}
71
72
	/**
73
	 * Returns the {@link String} condition set for this request using {@link #addConditionFilter(String)} or <code>null</code>
74
	 * 
75
	 * @return the condition filter or <code>null</code>
76
	 */
77
	public String getConditionFilter() {
78
		return condition;
79
	}
80
	
81
	/* (non-Javadoc)
82
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.BreakpointRequest#addHitCountFilter(int)
83
	 */
84
	public void addHitCountFilter(int hitcount) {
85
		this.hitcount = hitcount;
86
	}
87
88
	/**
89
	 * Returns the hit count set using {@link #addHitCountFilter(int)} or <code>0</code>
90
	 * 
91
	 * @return the specified hit count or <code>0</code>
92
	 */
93
	public int getHitCount() {
94
		return hitcount;
95
	}
96
	
97
	/* (non-Javadoc)
98
	 * @see org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFEventRequest#setEnabled(boolean)
99
	 */
100
	public void setEnabled(boolean enabled) {
101
		super.setEnabled(enabled);
102
		if(enabled) {
103
			//send setbreakpoint request
104
			CFScriptReference script = (CFScriptReference) location.scriptReference();
105
			CFRequestPacket request = new CFRequestPacket(Commands.SET_BREAKPOINTS, null);
106
			Map bp = new HashMap();
107
			bp.put(Attributes.TYPE, Attributes.LINE);
108
			Map loc = new HashMap();
109
			loc.put(Attributes.LINE, new Integer(location.lineNumber()));
110
			loc.put(Attributes.URL, script.url());
111
			bp.put(Attributes.LOCATION, loc);
112
			Map attribs = new HashMap();
113
			if (condition != null) {
114
				attribs.put(Attributes.CONDITION, condition);	
115
			}
116
			if (hitcount > 0) {
117
				attribs.put(Attributes.HIT_COUNT, new Long(hitcount));
118
			}
119
			attribs.put(Attributes.ENABLED, Boolean.TRUE);
120
			bp.put(Attributes.ATTRIBUTES, attribs);
121
			request.setArgument(Attributes.BREAKPOINTS, Arrays.asList(new Object[] {bp}));
122
			CFResponsePacket response = ((CFVirtualMachine)virtualMachine()).sendRequest(request);
123
			if(response.isSuccess()) {
124
				//process the response to get the handle of the breakpoint
125
				List list = (List)response.getBody().get(Attributes.BREAKPOINTS);
126
				if (list != null && list.size() > 0) {
127
					bp = (Map)list.get(0);
128
					if (bp != null) {
129
						Number handle = (Number) bp.get(Attributes.HANDLE);
130
						bpHandle = new Long(handle.longValue());
131
					}
132
				}
133
				else {
134
					//TODO create a dummy breakpoint whose details can be filled in when an onToggleBreakpoint event is received
135
				}
136
			}
137
		}
138
		else if(bpHandle != null) {
139
			//send deletebreakpoint request
140
			CFRequestPacket request = new CFRequestPacket(Commands.DELETE_BREAKPOINTS, null);
141
			request.getArguments().put(Attributes.HANDLES, Arrays.asList(new Number[] {bpHandle}));
142
			CFResponsePacket response = ((CFVirtualMachine)virtualMachine()).sendRequest(request);
143
			if(response.isSuccess()) {
144
				bpHandle = null;
145
			}
146
		}
147
	}
148
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDeathRequest.java (+30 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.request.VMDeathRequest;
15
16
/**
17
 * Default implementation of {@link VMDeathRequest} for Crossfire
18
 * 
19
 * @since 1.0
20
 */
21
public class CFDeathRequest extends CFEventRequest implements VMDeathRequest {
22
23
	/**
24
	 * Constructor
25
	 * @param vm
26
	 */
27
	public CFDeathRequest(VirtualMachine vm) {
28
		super(vm);
29
	}
30
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDebuggerRequest.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.request.DebuggerStatementRequest;
16
17
/**
18
 * Default implementation of {@link DebuggerStatementRequest} for Crossfire
19
 * 
20
 * @since 1.0
21
 */
22
public class CFDebuggerRequest extends CFThreadEventRequest implements DebuggerStatementRequest {
23
24
	/**
25
	 * Constructor
26
	 * @param vm
27
	 */
28
	public CFDebuggerRequest(VirtualMachine vm) {
29
		super(vm);
30
	}
31
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.DebuggerStatementRequest#addThreadFilter(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
34
	 */
35
	public void addThreadFilter(ThreadReference thread) {
36
		setThread(thread);
37
	}
38
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFDisconnectRequest.java (+30 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.request.VMDisconnectRequest;
15
16
/**
17
 * Default implementation of {@link VMDisconnectRequest} for Crossfire
18
 * 
19
 * @since 1.0
20
 */
21
public class CFDisconnectRequest extends CFEventRequest implements VMDisconnectRequest {
22
23
	/**
24
	 * Constructor
25
	 * @param vm
26
	 */
27
	public CFDisconnectRequest(VirtualMachine vm) {
28
		super(vm);
29
	}
30
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFEventRequest.java (+53 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest;
15
16
/**
17
 * Default {@link EventRequest} for Crossfire
18
 * 
19
 * @since 1.0
20
 */
21
public class CFEventRequest implements EventRequest {
22
23
	private boolean enabled = false;
24
	private VirtualMachine vm = null;
25
	
26
	/**
27
	 * Constructor
28
	 */
29
	public CFEventRequest(VirtualMachine vm) {
30
		this.vm = vm;
31
	}
32
	
33
	/* (non-Javadoc)
34
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.Mirror#virtualMachine()
35
	 */
36
	public VirtualMachine virtualMachine() {
37
		return vm;
38
	}
39
40
	/* (non-Javadoc)
41
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#isEnabled()
42
	 */
43
	public boolean isEnabled() {
44
		return enabled;
45
	}
46
47
	/* (non-Javadoc)
48
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.EventRequest#setEnabled(boolean)
49
	 */
50
	public void setEnabled(boolean enabled) {
51
		this.enabled = enabled;
52
	}
53
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFExceptionRequest.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ExceptionRequest;
16
17
/**
18
 * Default implementation of {@link ExceptionRequest} for Crossfire
19
 * 
20
 * @since 1.0
21
 */
22
public class CFExceptionRequest extends CFThreadEventRequest implements ExceptionRequest {
23
24
	/**
25
	 * Constructor
26
	 * @param vm
27
	 */
28
	public CFExceptionRequest(VirtualMachine vm) {
29
		super(vm);
30
	}
31
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.ExceptionRequest#addThreadFilter(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
34
	 */
35
	public void addThreadFilter(ThreadReference thread) {
36
		setThread(thread);
37
	}
38
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFResumeRequest.java (+33 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ResumeRequest;
16
17
/**
18
 * Crossfire implementation of {@link ResumeRequest}
19
 * 
20
 * @since 1.0
21
 */
22
public class CFResumeRequest extends CFThreadEventRequest implements ResumeRequest {
23
24
	/**
25
	 * Constructor
26
	 * @param vm
27
	 * @param thread
28
	 */
29
	public CFResumeRequest(VirtualMachine vm, ThreadReference thread) {
30
		super(vm);
31
		setThread(thread);
32
	}
33
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFScriptLoadRequest.java (+30 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ScriptLoadRequest;
15
16
/**
17
 * Default implementation of {@link ScriptLoadRequest} for Crossfire
18
 * 
19
 * @since 1.0
20
 */
21
public class CFScriptLoadRequest extends CFEventRequest implements ScriptLoadRequest {
22
23
	/**
24
	 * Constructor
25
	 * @param vm
26
	 */
27
	public CFScriptLoadRequest(VirtualMachine vm) {
28
		super(vm);
29
	}
30
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFStepRequest.java (+50 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest;
16
import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFThreadReference;
17
18
/**
19
 * Default implementation of {@link StepRequest} for Crossfire
20
 * 
21
 * @since 1.0
22
 */
23
public class CFStepRequest extends CFThreadEventRequest implements StepRequest {
24
25
	private int stepkind = 0;
26
	
27
	/**
28
	 * Constructor
29
	 * @param vm
30
	 */
31
	public CFStepRequest(VirtualMachine vm, ThreadReference thread, int step) {
32
		super(vm);
33
		setThread(thread);
34
		this.stepkind = step;
35
	}
36
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.StepRequest#step()
39
	 */
40
	public int step() {
41
		return stepkind;
42
	}
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.wst.jsdt.debug.internal.crossfire.request.CFEventRequest#setEnabled(boolean)
45
	 */
46
	public void setEnabled(boolean enabled) {
47
		super.setEnabled(enabled);
48
		((CFThreadReference)thread()).setStep((enabled ? stepkind : -1));
49
	}
50
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFSuspendRequest.java (+32 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.request.SuspendRequest;
16
17
/**
18
 * Default implementation of {@link SuspendRequest} for Crossfire
19
 * 
20
 * @since 1.0
21
 */
22
public class CFSuspendRequest extends CFThreadEventRequest implements SuspendRequest {
23
24
	/**
25
	 * Constructor
26
	 * @param vm
27
	 */
28
	public CFSuspendRequest(VirtualMachine vm, ThreadReference thread) {
29
		super(vm);
30
		setThread(thread);
31
	}
32
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadEnterRequest.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadEnterRequest;
16
17
/**
18
 * Default implementation of {@link ThreadEnterRequest} for Crossfire
19
 * 
20
 * @since 1.0
21
 */
22
public class CFThreadEnterRequest extends CFThreadEventRequest implements ThreadEnterRequest {
23
24
	/**
25
	 * Constructor
26
	 * @param vm
27
	 */
28
	public CFThreadEnterRequest(VirtualMachine vm) {
29
		super(vm);
30
	}
31
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadEnterRequest#addThreadFilter(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
34
	 */
35
	public void addThreadFilter(ThreadReference thread) {
36
		setThread(thread);
37
	}
38
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadEventRequest.java (+48 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
16
/**
17
 * Abstract notion of an event that knows about a thread
18
 * 
19
 * @since 1.0
20
 */
21
public class CFThreadEventRequest extends CFEventRequest {
22
23
	private ThreadReference thread = null;
24
	
25
	/**
26
	 * Constructor
27
	 * @param vm
28
	 */
29
	public CFThreadEventRequest(VirtualMachine vm) {
30
		super(vm);
31
	}
32
	
33
	/**
34
	 * Sets the backing {@link ThreadReference} for the request
35
	 * @param thread
36
	 */
37
	public void setThread(ThreadReference thread) {
38
		this.thread = thread;
39
	}
40
	
41
	/**
42
	 * Returns the underlying {@link ThreadReference} this request is filtered to.
43
	 * @return the thread filter
44
	 */
45
	public ThreadReference thread() {
46
		return this.thread;
47
	}
48
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/request/CFThreadExitRequest.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.request;
12
13
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
14
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;
15
import org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadExitRequest;
16
17
/**
18
 * Default implementation of {@link ThreadExitRequest} for Crossfire
19
 * 
20
 * @since 1.0
21
 */
22
public class CFThreadExitRequest extends CFThreadEventRequest implements ThreadExitRequest {
23
	
24
	/**
25
	 * Constructor
26
	 * @param vm
27
	 */
28
	public CFThreadExitRequest(VirtualMachine vm) {
29
		super(vm);
30
	}
31
	
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.request.ThreadExitRequest#addThreadFilter(org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference)
34
	 */
35
	public void addThreadFilter(ThreadReference thread) {
36
		setThread(thread);
37
	}
38
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/Attributes.java (+356 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
12
13
/**
14
 * Interface for all the attribute constants
15
 * 
16
 * @since 1.0
17
 */
18
public interface Attributes {
19
20
	/**
21
	 * The "arguments" attribute
22
	 */
23
	public static final String ARGUMENTS = "arguments"; //$NON-NLS-1$
24
	/**
25
	 * The "attributes" attribute
26
	 */
27
	public static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
28
	/**
29
	 * The "body" attribute
30
	 */
31
	public static final String BODY = "body"; //$NON-NLS-1$
32
	/**
33
	 * The type "boolean"
34
	 */
35
	public static final String BOOLEAN = "boolean"; //$NON-NLS-1$
36
 	/**
37
	 * The "breakpoint" attribute
38
	 */
39
	public static final String BREAKPOINT = "breakpoint"; //$NON-NLS-1$
40
	/**
41
	 * The "breakpoints" attribute
42
	 */
43
	public static final String BREAKPOINTS = "breakpoints"; //$NON-NLS-1$
44
	/**
45
	 * The "category" attribute
46
	 */
47
	public static final String CATEGORY = "category"; //$NON-NLS-1$
48
	/**
49
	 * The "callee attribute"
50
	 */
51
	public static final String CALLEE = "callee"; //$NON-NLS-1$
52
	/**
53
	 * The "callingFrame" attribute
54
	 */
55
	public static final String CALLING_FRAME = "callingFrame"; //$NON-NLS-1$
56
	/**
57
	 * The code attribute for this packet
58
	 */
59
	public static final String CODE = "code"; //$NON-NLS-1$
60
	/**
61
	 * The "columnNumber" attribute
62
	 */
63
	public static final String COLUMN_NUMBER = "columnNumber"; //$NON-NLS-1$
64
	/**
65
	 * The "columnOffset" attribute
66
	 */
67
	public static final String COLUMN_OFFSET = "columnOffset"; //$NON-NLS-1$
68
	/**
69
	 * The "command" attribute
70
	 */
71
	public static final String COMMAND = "command"; //$NON-NLS-1$
72
	/**
73
	 * The "condition" argument
74
	 */
75
	public static final String CONDITION = "condition"; //$NON-NLS-1$
76
	/**
77
	 * the "constructor" attribute
78
	 */
79
	public static final String CONSTRUCTOR = "constructor"; //$NON-NLS-1$
80
	/**
81
	 * the "context_href" attribute
82
	 */
83
	public static final String CONTEXT_HREF = "context_href"; //$NON-NLS-1$
84
	/**
85
	 * The "contextId" attribute
86
	 */
87
	public static final String CONTEXT_ID = "contextId"; //$NON-NLS-1$
88
	/**
89
	 * The "contexts" attribute
90
	 */
91
	public static final String CONTEXTS = "contexts"; //$NON-NLS-1$
92
	/**
93
	 * the "current" attribute
94
	 */
95
	public static final String CURRENT = "current"; //$NON-NLS-1$
96
	/**
97
	 * The "data" attribute
98
	 */
99
	public static final String DATA = "data"; //$NON-NLS-1$
100
	/**
101
	 * The "enabled" argument
102
	 */
103
	public static final String ENABLED = "enabled"; //$NON-NLS-1$
104
	/**
105
	 * The "error" attribute for an onError event
106
	 */
107
	public static final String ERROR = "error"; //$NON-NLS-1$
108
	/**
109
	 * The "errorMessage" attribute
110
	 */
111
	public static final String ERROR_MESSAGE = "errorMessage"; //$NON-NLS-1$
112
	/**
113
	 * The "executionContext" attribute
114
	 */
115
	public static final String EXECUTION_CONTEXT = "executionContext"; //$NON-NLS-1$
116
	/**
117
	 * The "expression" attribute
118
	 */
119
	public static final String EXPRESSION = "expression"; //$NON-NLS-1$
120
	/**
121
	 * The "fileName" attribute
122
	 */
123
	public static final String FILE_NAME = "fileName"; //$NON-NLS-1$
124
	/**
125
	 * The "flags" attributes
126
	 */
127
	public static final String FLAGS = "flags"; //$NON-NLS-1$
128
	/**
129
	 * The "frame" argument
130
	 */
131
	public static final String FRAME = "frame"; //$NON-NLS-1$
132
	/**
133
	 * The "frameIndex" argument
134
	 */
135
	public static final String FRAME_INDEX = "frameIndex"; //$NON-NLS-1$
136
	/**
137
	 * The "frameNumber" argument
138
	 */
139
	public static final String FRAME_NUMBER = "frameNumber"; //$NON-NLS-1$
140
	/**
141
	 * The "frames" attribute
142
	 */
143
	public static final String FRAMES = "frames"; //$NON-NLS-1$
144
	/**
145
	 * The "fromFrame" attribute
146
	 */
147
	public static final String FROM_FRAME = "fromFrame"; //$NON-NLS-1$
148
	/**
149
	 * The "functionName" attribute
150
	 */
151
	public static final String FUNCTION_NAME = "functionName"; //$NON-NLS-1$
152
	/**
153
	 * The type "function"
154
	 */
155
	public static final String FUNCTION = "function"; //$NON-NLS-1$
156
	/**
157
	 * The "handle" attribute
158
	 */
159
	public static final String HANDLE = "handle"; //$NON-NLS-1$
160
	/**
161
	 * The "handles" attribute
162
	 */
163
	public static final String HANDLES = "handles"; //$NON-NLS-1$
164
	/**
165
	 * The "handshake" attribute
166
	 */
167
	public static final String HANDSHAKE = "handshake"; //$NON-NLS-1$
168
	/**
169
	 * The "hitCount" attribute
170
	 */
171
	public static final String HIT_COUNT = "hitCount"; //$NON-NLS-1$
172
	/**
173
	 * The "href" attribute
174
	 */
175
	public static final String HREF = "href"; //$NON-NLS-1$
176
	/**
177
	 * The "includeScopes" attribute
178
	 */
179
	public static final String INCLUDE_SCOPES = "includeScopes"; //$NON-NLS-1$
180
	/**
181
	 * The "includeSource" attribute
182
	 */
183
	public static final String INCLUDE_SOURCE = "includeSource"; //$NON-NLS-1$
184
	/**
185
	 * The "index" attribute
186
	 */
187
	public static final String INDEX = "index"; //$NON-NLS-1$
188
	/**
189
	 * The "isConstructing" attribute
190
	 */
191
	public static final String IS_CONSTRUCTING = "isConstructing"; //$NON-NLS-1$
192
	/**
193
	 * the "isDebugger" attribute
194
	 */
195
	public static final String IS_DEBUGGER = "isDebugger"; //$NON-NLS-1$
196
	/**
197
	 * the "isValid" attribute
198
	 */
199
	public static final String IS_VALID = "isValid"; //$NON-NLS-1$
200
	/**
201
	 * The "line" attribute
202
	 */
203
	public static final String LINE = "line"; //$NON-NLS-1$
204
	/**
205
	 * The "lineCount" attribute
206
	 */
207
	public static final String LINE_COUNT = "lineCount"; //$NON-NLS-1$
208
	/**
209
	 * The "lineNumber" attribute
210
	 */
211
	public static final String LINE_NUMBER = "lineNumber"; //$NON-NLS-1$
212
	/**
213
	 * The "lineNo" attribute
214
	 */
215
	public static final String LINE_NO = "lineNo"; //$NON-NLS-1$
216
	/**
217
	 * The "lineOffset" attribute
218
	 */
219
	public static final String LINE_OFFSET = "lineOffset"; //$NON-NLS-1$
220
	/**
221
	 * The "locals" attribute
222
	 */
223
	public static final String LOCALS = "locals"; //$NON-NLS-1$
224
	/**
225
	* The "location" attribute
226
	*/
227
	public static final String LOCATION = "location"; //$NON-NLS-1$
228
	/**
229
	 * The message attribute for this packet
230
	 */
231
	public static final String MESSAGE = "message"; //$NON-NLS-1$
232
	/**
233
	 * The "newContextId" attribute
234
	 */
235
	public static final String NEW_CONTEXT_ID = "newContextId"; //$NON-NLS-1$
236
	/**
237
	 * The type "number"
238
	 */
239
	public static final String NUMBER = "number"; //$NON-NLS-1$
240
	/**
241
	 * The type "object"
242
	 */
243
	public static final String OBJECT = "object"; //$NON-NLS-1$
244
	/**
245
	 * The type "proto"
246
	 */
247
	public static final String PROTO = "proto"; //$NON-NLS-1$
248
	/**
249
	 * The "ref" attribute / type
250
	 */
251
	public static final String REF = "ref"; //$NON-NLS-1$
252
	/**
253
	 * The "requestSeq" attribute
254
	 */
255
	public static final String REQUEST_SEQ = "requestSeq"; //$NON-NLS-1$
256
	/**
257
	 * The "result" attribute
258
	 */
259
	public static final String RESULT = "result"; //$NON-NLS-1$
260
	/**
261
	 * The running attribute for this packet
262
	 */
263
	public static final String RUNNING = "running"; //$NON-NLS-1$
264
	/**
265
	 * The "scope" attribute
266
	 */
267
	public static final String SCOPE = "scope"; //$NON-NLS-1$
268
	/**
269
	 * The "scopes" attribute
270
	 */
271
	public static final String SCOPES = "scopes"; //$NON-NLS-1$
272
	/**
273
	 * The "scopeIndexes" attribute
274
	 */
275
	public static final String SCOPE_INDEXES = "scopeIndexes"; //$NON-NLS-1$
276
	/**
277
	 * The "script" attribute
278
	 */
279
	public static final String SCRIPT = "script"; //$NON-NLS-1$
280
	/**
281
	 * The "scripts" attribute
282
	 */
283
	public static final String SCRIPTS = "scripts"; //$NON-NLS-1$
284
	/**
285
	 * The "seq" attribute
286
	 */
287
	public static final String SEQ = "seq"; //$NON-NLS-1$
288
	/**
289
	 * The "set" attribute
290
	 */
291
	public static final String SET = "set"; //$NON-NLS-1$
292
	/**
293
	 * The "source" attribute
294
	 */
295
	public static final String SOURCE = "source"; //$NON-NLS-1$
296
	/**
297
	 * The "sourceLength" attribute
298
	 */
299
	public static final String SOURCE_LENGTH = "sourceLength"; //$NON-NLS-1$
300
	/**
301
	 * The "sourceName" attribute
302
	 */
303
	public static final String SOURCE_NAME = "sourceName"; //$NON-NLS-1$
304
	/**
305
	 * The "stacktrace" attribute
306
	 */
307
	public static final String STACKTRACE = "stackTrace"; //$NON-NLS-1$
308
	/**
309
	 * The "status" attribute
310
	 */
311
	public static final String STATUS = "status"; //$NON-NLS-1$
312
	/**
313
	 * The "stepaction" attribute
314
	 */
315
	public static final String STEPACTION = "stepAction"; //$NON-NLS-1$
316
	/**
317
	 * The type "string"
318
	 */
319
	public static final String STRING = "string"; //$NON-NLS-1$
320
	/**
321
	 * The "this" attribute
322
	 */
323
	public static final String THIS = "this"; //$NON-NLS-1$
324
	/**
325
	 * The thisValue" attribute
326
	 */
327
	public static final String THIS_VALUE = "thisValue"; //$NON-NLS-1$
328
	/**
329
	 * the "toFrame" attribute
330
	 */
331
	public static final String TO_FRAME = "toFrame"; //$NON-NLS-1$
332
	/**
333
	 * The "tools" attribute
334
	 */
335
	public static final String TOOLS = "tools"; //$NON-NLS-1$
336
	/**
337
	 * The "type" attribute
338
	 */
339
	public static final String TYPE = "type"; //$NON-NLS-1$
340
	/**
341
	 * The "url" attribute
342
	 */
343
	public static final String URL = "url"; //$NON-NLS-1$
344
	/**
345
	 * The "urls" attribute
346
	 */
347
	public static final String URLS = "urls"; //$NON-NLS-1$
348
	/**
349
	 * The "value" attribute
350
	 */
351
	public static final String VALUE = "value"; //$NON-NLS-1$
352
	/**
353
	 * The "values" attribute
354
	 */
355
	public static final String VALUES = "values"; //$NON-NLS-1$
356
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFEventPacket.java (+174 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: IBM Corporation - initial API and implementation
8
 *******************************************************************************/
9
package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
10
11
import java.util.Collections;
12
import java.util.HashMap;
13
import java.util.List;
14
import java.util.Map;
15
16
import org.eclipse.wst.jsdt.debug.transport.packet.Event;
17
18
19
/**
20
 * An {@link CFEventPacket} is a specialized {@link CFPacket}
21
 * that only handles <code>event</code> data.
22
 * 
23
 * @since 1.0
24
 */
25
public class CFEventPacket extends CFPacket implements Event {
26
27
	/**
28
	 * The type of this packet
29
	 */
30
	public static final String EVENT = "event"; //$NON-NLS-1$
31
	/**
32
	 * The "closed" event kind
33
	 */
34
	public static final String CLOSED = "closed"; //$NON-NLS-1$
35
	/**
36
	 * The "onScript" event kind
37
	 */
38
	public static final String ON_SCRIPT = "onScript"; //$NON-NLS-1$
39
	/**
40
	 * The "onBreak" event kind
41
	 */
42
	public static final String ON_BREAK = "onBreak"; //$NON-NLS-1$
43
	/**
44
	 * The "onConsoleDebug" event kind
45
	 */
46
	public static final String ON_CONSOLE_DEBUG = "onConsoleDebug"; //$NON-NLS-1$
47
	/**
48
	 * The "onConsoleError" event kind
49
	 */
50
	public static final String ON_CONSOLE_ERROR = "onConsoleError"; //$NON-NLS-1$
51
	/**
52
	 * The "onConsoleInfo" event kind
53
	 */
54
	public static final String ON_CONSOLE_INFO = "onConsoleInfo"; //$NON-NLS-1$
55
	/**
56
	 * The "onConsoleLog" event kind
57
	 */
58
	public static final String ON_CONSOLE_LOG = "onConsoleLog"; //$NON-NLS-1$
59
	/**
60
	 * The "onConsoleWarn" event kind
61
	 */
62
	public static final String ON_CONSOLE_WARN = "onConsoleWarn"; //$NON-NLS-1$
63
	/**
64
	 * The "onError" event kind
65
	 */
66
	public static final String ON_ERROR = "onError"; //$NON-NLS-1$
67
	/**
68
	 * The "onInspectNode" event kind
69
	 */
70
	public static final String ON_INSPECT_NODE = "onInspectNode"; //$NON-NLS-1$
71
	/**
72
	 * The "onResume" event kind
73
	 */
74
	public static final String ON_RESUME = "onResume"; //$NON-NLS-1$
75
	/**
76
	 * The "onToggleBreakpoint" event kind
77
	 */
78
	public static final String ON_TOGGLE_BREAKPOINT = "onToggleBreakpoint"; //$NON-NLS-1$
79
	/**
80
	 * The "onContextSelected" event kind
81
	 */
82
	public static final String ON_CONTEXT_SELECTED = "onContextSelected"; //$NON-NLS-1$
83
	/**
84
	 * The "onContextDestroyed" event kind
85
	 */
86
	public static final String ON_CONTEXT_DESTROYED = "onContextDestroyed"; //$NON-NLS-1$
87
	/**
88
	 * The "onContextCreated" event kind
89
	 */
90
	public static final String ON_CONTEXT_CREATED = "onContextCreated"; //$NON-NLS-1$
91
	/**
92
	 * The "onContextLoaded" event kind
93
	 */
94
	public static final String ON_CONTEXT_LOADED = "onContextLoaded"; //$NON-NLS-1$
95
	
96
	private final String event;
97
	private final Map body = Collections.synchronizedMap(new HashMap());
98
	
99
	/**
100
	 * Constructor
101
	 * @param event
102
	 */
103
	public CFEventPacket(String event) {
104
		super(EVENT, null);
105
		this.event = event.intern();
106
	}
107
108
	/**
109
	 * Constructor
110
	 * @param json
111
	 */
112
	public CFEventPacket(Map json) {
113
		super(json);
114
		String packetEvent = (String) json.get(EVENT);
115
		event = packetEvent.intern();
116
		Object data = json.get(Attributes.BODY);
117
		if(data instanceof Map) {
118
			body.putAll((Map) data);
119
		}
120
		else if(data instanceof String ||
121
				data instanceof List) {
122
			body.put(Attributes.BODY, data);
123
		}
124
		
125
	}
126
127
	/* (non-Javadoc)
128
	 * @see org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket#getContextId()
129
	 */
130
	public String getContextId() {
131
		String id = super.getContextId();
132
		if(id == null) {
133
			id = (String) body.get(Attributes.CONTEXT_ID);
134
		}
135
		return id;
136
	}
137
	
138
	/* (non-Javadoc)
139
	 * @see org.eclipse.wst.jsdt.debug.transport.packet.Event#getEvent()
140
	 */
141
	public String getEvent() {
142
		return event;
143
	}
144
145
	/* (non-Javadoc)
146
	 * @see org.eclipse.wst.jsdt.debug.transport.packet.Event#getBody()
147
	 */
148
	public Map getBody() {
149
		return body;
150
	}
151
152
	/* (non-Javadoc)
153
	 * @see org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket#toJSON()
154
	 */
155
	public Map toJSON() {
156
		Map json = super.toJSON();
157
		json.put(EVENT, event);
158
		if(body.size() > 0) {
159
			json.put(Attributes.BODY, body);
160
		}
161
		return json;
162
	}
163
	
164
	/* (non-Javadoc)
165
	 * @see java.lang.Object#toString()
166
	 */
167
	public String toString() {
168
		StringBuffer buffer = new StringBuffer();
169
		Object json = toJSON();
170
		buffer.append("CFEventPacket: "); //$NON-NLS-1$
171
		JSON.writeValue(json, buffer);
172
		return buffer.toString();
173
	}
174
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFPacket.java (+117 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: IBM Corporation - initial API and implementation
8
 *******************************************************************************/
9
package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
10
11
import java.util.HashMap;
12
import java.util.Map;
13
14
/**
15
 * Abstract description of a packet for sending / receiving information to the debug client
16
 * using JSON
17
 *  
18
 *  @since 1.0
19
 */
20
public abstract class CFPacket implements org.eclipse.wst.jsdt.debug.transport.packet.Packet {
21
22
	/**
23
	 * Debugging flag
24
	 */
25
	public static boolean TRACE = false;
26
	
27
	private final String type;
28
	private final String context_id;
29
	
30
	/**
31
	 * Constructor
32
	 * 
33
	 * @param type the type for the {@link CFPacket} <code>null</code> is not accepted
34
	 */
35
	protected CFPacket(String type, String context_id) {
36
		if(type == null) {
37
			throw new IllegalArgumentException("The type for a packet cannot be null"); //$NON-NLS-1$
38
		}
39
		this.type = type.intern();
40
		this.context_id = context_id;
41
	}
42
43
	/**
44
	 * Constructor
45
	 * 
46
	 * @param json the pre-composed map of attributes for the packet, <code>null</code> is not accepted
47
	 */
48
	protected CFPacket(Map json) {
49
		if(json == null) {
50
			throw new IllegalArgumentException("The JSON map for a packet cannot be null"); //$NON-NLS-1$
51
		}
52
		String packetType = (String) json.get(Attributes.TYPE);
53
		this.type = packetType.intern();
54
		this.context_id = (String) json.get(Attributes.CONTEXT_ID);
55
	}
56
57
	/**
58
	 * @return the context id or <code>null</code>
59
	 */
60
	public String getContextId() {
61
		return context_id;
62
	}
63
	
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.wst.jsdt.debug.transport.packet.Packet#getType()
66
	 */
67
	public String getType() {
68
		return type;
69
	}
70
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.wst.jsdt.debug.transport.packet.Packet#toJSON()
73
	 */
74
	public Map toJSON() {
75
		Map json = new HashMap();
76
		json.put(Attributes.TYPE, type);
77
		if(context_id != null) {
78
			json.put(Attributes.CONTEXT_ID, context_id);
79
		}
80
		return json;
81
	}
82
83
	/**
84
	 * Returns the type from the given JSON map.<br>
85
	 * <br>
86
	 * This method can return <code>null</code> if the map is not correctly
87
	 * formed.
88
	 * 
89
	 * @param json the JSON map, <code>null</code> is not accepted
90
	 * @return the type from the JSON map or <code>null</code>
91
	 */
92
	public static String getType(Map json) {
93
		if(json == null) {
94
			throw new IllegalArgumentException("A null JSON map is not allowed when trying to get the packet type"); //$NON-NLS-1$
95
		}
96
		return (String) json.get(Attributes.TYPE);
97
	}
98
99
	/* (non-Javadoc)
100
	 * @see java.lang.Object#toString()
101
	 */
102
	public String toString() {
103
		StringBuffer buffer = new StringBuffer();
104
		Object json = toJSON();
105
		buffer.append("CFPacket: "); //$NON-NLS-1$
106
		JSON.writeValue(json, buffer);
107
		return buffer.toString();
108
	}
109
	
110
	/**
111
	 * Sets if packet transfer should be traced
112
	 * @param tracing
113
	 */
114
	public static void setTracing(boolean tracing) {
115
		TRACE = tracing;
116
	}
117
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFRequestPacket.java (+151 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: IBM Corporation - initial API and implementation
8
 *******************************************************************************/
9
package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
10
11
import java.util.Collections;
12
import java.util.HashMap;
13
import java.util.Iterator;
14
import java.util.Map;
15
import java.util.Map.Entry;
16
17
import org.eclipse.wst.jsdt.debug.transport.packet.Request;
18
19
/**
20
 * Default request implementation using JSON
21
 * 
22
 * @since 1.0
23
 */
24
public class CFRequestPacket extends CFPacket implements Request {
25
26
	/**
27
	 * The type of this packet
28
	 */
29
	public static final String REQUEST = "request"; //$NON-NLS-1$
30
	
31
	private final String command;
32
	private final Map arguments = Collections.synchronizedMap(new HashMap());
33
	private final Map params = Collections.synchronizedMap(new HashMap());
34
	private static int currentSequence = 0;
35
	private final int sequence;
36
	
37
	/**
38
	 * Constructor
39
	 * 
40
	 * @param command the command, <code>null</code> is not accepted
41
	 * @param context_id the id of the context to scope the request to
42
	 * @see http://getfirebug.com/wiki/index.php/Crossfire_Protocol_Reference for 
43
	 * requests that do not require a context id.
44
	 */
45
	public CFRequestPacket(String command, String context_id) {
46
		super(REQUEST, context_id);
47
		if(command == null) {
48
			throw new IllegalArgumentException("The request command kind cannot be null"); //$NON-NLS-1$
49
		}
50
		this.sequence = nextSequence();
51
		this.command = command.intern();
52
	}
53
54
	/**
55
	 * Constructor
56
	 * 
57
	 * @param json map of JSON attributes, <code>null</code> is not accepted
58
	 */
59
	public CFRequestPacket(Map json) {
60
		super(json);
61
		if(json == null) {
62
			throw new IllegalArgumentException("The JSON map for a request packet cannot be null"); //$NON-NLS-1$
63
		}
64
		String value = (String) json.get(Attributes.COMMAND);
65
		this.command = value.intern();
66
		Map packetArguments = (Map) json.get(Attributes.ARGUMENTS);
67
		arguments.putAll(packetArguments);
68
		Number packetSeq = (Number) json.get(Attributes.SEQ);
69
		this.sequence = packetSeq.intValue();
70
	}
71
72
	/**
73
	 * @return a next value for the sequence
74
	 */
75
	private static synchronized int nextSequence() {
76
		return ++currentSequence;
77
	}
78
	
79
	/* (non-Javadoc)
80
	 * @see org.eclipse.wst.jsdt.debug.transport.packet.Request#getSequence()
81
	 */
82
	public int getSequence() {
83
		return sequence;
84
	}
85
	
86
	/**
87
	 * Allows additional parameters to be added to the request
88
	 * 
89
	 * @param key
90
	 * @param value
91
	 */
92
	public void addAdditionalParam(String key, Object value) {
93
		params.put(key, value);
94
	}
95
	
96
	/* (non-Javadoc)
97
	 * @see org.eclipse.wst.jsdt.debug.transport.packet.Request#getCommand()
98
	 */
99
	public String getCommand() {
100
		return command;
101
	}
102
103
	/* (non-Javadoc)
104
	 * @see org.eclipse.wst.jsdt.debug.transport.packet.Request#getArguments()
105
	 */
106
	public Map getArguments() {
107
		return arguments;
108
	}
109
110
	/**
111
	 * Sets the given argument in the JSON map.
112
	 * 
113
	 * @param key the key for the attribute, <code>null</code> is not accepted
114
	 * @param argument the value for the argument
115
	 */
116
	public void setArgument(String key, Object argument) {
117
		if(key == null) {
118
			throw new IllegalArgumentException("The argument key cannot be null"); //$NON-NLS-1$
119
		}
120
		arguments.put(key, argument);
121
	}
122
123
	/* (non-Javadoc)
124
	 * @see org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket#toJSON()
125
	 */
126
	public Map toJSON() {
127
		Map json = super.toJSON();
128
		json.put(Attributes.SEQ, new Integer(sequence));
129
		json.put(Attributes.COMMAND, command);
130
		if(!arguments.isEmpty()) {
131
			json.put(Attributes.ARGUMENTS, arguments);
132
		}
133
		Entry entry = null;
134
		for(Iterator iter = params.entrySet().iterator(); iter.hasNext();) {
135
			entry = (Entry) iter.next();
136
			json.put(entry.getKey(), entry.getValue());
137
		}
138
		return json;
139
	}
140
	
141
	/* (non-Javadoc)
142
	 * @see java.lang.Object#toString()
143
	 */
144
	public String toString() {
145
		StringBuffer buffer = new StringBuffer();
146
		Object json = toJSON();
147
		buffer.append("CFRequestPacket: "); //$NON-NLS-1$
148
		JSON.writeValue(json, buffer);
149
		return buffer.toString();
150
	}
151
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFResponsePacket.java (+251 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: IBM Corporation - initial API and implementation
8
 *******************************************************************************/
9
package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
10
11
import java.util.Collections;
12
import java.util.HashMap;
13
import java.util.Map;
14
15
import org.eclipse.wst.jsdt.debug.transport.packet.Response;
16
17
/**
18
 * Default {@link CFResponsePacket} implementation using JSON
19
 * 
20
 * @since 1.0
21
 */
22
public class CFResponsePacket extends CFPacket implements Response {
23
24
	/**
25
	 * The type of this packet
26
	 */
27
	public static final String RESPONSE = "response"; //$NON-NLS-1$
28
	
29
	/**
30
	 * Response codes
31
	 */
32
	public static final int CODE_OK = 0;
33
	public static final int CODE_MALFORMED_PACKET = 1;
34
	public static final int CODE_MALFORMED_REQUEST = 2;
35
	public static final int CODE_COMMAND_NOT_IMPLEMENTED = 3;
36
	public static final int CODE_INVALID_ARGUMENTS = 4;
37
	public static final int CODE_UNEXPECTED_EXCEPTION = 5;
38
	public static final int CODE_COMMAND_FAILED = 6;
39
	public static final int CODE_INVALID_STATE = 7;
40
41
	static final Map failed_attributes;
42
	static {
43
		failed_attributes = new HashMap();
44
		Integer value = new Integer(-1);
45
		failed_attributes.put(Attributes.SEQ, value);
46
		failed_attributes.put(Attributes.TYPE, RESPONSE);
47
		failed_attributes.put(Attributes.REQUEST_SEQ, value);
48
		failed_attributes.put(Attributes.COMMAND, "failed"); //$NON-NLS-1$
49
		Map status = new HashMap();
50
		failed_attributes.put(Attributes.STATUS, status);
51
		status.put(Attributes.CODE, new Integer(CODE_UNEXPECTED_EXCEPTION));
52
		status.put(Attributes.RUNNING, Boolean.FALSE);
53
		status.put(Attributes.MESSAGE, "failed"); //$NON-NLS-1$
54
	}
55
	
56
	public static final CFResponsePacket FAILED = new CFResponsePacket(failed_attributes);
57
	
58
	private String command;
59
	private int requestSequence;
60
	private Map body = Collections.synchronizedMap(new HashMap());
61
	private volatile int code = 0;
62
	private volatile boolean running = true;
63
	private volatile String message;
64
	private Map stackTrace = Collections.synchronizedMap(new HashMap());
65
66
	/**
67
	 * Constructor
68
	 * 
69
	 * @param requestSequence the sequence
70
	 * @param command the command, <code>null</code> is not accepted
71
	 */
72
	public CFResponsePacket(int requestSequence, String command) {
73
		super(RESPONSE, null);
74
		if(command == null) {
75
			throw new IllegalArgumentException("The command string for a response packet cannot be null"); //$NON-NLS-1$
76
		}
77
		this.requestSequence = requestSequence;
78
		this.command = command.intern();
79
	}
80
81
	/**
82
	 * Constructor
83
	 * 
84
	 * @param json the JSON map for a response, <code>null</code> is not accepted
85
	 */
86
	public CFResponsePacket(Map json) {
87
		super(json);
88
		Number packetRequestSeq = (Number) json.get(Attributes.REQUEST_SEQ);
89
		requestSequence = packetRequestSeq.intValue();
90
91
		String packetCommand = (String) json.get(Attributes.COMMAND);
92
		command = packetCommand.intern();
93
94
		Object bdy = json.get(Attributes.BODY);
95
		if(bdy instanceof Map) {
96
			Map packetBody = (Map)bdy; 
97
			body.putAll(packetBody);
98
		}
99
100
		Object status = json.get(Attributes.STATUS);
101
		if (status != null && status instanceof Map) {
102
			Map packetStatus = (Map)status;
103
			Object codeObj = packetStatus.get(Attributes.CODE);
104
			if (codeObj != null) {
105
				code = ((Number)codeObj).intValue();
106
			}
107
			Boolean runningObj = (Boolean)packetStatus.get(Attributes.RUNNING);
108
			if (runningObj != null) {
109
				running = runningObj.booleanValue();
110
			}
111
			message = (String)packetStatus.get(Attributes.MESSAGE);
112
			stackTrace = (Map)packetStatus.get(Attributes.STACKTRACE);
113
		}
114
	}
115
116
	/* (non-Javadoc)
117
	 * @see org.eclipse.wst.jsdt.debug.transport.packet.Response#getRequestSequence()
118
	 */
119
	public int getRequestSequence() {
120
		return requestSequence;
121
	}
122
123
	/* (non-Javadoc)
124
	 * @see org.eclipse.wst.jsdt.debug.transport.packet.Response#getCommand()
125
	 */
126
	public String getCommand() {
127
		return command;
128
	}
129
130
	/* (non-Javadoc)
131
	 * @see org.eclipse.wst.jsdt.debug.transport.packet.Response#getBody()
132
	 */
133
	public Map getBody() {
134
		return body;
135
	}
136
137
	/* (non-Javadoc)
138
	 * @see org.eclipse.wst.jsdt.debug.transport.packet.Response#isSuccess()
139
	 */
140
	public boolean isSuccess() {
141
		return code == CODE_OK;
142
	}
143
144
	/**
145
	 * Set the success code for the response
146
	 * 
147
	 * @param code the new success code
148
	 */
149
	public void setCode(int code) {
150
		this.code = code;
151
	}
152
153
	/**
154
	 * Get the success code for the response
155
	 * 
156
	 * return the success code
157
	 */
158
	public int getCode() {
159
		return code;
160
	}
161
162
	/* (non-Javadoc)
163
	 * @see org.eclipse.wst.jsdt.debug.transport.packet.Response#isRunning()
164
	 */
165
	public boolean isRunning() {
166
		return running;
167
	}
168
169
	/**
170
	 * Sets the running state of the underlying command
171
	 * 
172
	 * @param running the new running state for the underlying command
173
	 */
174
	public void setRunning(boolean running) {
175
		this.running = running;
176
	}
177
178
	/**
179
	 * Returns the status message for this {@link CFResponsePacket}.<br>
180
	 * <br>
181
	 * This method can return <code>null</code>
182
	 * 
183
	 * @return the status message for this {@link CFResponsePacket} or <code>null</code>
184
	 */
185
	public String getMessage() {
186
		return message;
187
	}
188
189
	/**
190
	 * Set the status message for this {@link CFResponsePacket}
191
	 * 
192
	 * @param message the new message, <code>null</code> is accepted
193
	 */
194
	public void setMessage(String message) {
195
		this.message = message;
196
	}
197
	
198
	/**
199
	 * Returns the stack trace for this {@link CFResponsePacket}.<br>
200
	 * <br>
201
	 * This method can return <code>null</code>
202
	 * 
203
	 * @return the stack trace for this {@link CFResponsePacket} or <code>null</code>
204
	 */
205
	public Map getStackTrace() {
206
		return stackTrace;
207
	}
208
209
	/**
210
	 * Set the stack trace for this {@link CFResponsePacket}
211
	 * 
212
	 * @param stackTrace the new stack trace, <code>null</code> is accepted
213
	 */
214
	public void setStackTrace(Map stackTrace) {
215
		this.stackTrace = stackTrace;
216
	}
217
218
	/* (non-Javadoc)
219
	 * @see org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket#toJSON()
220
	 */
221
	public Map toJSON() {
222
		Map json = super.toJSON();
223
		json.put(Attributes.REQUEST_SEQ, new Integer(requestSequence));
224
		json.put(Attributes.COMMAND, command);
225
		if(body != null && body.size() > 0) {
226
			json.put(Attributes.BODY, body);
227
		}
228
		Map status = new HashMap();
229
		json.put(Attributes.STATUS, status);
230
		status.put(Attributes.RUNNING, new Boolean(running));
231
		status.put(Attributes.CODE, new Integer(code));
232
		if (message != null) {
233
			status.put(Attributes.MESSAGE, message);
234
		}
235
		if (stackTrace != null) {
236
			status.put(Attributes.STACKTRACE, stackTrace);
237
		}
238
		return json;
239
	}
240
	
241
	/* (non-Javadoc)
242
	 * @see java.lang.Object#toString()
243
	 */
244
	public String toString() {
245
		StringBuffer buffer = new StringBuffer();
246
		Object json = toJSON();
247
		buffer.append("CFResponsePacket: "); //$NON-NLS-1$
248
		JSON.writeValue(json, buffer);
249
		return buffer.toString();
250
	}
251
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFSocketConnection.java (+202 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: IBM Corporation - initial API and implementation
8
 *******************************************************************************/
9
package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
10
11
import java.io.EOFException;
12
import java.io.IOException;
13
import java.io.Reader;
14
import java.io.Writer;
15
import java.net.Socket;
16
import java.util.Map;
17
18
import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
19
import org.eclipse.wst.jsdt.debug.transport.Connection;
20
import org.eclipse.wst.jsdt.debug.transport.packet.Packet;
21
import org.eclipse.wst.jsdt.debug.transport.socket.SocketConnection;
22
23
/**
24
 * A specialized {@link Connection} that communicates using {@link Socket}s
25
 * 
26
 * @since 1.0
27
 */
28
public class CFSocketConnection extends SocketConnection {
29
30
	/**
31
	 * Constructor
32
	 * 
33
	 * @param socket the underlying {@link Socket}, <code>null</code> is not accepted
34
	 * 
35
	 * @throws IOException
36
	 */
37
	public CFSocketConnection(Socket socket) throws IOException {
38
		super(socket);
39
	}
40
	
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.wst.jsdt.debug.transport.socket.SocketConnection#writePacket(org.eclipse.wst.jsdt.debug.transport.packet.Packet)
43
	 */
44
	public void writePacket(Packet packet) throws IOException {
45
		String serialized = JSON.serialize((CFPacket) packet);
46
		if(CFPacket.TRACE) {
47
			Tracing.writeString("WRITE PACKET: "+serialized); //$NON-NLS-1$
48
		}
49
		Writer writer = getWriter();
50
		writer.write(serialized);
51
		writer.flush();
52
	}
53
54
	/**
55
	 * Writes the standard handshake packet to connect
56
	 * 
57
	 * @param tools the {@link String} array of tools to enable by default
58
	 * @throws IOException
59
	 */
60
	public void writeHandShake(String[] tools) throws IOException {
61
		if(CFPacket.TRACE) {
62
			Tracing.writeString("WRITE HANDSHAKE: "+HandShakePacket.getHandshake(tools)); //$NON-NLS-1$
63
		}
64
		Writer writer = getWriter();
65
		writer.write(HandShakePacket.getHandshake(tools));
66
		writer.flush();
67
	}
68
	
69
	/**
70
	 * Reads the {@link HandShakePacket} packet from the the stream
71
	 * 
72
	 * @return the {@link HandShakePacket}, never <code>null</code>
73
	 * @throws IOException
74
	 */
75
	public CFPacket readHandShake() throws IOException {
76
		StringBuffer buffer = new StringBuffer();
77
		//read the header first
78
		int c = 0;
79
		boolean r = false;
80
		Reader reader = getReader();
81
		while((c = reader.read()) > -1) {
82
			buffer.append((char)c);
83
			if(r) {
84
				if(c == '\n') {
85
					break;
86
				}
87
			}
88
			r = c == '\r';
89
		}
90
		//chew up the tool heading if there is one
91
		r = false;
92
		while(reader.ready() && (c = reader.read()) > -1) {
93
			if(r) {
94
				if(c == '\n') {
95
					buffer.append((char)c);
96
					break;
97
				}
98
			}
99
			r = c == '\r';
100
			if(r) {
101
				buffer.append((char)c);
102
			}
103
		}
104
		//XXX hack, we should be properly parsing and accounting for the tool header
105
		if(buffer.toString().equals(HandShakePacket.getHandshake(null))) {
106
			HandShakePacket ack = new HandShakePacket();
107
			if(CFPacket.TRACE) {
108
				Tracing.writeString("ACK HANDSHAKE: "+buffer.toString()); //$NON-NLS-1$
109
			}
110
			return ack;
111
		}	
112
		if(CFPacket.TRACE) {
113
			Tracing.writeString("Did not get correct CrossFire handshake: "+buffer.toString()); //$NON-NLS-1$
114
		}
115
		throw new IOException("Did not get correct CrossFire handshake: "+buffer.toString()); //$NON-NLS-1$
116
	}
117
	
118
	/* (non-Javadoc)
119
	 * @see org.eclipse.wst.jsdt.debug.transport.socket.SocketConnection#readPacket()
120
	 */
121
	public Packet readPacket() throws IOException {
122
		StringBuffer buffer = new StringBuffer();
123
		StringBuffer raw = new StringBuffer();
124
		int c = -1;
125
		boolean r = false;
126
		String len = null;
127
		Reader reader = getReader();
128
		while((c = reader.read()) > -1) {
129
			if(CFPacket.TRACE) {
130
				raw.append((char)c);
131
			}
132
			if(r) {
133
				if(c == '\n') {
134
					String str = buffer.toString();
135
					if(str.startsWith(JSON.CONTENT_LENGTH)) {
136
						len = grabAttrib(str);
137
					}
138
					else if(str.equals("\r")) { //$NON-NLS-1$
139
						break;
140
					}
141
					buffer = new StringBuffer();
142
					r = false;
143
				}
144
				continue;
145
			}
146
			buffer.append((char)c);
147
			r = c == '\r';
148
		}
149
		int length = 0;
150
		try {
151
			length = Integer.parseInt(len);
152
		} catch (NumberFormatException e) {
153
			if(CFPacket.TRACE) {
154
				Tracing.writeString("[SOCKET] failed to read content length: "+raw.toString()); //$NON-NLS-1$
155
			}
156
			throw new IOException("Failed to parse content length: " + raw.toString()); //$NON-NLS-1$
157
		}
158
		char[] message = new char[length];
159
		int n = 0;
160
		int off = 0;
161
		while (n < length) {
162
			int count = reader.read(message, off + n, length - n);
163
			if (count < 0) {
164
				throw new EOFException();
165
			}
166
			n += count;
167
		}
168
		if(CFPacket.TRACE) {
169
			raw.append(message);
170
			Tracing.writeString("READ PACKET: " + raw.toString()); //$NON-NLS-1$
171
		}
172
		Map json = (Map) JSON.read(new String(message));
173
		String type = CFPacket.getType(json);
174
		if (CFEventPacket.EVENT.equals(type)) {
175
			return new CFEventPacket(json);
176
		}
177
		if (CFRequestPacket.REQUEST.equals(type)) {
178
			return new CFRequestPacket(json);
179
		}
180
		if (CFResponsePacket.RESPONSE.equals(type)) {
181
			return new CFResponsePacket(json);
182
		}
183
		throw new IOException("Unknown packet type: " + type); //$NON-NLS-1$
184
	}
185
	
186
	/**
187
	 * Grabs the attribute from the RHS of the header. Where all headers
188
	 * have the form <code>[name]:[value]</code>.
189
	 * 
190
	 * @param str the string to parse
191
	 * @return the <code>[value]</code> from the header
192
	 */
193
	String grabAttrib(String str) {
194
		if(str != null) {
195
			int idx = str.indexOf(':');
196
			if(idx > -1) {
197
				return str.substring(idx+1, str.length()-1);
198
			}
199
		}
200
		return null;
201
	}
202
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/CFTransportService.java (+85 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: IBM Corporation - initial API and implementation
8
 *******************************************************************************/
9
package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
10
11
import java.io.IOException;
12
import java.net.ServerSocket;
13
import java.net.Socket;
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.wst.jsdt.debug.transport.Connection;
18
import org.eclipse.wst.jsdt.debug.transport.ListenerKey;
19
import org.eclipse.wst.jsdt.debug.transport.packet.Packet;
20
import org.eclipse.wst.jsdt.debug.transport.socket.SocketConnection;
21
import org.eclipse.wst.jsdt.debug.transport.socket.SocketTransportService;
22
23
24
/**
25
 * Implementation of a transport service that using a {@link Socket} for communication
26
 * 
27
 * @since 1.0
28
 */
29
public class CFTransportService extends SocketTransportService {
30
31
	static final Class serverSocketClass = ServerSocket.class; // temporary used to pre-load the ServerSocket.class
32
33
	/**
34
	 * Map of {@link ListenerKey} to {@link ServerSocket}s
35
	 */
36
	Map listeners = new HashMap();
37
	
38
	String[] tools = null;
39
	
40
	/**
41
	 * Constructor
42
	 */
43
	public CFTransportService(String[] tools) {
44
		this.tools = tools;
45
	}
46
	
47
	/* (non-Javadoc)
48
	 * @see org.eclipse.wst.jsdt.debug.transport.socket.SocketTransportService#getConnection(java.net.Socket)
49
	 */
50
	public SocketConnection getConnection(Socket socket) throws IOException {
51
		return new CFSocketConnection(socket);
52
	}
53
54
	/* (non-Javadoc)
55
	 * @see org.eclipse.wst.jsdt.debug.transport.socket.SocketTransportService#handleAccept(org.eclipse.wst.jsdt.debug.transport.Connection)
56
	 */
57
	public void handleAccept(Connection connection) throws IOException {
58
		if(connection instanceof CFSocketConnection) {
59
			CFSocketConnection cfconn = (CFSocketConnection) connection;
60
			Packet packet = cfconn.readHandShake();
61
			if (!(packet instanceof HandShakePacket)) {
62
				throw new IOException("failure establishing connection"); //$NON-NLS-1$
63
			}
64
			cfconn.writeHandShake(this.tools);
65
			return;
66
		}
67
		throw new IOException("failure establishing connection"); //$NON-NLS-1$
68
	}
69
	
70
	/* (non-Javadoc)
71
	 * @see org.eclipse.wst.jsdt.debug.transport.socket.SocketTransportService#handleAttach(org.eclipse.wst.jsdt.debug.transport.Connection)
72
	 */
73
	public void handleAttach(Connection connection) throws IOException {
74
		if(connection instanceof CFSocketConnection) {
75
			CFSocketConnection cfconn = (CFSocketConnection) connection;
76
			cfconn.writeHandShake(this.tools);
77
			Packet packet = cfconn.readHandShake();
78
			if (!(packet instanceof HandShakePacket)) {
79
				throw new IOException("failure establishing connection"); //$NON-NLS-1$
80
			}
81
			return;
82
		}
83
		throw new IOException("failure establishing connection"); //$NON-NLS-1$
84
	}
85
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/Commands.java (+113 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
12
13
/**
14
 * Interface for all the command constants
15
 * 
16
 * @since 1.0
17
 */
18
public interface Commands {
19
20
	/**
21
	 * The "backtrace" command
22
	 */
23
	public static final String BACKTRACE = "backtrace"; //$NON-NLS-1$
24
	/**
25
	 * The "changebreakpoint" command
26
	 */
27
	public static final String CHANGE_BREAKPOINTS = "changeBreakpoints"; //$NON-NLS-1$
28
	/**
29
	 * The "deletebreakpoint" command
30
	 */
31
	public static final String DELETE_BREAKPOINTS = "deleteBreakpoints"; //$NON-NLS-1$
32
	/**
33
	 * The "continue" command
34
	 */
35
	public static final String CONTINUE = "continue"; //$NON-NLS-1$
36
	/**
37
	 * The "disabletools" command
38
	 */
39
	public static final String DISABLE_TOOLS = "disableTools"; //$NON-NLS-1$
40
	/**
41
	 * The "enabletools" command
42
	 */
43
	public static final String ENABLE_TOOLS = "enableTools"; //$NON-NLS-1$
44
	/**
45
	 * The "evaluate" command
46
	 */
47
	public static final String EVALUATE = "evaluate"; //$NON-NLS-1$
48
	/**
49
	 * The "frame" command
50
	 */
51
	public static final String FRAME = "frame"; //$NON-NLS-1$
52
	/**
53
	 * The "getbreakpoints" command
54
	 */
55
	public static final String GET_BREAKPOINTS = "getBreakpoints"; //$NON-NLS-1$
56
	/**
57
	 * The "gettools" command
58
	 */
59
	public static final String GET_TOOLS = "getTools"; //$NON-NLS-1$
60
	/**
61
	 * The "inspect" command
62
	 */
63
	public static final String INSPECT = "inspect"; //$NON-NLS-1$
64
	/**
65
	 * The "listcontexts" command
66
	 */
67
	public static final String LISTCONTEXTS = "listContexts"; //$NON-NLS-1$
68
	/**
69
	 * The "lookup" command
70
	 */
71
	public static final String LOOKUP = "lookup"; //$NON-NLS-1$
72
	/**
73
	 * The "scopes" command
74
	 */
75
	public static final String SCOPES = "scopes"; //$NON-NLS-1$
76
	/**
77
	 * The "scripts" command
78
	 */
79
	public static final String SCRIPTS = "scripts"; //$NON-NLS-1$
80
	/**
81
	 * The "setbreakpoint" command
82
	 */
83
	public static final String SET_BREAKPOINTS = "setBreakpoints"; //$NON-NLS-1$
84
	/**
85
	 * The "in" step action
86
	 */
87
	public static final String STEP_IN = "in"; //$NON-NLS-1$
88
	/**
89
	 * The "next" step action 
90
	 */
91
	public static final String STEP_NEXT = "next"; //$NON-NLS-1$
92
	/**
93
	 * The "out" step action
94
	 */
95
	public static final String STEP_OUT = "out"; //$NON-NLS-1$
96
	/**
97
	 * The "source" command
98
	 */
99
	public static final String SOURCE = "source"; //$NON-NLS-1$
100
	/**
101
	 * The "suspend" command
102
	 */
103
	public static final String SUSPEND = "suspend"; //$NON-NLS-1$
104
	/** 
105
	 * The "createcontext" command
106
	 */
107
	public static final String CREATE_CONTEXT = "createContext"; //$NON-NLS-1$
108
	/**
109
	 * The "version" command
110
	 */
111
	public static final String VERSION = "version"; //$NON-NLS-1$
112
113
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/HandShakePacket.java (+73 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
12
13
import java.util.HashMap;
14
import java.util.Map;
15
16
/**
17
 * {@link CFPacket} for replying to the Crossfire handshake request
18
 * 
19
 * @since 1.0
20
 */
21
public class HandShakePacket extends CFPacket {
22
	
23
	/**
24
	 * handshake String
25
	 */
26
	private static String CROSSFIRE_HANDSHAKE = "CrossfireHandshake\r\n"; //$NON-NLS-1$
27
	
28
	
29
	/**
30
	 * Constructor
31
	 * @param type
32
	 */
33
	protected HandShakePacket() {
34
		super(CFResponsePacket.RESPONSE, null);
35
	}
36
37
	/**
38
	 * Creates a handshake object with the given set of tools
39
	 * 
40
	 * @param tools the {@link String} array of tools to enable
41
	 * @return the handshake
42
	 */
43
	public static String getHandshake(String[] tools) {
44
		StringBuffer buffer = new StringBuffer(CROSSFIRE_HANDSHAKE);
45
		if(tools != null) {
46
			for (int i = 0; i < tools.length; i++) {
47
				if(tools[i] != null) {
48
					buffer.append(tools[i]);
49
				}
50
				if(i < tools.length -1) {
51
					buffer.append(',');
52
				}
53
			}
54
		}
55
		return buffer.append(JSON.LINE_FEED).toString();
56
	}
57
	
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket#toString()
60
	 */
61
	public String toString() {
62
		return CROSSFIRE_HANDSHAKE;
63
	}
64
	
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.wst.jsdt.debug.internal.crossfire.transport.CFPacket#toJSON()
67
	 */
68
	public Map toJSON() {
69
		Map json = new HashMap(1);
70
		json.put(Attributes.HANDSHAKE, CROSSFIRE_HANDSHAKE);
71
		return json;
72
	}
73
}
(-)src/org/eclipse/wst/jsdt/debug/internal/crossfire/transport/JSON.java (+540 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.crossfire.transport;
12
13
import java.math.BigDecimal;
14
import java.text.CharacterIterator;
15
import java.text.StringCharacterIterator;
16
import java.util.ArrayList;
17
import java.util.Collection;
18
import java.util.Collections;
19
import java.util.HashMap;
20
import java.util.Iterator;
21
import java.util.List;
22
import java.util.Map;
23
24
import org.eclipse.wst.jsdt.debug.internal.crossfire.Tracing;
25
import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFNullValue;
26
import org.eclipse.wst.jsdt.debug.internal.crossfire.jsdi.CFUndefinedValue;
27
28
/**
29
 * Class for reading / writing JSON objects
30
 * <br><br>
31
 * Crossfire has the following types:
32
 * <ul>
33
 * 	<li>object</li>
34
 * 	<li>function</li>
35
 * 	<li>boolean</li>
36
 * 	<li>number</li>
37
 * 	<li>string</li>
38
 * 	<li>undefined</li>
39
 * 	<li>ref</li>
40
 * </ul> 
41
 * @since 1.0
42
 */
43
public final class JSON {
44
45
	static boolean TRACE = false;
46
	
47
	/**
48
	 * Standard line feed / control feed terminus for Crossfire packets
49
	 */
50
	public static final String LINE_FEED = "\r\n"; //$NON-NLS-1$
51
	/**
52
	 * The default <code>Content-Length:</code> preamble
53
	 */
54
	public static final String CONTENT_LENGTH = "Content-Length:"; //$NON-NLS-1$
55
	/**
56
	 * Enables / Disables tracing in the all of the JSDI implementations
57
	 * 
58
	 * @param trace
59
	 */
60
	public static void setTracing(boolean trace) {
61
		TRACE = trace;
62
	}
63
	
64
	/**
65
	 * Constructor
66
	 * 
67
	 * No instantiation
68
	 */
69
	private JSON() {}
70
	
71
	/**
72
	 * Writes the given key / value pair to the buffer in the form: <code>"key":["]value["]</code>
73
	 * 
74
	 * @param key
75
	 * @param value
76
	 * @param buffer
77
	 */
78
	public static void writeKeyValue(String key, Object value, StringBuffer buffer) {
79
		writeString(key, buffer);
80
		buffer.append(':');
81
		writeValue(value, buffer);
82
	}
83
	
84
	/**
85
	 * Writes out the given value to the buffer. <br><br>
86
	 * Values are written out as:
87
	 * <ul>
88
	 * 	<li>Boolean / Number: <code>value.toString()</code></li>
89
	 * 	<li>String: <code>"value"</code></li>
90
	 * 	<li>null: <code>null</code>
91
	 * 	<li>Collection: <code>[{@link #writeValue(Object, StringBuffer)},...]</code></li>
92
	 * 	<li>Map: <code>{"key":{@link #writeValue(Object, StringBuffer)},...}</code></li>
93
	 * </ul>
94
	 * 
95
	 * @param value
96
	 * @param buffer
97
	 */
98
	public static void writeValue(Object value, StringBuffer buffer) {
99
		if (value == null) {
100
			buffer.append(CFNullValue.NULL);
101
		}
102
		else if (value instanceof Boolean || value instanceof Number) {
103
			buffer.append(value.toString());
104
		}
105
		else if (value instanceof String) {
106
			writeString((String) value, buffer);
107
		}
108
		else if(value instanceof Collection) {
109
			writeArray((Collection) value, buffer);
110
		}
111
		else if(value instanceof Map) {
112
			writeObject((Map) value, buffer);
113
		}
114
	}
115
	
116
	/**
117
	 * Writes the given {@link String} into the given {@link StringBuffer} properly escaping
118
	 * all control characters
119
	 * 
120
	 * @param string
121
	 * @param buffer
122
	 */
123
	public static void writeString(String string, StringBuffer buffer) {
124
		buffer.append('"');
125
		int length = string.length();
126
		for (int i = 0; i < length; i++) {
127
			char c = string.charAt(i);
128
			switch (c) {
129
				case '"' :
130
				case '\\' :
131
				case '/' : {
132
					buffer.append('\\');
133
					buffer.append(c);
134
					break;
135
				}
136
				case '\b' : {
137
					buffer.append("\\b"); //$NON-NLS-1$
138
					break;
139
				}
140
				case '\f' : {
141
					buffer.append("\\f"); //$NON-NLS-1$
142
					break;
143
				}
144
				case '\n' : {
145
					buffer.append("\\n"); //$NON-NLS-1$
146
					break;
147
				}
148
				case '\r' : {
149
					buffer.append("\\r"); //$NON-NLS-1$
150
					break;
151
				}
152
				case '\t' : {
153
					buffer.append("\\t"); //$NON-NLS-1$
154
					break;
155
				}
156
				default :
157
					if (Character.isISOControl(c)) {
158
						buffer.append("\\u"); //$NON-NLS-1$
159
						String hexString = Integer.toHexString(c);
160
						for (int j = hexString.length(); j < 4; j++) {
161
							buffer.append('0');
162
						}
163
						buffer.append(hexString);
164
					} else {
165
						buffer.append(c);
166
					}
167
			}
168
		}
169
		buffer.append('"');
170
	}
171
172
	/**
173
	 * Writes the given collection into an array string of the form: <code>[{@link #writeValue(Object, StringBuffer)},...]</code>
174
	 * 
175
	 * @param collection
176
	 * @param buffer
177
	 */
178
	static void writeArray(Collection collection, StringBuffer buffer) {
179
		buffer.append('[');
180
		for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
181
			writeValue(iterator.next(), buffer);
182
			if(iterator.hasNext()) {
183
				buffer.append(',');
184
			}
185
		}
186
		buffer.append(']');
187
	}
188
	
189
	/**
190
	 * Writes an object mapping to the given buffer in the form: <code>{"key":{@link #writeValue(Object, StringBuffer)},...}</code>
191
	 * 
192
	 * @param map
193
	 * @param buffer
194
	 */
195
	public static void writeObject(Map map, StringBuffer buffer) {
196
		buffer.append('{');
197
		for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();) {
198
			String key = (String) iterator.next();
199
			writeString(key, buffer);
200
			buffer.append(':');
201
			writeValue(map.get(key), buffer);
202
			if(iterator.hasNext()) {
203
				buffer.append(',');
204
			}
205
		}
206
		buffer.append('}');
207
	}
208
	
209
	/**
210
	 * Writes the <code>Content-Length:N</code> preamble to the head of the given buffer
211
	 * 
212
	 * @param buffer
213
	 * @param length
214
	 */
215
	public static void writeContentLength(StringBuffer buffer, int length) {
216
		StringBuffer buff = new StringBuffer(18);
217
		buff.append(CONTENT_LENGTH).append(length).append(LINE_FEED).append(LINE_FEED);
218
		buffer.insert(0, buff.toString());
219
	}
220
	
221
	/**
222
	 * Serializes the given {@link CFPacket} to a {@link String}
223
	 * 
224
	 * @param packet the packet to serialize
225
	 * 
226
	 * @return the serialized {@link String}, never <code>null</code>
227
	 */
228
	public static String serialize(CFPacket packet) {
229
		Object json = packet.toJSON();
230
		StringBuffer buffer = new StringBuffer();
231
		writeValue(json, buffer);
232
		int length = buffer.length();
233
		writeContentLength(buffer, length);
234
		buffer.append(LINE_FEED);
235
		if(TRACE) {
236
			Tracing.writeString("SERIALIZE: " + packet.getType() +" packet as "+buffer.toString()); //$NON-NLS-1$ //$NON-NLS-2$
237
		}
238
		return buffer.toString();
239
	}
240
	
241
	/**
242
	 * Reads and returns a new object from the given JSON {@link String}. This method
243
	 * will throw an {@link IllegalStateException} if parsing fails.
244
	 * 
245
	 * @param jsonString
246
	 * @return the object, never <code>null</code>
247
	 */
248
	public static Object read(String jsonString) {
249
		return parse(new StringCharacterIterator(jsonString));
250
	}
251
	
252
	/**
253
	 * Reads and returns a new object form the given {@link CharacterIterator} that corresponds to
254
	 * a properly formatted JSON string. This method will throw an {@link IllegalStateException} if
255
	 * parsing fails.
256
	 * 
257
	 * @param it the {@link CharacterIterator} to parse
258
	 * @return the object, never <code>null</code>
259
	 */
260
	public static Object parse(CharacterIterator it) {
261
		parseWhitespace(it);
262
		Object result = parseValue(it);
263
		parseWhitespace(it);
264
		if (it.current() != CharacterIterator.DONE) {
265
			throw error("should be done", it); //$NON-NLS-1$
266
		}
267
		return result;
268
	}
269
	
270
	/**
271
	 * Creates an {@link IllegalStateException} for the given message and iterator
272
	 * 
273
	 * @param message the message for the exception
274
	 * @param it the {@link CharacterIterator} to parse
275
	 * 
276
	 * @return a new {@link IllegalStateException} 
277
	 */
278
	private static RuntimeException error(String message, CharacterIterator it) {
279
		return new IllegalStateException("[" + it.getIndex() + "] " + message); //$NON-NLS-1$//$NON-NLS-2$
280
	}
281
	
282
	/**
283
	 * Chews up whitespace from the iterator
284
	 * 
285
	 * @param it the {@link CharacterIterator} to parse
286
	 */
287
	private static void parseWhitespace(CharacterIterator it) {
288
		char c = it.current();
289
		while (Character.isWhitespace(c)) {
290
			c = it.next();
291
		}
292
	}
293
	
294
	/**
295
	 * Parses the {@link Object} from the {@link CharacterIterator}. This method 
296
	 * delegates to the proper parsing method depending on the current iterator context.
297
	 * This method will throw an {@link IllegalStateException} if parsing fails.
298
	 * 
299
	 * @param it the {@link CharacterIterator} to parse
300
	 * 
301
	 * @return the new object, never <code>null</code>
302
	 * @see #parseString(CharacterIterator)
303
	 * @see #parseNumber(CharacterIterator)
304
	 * @see #parseArray(CharacterIterator)
305
	 * @see #parseObject(CharacterIterator)
306
	 */
307
	private static Object parseValue(CharacterIterator it) {
308
		switch (it.current()) {
309
			case '{' : {
310
				return parseObject(it);
311
			}
312
			case '[' : {
313
				return parseArray(it);
314
			}
315
			case '"' : {
316
				return parseString(it);
317
			}
318
			case '-' :
319
			case '0' :
320
			case '1' :
321
			case '2' :
322
			case '3' :
323
			case '4' :
324
			case '5' :
325
			case '6' :
326
			case '7' :
327
			case '8' :
328
			case '9' : {
329
				return parseNumber(it);
330
			}
331
			case 't' : {
332
				parseText(Boolean.TRUE.toString(), it);
333
				return Boolean.TRUE;
334
			}
335
			case 'f' : {
336
				parseText(Boolean.FALSE.toString(), it);
337
				return Boolean.FALSE;
338
			}
339
			case 'n' : {
340
				parseText(CFNullValue.NULL, it);
341
				return null;
342
			}
343
			case 'u': {
344
				parseText(CFUndefinedValue.UNDEFINED, it);
345
				return null;
346
			}
347
		}
348
		throw error("Bad JSON starting character '" + it.current() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$;
349
	}
350
	
351
	/**
352
	 * Parses the JSON string from the {@link CharacterIterator}
353
	 * 
354
	 * @param it the {@link CharacterIterator} to parse
355
	 * @return the JSON {@link String}, never <code>null</code>
356
	 */
357
	private static String parseString(CharacterIterator it) {
358
		char c = it.next();
359
		if (c == '"') {
360
			it.next();
361
			return ""; //$NON-NLS-1$
362
		}
363
		StringBuffer buffer = new StringBuffer();
364
		while (c != CharacterIterator.DONE && c != '"') {
365
			if (Character.isISOControl(c)) {
366
				//ignore it and continue
367
				c = it.next();
368
				continue;
369
				//throw error("illegal ISO control character: '" + Integer.toHexString(c) + "'", it); //$NON-NLS-1$ //$NON-NLS-2$);
370
			}
371
			if (c == '\\') {
372
				c = it.next();
373
				switch (c) {
374
					case '"' :
375
					case '\\' :
376
					case '/' : {
377
						buffer.append(c);
378
						break;
379
					}
380
					case 'b' : {
381
						buffer.append('\b');
382
						break;
383
					}
384
					case 'f' : {
385
						buffer.append('\f');
386
						break;
387
					}
388
					case 'n' : {
389
						buffer.append('\n');
390
						break;
391
					}
392
					case 'r' : {
393
						buffer.append('\r');
394
						break;
395
					}
396
					case 't' : {
397
						buffer.append('\t');
398
						break;
399
					}
400
					case 'u' : {
401
						StringBuffer unicode = new StringBuffer(4);
402
						for (int i = 0; i < 4; i++) {
403
							unicode.append(it.next());
404
						}
405
						try {
406
							buffer.append((char) Integer.parseInt(unicode.toString(), 16));
407
						} catch (NumberFormatException e) {
408
							throw error("expected a unicode hex number but was '" + unicode.toString() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$););
409
						}
410
						break;
411
					}
412
					default : {
413
						throw error("illegal escape character '" + c + "'", it); //$NON-NLS-1$ //$NON-NLS-2$););
414
					}
415
				}
416
			} else {
417
				buffer.append(c);
418
			}
419
			c = it.next();
420
		}
421
		c = it.next();
422
		return buffer.toString();
423
	}
424
	
425
	/**
426
	 * Parses an {@link Map} object from the iterator or throws an
427
	 * {@link IllegalStateException} if parsing fails.
428
	 * 
429
	 * @param it the {@link CharacterIterator} to parse
430
	 * @return a new {@link Map} object, never <code>null</code>
431
	 */
432
	private static Map parseObject(CharacterIterator it) {
433
		it.next();
434
		parseWhitespace(it);
435
		if (it.current() == '}') {
436
			it.next();
437
			return Collections.EMPTY_MAP;
438
		}
439
440
		Map map = new HashMap();
441
		while (it.current() != CharacterIterator.DONE) {
442
			if (it.current() != '"') {
443
				throw error("expected a string start '\"' but was '" + it.current() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$
444
			}
445
			String key = parseString(it);
446
			if (map.containsKey(key)) {
447
				throw error("' already defined" + "key '" + key, it); //$NON-NLS-1$ //$NON-NLS-2$
448
			}
449
			parseWhitespace(it);
450
			if (it.current() != ':') {
451
				throw error("expected a pair separator ':' but was '" + it.current() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$
452
			}
453
			it.next();
454
			parseWhitespace(it);
455
			Object value = parseValue(it);
456
			map.put(key, value);
457
			parseWhitespace(it);
458
			if (it.current() == ',') {
459
				it.next();
460
				parseWhitespace(it);
461
				continue;
462
			}
463
			if (it.current() != '}') {
464
				throw error("expected an object close '}' but was '" + it.current() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$
465
			}
466
			break;
467
		}
468
		it.next();
469
		return map;
470
	}
471
	
472
	/**
473
	 * Parses an {@link ArrayList} from the given iterator or throws an
474
	 * {@link IllegalStateException} if parsing fails
475
	 * 
476
	 * @param it the {@link CharacterIterator} to parse
477
	 * @return a new {@link ArrayList} object never <code>null</code>
478
	 */
479
	private static List parseArray(CharacterIterator it) {
480
		it.next();
481
		parseWhitespace(it);
482
		if (it.current() == ']') {
483
			it.next();
484
			return Collections.EMPTY_LIST;
485
		}
486
487
		List list = new ArrayList();
488
		while (it.current() != CharacterIterator.DONE) {
489
			Object value = parseValue(it);
490
			list.add(value);
491
			parseWhitespace(it);
492
			if (it.current() == ',') {
493
				it.next();
494
				parseWhitespace(it);
495
				continue;
496
			}
497
			if (it.current() != ']') {
498
				throw error("expected an array close ']' but was '" + it.current() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$
499
			}
500
			break;
501
		}
502
		it.next();
503
		return list;
504
	}
505
506
	/**
507
	 * @param string
508
	 * @param it
509
	 */
510
	private static void parseText(String string, CharacterIterator it) {
511
		int length = string.length();
512
		char c = it.current();
513
		for (int i = 0; i < length; i++) {
514
			if (c != string.charAt(i)) {
515
				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$;
516
			}
517
			c = it.next();
518
		}
519
	}
520
521
	/**
522
	 * Parses a {@link Number} object from the given {@link CharacterIterator}
523
	 * 
524
	 * @param it
525
	 * @return a new {@link Number}, never <code>null</code>
526
	 */
527
	private static Object parseNumber(CharacterIterator it) {
528
		StringBuffer buffer = new StringBuffer();
529
		char c = it.current();
530
		while (Character.isDigit(c) || c == '-' || c == '+' || c == '.' || c == 'e' || c == 'E') {
531
			buffer.append(c);
532
			c = it.next();
533
		}
534
		try {
535
			return new BigDecimal(buffer.toString());
536
		} catch (NumberFormatException e) {
537
			throw error("expected a number but was '" + buffer.toString() + "'", it); //$NON-NLS-1$ //$NON-NLS-2$;
538
		}
539
	}
540
}
(-)build.properties (-1 / +12 lines)
Lines 1-8 Link Here
1
###############################################################################
2
# Copyright (c) 2010, 2011 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
1
source.. = src/
11
source.. = src/
2
output.. = bin/
12
output.. = bin/
3
bin.includes = META-INF/,\
13
bin.includes = META-INF/,\
4
               .,\
14
               .,\
5
               plugin.xml,\
15
               plugin.xml,\
6
               about.html,\
16
               about.html,\
7
               OSGI-INF/l10n/bundle.properties
17
               OSGI-INF/l10n/bundle.properties,\
18
               OSGI-INF/
8
src.includes = about.html
19
src.includes = about.html
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/RhinoPreferenceInitializer.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 31-37 Link Here
31
	 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
31
	 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
32
	 */
32
	 */
33
	public void initializeDefaultPreferences() {
33
	public void initializeDefaultPreferences() {
34
		IEclipsePreferences defaultscope = new DefaultScope().getNode(RhinoDebugPlugin.PLUGIN_ID);
34
		IEclipsePreferences defaultscope = DefaultScope.INSTANCE.getNode(RhinoDebugPlugin.PLUGIN_ID);
35
		defaultscope.putBoolean(Constants.SUSPEND_ON_STDIN_LOAD, false);
35
		defaultscope.putBoolean(Constants.SUSPEND_ON_STDIN_LOAD, false);
36
		try {
36
		try {
37
			defaultscope.flush();
37
			defaultscope.flush();
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/RhinoPreferencesManager.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 28-34 Link Here
28
	 * Starts the manager
28
	 * Starts the manager
29
	 */
29
	 */
30
	public void start() {
30
	public void start() {
31
		IEclipsePreferences node = new InstanceScope().getNode(RhinoDebugPlugin.PLUGIN_ID);
31
		IEclipsePreferences node = InstanceScope.INSTANCE.getNode(RhinoDebugPlugin.PLUGIN_ID);
32
		if(node != null) {
32
		if(node != null) {
33
			node.addPreferenceChangeListener(this);
33
			node.addPreferenceChangeListener(this);
34
		}
34
		}
Lines 42-48 Link Here
42
	 * Stops the manager and frees any resources held
42
	 * Stops the manager and frees any resources held
43
	 */
43
	 */
44
	public void stop() {
44
	public void stop() {
45
		IEclipsePreferences node = new InstanceScope().getNode(RhinoDebugPlugin.PLUGIN_ID);
45
		IEclipsePreferences node = InstanceScope.INSTANCE.getNode(RhinoDebugPlugin.PLUGIN_ID);
46
		if(node != null) {
46
		if(node != null) {
47
			node.removePreferenceChangeListener(this);
47
			node.removePreferenceChangeListener(this);
48
		}
48
		}
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/jsdi/VirtualMachineImpl.java (+8 lines)
Lines 91-96 Link Here
91
	}
91
	}
92
92
93
	/**
93
	/**
94
	 * Called via reflection to determine if the vm supports suspend on script loads
95
	 * @return <code>true</code> if this VM can suspend when a script loads <code>false</code> otherwise
96
	 */
97
	public boolean supportsSuspendOnScriptLoads() {
98
		return true;
99
	}
100
	
101
	/**
94
	 * Creates a new {@link ScriptReferenceImpl} for the given ID
102
	 * Creates a new {@link ScriptReferenceImpl} for the given ID
95
	 * @param scriptId
103
	 * @param scriptId
96
	 * @return the new {@link ScriptReferenceImpl} or <code>null</code>
104
	 * @return the new {@link ScriptReferenceImpl} or <code>null</code>
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/jsdi/messages.properties (+10 lines)
Line 1 Link Here
1
###############################################################################
2
# Copyright (c) 2010, 2011 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
1
ArrayReferenceImpl_array_count_=Array [{0}]
11
ArrayReferenceImpl_array_count_=Array [{0}]
(-)build.properties (-1 / +13 lines)
Lines 1-7 Link Here
1
###############################################################################
2
# Copyright (c) 2010, 2011 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
1
source.. = src/
11
source.. = src/
2
output.. = bin/
12
output.. = bin/
3
bin.includes = META-INF/,\
13
bin.includes = META-INF/,\
4
               .,\
14
               .,\
5
               about.html,\
15
               about.html,\
6
               OSGI-INF/l10n/bundle.properties
16
               OSGI-INF/l10n/bundle.properties,\
17
               OSGI-INF/,\
18
               OSGI-INF/l10n/
7
src.includes = about.html
19
src.includes = about.html
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/ScriptSource.java (-9 / +11 lines)
Lines 182-190 Link Here
182
	void clearBreakpoints(RhinoDebuggerImpl debugger) {
182
	void clearBreakpoints(RhinoDebuggerImpl debugger) {
183
		if(this.lines != null) {
183
		if(this.lines != null) {
184
			for (int i = 0; i < this.lines.length; i++) {
184
			for (int i = 0; i < this.lines.length; i++) {
185
				Breakpoint bp = lines[i].breakpoint;
185
				if(lines[i] != null) {
186
				if(bp != null) {
186
					Breakpoint bp = lines[i].breakpoint;
187
					debugger.clearBreakpoint(bp.breakpointId);
187
					if(bp != null) {
188
						debugger.clearBreakpoint(bp.breakpointId);
189
					}
188
				}
190
				}
189
			}
191
			}
190
		}
192
		}
Lines 277-289 Link Here
277
		result.put(JSONConstants.SOURCE, source);
279
		result.put(JSONConstants.SOURCE, source);
278
		result.put(JSONConstants.GENERATED, Boolean.valueOf(generated));
280
		result.put(JSONConstants.GENERATED, Boolean.valueOf(generated));
279
		if(lines != null) {
281
		if(lines != null) {
280
		HashSet lineNumbers = new HashSet();
282
			HashSet lineNumbers = new HashSet();
281
		for (int i = 0; i < lines.length; i++) {
283
			for (int i = 0; i < lines.length; i++) {
282
			if(lines[i] != null) {
284
				if(lines[i] != null) {
283
				lineNumbers.add(new Integer(i));
285
					lineNumbers.add(new Integer(i));
286
				}
284
			}
287
			}
285
		}
288
			result.put(JSONConstants.LINES, (lineNumbers == null ? Collections.EMPTY_SET : lineNumbers));
286
		result.put(JSONConstants.LINES, (lineNumbers == null ? Collections.EMPTY_SET : lineNumbers));
287
		}
289
		}
288
		else {
290
		else {
289
			result.put(JSONConstants.LINES, Collections.EMPTY_SET);
291
			result.put(JSONConstants.LINES, Collections.EMPTY_SET);
(-)build.properties (-1 / +12 lines)
Lines 1-3 Link Here
1
###############################################################################
2
# Copyright (c) 2010, 2011 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
1
source.. = src/
11
source.. = src/
2
output.. = bin/
12
output.. = bin/
3
bin.includes = META-INF/,\
13
bin.includes = META-INF/,\
Lines 5-8 Link Here
5
               plugin.xml,\
15
               plugin.xml,\
6
               OSGI-INF/l10n/bundle.properties,\
16
               OSGI-INF/l10n/bundle.properties,\
7
               icons/,\
17
               icons/,\
8
               about.html
18
               about.html,\
19
               OSGI-INF/
(-)plugin.xml (+8 lines)
Lines 152-157 Link Here
152
                        <test
152
                        <test
153
                              property="rhino.ui.isScript">
153
                              property="rhino.ui.isScript">
154
                        </test>
154
                        </test>
155
                        <with
156
                              variable="org.eclipse.core.runtime.Platform">
157
                           <test
158
                                 args="org.eclipse.wst.jsdt.debug.rhino"
159
                                 property="org.eclipse.core.runtime.bundleState"
160
                                 value="ACTIVE">
161
                           </test>
162
                        </with>
155
                     </and>
163
                     </and>
156
                  </iterate>
164
                  </iterate>
157
               </with>
165
               </with>
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/RhinoPropertyTester.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 57-67 Link Here
57
		IJavaScriptElement jselement = (IJavaScriptElement) element.getAdapter(IJavaScriptElement.class);
57
		IJavaScriptElement jselement = (IJavaScriptElement) element.getAdapter(IJavaScriptElement.class);
58
		if(jselement != null) {
58
		if(jselement != null) {
59
			int type = jselement.getElementType();
59
			int type = jselement.getElementType();
60
			return type == IJavaScriptElement.JAVASCRIPT_UNIT || type == IJavaScriptElement.JAVASCRIPT_UNIT;
60
			return type == IJavaScriptElement.JAVASCRIPT_UNIT;
61
		}
61
		}
62
		IFile file = (IFile) element.getAdapter(IFile.class);
62
		IFile file = (IFile) element.getAdapter(IFile.class);
63
		if(file != null) {
63
		if(file != null) {
64
			return file.getFileExtension().equals("js"); //$NON-NLS-1$
64
			return "js".equals(file.getFileExtension()); //$NON-NLS-1$
65
		}
65
		}
66
		return false;
66
		return false;
67
	}
67
	}
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/RhinoUIPlugin.java (-1 / +11 lines)
Lines 1-3 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
1
package org.eclipse.wst.jsdt.debug.internal.rhino.ui;
11
package org.eclipse.wst.jsdt.debug.internal.rhino.ui;
2
12
3
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.core.runtime.IStatus;
Lines 27-33 Link Here
27
37
28
	// The shared instance
38
	// The shared instance
29
	private static RhinoUIPlugin plugin;
39
	private static RhinoUIPlugin plugin;
30
	private static IPreferenceStore corestore = new ScopedPreferenceStore(new InstanceScope(), RhinoDebugPlugin.PLUGIN_ID);
40
	private static IPreferenceStore corestore = new ScopedPreferenceStore(InstanceScope.INSTANCE, RhinoDebugPlugin.PLUGIN_ID);
31
	
41
	
32
	/**
42
	/**
33
	 * The constructor
43
	 * The constructor
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/launching/IncludeEntry.java (+10 lines)
Lines 1-3 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
1
package org.eclipse.wst.jsdt.debug.internal.rhino.ui.launching;
11
package org.eclipse.wst.jsdt.debug.internal.rhino.ui.launching;
2
12
3
import org.eclipse.debug.core.ILaunchConfiguration;
13
import org.eclipse.debug.core.ILaunchConfiguration;
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/launching/IncludeTab.java (-2 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 21-27 Link Here
21
import org.eclipse.core.runtime.Path;
21
import org.eclipse.core.runtime.Path;
22
import org.eclipse.debug.core.ILaunchConfiguration;
22
import org.eclipse.debug.core.ILaunchConfiguration;
23
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
23
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
24
import org.eclipse.debug.internal.ui.SWTFactory;
25
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
24
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
26
import org.eclipse.jface.dialogs.IDialogConstants;
25
import org.eclipse.jface.dialogs.IDialogConstants;
27
import org.eclipse.jface.viewers.ISelectionChangedListener;
26
import org.eclipse.jface.viewers.ISelectionChangedListener;
Lines 48-53 Link Here
48
import org.eclipse.wst.jsdt.debug.internal.rhino.ui.ISharedImages;
47
import org.eclipse.wst.jsdt.debug.internal.rhino.ui.ISharedImages;
49
import org.eclipse.wst.jsdt.debug.internal.rhino.ui.RhinoImageRegistry;
48
import org.eclipse.wst.jsdt.debug.internal.rhino.ui.RhinoImageRegistry;
50
import org.eclipse.wst.jsdt.debug.internal.rhino.ui.refactoring.Refactoring;
49
import org.eclipse.wst.jsdt.debug.internal.rhino.ui.refactoring.Refactoring;
50
import org.eclipse.wst.jsdt.debug.internal.ui.SWTFactory;
51
import org.eclipse.wst.jsdt.debug.internal.ui.dialogs.ScriptSelectionDialog;
51
import org.eclipse.wst.jsdt.debug.internal.ui.dialogs.ScriptSelectionDialog;
52
52
53
/**
53
/**
Lines 185-190 Link Here
185
		setControl(comp);
185
		setControl(comp);
186
	}
186
	}
187
187
188
	/* (non-Javadoc)
189
	 * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getHelpContextId()
190
	 */
191
	public String getHelpContextId() {
192
		return IHelpConstants.INCLUDE_TAB_CONTEXT;
193
	}
194
	
188
	/**
195
	/**
189
	 * Updates the buttons based on the selection from the viewer
196
	 * Updates the buttons based on the selection from the viewer
190
	 * 
197
	 * 
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/launching/RhinoMainTab.java (-2 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 64-70 Link Here
64
	/**
64
	/**
65
	 * The id of the tab
65
	 * The id of the tab
66
	 * <br><br>
66
	 * <br><br>
67
	 * Value is: <code>thino.main.tab</code>
67
	 * Value is: <code>rhino.main.tab</code>
68
	 */
68
	 */
69
	public static final String TAB_ID = "rhino.main.tab"; //$NON-NLS-1$
69
	public static final String TAB_ID = "rhino.main.tab"; //$NON-NLS-1$
70
	public static final String[] VERSIONS = {"100", "110", "120", "130", "140", "150", "160", "170"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
70
	public static final String[] VERSIONS = {"100", "110", "120", "130", "140", "150", "160", "170"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
Lines 127-132 Link Here
127
		setControl(comp);
127
		setControl(comp);
128
	}
128
	}
129
	
129
	
130
	public String getHelpContextId() {
131
		return IHelpConstants.MAIN_TAB_CONTEXT;
132
	};
133
	
130
	/**
134
	/**
131
	 * Allows users to select a script from either a project context, if there is one or the workspace
135
	 * Allows users to select a script from either a project context, if there is one or the workspace
132
	 * 
136
	 * 
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/preferences/RhinoDebugPreferencePage.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 42-48 Link Here
42
	public RhinoDebugPreferencePage() {
42
	public RhinoDebugPreferencePage() {
43
		super(GRID);
43
		super(GRID);
44
		setDescription(Messages.rhino_pref_page_desc);
44
		setDescription(Messages.rhino_pref_page_desc);
45
		setPreferenceStore(RhinoUIPlugin.getDefault().getPreferenceStore());
45
		setPreferenceStore(RhinoUIPlugin.getCorePreferenceStore());
46
	}
46
	}
47
47
48
	/* (non-Javadoc)
48
	/* (non-Javadoc)
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/refactoring/ProjectChange.java (+10 lines)
Lines 1-3 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
1
package org.eclipse.wst.jsdt.debug.internal.rhino.ui.refactoring;
11
package org.eclipse.wst.jsdt.debug.internal.rhino.ui.refactoring;
2
12
3
import org.eclipse.core.resources.IContainer;
13
import org.eclipse.core.resources.IContainer;
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/source/RhinoSourceDirector.java (-1 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 26-29 Link Here
26
	public void initializeParticipants() {
26
	public void initializeParticipants() {
27
		addParticipants(new ISourceLookupParticipant[] {new RhinoSourceLookupParticipant()});
27
		addParticipants(new ISourceLookupParticipant[] {new RhinoSourceLookupParticipant()});
28
	}
28
	}
29
	
30
	/* (non-Javadoc)
31
	 * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#isFindDuplicates()
32
	 */
33
	public boolean isFindDuplicates() {
34
		return true;
35
	}
29
}
36
}
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/ui/source/RhinoSourceLookupParticipant.java (-13 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-23 Link Here
14
14
15
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.URIUtil;
18
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
17
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
19
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame;
20
import org.eclipse.wst.jsdt.debug.core.model.IScript;
21
import org.eclipse.wst.jsdt.debug.internal.core.launching.SourceLookup;
18
import org.eclipse.wst.jsdt.debug.internal.core.launching.SourceLookup;
22
19
23
/**
20
/**
Lines 31-45 Link Here
31
	 * @see org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant#getSourceName(java.lang.Object)
28
	 * @see org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant#getSourceName(java.lang.Object)
32
	 */
29
	 */
33
	public String getSourceName(Object object) throws CoreException {
30
	public String getSourceName(Object object) throws CoreException {
34
		if(object instanceof IJavaScriptStackFrame) {
31
		return SourceLookup.getSourceName(object);
35
			IJavaScriptStackFrame frame = (IJavaScriptStackFrame) object;
36
			return frame.getSourceName();
37
		}
38
		if(object instanceof IScript) {
39
			IScript script = (IScript) object;
40
			return URIUtil.lastSegment(script.sourceURI());
41
		}
42
		return null;
43
	}
32
	}
44
	
33
	
45
	/* (non-Javadoc)
34
	/* (non-Javadoc)
(-)build.properties (-1 / +13 lines)
Lines 1-6 Link Here
1
###############################################################################
2
# Copyright (c) 2010, 2011 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
1
source.. = src/
11
source.. = src/
2
output.. = bin/
12
output.. = bin/
3
bin.includes = META-INF/,\
13
bin.includes = META-INF/,\
4
               .,\
14
               .,\
5
               OSGI-INF/l10n/bundle.properties,\
15
               OSGI-INF/l10n/bundle.properties,\
6
               about.html
16
               about.html,\
17
               OSGI-INF/,\
18
               OSGI-INF/l10n/
(-)src/org/eclipse/wst/jsdt/debug/transport/ListenerKey.java (+10 lines)
Lines 1-3 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
1
package org.eclipse.wst.jsdt.debug.transport;
11
package org.eclipse.wst.jsdt.debug.transport;
2
12
3
import java.net.Socket;
13
import java.net.Socket;
(-)src/org/eclipse/wst/jsdt/debug/transport/socket/SocketListenerKey.java (+10 lines)
Lines 1-3 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
1
package org.eclipse.wst.jsdt.debug.transport.socket;
11
package org.eclipse.wst.jsdt.debug.transport.socket;
2
12
3
import org.eclipse.wst.jsdt.debug.transport.ListenerKey;
13
import org.eclipse.wst.jsdt.debug.transport.ListenerKey;
(-)META-INF/MANIFEST.MF (-4 / +4 lines)
Lines 16-34 Link Here
16
 org.eclipse.ui.workbench.texteditor,
16
 org.eclipse.ui.workbench.texteditor,
17
 org.eclipse.wst.jsdt.ui,
17
 org.eclipse.wst.jsdt.ui,
18
 org.eclipse.ui.editors,
18
 org.eclipse.ui.editors,
19
 org.eclipse.core.expressions
19
 org.eclipse.core.expressions,
20
 org.eclipse.wst.sse.ui;bundle-version="1.3.1"
20
Bundle-RequiredExecutionEnvironment: J2SE-1.4
21
Bundle-RequiredExecutionEnvironment: J2SE-1.4
21
Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.wst.jsdt.debug.internal.ui.filters"
22
Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.wst.jsdt.debug.internal.ui.filters"
22
Export-Package: org.eclipse.wst.jsdt.debug.internal.ui;x-internal:=true,
23
Export-Package: org.eclipse.wst.jsdt.debug.internal.ui;x-friends:="org.eclipse.wst.jsdt.debug.rhino.ui",
23
 org.eclipse.wst.jsdt.debug.internal.ui.actions;x-internal:=true,
24
 org.eclipse.wst.jsdt.debug.internal.ui.actions;x-internal:=true,
24
 org.eclipse.wst.jsdt.debug.internal.ui.adapters;x-internal:=true,
25
 org.eclipse.wst.jsdt.debug.internal.ui.adapters;x-internal:=true,
25
 org.eclipse.wst.jsdt.debug.internal.ui.breakpoints;x-internal:=true,
26
 org.eclipse.wst.jsdt.debug.internal.ui.breakpoints;x-internal:=true,
26
 org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.details;x-internal:=true,
27
 org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.details;x-internal:=true,
27
 org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.editors;x-internal:=true,
28
 org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.editors;x-internal:=true,
28
 org.eclipse.wst.jsdt.debug.internal.ui.dialogs;x-internal:=true,
29
 org.eclipse.wst.jsdt.debug.internal.ui.dialogs;x-friends:="org.eclipse.wst.jsdt.debug.rhino.ui",
29
 org.eclipse.wst.jsdt.debug.internal.ui.display;x-internal:=true,
30
 org.eclipse.wst.jsdt.debug.internal.ui.display;x-internal:=true,
30
 org.eclipse.wst.jsdt.debug.internal.ui.eval;x-internal:=true,
31
 org.eclipse.wst.jsdt.debug.internal.ui.eval;x-internal:=true,
31
 org.eclipse.wst.jsdt.debug.internal.ui.filters;x-internal:=true,
32
 org.eclipse.wst.jsdt.debug.internal.ui.launching;x-internal:=true,
32
 org.eclipse.wst.jsdt.debug.internal.ui.launching;x-internal:=true,
33
 org.eclipse.wst.jsdt.debug.internal.ui.preferences;x-internal:=true,
33
 org.eclipse.wst.jsdt.debug.internal.ui.preferences;x-internal:=true,
34
 org.eclipse.wst.jsdt.debug.internal.ui.source;x-internal:=true,
34
 org.eclipse.wst.jsdt.debug.internal.ui.source;x-internal:=true,
(-)OSGI-INF/l10n/bundle.properties (-4 lines)
Lines 42-51 Link Here
42
openSourceObjectAction.tooltip = Shows the JavaScript source for the selected script element
42
openSourceObjectAction.tooltip = Shows the JavaScript source for the selected script element
43
commandCategory.description = Tooling for debugging JavaScript
43
commandCategory.description = Tooling for debugging JavaScript
44
commandCategory.name = JavaScript Debug
44
commandCategory.name = JavaScript Debug
45
jsdtProjectFilter.description = Filters the External JavaScript Source project, which is used in the workspace to hold temporary JavaScript sources
46
jsdtProjectFilter.name = External JavaScript Source
47
jdtProjectFilter.description = Filters the External JavaScript Source project, which is used in the workspace to hold temporary JavaScript sources
48
jdtProjectFilter.name = External JavaScript Source
49
45
50
showFunctionVarAction.label = Show function variables
46
showFunctionVarAction.label = Show function variables
51
showFunctionVarAction.tooltip = Show or hide function variables
47
showFunctionVarAction.tooltip = Show or hide function variables
(-)build.properties (+10 lines)
Lines 1-3 Link Here
1
###############################################################################
2
# Copyright (c) 2010, 2011 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
1
source.. = src/
11
source.. = src/
2
output.. = bin/
12
output.. = bin/
3
bin.includes = META-INF/,\
13
bin.includes = META-INF/,\
(-)plugin.xml (-10 / +41 lines)
Lines 89-94 Link Here
89
               type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider">
89
               type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider">
90
         </adapter>
90
         </adapter>
91
      </factory>
91
      </factory>
92
      <factory
93
            adaptableType="org.eclipse.wst.sse.ui.StructuredTextEditor"
94
            class="org.eclipse.wst.jsdt.debug.internal.ui.adapters.JavaScriptAdapterFactory">
95
         <adapter
96
               type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget">
97
         </adapter>
98
         <adapter
99
               type="org.eclipse.debug.ui.actions.IRunToLineTarget">
100
         </adapter>
101
      </factory>
92
   </extension>
102
   </extension>
93
   <extension
103
   <extension
94
         point="org.eclipse.ui.editorActions">
104
         point="org.eclipse.ui.editorActions">
Lines 284-289 Link Here
284
            </separator>
294
            </separator>
285
         </menu>
295
         </menu>
286
      </viewerContribution>
296
      </viewerContribution>
297
      <viewerContribution
298
            id="org.eclipse.wst.jsdt.debug.ui.html.ruler.popup.actions"
299
            targetID="org.eclipse.wst.html.core.htmlsource.source">
300
         <action
301
               class="org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.ToggleBreakpointEnablementEditorDelegate"
302
               helpContextId="toggle_breakpoint_anablement_ruler_context"
303
               id="org.eclipse.wst.jsdt.debug.ui.html.toggle.breakpoint.enablement"
304
               label="%togglebreakpointenablementRulerAction.name"
305
               menubarPath="debug"
306
               tooltip="%togglebreakpointenablementRulerAction.tooltip">
307
         </action>
308
         <action
309
               class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
310
               helpContextId="editor_toggle_breakpoint_action_context"
311
               icon="$nl$/icons/elcl16/brkp_obj.gif"
312
               id="org.eclipse.wst.jsdt.debug.ui.html.toggle.breakpoint.ruler.delegate"
313
               label="%togglebreakpointRulerAction.name"
314
               menubarPath="debug">
315
         </action>
316
      </viewerContribution>
287
   </extension>
317
   </extension>
288
   <extension
318
   <extension
289
         point="org.eclipse.debug.ui.debugModelPresentations">
319
         point="org.eclipse.debug.ui.debugModelPresentations">
Lines 509-524 Link Here
509
      </markerTypeCategory>
539
      </markerTypeCategory>
510
   </extension>
540
   </extension>
511
   <extension
541
   <extension
512
         point="org.eclipse.wst.jsdt.ui.javaElementFilters">
513
      <filter
514
            class="org.eclipse.wst.jsdt.debug.internal.ui.filters.ExternalSourceProjectFilter"
515
            description="%jsdtProjectFilter.description"
516
            enabled="true"
517
            id="jsdt.external.source.project.filter"
518
            name="%jsdtProjectFilter.name">
519
      </filter>
520
   </extension>
521
   <extension
522
         point="org.eclipse.core.runtime.preferences">
542
         point="org.eclipse.core.runtime.preferences">
523
      <initializer
543
      <initializer
524
            class="org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPreferenceInitializer">
544
            class="org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPreferenceInitializer">
Lines 580-584 Link Here
580
            markerType="org.eclipse.wst.jsdt.debug.core.breakpoint.marker">
600
            markerType="org.eclipse.wst.jsdt.debug.core.breakpoint.marker">
581
      </updater>
601
      </updater>
582
   </extension>
602
   </extension>
603
   <extension
604
         point="org.eclipse.wst.sse.ui.breakpoint">
605
      <breakpointContribution
606
            id="org.eclipse.wst.jsdt.html.breakpointContribution">
607
         <provider
608
               class="org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.JavaScriptHtmlBreakpointProvider"
609
               contentTypes="org.eclipse.wst.html.core.htmlsource"
610
               id="org.eclipse.wst.jsdt.html.breakpoint.provider">
611
         </provider>
612
      </breakpointContribution>
613
   </extension>
583
614
584
</plugin>
615
</plugin>
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/IHelpContextIds.java (-1 / +16 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 34-37 Link Here
34
	 * @since 1.1
34
	 * @since 1.1
35
	 */
35
	 */
36
	public static final String DEBUG_PREFERENCE_PAGE = JavaScriptDebugUIPlugin.PLUGIN_ID + ".debug_pref_page"; //$NON-NLS-1$
36
	public static final String DEBUG_PREFERENCE_PAGE = JavaScriptDebugUIPlugin.PLUGIN_ID + ".debug_pref_page"; //$NON-NLS-1$
37
	/**
38
	 * Help constant for the Source tab
39
	 * @since 1.2
40
	 */
41
	public static final String SOURCE_LOOKUP_TAB = JavaScriptDebugUIPlugin.PLUGIN_ID + ".source_lookup_tab"; //$NON-NLS-1$
42
	/**
43
	 * Help constant for the Environment tab
44
	 * @since 1.2
45
	 */
46
	public static final String ENVIRONMENT_TAB = JavaScriptDebugUIPlugin.PLUGIN_ID + ".environment_tab"; //$NON-NLS-1$
47
	/**
48
	 * Help constant for the Common tab
49
	 * @since 1.2
50
	 */
51
	public static final String COMMON_TAB = JavaScriptDebugUIPlugin.PLUGIN_ID + ".common_tab"; //$NON-NLS-1$
37
}
52
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptDebugUIPlugin.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 53-59 Link Here
53
53
54
	// The shared instance
54
	// The shared instance
55
	private static JavaScriptDebugUIPlugin plugin;
55
	private static JavaScriptDebugUIPlugin plugin;
56
	private static ScopedPreferenceStore corestore = new ScopedPreferenceStore(new InstanceScope(), JavaScriptDebugPlugin.PLUGIN_ID);
56
	private static ScopedPreferenceStore corestore = new ScopedPreferenceStore(InstanceScope.INSTANCE, JavaScriptDebugPlugin.PLUGIN_ID);
57
	
57
	
58
	/*
58
	/*
59
	 * (non-Javadoc)
59
	 * (non-Javadoc)
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptModelPresentation.java (-9 / +10 lines)
Lines 296-310 Link Here
296
	 * @throws DebugException
296
	 * @throws DebugException
297
	 */
297
	 */
298
	String getStackframeText(IJavaScriptStackFrame frame) throws DebugException {
298
	String getStackframeText(IJavaScriptStackFrame frame) throws DebugException {
299
		try {
299
		String fname = frame.getName();
300
			return TextUtils.shortenText(NLS.bind(Messages.stackframe_name, new String[] {
300
		if(fname == null || fname.trim().length() < 1) {
301
					URLDecoder.decode(frame.getName(), Constants.UTF_8),
301
			return NLS.bind(Messages.stackframe_name, new String[] {
302
					Integer.toString(frame.getLineNumber())}), 100);
302
					frame.getSourceName(),
303
		}
303
					Integer.toString(frame.getLineNumber())});
304
		catch (UnsupportedEncodingException uee) {
304
		}
305
			//ignore
305
		return NLS.bind(Messages.JavaScriptModelPresentation_stackframe_name_with_fname, new String[] {
306
		}
306
				frame.getSourceName(),
307
		return Messages.unknown;
307
				fname,
308
				Integer.toString(frame.getLineNumber())});
308
	}
309
	}
309
	
310
	
310
	/**
311
	/**
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/Messages.java (+1 lines)
Lines 37-42 Link Here
37
	public static String evald_script;
37
	public static String evald_script;
38
	public static String exception_occurred_setting_bp_properties;
38
	public static String exception_occurred_setting_bp_properties;
39
	public static String hit_count_must_be_positive;
39
	public static String hit_count_must_be_positive;
40
	public static String JavaScriptModelPresentation_stackframe_name_with_fname;
40
	public static String no_description_provided;
41
	public static String no_description_provided;
41
	public static String opening_source__0;
42
	public static String opening_source__0;
42
	public static String running_state;
43
	public static String running_state;
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/PreferencesManager.java (+10 lines)
Lines 1-3 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
1
package org.eclipse.wst.jsdt.debug.internal.ui;
11
package org.eclipse.wst.jsdt.debug.internal.ui;
2
12
3
import org.eclipse.jface.util.IPropertyChangeListener;
13
import org.eclipse.jface.util.IPropertyChangeListener;
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ShowLoadedScriptsAction.java (+10 lines)
Lines 1-3 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
1
package org.eclipse.wst.jsdt.debug.internal.ui.actions;
11
package org.eclipse.wst.jsdt.debug.internal.ui.actions;
2
12
3
import org.eclipse.debug.ui.IDebugView;
13
import org.eclipse.debug.ui.IDebugView;
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/SuspendOnAllScriptLoadsAction.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 47-53 Link Here
47
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
47
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
48
	 */
48
	 */
49
	public void run(IAction action) {
49
	public void run(IAction action) {
50
		IEclipsePreferences prefs = new InstanceScope().getNode(JavaScriptDebugPlugin.PLUGIN_ID);
50
		IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(JavaScriptDebugPlugin.PLUGIN_ID);
51
		if(prefs != null) {
51
		if(prefs != null) {
52
			prefs.putBoolean(Constants.SUSPEND_ON_ALL_SCRIPT_LOADS, getValue());
52
			prefs.putBoolean(Constants.SUSPEND_ON_ALL_SCRIPT_LOADS, getValue());
53
			try {
53
			try {
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/SuspendOnExceptionsAction.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 32-38 Link Here
32
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
32
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
33
	 */
33
	 */
34
	public void run(IAction action) {
34
	public void run(IAction action) {
35
		IEclipsePreferences prefs = new InstanceScope().getNode(JavaScriptDebugPlugin.PLUGIN_ID);
35
		IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(JavaScriptDebugPlugin.PLUGIN_ID);
36
		if(prefs != null) {
36
		if(prefs != null) {
37
			prefs.putBoolean(Constants.SUSPEND_ON_THROWN_EXCEPTION, action.isChecked());
37
			prefs.putBoolean(Constants.SUSPEND_ON_THROWN_EXCEPTION, action.isChecked());
38
			try {
38
			try {
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptAdapterFactory.java (-1 / +1 lines)
Lines 160-166 Link Here
160
	/**
160
	/**
161
	 * @return the singleton {@link ToggleBreakpointAdapter}
161
	 * @return the singleton {@link ToggleBreakpointAdapter}
162
	 */
162
	 */
163
	synchronized ToggleBreakpointAdapter getToggleBreakpointAdapter() {
163
	public static synchronized ToggleBreakpointAdapter getToggleBreakpointAdapter() {
164
		if(tbadapter == null) {
164
		if(tbadapter == null) {
165
			tbadapter = new ToggleBreakpointAdapter();
165
			tbadapter = new ToggleBreakpointAdapter();
166
		}
166
		}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptAsyncContentProvider.java (+10 lines)
Lines 1-3 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
1
package org.eclipse.wst.jsdt.debug.internal.ui.adapters;
11
package org.eclipse.wst.jsdt.debug.internal.ui.adapters;
2
12
3
import java.util.List;
13
import java.util.List;
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/JavaScriptHtmlBreakpointProvider.java (+89 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.breakpoints;
12
13
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.ResourcesPlugin;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.Status;
20
import org.eclipse.core.runtime.jobs.Job;
21
import org.eclipse.jface.text.BadLocationException;
22
import org.eclipse.jface.text.IDocument;
23
import org.eclipse.jface.text.ITypedRegion;
24
import org.eclipse.ui.IEditorInput;
25
import org.eclipse.wst.jsdt.debug.internal.ui.adapters.JavaScriptAdapterFactory;
26
import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;
27
import org.eclipse.wst.sse.ui.internal.provisional.extensions.breakpoint.IBreakpointProvider;
28
29
/**
30
 * Provide the JavaScript breakpoint for the HTML editor
31
 * 
32
 * @since 3.4
33
 */
34
public class JavaScriptHtmlBreakpointProvider implements IBreakpointProvider {
35
36
	static final String SCRIPT_REGION = "org.eclipse.wst.html.SCRIPT"; //$NON-NLS-1$
37
	
38
	/**
39
	 * Constructor
40
	 */
41
	public JavaScriptHtmlBreakpointProvider() {
42
	}
43
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.wst.sse.ui.internal.provisional.extensions.breakpoint.IBreakpointProvider#addBreakpoint(org.eclipse.jface.text.IDocument, org.eclipse.ui.IEditorInput, int, int)
46
	 */
47
	public IStatus addBreakpoint(final IDocument document, IEditorInput input, final int lineNumber, final int offset) throws CoreException {
48
		final IResource resource = getResource(input);
49
		if(resource != null && offset > -1) {
50
			try {
51
				final ITypedRegion region = document.getPartition(document.getLineOffset(lineNumber));
52
				if (region != null && SCRIPT_REGION.equals(region.getType())) {
53
					Job j = new Job("Toggle JavaScript Line Breakpoint") { //$NON-NLS-1$
54
						protected IStatus run(IProgressMonitor monitor) {
55
							try {
56
								JavaScriptAdapterFactory.getToggleBreakpointAdapter().addBreakpoint(resource, document, lineNumber);
57
								return Status.OK_STATUS;
58
							}
59
							catch(CoreException ce) {
60
								return Status.CANCEL_STATUS;
61
							}
62
						}
63
					};
64
					j.setPriority(Job.INTERACTIVE);
65
					j.schedule();
66
				}
67
			}
68
			catch(BadLocationException ble) {}
69
		}
70
		return Status.CANCEL_STATUS;
71
	}
72
	
73
	/* (non-Javadoc)
74
	 * @see org.eclipse.wst.sse.ui.internal.provisional.extensions.breakpoint.IBreakpointProvider#getResource(org.eclipse.ui.IEditorInput)
75
	 */
76
	public IResource getResource(IEditorInput input) {
77
        IResource resource = (IResource) input.getAdapter(IFile.class);
78
        if (resource == null) {
79
            resource = ResourcesPlugin.getWorkspace().getRoot();
80
        }
81
        return resource;
82
	}
83
84
	/* (non-Javadoc)
85
	 * @see org.eclipse.wst.sse.ui.internal.provisional.extensions.breakpoint.IBreakpointProvider#setSourceEditingTextTools(org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools)
86
	 */
87
	public void setSourceEditingTextTools(ISourceEditingTextTools tool) {
88
	}
89
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/ToggleBreakpointAdapter.java (+53 lines)
Lines 29-34 Link Here
29
import org.eclipse.jface.text.IDocument;
29
import org.eclipse.jface.text.IDocument;
30
import org.eclipse.jface.text.IRegion;
30
import org.eclipse.jface.text.IRegion;
31
import org.eclipse.jface.text.ITextSelection;
31
import org.eclipse.jface.text.ITextSelection;
32
import org.eclipse.jface.text.ITypedRegion;
32
import org.eclipse.jface.text.TextSelection;
33
import org.eclipse.jface.text.TextSelection;
33
import org.eclipse.jface.viewers.ISelection;
34
import org.eclipse.jface.viewers.ISelection;
34
import org.eclipse.jface.viewers.IStructuredSelection;
35
import org.eclipse.jface.viewers.IStructuredSelection;
Lines 48-53 Link Here
48
import org.eclipse.wst.jsdt.core.ISourceRange;
49
import org.eclipse.wst.jsdt.core.ISourceRange;
49
import org.eclipse.wst.jsdt.core.IType;
50
import org.eclipse.wst.jsdt.core.IType;
50
import org.eclipse.wst.jsdt.core.ITypeRoot;
51
import org.eclipse.wst.jsdt.core.ITypeRoot;
52
import org.eclipse.wst.jsdt.core.dom.AST;
53
import org.eclipse.wst.jsdt.core.dom.ASTParser;
51
import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
54
import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
52
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpoint;
55
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpoint;
53
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptFunctionBreakpoint;
56
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptFunctionBreakpoint;
Lines 134-139 Link Here
134
	}
137
	}
135
	
138
	
136
	/**
139
	/**
140
	 * Callback from {@link JavaScriptHtmlBreakpointProvider}
141
	 * @param resource
142
	 * @param document
143
	 * @param linenumber
144
	 * @throws CoreException
145
	 */
146
	void addBreakpoint(IResource resource, IDocument document, int linenumber) throws CoreException {
147
		IBreakpoint bp = lineBreakpointExists(resource, linenumber);
148
		if(bp != null) {
149
			DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(bp, true);
150
		}
151
		int charstart = -1, charend = -1;
152
		try {
153
			IRegion line = document.getLineInformation(linenumber - 1);
154
			charstart = line.getOffset();
155
			charend = charstart + line.getLength();
156
		}
157
		catch (BadLocationException ble) {}
158
		HashMap attributes = new HashMap();
159
		attributes.put(IJavaScriptBreakpoint.TYPE_NAME, null);
160
		attributes.put(IJavaScriptBreakpoint.SCRIPT_PATH, resource.getFullPath().makeAbsolute().toString());
161
		attributes.put(IJavaScriptBreakpoint.ELEMENT_HANDLE, null);
162
		JavaScriptDebugModel.createLineBreakpoint(resource, linenumber, charstart, charend, attributes, true);
163
	}
164
	
165
	/**
137
	 * Returns the path to the script in the workspace or the name of the script in the event it is
166
	 * Returns the path to the script in the workspace or the name of the script in the event it is
138
	 * and external or virtual script
167
	 * and external or virtual script
139
	 * @param element
168
	 * @param element
Lines 207-212 Link Here
207
	}
236
	}
208
	
237
	
209
	/**
238
	/**
239
	 * Resolves the region from the given document and tries to parse the text of the region. Returns the {@link JavaScriptUnit}
240
	 * representing the region or <code>null</code> if it could not be computed
241
	 * 
242
	 * @param doc
243
	 * @param offset
244
	 * @return the {@link JavaScriptUnit} for the region from the document or <code>null</code>
245
	 */
246
	JavaScriptUnit parse(IDocument doc, int offset) {
247
		try {
248
			ITypedRegion region = doc.getPartition(offset);
249
			if(region != null) {
250
				ASTParser parser = ASTParser.newParser(AST.JLS3);
251
				//parser.setKind(ASTParser.K_STATEMENTS);
252
				parser.setSource(doc.get(offset, region.getLength()).toCharArray());
253
				return (JavaScriptUnit)parser.createAST(null);
254
			}
255
		}
256
		catch(BadLocationException ble) {
257
			//do nothing, return null
258
		}
259
		return null;
260
	}
261
	
262
	/**
210
	 * Returns the resource on which a breakpoint marker should
263
	 * Returns the resource on which a breakpoint marker should
211
	 * be created for the given member. The resource returned is the 
264
	 * be created for the given member. The resource returned is the 
212
	 * associated file, or workspace root in the case of a binary in 
265
	 * associated file, or workspace root in the case of a binary in 
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/eval/messages.properties (+10 lines)
Lines 1-3 Link Here
1
###############################################################################
2
# Copyright (c) 201o IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
1
cannot_find_debug_target=Unable to locate debug target
11
cannot_find_debug_target=Unable to locate debug target
2
cursor_position_not_valid=Cursor position is not a valid location to run to
12
cursor_position_not_valid=Cursor position is not a valid location to run to
3
empty_editor=Empty editor
13
empty_editor=Empty editor
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/filters/ExternalSourceProjectFilter.java (-41 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.filters;
12
13
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.jface.viewers.Viewer;
16
import org.eclipse.jface.viewers.ViewerFilter;
17
18
/**
19
 * Viewer filter for the 'JavaScript External Source' project
20
 * 
21
 * @since 1.1
22
 */
23
public class ExternalSourceProjectFilter extends ViewerFilter {
24
25
	/**
26
	 * Constructor
27
	 */
28
	public ExternalSourceProjectFilter() {
29
	}
30
31
	/* (non-Javadoc)
32
	 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
33
	 */
34
	public boolean select(Viewer viewer, Object parentElement, Object element) {
35
		if(element instanceof IProject) {
36
			return !((IProject)element).getName().equals(Messages.external_javascript_source);
37
		}
38
		return true;
39
	}
40
41
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/filters/Messages.java (-28 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.filters;
12
13
import org.eclipse.osgi.util.NLS;
14
15
/**
16
 * 
17
 */
18
public class Messages extends NLS {
19
	private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.ui.filters.messages"; //$NON-NLS-1$
20
	public static String external_javascript_source;
21
	static {
22
		// initialize resource bundle
23
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
24
	}
25
26
	private Messages() {
27
	}
28
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/filters/messages.properties (-11 lines)
Removed Link Here
1
###############################################################################
2
# Copyright (c) 2010 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
external_javascript_source=External JavaScript Source
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptConnectTab.java (-2 / +30 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 154-163 Link Here
154
		
154
		
155
		this.argumentsgroup = SWTFactory.createGroup(comp, Messages.connector_properties, 2, 1, GridData.FILL_HORIZONTAL);
155
		this.argumentsgroup = SWTFactory.createGroup(comp, Messages.connector_properties, 2, 1, GridData.FILL_HORIZONTAL);
156
		this.argumentsgroup.setVisible(false);
156
		this.argumentsgroup.setVisible(false);
157
		setControl(comp);
158
		PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IHelpContextIds.CONNECT_TAB);
157
		PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IHelpContextIds.CONNECT_TAB);
158
		setControl(comp);
159
	}
159
	}
160
160
161
	/* (non-Javadoc)
162
	 * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getHelpContextId()
163
	 */
164
	public String getHelpContextId() {
165
		return IHelpContextIds.CONNECT_TAB;
166
	};
167
	
161
	/**
168
	/**
162
	 * Returns the {@link Connector} based on the selection of the combo
169
	 * Returns the {@link Connector} based on the selection of the combo
163
	 * @return the selected combo
170
	 * @return the selected combo
Lines 276-281 Link Here
276
					return false;
283
					return false;
277
				}		
284
				}		
278
			}
285
			}
286
			else if (editor instanceof BooleanFieldEditor) {
287
		        boolean value = ((BooleanFieldEditor)editor).getBooleanValue();
288
		        if (!arg.isValid(String.valueOf(value))) {
289
		          setErrorMessage(NLS.bind(Messages.the_argument_0_is_not_valid, new String[] {arg.name()})); 
290
		          return false;
291
		        }   
292
		    }
293
			else if (editor instanceof IntegerFieldEditor) {
294
		        int value = ((IntegerFieldEditor)editor).getIntValue();
295
		        if (!arg.isValid(String.valueOf(value))) {
296
		          setErrorMessage(NLS.bind(Messages.the_argument_0_is_not_valid, new String[] {arg.name()})); 
297
		          return false;
298
		        }   
299
		    }
300
			else if(editor instanceof ComboFieldEditor) {
301
				editor.store();
302
				if (!arg.isValid(editor.getPreferenceStore().getString(key))) {
303
		          setErrorMessage(NLS.bind(Messages.the_argument_0_is_not_valid, new String[] {arg.name()})); 
304
		          return false;
305
		        }  
306
			}
279
		}		
307
		}		
280
		return true;
308
		return true;
281
	}
309
	}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavascriptTabGroup.java (-5 / +12 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 16-24 Link Here
16
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
16
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
17
import org.eclipse.debug.ui.ILaunchConfigurationTab;
17
import org.eclipse.debug.ui.ILaunchConfigurationTab;
18
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
18
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
19
import org.eclipse.wst.jsdt.debug.internal.ui.IHelpContextIds;
19
20
20
/**
21
/**
21
 * Default tab group for Javascript debugging
22
 * Default tab group for JavaScript debugging
22
 * 
23
 * 
23
 * @since 1.0
24
 * @since 1.0
24
 */
25
 */
Lines 28-38 Link Here
28
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
29
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
29
	 */
30
	 */
30
	public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
31
	public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
32
		SourceLookupTab slt = new SourceLookupTab();
33
		slt.setHelpContextId(IHelpContextIds.SOURCE_LOOKUP_TAB);
34
		EnvironmentTab et = new EnvironmentTab();
35
		et.setHelpContextId(IHelpContextIds.ENVIRONMENT_TAB);
36
		CommonTab ct = new CommonTab();
37
		ct.setHelpContextId(IHelpContextIds.COMMON_TAB);
31
		ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
38
		ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
32
				new JavaScriptConnectTab(),
39
				new JavaScriptConnectTab(),
33
				new SourceLookupTab(),
40
				slt,
34
				new EnvironmentTab(),
41
				et,
35
				new CommonTab()
42
				ct
36
		};
43
		};
37
		setTabs(tabs);
44
		setTabs(tabs);
38
	}
45
	}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/messages.properties (-1 / +2 lines)
Lines 28-40 Link Here
28
evald_script=<evaluated script>
28
evald_script=<evaluated script>
29
exception_occurred_setting_bp_properties=Exceptions occurred attempting to modify breakpoint.
29
exception_occurred_setting_bp_properties=Exceptions occurred attempting to modify breakpoint.
30
hit_count_must_be_positive=Hit count must be a positive integer
30
hit_count_must_be_positive=Hit count must be a positive integer
31
JavaScriptModelPresentation_stackframe_name_with_fname={0} {1}() line: {2}
31
no_description_provided=No description provided.
32
no_description_provided=No description provided.
32
opening_source__0=Opening Source: {0}
33
opening_source__0=Opening Source: {0}
33
running_state=running
34
running_state=running
34
scripts=Scripts
35
scripts=Scripts
35
select_javascript_file=Select a JavaScript script file
36
select_javascript_file=Select a JavaScript script file
36
set_bp_hit_count=Set Breakpoint Hit Count
37
set_bp_hit_count=Set Breakpoint Hit Count
37
stackframe_name={0} - line: {1}
38
stackframe_name={0} line: {1}
38
stepping_state=stepping
39
stepping_state=stepping
39
suspend_loading_script=suspended loading script: {0}
40
suspend_loading_script=suspended loading script: {0}
40
suspend_target=&Suspend Target
41
suspend_target=&Suspend Target
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/JavaScriptDebugPreferencePage.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 40-46 Link Here
40
	 */
40
	 */
41
	public JavaScriptDebugPreferencePage() {
41
	public JavaScriptDebugPreferencePage() {
42
		super(GRID);
42
		super(GRID);
43
		setPreferenceStore(JavaScriptDebugUIPlugin.getDefault().getPreferenceStore());
43
		setPreferenceStore(JavaScriptDebugUIPlugin.getCorePreferenceStore());
44
		setDescription(Messages.js_debug_pref_page_desc);
44
		setDescription(Messages.js_debug_pref_page_desc);
45
	}
45
	}
46
	
46
	

Return to bug 356862