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

Collapse All | Expand All

(-)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.IScriptResolver
63
               </documentation>
64
               <appinfo>
65
                  <meta.attribute kind="java" basedOn=":org.eclipse.wst.jsdt.debug.core.model.IScriptResolver"/>
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 implements &lt;code&gt;org.eclipse.wst.jsdt.debug.core.model.IScriptResolver.java&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 (+47 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
23
 * @noextend This interface is not intended to be extended by clients.
24
 * @since 3.4
25
 */
26
public interface IScriptResolver {
27
28
	/**
29
	 * This method determines if the given {@link IPath} matches the {@link URI} from {@link ScriptReference#sourceURI()}.
30
31
	 * @param script the {@link ScriptReference} to compare the source {@link URI} from - never <code>null</code>
32
	 * @param path the path to match against the source {@link URI} - never <code>null</code>
33
	 * 
34
	 * @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.
35
	 */
36
	public boolean matches(ScriptReference script, IPath path);
37
	
38
	/**
39
	 * This method is used to find the workspace {@link IFile} that corresponds to the source {@link URI} from the given {@link ScriptReference}.
40
	 * <br><br>
41
	 * If no file can be determined the method must return <code>null</code>. The result will be checked for existence.
42
	 * 
43
	 * @param script the {@link ScriptReference} to find the {@link IFile} for
44
	 * @return the {@link IFile} for the {@link ScriptReference} or <code>null</code>
45
	 */
46
	public IFile getFile(ScriptReference script);
47
}
(-)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 (+17 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
	 * 
(-)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 (-6 / +20 lines)
Lines 20-25 Link Here
20
import org.eclipse.core.resources.ResourcesPlugin;
20
import org.eclipse.core.resources.ResourcesPlugin;
21
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.core.runtime.Path;
23
import org.eclipse.debug.core.DebugException;
24
import org.eclipse.debug.core.DebugException;
24
import org.eclipse.debug.core.model.IBreakpoint;
25
import org.eclipse.debug.core.model.IBreakpoint;
25
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpointParticipant;
26
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpointParticipant;
Lines 102-108 Link Here
102
			ScriptReference script = sevent.script();
103
			ScriptReference script = sevent.script();
103
			JavaScriptThread thread = target.findThread((sevent).thread());
104
			JavaScriptThread thread = target.findThread((sevent).thread());
104
			if (thread != null) {
105
			if (thread != null) {
105
				if(isGlobalLoadSuspend(target.getVM())) {
106
				if(isGlobalLoadSuspend()) {
107
					if(!supportsGlobalSuspend(target.getVM())) {
108
						return true;
109
					}
106
					JavaScriptPreferencesManager.setGlobalSuspendOn(script.sourceURI().toString());
110
					JavaScriptPreferencesManager.setGlobalSuspendOn(script.sourceURI().toString());
107
					thread.addBreakpoint(this);
111
					thread.addBreakpoint(this);
108
					return false;
112
					return false;
Lines 126-132 Link Here
126
	 */
130
	 */
127
	private boolean isMatchedScriptLoadSuspend(ScriptReference script, JavaScriptThread thread, boolean suspendVote) {
131
	private boolean isMatchedScriptLoadSuspend(ScriptReference script, JavaScriptThread thread, boolean suspendVote) {
128
		try {
132
		try {
129
			if (scriptPathMatches(script)) {
133
			if (JavaScriptDebugPlugin.getResolutionManager().matches(script, new Path(getScriptPath()))) {
130
				int vote = thread.suspendForScriptLoad(this, script, suspendVote);
134
				int vote = thread.suspendForScriptLoad(this, script, suspendVote);
131
				return (vote & IJavaScriptBreakpointParticipant.SUSPEND) > 0 || vote == IJavaScriptBreakpointParticipant.DONT_CARE;
135
				return (vote & IJavaScriptBreakpointParticipant.SUSPEND) > 0 || vote == IJavaScriptBreakpointParticipant.DONT_CARE;
132
			}
136
			}
Lines 138-148 Link Here
138
	}
142
	}
139
	
143
	
140
	/**
144
	/**
141
	 * Returns if this breakpoint supports global suspend
145
	 * Use reflection hack to opt-out of global suspend
142
	 * 
146
	 * 
143
	 * @return <code>true</code> if we should suspend on all script loads <code>false</code> otherwise
147
	 * @param vm
148
	 * @return <code>true</code> if the backing {@link VirtualMachine} supports global suspend
144
	 */
149
	 */
145
	private boolean isGlobalLoadSuspend(VirtualMachine vm) {
150
	boolean supportsGlobalSuspend(VirtualMachine vm) {
146
		boolean supports = true;
151
		boolean supports = true;
147
		try {
152
		try {
148
			//TODO consider supportsSuspendOnScriptLoads for future VirtualMachine extensions
153
			//TODO consider supportsSuspendOnScriptLoads for future VirtualMachine extensions
Lines 153-160 Link Here
153
			//assume the method is not there / problematic
158
			//assume the method is not there / problematic
154
			supports = true;
159
			supports = true;
155
		}
160
		}
161
		return supports;
162
	}
163
	
164
	/**
165
	 * Returns if this breakpoint supports global suspend
166
	 * 
167
	 * @return <code>true</code> if we should suspend on all script loads <code>false</code> otherwise
168
	 */
169
	private boolean isGlobalLoadSuspend() {
156
		try {
170
		try {
157
			return supports && ensureMarker().getAttribute(GLOBAL_SUSPEND, false);
171
			return ensureMarker().getAttribute(GLOBAL_SUSPEND, false);
158
		}
172
		}
159
		catch(CoreException ce) {
173
		catch(CoreException ce) {
160
			JavaScriptDebugPlugin.log(ce);
174
			JavaScriptDebugPlugin.log(ce);
(-)src/org/eclipse/wst/jsdt/debug/internal/core/launching/SourceLookup.java (-6 / +9 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-61 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
			String name = URIUtil.lastSegment(((IScript)object).sourceURI());
58
			name = URIUtil.lastSegment(((IScript)object).sourceURI());
58
			if(!JavaScriptCore.isJavaScriptLikeFileName(name)) {
59
		}
60
		if(name != null) {
61
			if(new Path(name).getFileExtension() == null) {
59
				//append .js, there is no case where we would look up a file with no extension from a script node
62
				//append .js, there is no case where we would look up a file with no extension from a script node
60
				StringBuffer buf = new StringBuffer(name.length()+3);
63
				StringBuffer buf = new StringBuffer(name.length()+3);
61
				buf.append(name).append('.').append(Constants.JS_EXTENSION);
64
				buf.append(name).append('.').append(Constants.JS_EXTENSION);
Lines 165-171 Link Here
165
			return null;
168
			return null;
166
		}
169
		}
167
		if(uripath.trim().equals("/")) { //$NON-NLS-1$
170
		if(uripath.trim().equals("/")) { //$NON-NLS-1$
168
			uripath = "page.js"; //$NON-NLS-1$
171
			uripath = "index.htm"; //$NON-NLS-1$
169
		}
172
		}
170
		String host = sourceuri.getHost();
173
		String host = sourceuri.getHost();
171
		IPath path = null;
174
		IPath path = null;
Lines 244-250 Link Here
244
			newpath = newpath.append((String) segments.get(i));
247
			newpath = newpath.append((String) segments.get(i));
245
		}
248
		}
246
		String ext = newpath.getFileExtension(); 
249
		String ext = newpath.getFileExtension(); 
247
		if(ext == null || !Constants.JS_EXTENSION.equals(ext)) {
250
		if(ext == null && !Constants.JS_EXTENSION.equals(ext)) {
248
			newpath = newpath.addFileExtension(Constants.JS_EXTENSION);
251
			newpath = newpath.addFileExtension(Constants.JS_EXTENSION);
249
		}
252
		}
250
		return newpath; 
253
		return newpath; 
(-)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.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
}
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 16-22 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.100"
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-friends:="org.eclipse.wst.jsdt.debug.rhino.ui",
23
Export-Package: org.eclipse.wst.jsdt.debug.internal.ui;x-friends:="org.eclipse.wst.jsdt.debug.rhino.ui",
(-)plugin.xml (+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 570-574 Link Here
570
            markerType="org.eclipse.wst.jsdt.debug.core.breakpoint.marker">
600
            markerType="org.eclipse.wst.jsdt.debug.core.breakpoint.marker">
571
      </updater>
601
      </updater>
572
   </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>
573
614
574
</plugin>
615
</plugin>
(-)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/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 

Return to bug 361315