Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 310949 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/wst/jsdt/debug/internal/core/JavaScriptDebugPlugin.java (+11 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.core;
11
package org.eclipse.wst.jsdt.debug.internal.core;
12
12
13
import java.util.HashMap;
14
import java.util.Map;
13
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.core.runtime.Plugin;
16
import org.eclipse.core.runtime.Plugin;
15
import org.eclipse.core.runtime.Status;
17
import org.eclipse.core.runtime.Status;
Lines 49-54 Link Here
49
	private static BreakpointParticipantManager participantmanager = null;
51
	private static BreakpointParticipantManager participantmanager = null;
50
	
52
	
51
	private static JavaScriptPreferencesManager prefmanager = null;
53
	private static JavaScriptPreferencesManager prefmanager = null;
54
	private static Map externalScriptPaths = new HashMap();
52
	
55
	
53
	/**
56
	/**
54
	 * Returns the singleton {@link ConnectorsManager} instance
57
	 * Returns the singleton {@link ConnectorsManager} instance
Lines 154-157 Link Here
154
	public static IStatus newErrorStatus(String message, Throwable exception) {
157
	public static IStatus newErrorStatus(String message, Throwable exception) {
155
		return new Status(IStatus.ERROR, PLUGIN_ID, INTERNAL_ERROR, message, exception);
158
		return new Status(IStatus.ERROR, PLUGIN_ID, INTERNAL_ERROR, message, exception);
156
	}
159
	}
160
161
	public static synchronized void addExternalScriptPath(String sourceName, String scriptPath) {
162
		externalScriptPaths.put(sourceName, scriptPath);		
163
	}
164
	
165
	public static synchronized String getExternalScriptPath(String sourceName) {
166
		return (String) externalScriptPaths.get(sourceName);		
167
	}
157
}
168
}
(-)src/org/eclipse/wst/jsdt/debug/internal/core/breakpoints/DefaultJavaScriptBreakpointParticipant.java (-1 / +1 lines)
Lines 44-50 Link Here
44
		if(breakpoint instanceof IJavaScriptLoadBreakpoint) {
44
		if(breakpoint instanceof IJavaScriptLoadBreakpoint) {
45
			try {
45
			try {
46
				String bpath = breakpoint.getScriptPath();
46
				String bpath = breakpoint.getScriptPath();
47
				if(bpath.equals(script.sourceURI().getPath())) {
47
				if(bpath.equals(script.sourceURI().toString())) {
48
					return SUSPEND;
48
					return SUSPEND;
49
				}
49
				}
50
			} catch (CoreException e) {
50
			} catch (CoreException e) {
(-)src/org/eclipse/wst/jsdt/debug/internal/core/breakpoints/JavaScriptBreakpoint.java (-3 / +1 lines)
Lines 24-30 Link Here
24
import org.eclipse.core.runtime.IPath;
24
import org.eclipse.core.runtime.IPath;
25
import org.eclipse.core.runtime.IProgressMonitor;
25
import org.eclipse.core.runtime.IProgressMonitor;
26
import org.eclipse.core.runtime.Path;
26
import org.eclipse.core.runtime.Path;
27
import org.eclipse.core.runtime.URIUtil;
28
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.DebugPlugin;
29
import org.eclipse.debug.core.model.Breakpoint;
28
import org.eclipse.debug.core.model.Breakpoint;
30
import org.eclipse.debug.core.model.IDebugTarget;
29
import org.eclipse.debug.core.model.IDebugTarget;
Lines 418-425 Link Here
418
				// TODO need something fancier in the future
417
				// TODO need something fancier in the future
419
				// perhaps add this to the participants so each can decide what makes
418
				// perhaps add this to the participants so each can decide what makes
420
				// a script "equal" to suspend on
419
				// a script "equal" to suspend on
421
				IPath path = new Path(getScriptPath());
420
				if (getScriptPath().equals(script.sourceURI().toString())) {
422
				if (path.lastSegment().equals(URIUtil.lastSegment(script.sourceURI()))) {
423
					createRequest(target, sevent.script());
421
					createRequest(target, sevent.script());
424
				}
422
				}
425
			} catch (CoreException ce) {
423
			} catch (CoreException ce) {
(-)src/org/eclipse/wst/jsdt/debug/internal/core/breakpoints/JavaScriptLoadBreakpoint.java (-1 / +1 lines)
Lines 103-109 Link Here
103
				int vote = thread.suspendForScriptLoad(this, script, suspendVote);
103
				int vote = thread.suspendForScriptLoad(this, script, suspendVote);
104
				if(isGlobalLoadSuspend(vote) ||
104
				if(isGlobalLoadSuspend(vote) ||
105
						((vote & IJavaScriptBreakpointParticipant.SUSPEND) > 0 || vote == IJavaScriptBreakpointParticipant.DONT_CARE)) {
105
						((vote & IJavaScriptBreakpointParticipant.SUSPEND) > 0 || vote == IJavaScriptBreakpointParticipant.DONT_CARE)) {
106
					JavaScriptPreferencesManager.setGlobalSuspendOn(script.sourceURI().getPath());
106
					JavaScriptPreferencesManager.setGlobalSuspendOn(script.sourceURI().toString());
107
					thread.addBreakpoint(this);
107
					thread.addBreakpoint(this);
108
					return false;
108
					return false;
109
				}
109
				}
(-)src/org/eclipse/wst/jsdt/debug/internal/core/launching/JavaScriptSourceLookupParticipant.java (-41 / +39 lines)
Lines 13-23 Link Here
13
import java.io.File;
13
import java.io.File;
14
import java.io.FileWriter;
14
import java.io.FileWriter;
15
import java.io.IOException;
15
import java.io.IOException;
16
import java.net.URI;
16
17
17
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IWorkspaceRoot;
18
import org.eclipse.core.resources.ResourcesPlugin;
20
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.Path;
22
import org.eclipse.core.runtime.Path;
22
import org.eclipse.core.runtime.URIUtil;
23
import org.eclipse.core.runtime.URIUtil;
23
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
24
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
Lines 55-74 Link Here
55
	 * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant#findSourceElements(java.lang.Object)
56
	 * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant#findSourceElements(java.lang.Object)
56
	 */
57
	 */
57
	public Object[] findSourceElements(Object object) throws CoreException {
58
	public Object[] findSourceElements(Object object) throws CoreException {
58
		String path = getSourcePath(object);
59
		URI sourceURI = getSourceURI(object);
59
		if (path != null) {
60
		if (sourceURI != null) {
60
			// TODO not sure if we should do a search for the member if the URI path is a miss
61
			IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
61
			IFile file = (IFile) ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path), false);
62
			URI workspaceURI = workspaceRoot.getRawLocationURI();			
62
			if (file != null) {
63
			URI workspaceRelativeURI = workspaceURI.relativize(sourceURI);
63
				return new IFile[] { file };
64
			if (! workspaceRelativeURI.isAbsolute()) {
65
				IFile file = (IFile) ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(workspaceRelativeURI.getPath()), false);
66
				if (file != null) {
67
					return new IFile[] { file };
68
				}
64
			}
69
			}
70
65
			//try to find it using the source tab infos
71
			//try to find it using the source tab infos
66
			Object[] sources = super.findSourceElements(object);
72
			Object[] sources = super.findSourceElements(object);
67
			if(sources != null && sources.length > 0) {
73
			if(sources != null && sources.length > 0) {
68
				return sources;
74
				return sources;
69
			}
75
			}
70
			//else show the temp source
76
			//else show the temp source
71
			return showExternalSource(getSource(object), path);
77
			return showExternalSource(getSource(object), sourceURI);
72
		}
78
		}
73
		return NO_SOURCE;
79
		return NO_SOURCE;
74
	}
80
	}
Lines 78-84 Link Here
78
	 * @param object
84
	 * @param object
79
	 * @return the raw source or <code>null</code>
85
	 * @return the raw source or <code>null</code>
80
	 */
86
	 */
81
	String getSource(Object object) {
87
	private String getSource(Object object) {
82
		if(object instanceof IJavaScriptStackFrame) {
88
		if(object instanceof IJavaScriptStackFrame) {
83
			IJavaScriptStackFrame jframe = (IJavaScriptStackFrame) object;
89
			IJavaScriptStackFrame jframe = (IJavaScriptStackFrame) object;
84
			return jframe.getSource();
90
			return jframe.getSource();
Lines 91-109 Link Here
91
	}
97
	}
92
	
98
	
93
	/**
99
	/**
94
	 * Returns the path to use to look up source
100
	 * Returns the uri to use to look up source
95
	 * @param object
101
	 * @param object
96
	 * @return the path or <code>null</code>
102
	 * @return the URI or <code>null</code>
97
	 * @since 1.1
103
	 * @since 1.1
98
	 */
104
	 */
99
	String getSourcePath(Object object) {
105
	private URI getSourceURI(Object object) {
100
		if(object instanceof IJavaScriptStackFrame) {
106
		if(object instanceof IJavaScriptStackFrame) {
101
			IJavaScriptStackFrame jframe = (IJavaScriptStackFrame) object;
107
			IJavaScriptStackFrame jframe = (IJavaScriptStackFrame) object;
102
			return jframe.getSourcePath();
108
			return URI.create(jframe.getSourcePath());
103
		}
109
		}
104
		if(object instanceof IScript) {
110
		if(object instanceof IScript) {
105
			IScript script = (IScript) object;
111
			IScript script = (IScript) object;
106
			return script.sourceURI().getPath().toString();
112
			return script.sourceURI();
107
		}
113
		}
108
		return null;
114
		return null;
109
	}
115
	}
Lines 115-128 Link Here
115
	 * @param path
121
	 * @param path
116
	 * @return the collection of files to show in external editors
122
	 * @return the collection of files to show in external editors
117
	 */
123
	 */
118
	Object[] showExternalSource(String source, String path) {
124
	private Object[] showExternalSource(String source, URI uri) {
119
		try {
125
		try {
120
			File tempdir = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$
126
			File tempdir = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$
121
			File file = new File(tempdir, formatExternalName(path));
127
			File jsdt_debug = new File(tempdir, "jsdt_debug"); //$NON-NLS-1$
128
			jsdt_debug.mkdir();
129
			jsdt_debug.deleteOnExit();
130
131
			String fileName = URIUtil.lastSegment(uri);
132
			if (fileName.endsWith(".js")) //$NON-NLS-1$
133
				fileName = fileName.substring(0, fileName.length()-3);
134
			fileName +="(" + Integer.toString(uri.toString().hashCode() + source.hashCode()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
135
			fileName += ".js"; //$NON-NLS-1$
136
			
137
			File file = new File(jsdt_debug, fileName);
122
			file.deleteOnExit();
138
			file.deleteOnExit();
123
			FileWriter writer = new FileWriter(file);
139
			
124
			writer.write(source);
140
			if (!file.exists() || JavaScriptDebugPlugin.getExternalScriptPath(fileName) == null) {
125
			writer.close();
141
				FileWriter writer = new FileWriter(file);
142
				writer.write(source);
143
				writer.close();
144
				JavaScriptDebugPlugin.addExternalScriptPath(fileName, uri.toString());
145
			}
126
			return new Object[] {file};
146
			return new Object[] {file};
127
147
128
		} catch (IOException e) {
148
		} catch (IOException e) {
Lines 130-157 Link Here
130
			return NO_SOURCE;
150
			return NO_SOURCE;
131
		}
151
		}
132
	}
152
	}
133
134
	/**
135
	 * Formats the name of the external source to be:
136
	 * <code>[name]_[counter].js</code>.<br><br>
137
	 * If the given name is <code>null</code> the default
138
	 * name of <code>script_[counter].js</code> will be used
139
	 * @param basename
140
	 * @return the formatted external source name
141
	 */
142
	String formatExternalName(String basename) {
143
		IPath path = null;
144
		if(basename == null) {
145
			path = new Path("script"); //$NON-NLS-1$
146
		}
147
		else {
148
			path = new Path(basename);
149
		}
150
		path = path.removeFileExtension();
151
		StringBuffer buffer = new StringBuffer(path.toString());
152
		buffer.append(".js"); //$NON-NLS-1$
153
		return buffer.toString();
154
	}
155
	
153
	
156
	/*
154
	/*
157
	 * (non-Javadoc)
155
	 * (non-Javadoc)
(-)src/org/eclipse/wst/jsdt/debug/internal/core/model/JavaScriptStackFrame.java (-2 / +2 lines)
Lines 102-108 Link Here
102
	public String getName() throws DebugException {
102
	public String getName() throws DebugException {
103
		if (this.name == null) {
103
		if (this.name == null) {
104
			this.name = NLS.bind(ModelMessages.JSDIStackFrame_stackframe_name, new String[] {
104
			this.name = NLS.bind(ModelMessages.JSDIStackFrame_stackframe_name, new String[] {
105
									this.stackFrame.location().scriptReference().sourceURI().getPath(), 
105
									this.stackFrame.location().scriptReference().sourceURI().toString(), 
106
									Integer.toString(stackFrame.location().lineNumber()) 
106
									Integer.toString(stackFrame.location().lineNumber()) 
107
									});
107
									});
108
		}
108
		}
Lines 331-337 Link Here
331
		if(loc != null) {
331
		if(loc != null) {
332
			ScriptReference script = loc.scriptReference();
332
			ScriptReference script = loc.scriptReference();
333
			if(script != null) {
333
			if(script != null) {
334
				return script.sourceURI().getPath();
334
				return script.sourceURI().toString();
335
			}
335
			}
336
		}
336
		}
337
		return null;
337
		return null;
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/jsdi/ScriptReferenceImpl.java (-25 / +14 lines)
Lines 138-169 Link Here
138
	/* (non-Javadoc)
138
	/* (non-Javadoc)
139
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#sourceURI()
139
	 * @see org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference#sourceURI()
140
	 */
140
	 */
141
	public URI sourceURI() {
141
	public synchronized URI sourceURI() {
142
		synchronized (vm) {
142
		if (this.sourceuri == null) {
143
			if (this.sourceuri == null) {
143
			try {
144
				try {
144
				if (this.sourceProperties != null) {
145
					if(this.sourceProperties != null) {
145
					IPath path = new Path((String) this.sourceProperties.get(Constants.BUNDLE_SYMBOLICNAME));
146
						IPath path = new Path((String) this.sourceProperties.get(Constants.BUNDLE_SYMBOLICNAME));
146
					path = path.append((String) this.sourceProperties.get(JSONConstants.PATH));
147
						path = path.append((String) this.sourceProperties.get(JSONConstants.PATH));
147
					path = path.append((String) this.sourceProperties.get(JSONConstants.NAME));
148
						path = path.append((String) this.sourceProperties.get(JSONConstants.NAME));
148
					this.sourceuri = URI.create(path.toString());
149
						this.sourceuri = RhinoDebugPlugin.fileURI(path);
149
				} else if (this.sourcePath != null) {
150
					}
150
					this.sourceuri = URI.create(sourcePath);
151
					else if(this.sourcePath != null) {
151
				} else {
152
						IPath path = null;
152
					this.sourceuri = RhinoDebugPlugin.fileURI(new Path("script")); //$NON-NLS-1$
153
						if(this.sourcePath.equals(org.eclipse.wst.jsdt.debug.internal.rhino.Constants.STD_IN_URI)) {
154
							path = new Path(org.eclipse.wst.jsdt.debug.internal.rhino.Constants.STD_IN);
155
						}
156
						else {
157
							path = new Path(this.sourcePath);
158
						}
159
						this.sourceuri = RhinoDebugPlugin.fileURI(path);
160
					}
161
					else {
162
						this.sourceuri = RhinoDebugPlugin.fileURI(new Path("script")); //$NON-NLS-1$
163
					}
164
				} catch (URISyntaxException urise) {
165
					RhinoDebugPlugin.log(urise);
166
				}
153
				}
154
			} catch (URISyntaxException urise) {
155
				RhinoDebugPlugin.log(urise);
167
			}
156
			}
168
		}
157
		}
169
		return this.sourceuri;
158
		return this.sourceuri;
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/RhinoDebuggerImpl.java (-20 / +38 lines)
Lines 8-13 Link Here
8
 *******************************************************************************/
8
 *******************************************************************************/
9
package org.eclipse.wst.jsdt.debug.internal.rhino.debugger;
9
package org.eclipse.wst.jsdt.debug.internal.rhino.debugger;
10
10
11
import java.io.File;
11
import java.net.URI;
12
import java.net.URI;
12
import java.net.URISyntaxException;
13
import java.net.URISyntaxException;
13
import java.util.ArrayList;
14
import java.util.ArrayList;
Lines 42-49 Link Here
42
public class RhinoDebuggerImpl implements Debugger, ContextFactory.Listener {
43
public class RhinoDebuggerImpl implements Debugger, ContextFactory.Listener {
43
44
44
	public static final DebuggableScript[] NO_SCRIPTS = new DebuggableScript[0];
45
	public static final DebuggableScript[] NO_SCRIPTS = new DebuggableScript[0];
45
46
	private static final String RHINO_SCHEME = "rhino"; //$NON-NLS-1$
46
47
	
47
	private final Map threadToThreadId = new HashMap();
48
	private final Map threadToThreadId = new HashMap();
48
	private final Map threadIdToData = new HashMap();
49
	private final Map threadIdToData = new HashMap();
49
	private final Map breakpoints = new HashMap();
50
	private final Map breakpoints = new HashMap();
Lines 170-198 Link Here
170
	 * @param properties any special properties @see {@link #parseSourceProperties(String)}
171
	 * @param properties any special properties @see {@link #parseSourceProperties(String)}
171
	 * @return the {@link URI} for the source or <code>null</code>
172
	 * @return the {@link URI} for the source or <code>null</code>
172
	 */
173
	 */
173
	URI getSourceUri(DebuggableScript script, Map properties) {
174
	private URI getSourceUri(DebuggableScript script, Map properties) {
174
		try {
175
			String sourceName = script.getSourceName();
175
			if(properties != null) {
176
			if(properties != null) {
176
				return new URI((String) properties.get(JSONConstants.NAME));
177
				String jsonName = (String) properties.get(JSONConstants.NAME);
178
				if (jsonName != null)
179
					sourceName = jsonName;
177
			}
180
			}
178
			String path = script.getSourceName();
181
			
179
			if("<stdin>".equals(path)) { //$NON-NLS-1$
182
			// handle null sourceName
180
				path = "stdin"; //$NON-NLS-1$
183
			if (sourceName == null)
181
			}
184
				return null;
182
			try {
185
			
186
			// handle input from the Rhino Shell
187
			if (sourceName.equals("<stdin>")) { //$NON-NLS-1$
188
				sourceName = "stdin"; //$NON-NLS-1$
189
			} else {		
190
				// try to parse it as a file
191
				File sourceFile = new File(sourceName);
192
				if (sourceFile.exists())
193
					return sourceFile.toURI();
194
				
183
				//try to just create a URI from the name
195
				//try to just create a URI from the name
184
				return new URI(path);
196
				try {
197
					URI uri = new URI(sourceName);
198
					if (uri.getScheme() != null && uri.isAbsolute())
199
						return uri;
200
				}
201
				catch(URISyntaxException e) {
202
					//do nothing and fall through
203
				}
185
			}
204
			}
186
			catch(URISyntaxException urise) {
205
			
187
				//do nothing
206
			//fall back to creating a rhino specific URI from the script source name as a path
207
			try {
208
				if (! (sourceName.charAt(0) == '/'))
209
					sourceName = "/" + sourceName; //$NON-NLS-1$
210
				return new URI(RHINO_SCHEME, null, sourceName, null);
211
			} catch (URISyntaxException e) {
212
				return null;
188
			}
213
			}
189
			//fall back to creating a file URI
190
			return new URI("file:", null, path, null); //$NON-NLS-1$
191
		}
192
		catch (URISyntaxException urise) {
193
			//do nothing just return null
194
		}
195
		return null;
196
	}
214
	}
197
	
215
	
198
	/**
216
	/**
(-)src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/ScriptSource.java (-5 / +5 lines)
Lines 172-178 Link Here
172
	 * @return if this script represents the stdin script
172
	 * @return if this script represents the stdin script
173
	 */
173
	 */
174
	public boolean isStdIn() {
174
	public boolean isStdIn() {
175
		return this.uri.getPath().endsWith("stdin"); //$NON-NLS-1$
175
		return this.uri.toString().endsWith("stdin"); //$NON-NLS-1$
176
	}
176
	}
177
	
177
	
178
	/**
178
	/**
Lines 239-245 Link Here
239
	 */
239
	 */
240
	public boolean equals(Object obj) {
240
	public boolean equals(Object obj) {
241
		if(obj instanceof ScriptSource) {
241
		if(obj instanceof ScriptSource) {
242
			return this.uri.getPath().equals(((ScriptSource)obj).uri.getPath());
242
			return this.uri.toString().equals(((ScriptSource)obj).uri.toString());
243
		}
243
		}
244
		return false;
244
		return false;
245
	}
245
	}
Lines 248-254 Link Here
248
	 * @see java.lang.Object#hashCode()
248
	 * @see java.lang.Object#hashCode()
249
	 */
249
	 */
250
	public int hashCode() {
250
	public int hashCode() {
251
		return this.uri.getPath().hashCode();
251
		return this.uri.toString().hashCode();
252
	}
252
	}
253
253
254
	/**
254
	/**
Lines 257-263 Link Here
257
	public Object toJSON() {
257
	public Object toJSON() {
258
		HashMap result = new HashMap();
258
		HashMap result = new HashMap();
259
		result.put(JSONConstants.SCRIPT_ID, this.scriptId);
259
		result.put(JSONConstants.SCRIPT_ID, this.scriptId);
260
		result.put(JSONConstants.LOCATION, this.uri.getPath());
260
		result.put(JSONConstants.LOCATION, this.uri.toString());
261
		result.put(JSONConstants.PROPERTIES, properties);
261
		result.put(JSONConstants.PROPERTIES, properties);
262
		result.put(JSONConstants.SOURCE, source);
262
		result.put(JSONConstants.SOURCE, source);
263
		result.put(JSONConstants.GENERATED, Boolean.valueOf(generated));
263
		result.put(JSONConstants.GENERATED, Boolean.valueOf(generated));
Lines 400-406 Link Here
400
	 * @return the string location of this script
400
	 * @return the string location of this script
401
	 */
401
	 */
402
	public String getLocation() {
402
	public String getLocation() {
403
		return this.uri.getPath();
403
		return this.uri.toString();
404
	}
404
	}
405
	
405
	
406
	/**
406
	/**
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/ToggleBreakpointAdapter.java (-12 / +25 lines)
Lines 18-23 Link Here
18
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.Path;
21
import org.eclipse.core.runtime.Status;
22
import org.eclipse.core.runtime.Status;
22
import org.eclipse.core.runtime.jobs.Job;
23
import org.eclipse.core.runtime.jobs.Job;
23
import org.eclipse.debug.core.DebugPlugin;
24
import org.eclipse.debug.core.DebugPlugin;
Lines 52-57 Link Here
52
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptFunctionBreakpoint;
53
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptFunctionBreakpoint;
53
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLineBreakpoint;
54
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLineBreakpoint;
54
import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel;
55
import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel;
56
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
55
import org.eclipse.wst.jsdt.debug.internal.ui.DebugWCManager;
57
import org.eclipse.wst.jsdt.debug.internal.ui.DebugWCManager;
56
58
57
/**
59
/**
Lines 133-156 Link Here
133
	 * @return the path to the script 
135
	 * @return the path to the script 
134
	 */
136
	 */
135
	String getScriptPath(IJavaScriptElement element) {
137
	String getScriptPath(IJavaScriptElement element) {
136
		switch(element.getElementType()) {
138
		String scriptPath  = getElementScriptPath(element);
139
		if (! scriptPath.endsWith(").js")) //$NON-NLS-1$
140
			return scriptPath;
141
		
142
		Path path = new Path(scriptPath);
143
		String scriptName = path.lastSegment();
144
		String externalScriptPath = (JavaScriptDebugPlugin.getExternalScriptPath(scriptName));
145
		return (externalScriptPath == null) ? scriptPath : externalScriptPath;
146
	}
147
148
	private String getElementScriptPath(IJavaScriptElement element) {
149
		switch (element.getElementType()) {
137
		case IJavaScriptElement.TYPE: {
150
		case IJavaScriptElement.TYPE: {
138
			return ((IType)element).getPath().toOSString();
151
			return ((IType) element).getPath().toOSString();
139
		}
152
		}
140
		case IJavaScriptElement.METHOD:
153
		case IJavaScriptElement.METHOD:
141
		case IJavaScriptElement.FIELD: {
154
		case IJavaScriptElement.FIELD: {
142
			IMember member = (IMember) element;
155
			IMember member = (IMember) element;
143
			IType type = member.getDeclaringType();
156
			IType type = member.getDeclaringType();
144
			if(type == null) {
157
			if (type == null) {
145
				IJavaScriptElement parent = element.getParent();
158
				IJavaScriptElement parent = element.getParent();
146
				switch(parent.getElementType()) {
159
				switch (parent.getElementType()) {
147
					case IJavaScriptElement.TYPE: {
160
				case IJavaScriptElement.TYPE: {
148
						return ((IType)parent).getPath().toOSString();
161
					return ((IType) parent).getPath().toOSString();
149
					}
162
				}
150
					case IJavaScriptElement.JAVASCRIPT_UNIT: 
163
				case IJavaScriptElement.JAVASCRIPT_UNIT:
151
					case IJavaScriptElement.CLASS_FILE: {
164
				case IJavaScriptElement.CLASS_FILE: {
152
						return ((ITypeRoot)parent).getPath().toOSString();
165
					return ((ITypeRoot) parent).getPath().toOSString();
153
					}
166
				}
154
				}
167
				}
155
				return element.getParent().getElementName();
168
				return element.getParent().getElementName();
156
			}
169
			}
Lines 159-165 Link Here
159
		default: {
172
		default: {
160
			return element.getElementName();
173
			return element.getElementName();
161
		}
174
		}
162
	}
175
		}
163
	}
176
	}
164
	
177
	
165
	/**
178
	/**

Return to bug 310949