Lines 10-15
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi; |
11 |
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi; |
12 |
|
12 |
|
|
|
13 |
import java.util.Comparator; |
14 |
|
13 |
import org.eclipse.wst.jsdt.debug.core.jsdi.Location; |
15 |
import org.eclipse.wst.jsdt.debug.core.jsdi.Location; |
14 |
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference; |
16 |
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference; |
15 |
|
17 |
|
Lines 19-24
Link Here
|
19 |
* @since 1.0 |
21 |
* @since 1.0 |
20 |
*/ |
22 |
*/ |
21 |
public class LocationImpl extends MirrorImpl implements Location { |
23 |
public class LocationImpl extends MirrorImpl implements Location { |
|
|
24 |
|
25 |
/** |
26 |
* Comparator that orders {@link Location}s by line number - useful for debugging |
27 |
*/ |
28 |
static class LocationComparator implements Comparator { |
29 |
/* (non-Javadoc) |
30 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
31 |
*/ |
32 |
public int compare(Object o1, Object o2) { |
33 |
int value = -1; |
34 |
if(o1 instanceof Location && o2 instanceof Location) { |
35 |
int first = ((Location)o1).lineNumber(); |
36 |
int second = ((Location)o2).lineNumber(); |
37 |
if(first == second) { |
38 |
value = 0; |
39 |
} |
40 |
else if(first > second) { |
41 |
value = 1; |
42 |
} |
43 |
} |
44 |
return value; |
45 |
} |
46 |
|
47 |
} |
48 |
private static LocationComparator comparator = new LocationComparator(); |
22 |
private String functionName; |
49 |
private String functionName; |
23 |
private int lineNumber; |
50 |
private int lineNumber; |
24 |
private ScriptReferenceImpl scriptReference; |
51 |
private ScriptReferenceImpl scriptReference; |
Lines 38-43
Link Here
|
38 |
this.scriptReference = scriptReference; |
65 |
this.scriptReference = scriptReference; |
39 |
} |
66 |
} |
40 |
|
67 |
|
|
|
68 |
static LocationComparator getLocationComparator() { |
69 |
return comparator; |
70 |
} |
71 |
|
41 |
/* (non-Javadoc) |
72 |
/* (non-Javadoc) |
42 |
* @see org.eclipse.wst.jsdt.debug.core.jsdi.Location#functionName() |
73 |
* @see org.eclipse.wst.jsdt.debug.core.jsdi.Location#functionName() |
43 |
*/ |
74 |
*/ |
Lines 58-61
Link Here
|
58 |
public ScriptReference scriptReference() { |
89 |
public ScriptReference scriptReference() { |
59 |
return scriptReference; |
90 |
return scriptReference; |
60 |
} |
91 |
} |
|
|
92 |
|
93 |
/* (non-Javadoc) |
94 |
* @see java.lang.Object#toString() |
95 |
*/ |
96 |
public String toString() { |
97 |
StringBuffer buffer = new StringBuffer(); |
98 |
buffer.append("LocationImpl: "); //$NON-NLS-1$ |
99 |
buffer.append("[script - ").append(scriptReference.sourceURI()).append("] "); //$NON-NLS-1$ //$NON-NLS-2$ |
100 |
buffer.append("[function - ").append(functionName).append("] "); //$NON-NLS-1$ //$NON-NLS-2$ |
101 |
buffer.append("[line - ").append(lineNumber).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ |
102 |
return buffer.toString(); |
103 |
} |
61 |
} |
104 |
} |