Skip to content

Commit 298ccb4

Browse files
author
Chris
committed
Version of tool used for test run of study with Tyler
1 parent b96aee8 commit 298ccb4

12 files changed

Lines changed: 96 additions & 236 deletions

File tree

dataTool/.classpath

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
</attributes>
99
</classpathentry>
1010
<classpathentry kind="src" path="src_tests"/>
11-
<classpathentry exported="true" kind="lib" path="org.eclipse.jdt.internal.ui.jar"/>
1211
<classpathentry kind="output" path="bin"/>
1312
</classpath>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
resolve.requirebundle=false

dataTool/META-INF/MANIFEST.MF

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,3 @@ Import-Package: org.eclipse.jdt.internal.ui.search
2828
Export-Package: dataTool,
2929
dataTool.annotations,
3030
dataTool.ui
31-
Bundle-ClassPath: org.eclipse.jdt.internal.ui.jar,
32-
.

dataTool/build.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ output.. = bin/
33
bin.includes = META-INF/,\
44
.,\
55
plugin.xml,\
6-
icons/,\
7-
org.eclipse.jdt.internal.ui.jar
6+
icons/

dataTool/src/dataTool/AnnotationManager.java

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,15 @@ public AnnotationManager(AbstractDecoratedTextEditor anEditor) {
6868
sourceViewer.addPainter(painter);
6969
selectionChanged((ITextSelection) painter.getSelection());
7070
}
71-
72-
/**
73-
* Handles updating the annotations and searching when user clicks a variable
74-
* @param selection: current text selected
75-
*/
71+
7672
public void selectionChanged(ITextSelection selection) {
7773
painter.removeAllAnnotations();
7874
try {
7975
DataNode one = getNode(selection.getOffset());
8076
Finder finder = Finder.getInstance();
8177
if(one != null) {
8278
addAnnotation(one);
83-
currentSearch = one.getBinding();
79+
currentSearch = one.getKey();
8480
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
8581
IEditorPart activeEditor = activePage.getActiveEditor();
8682
JavaEditor j = (JavaEditor) activeEditor;
@@ -96,20 +92,18 @@ public void selectionChanged(ITextSelection selection) {
9692
DataCallHierarchy call = new DataCallHierarchy();
9793
Set<IMethod> searchUp = null;
9894
Set<IMethod> searchDown = null;
99-
if((finder.upSearch(one) != null || finder.downSearch(one) != null ||
100-
one.getInvocationMethod() != null || one.getDeclarationMethod() != null) && currentSearch != null) {
95+
if((finder.upSearch(one) != null || finder.downSearch(one) != null || one.getInvocationMethod() != null) && currentSearch != null) {
10196
searchUp = call.searchProject(one, Finder.UP);
10297
searchDown = call.searchProject(one, Finder.DOWN);
103-
linkAnnotation.searchResultsDown = searchDown;
104-
linkAnnotation.searchResultsUp = searchUp;
105-
linkAnnotation.setDataNode(one);
106-
addLinkAnnotation(one);
10798
}
10899

109100
//Adds all occurrences of data node off screen
101+
linkAnnotation.searchResultsDown = searchDown;
102+
linkAnnotation.searchResultsUp = searchUp;
103+
110104
ArrayList<Object> textUp = new ArrayList<Object>();
111105
ArrayList<Object> textDown = new ArrayList<Object>();
112-
for(DataNode dn: finder.getOccurrences(one.getValue(), new Position(one.getStartPosition(), one.getLength()))) {
106+
for(DataNode dn: finder.getOccurrences(one.getPosition())) {
113107
int[] offScreen = new int[3];
114108
int line = sourceViewer.widgetLineOfWidgetOffset(dn.getStartPosition())+1;
115109
offScreen[0] = line;
@@ -121,15 +115,25 @@ public void selectionChanged(ITextSelection selection) {
121115
else if(dn.getStartPosition() > sourceViewer.getBottomIndexEndOffset()) {
122116
textDown.add(offScreen);
123117
}
118+
if(dn.getDeclarationMethod() != null) {
119+
linkAnnotation.setDataNode(dn);
120+
linkAnnotation.draw(null, sourceViewer.getTextWidget(),
121+
dn.getDeclarationMethod().getName().getStartPosition(), dn.getDeclarationMethod().getName().getLength());
122+
}
123+
if(dn.getInvocationMethod() != null) {
124+
linkAnnotation.setDataNode(dn);
125+
linkAnnotation.draw(null, sourceViewer.getTextWidget(), dn.getInvocationMethod().getName().getStartPosition(),
126+
dn.getInvocationMethod().getName().getLength());
127+
}
124128
}
125129
if(searchUp != null) {
126130
textUp.addAll(searchUp);
127-
((EditorBreadcrumb)upBreadcrumb).setSearchMethod(call.getCurrentMethod(one.getStartPosition()));
128131
((EditorBreadcrumb)upBreadcrumb).setSearchIndex(one.getParameterIndex());
132+
((EditorBreadcrumb)upBreadcrumb).setSearchMethod(call.getCurrentMethod(one.getStartPosition()));
129133
}
130134
if(searchDown != null) {
131-
textDown.addAll(searchDown);
132135
((EditorBreadcrumb)downBreadcrumb).setSearchIndex(one.getParameterIndex());
136+
textDown.addAll(searchDown);
133137
}
134138
upBreadcrumb.setText(textUp);
135139
downBreadcrumb.setText(textDown);
@@ -185,7 +189,7 @@ private ASTNode meet(ASTNode from, ASTNode to) {
185189
private boolean isAlreadyAnnotated(int start, int end) {
186190

187191
Position headPosition = painter.getPosition(highlightAnnotation);
188-
192+
189193
if (headPosition != null)
190194
return headPosition.getOffset() == start && headPosition.getOffset() + headPosition.getLength() == end;
191195

@@ -232,7 +236,7 @@ private void addAnnotationsAt(int statementStart, int length, boolean isHighligh
232236

233237
public void removeAnnotations() {
234238
try {
235-
if (highlightAnnotation != null || linkAnnotation != null) {
239+
if (highlightAnnotation != null) {
236240
painter.removeAllAnnotations();
237241
}
238242
} catch (Exception ignore) {

dataTool/src/dataTool/DataCallHierarchy.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public Set<IMethod> searchProject(DataNode node, String direction) throws JavaMo
8787
}
8888
else if (direction.equals(Finder.DOWN)) {
8989
ArrayList<String> down = new ArrayList<String>();
90-
for(DataNode dn: Finder.getInstance().getOccurrences(node.getValue(), new Position(node.getStartPosition(),node.getLength()))) {
90+
for(DataNode dn: Finder.getInstance().getOccurrences(node.getPosition())) {
9191
if(dn.getInvocationMethod() != null) {
9292
down.add(dn.getInvocationMethod().getName().getIdentifier());
9393
}
@@ -96,6 +96,11 @@ else if (direction.equals(Finder.DOWN)) {
9696
if( node.getInvocationMethod() != null ) {
9797
Set<IMethod> searchDown = new HashSet<IMethod>();
9898
Set<IMethod> temp = search(node, node.getInvocationMethod(), Finder.DOWN);
99+
for(IMethod i: temp) {
100+
if(down.contains(i.getElementName())) {
101+
searchDown.add(i);
102+
}
103+
}
99104
results = searchDown;
100105
}
101106
}

dataTool/src/dataTool/DataNode.java

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import org.eclipse.jdt.core.dom.SimpleName;
77
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
88
import org.eclipse.jdt.core.dom.VariableDeclaration;
9+
import org.eclipse.jface.text.Position;
10+
11+
import jdk.internal.org.objectweb.asm.tree.analysis.Value;
912

1013
/**
1114
* DataNode class that creates objects for the data we find and want to highlight.
@@ -22,71 +25,44 @@ public class DataNode implements Comparable {
2225
final public static String FOR_VAR = "variableFor";
2326
final public static String VAR = "variable";
2427

25-
private String binding;
2628
private String key;
27-
private String value;
28-
private int index;
29+
private String name;
30+
private int startPosition;
2931
private int length;
3032
private int parameterIndex;
3133
private SimpleName sn;
3234
private String type;
33-
private String signature;
3435
private Method declarationMethod;
3536
private Method invocationMethod;
36-
private boolean isHighlighted;
37+
private Position position;
3738

38-
// /**
39-
// * Constructor to create DataNodes with just values, mainly for DownFinder
40-
// * @param val= Current variable name
41-
// * @param start= start position of the current variable
42-
// */
43-
// public DataNode (String val, int start, String nodeType, Method call) {
44-
//
45-
//
46-
// value = val;
47-
// index = start;
48-
// length = val.length();
49-
// type = nodeType;
50-
// method = call;
51-
// if( method != null ) {
52-
// signature = method.getSignature() + "." + value;
53-
// } else {
54-
// signature = "null";
55-
// }
56-
// }
57-
5839
public DataNode( SimpleName sn ) {
5940
this.sn = sn;
60-
value = sn.getFullyQualifiedName();
61-
index = sn.getStartPosition();
62-
length = value.length();
63-
isHighlighted = false;
41+
name = sn.getFullyQualifiedName();
42+
startPosition = sn.getStartPosition();
43+
length = name.length();
44+
position = new Position( startPosition, length );
6445
parameterIndex = -1;
6546
this.key = sn.resolveBinding().getKey();
66-
this.binding = sn.resolveBinding().toString();
6747
}
6848
public void setStartPosition( int i ) {
69-
index = i;
49+
startPosition = i;
7050
}
7151

7252
/**
7353
* Gets the value of the data
7454
* @returns variable name
7555
*/
7656
public String getValue() {
77-
return this.value;
78-
}
79-
80-
public String getBinding() {
81-
return binding;
57+
return this.name;
8258
}
8359

8460
/**
8561
* Gets the start position of current data in the source code
8662
* @returns variable start position
8763
*/
8864
public int getStartPosition() {
89-
return this.index;
65+
return this.startPosition;
9066
}
9167

9268
/**
@@ -115,16 +91,13 @@ public Method getInvocationMethod() {
11591
public void setInvocationMethod( Method m ) {
11692
invocationMethod = m;
11793
}
118-
public String getSignature() {
119-
return this.signature;
120-
}
12194
/**
12295
* Checks to see if current node is a parameter, only want to display box when actual
12396
* param is selected
12497
* @returns true if node is a parameter, else false
12598
*/
12699
public boolean isParameterSelected(int pos) {
127-
if(pos < index || pos > index+length) {
100+
if(pos < startPosition || pos > startPosition+length) {
128101
return false;
129102
}
130103
return true;
@@ -137,11 +110,14 @@ public int compareTo(Object o) {
137110
if( o == null || !( o instanceof DataNode ) ) {
138111
return 1;
139112
}
140-
return index - ((DataNode)o).getStartPosition();
113+
return startPosition - ((DataNode)o).getStartPosition();
141114
}
142115
@Override
143116
public String toString() {
144-
return binding;
117+
return key;
118+
}
119+
public Position getPosition() {
120+
return position;
145121
}
146122

147-
}
123+
}

0 commit comments

Comments
 (0)