Skip to content

Commit de0628f

Browse files
author
Chris
committed
Fixed plugin.xml to hopefully work for Justin and other updates.
1 parent 7d5819b commit de0628f

10 files changed

Lines changed: 24 additions & 97 deletions

dataTool/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
icon="icons/data.gif"
1818
id="dataTool.action1"
1919
label="Find EOS"
20-
style="menu"
20+
style="toggle"
2121
toolbarPath="TempGroup"
2222
tooltip="Highlights flow of data within your code"/>
2323
</actionSet>

dataTool/src/dataTool/DataCallHierarchy.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,16 @@ public void setGoTo(int offset) {
6262
goToOffset = offset;
6363
}
6464

65+
/**
66+
* Returns all instances of method
67+
* @param m: IMethod to search for
68+
* @returns Set of IMethods for m
69+
*/
6570
public HashSet<IMethod> getCalls(IMethod m) {
66-
Finder f = Finder.getInstance();
67-
if(f instanceof UpFinder) {
68-
return getCallersOf(m);
69-
}
70-
else if(f instanceof DownFinder) {
71-
return getCalleesOf(m);
72-
}
73-
return null;
71+
HashSet<IMethod> methods = new HashSet<IMethod>();
72+
methods.addAll(getCallersOf(m));
73+
methods.addAll(getCalleesOf(m));
74+
return methods;
7475
}
7576

7677
public HashSet<IMethod> getCalleesOf(IMethod m) {

dataTool/src/dataTool/DataNode.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ public String getMethod() {
112112
* @returns true if node is a parameter, else false
113113
*/
114114
public boolean isParameter(int pos) {
115-
Finder f = Finder.getInstance();
116115
if(pos < index || pos > index+length) {
117116
return false;
118117
}

dataTool/src/dataTool/DownFinder.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ public boolean variableCheck(String var, int index, String sourceCode) {
111111
if(sourceCode.substring(index+var.length(),index+var.length()+1).matches("[a-zA-Z0-9]") || sourceCode.substring(index-1,index).matches("[a-zA-Z0-9]")) {
112112
return false;
113113
}
114-
if(isUp(var,index)) {
115-
return false;
116-
}
117114
if(isComment(var, index, sourceCode)) {
118115
return false;
119116
}
@@ -137,21 +134,4 @@ private boolean isComment(String var, int index, String sourceCode) {
137134
}
138135
return false;
139136
}
140-
141-
/**
142-
* Function that checks to see if the variable is not a declaration/initialization
143-
* @param var: String variable name
144-
* @param start: int start position
145-
* @returns true if variable is not "up", else false
146-
*/
147-
public boolean isUp(String var, int start) {
148-
UpFinder up = UpFinder.getInstance();
149-
ArrayList<DataNode> varList = up.getUpOccurrences(var);
150-
for(DataNode node: varList) {
151-
if(node.getStartPosition() <= start && node.getStartPosition()+node.getLength()+1 >= start) {
152-
return true;
153-
}
154-
}
155-
return false;
156-
}
157137
}

dataTool/src/dataTool/Finder.java

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public class Finder {
1616
final public static String UP = "up";
1717
final public static String DOWN = "down";
1818

19-
private static String findDirection = UP; //default direction is up
2019
private static Finder currentFinder;
2120
private static Color currentColor;
2221
private String goToName = null;
@@ -27,7 +26,6 @@ public Finder () {
2726
}
2827

2928
public void setGoToIndex(int offset) {
30-
System.out.println(offset + " off");
3129
goToOffset = offset;
3230
}
3331

@@ -49,44 +47,16 @@ public String getGoToFunc() {
4947
return null;
5048
}
5149

52-
public ArrayList<DataNode> getOccurrences(String data) {
53-
if(findDirection.equals(UP)) {
54-
UpFinder finder = UpFinder.getInstance();
55-
return finder.getUpOccurrences(data);
56-
}
57-
else if(findDirection.equals(DOWN)) {
58-
DownFinder finder = DownFinder.getInstance();
59-
return finder.getDownOccurrences(data);
60-
}
61-
return null;
62-
}
63-
64-
/**
65-
* Controls which flow the tool will navigate to show data flow
66-
* @param s: Direction for flow display, required to be UP or DOWN
67-
*/
68-
/*public void setFlowDirection(String s) {
69-
if(s.equals(UP)) {
70-
findDirection = s;
71-
currentFinder = UpFinder.getInstance();
72-
SuggestedSelectionAnnotation.color = new Color(null, 0, 0, 255);
73-
}
74-
else if(s.equals(DOWN)) {
75-
findDirection = s;
76-
currentFinder = DownFinder.getInstance();
77-
SuggestedSelectionAnnotation.color = new Color(null, 255, 0, 0);
78-
}
79-
else {
80-
//something went very wrong...
81-
findDirection = null;
82-
}
83-
}*/
84-
8550
/**
86-
* Function to return the current direction of the flow navigation.
51+
* Returns the occurrences of the selected string in the class
52+
* @param data: current String value
53+
* @returns ArrayList of DataNodes for string
8754
*/
88-
public String getFlowDirection() {
89-
return findDirection;
55+
public ArrayList<DataNode> getOccurrences(String data) {
56+
ArrayList<DataNode> occurrences = new ArrayList<DataNode>();
57+
occurrences.addAll(UpFinder.getInstance().getUpOccurrences(data));
58+
occurrences.addAll(DownFinder.getInstance().getDownOccurrences(data));
59+
return occurrences;
9060
}
9161

9262
/**
@@ -95,20 +65,6 @@ public String getFlowDirection() {
9565
* @returns true if current variable is a DataNode, else false
9666
*/
9767
public boolean contains(String str) {
98-
return currentFinder.contains(str);
99-
}
100-
101-
/**
102-
* Function to get the finder instance
103-
* @returns the current finder instance searching in the appropriate direction.
104-
*/
105-
public static Finder getInstance() {
106-
if(findDirection.equals(UP)) {
107-
return UpFinder.getInstance();
108-
}
109-
else if(findDirection.equals(DOWN)){
110-
return DownFinder.getInstance();
111-
}
112-
return null;
68+
return (UpFinder.getInstance().contains(str) || DownFinder.getInstance().contains(str));
11369
}
11470
}

dataTool/src/dataTool/Visitor.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ public static void parseData() {
115115
char[] code = source.toCharArray();
116116
upFinder = UpFinder.getInstance();
117117
downFinder = DownFinder.getInstance();
118-
Finder finder = Finder.getInstance();
119118
ASTParser parser = ASTParser.newParser(AST.JLS3);
120119
parser.setSource(code);
121120
parser.setKind(ASTParser.K_COMPILATION_UNIT);
@@ -135,9 +134,6 @@ public boolean visit(VariableDeclarationFragment vdf) {
135134
public boolean visit(MethodDeclaration md) {
136135
if (!seenMethod.contains(md.getName())) {
137136
seenMethod.add(md.getName());
138-
if(md.getName().getIdentifier().equals(finder.getGoToFunc())) {
139-
finder.setGoToIndex(md.getStartPosition());
140-
}
141137
String param = "";
142138
String[] array = new String[md.parameters().size()];
143139
int i = 0;
@@ -213,9 +209,6 @@ public boolean visit(TryStatement ts) {
213209

214210
public boolean visit(MethodInvocation mi) {
215211
List<ASTNode> args = mi.arguments();
216-
if(finder.getFlowDirection().equals(Finder.UP) && mi.getName().getIdentifier().equals(finder.getGoToFunc())) {
217-
finder.setGoToIndex(mi.getStartPosition());
218-
}
219212
for(ASTNode arg: args) {
220213
if(data.contains(arg.toString())) {
221214
downFinder.add(arg.toString(), arg.getStartPosition(), DataNode.PARAM_DOWN, mi.getName().getIdentifier());
@@ -237,6 +230,7 @@ public boolean visit(MethodInvocation mi) {
237230
public HashSet<String> getData() {
238231
return data;
239232
}
233+
240234
/**
241235
* Adds the current node to list of nodes to be highlighted
242236
* @param node

dataTool/src/dataTool/annotations/ProgramNavigationPainter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ public void paintControl(PaintEvent e) {
207207
Position p;
208208
String word;
209209
OccurrenceLocation[] locations = null;
210-
Finder finder = Finder.getInstance();
211210
DataCallHierarchy call = new DataCallHierarchy();
211+
Finder finder = new Finder();
212212
HashMap<String, ArrayList<DataLink>> map = new HashMap<String, ArrayList<DataLink>>();
213213
for(Map.Entry<ISelfDrawingAnnotation,Position> entry : anns.entrySet()){
214214
ann = entry.getKey();
@@ -228,7 +228,6 @@ public void paintControl(PaintEvent e) {
228228
for (DataNode node: finder.getOccurrences(word)) {
229229
if(node.isParameter(r.getOffset())) {
230230
//Only display pop-up if selected text is a parameter
231-
finder.setGoToFunc(word);
232231
try {
233232
map = call.searchProject(node.getMethod());
234233
if(!map.isEmpty()) {

dataTool/src/dataTool/ui/NavigationBox.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ public void setText(HashMap<String, ArrayList<DataLink>> map) {
4949
NavigationDownBox down = NavigationDownBox.getInstance(null, -1);
5050
up.setText(map.get(Finder.UP));
5151
down.setText(map.get(Finder.DOWN));
52-
52+
System.out.println(map.get(Finder.DOWN));
5353
}
5454
}

dataTool/src/dataTool/ui/NavigationDownBox.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ public void handleEvent(Event arg0) {
8282
}
8383

8484
public void setText(ArrayList<DataLink> text) {
85-
Finder finder = Finder.getInstance();
8685
Composite composite = new Composite(shell, SWT.NULL);
8786
composite.setLayout(new RowLayout());
8887
if(text != null) {
@@ -93,7 +92,7 @@ public void setText(ArrayList<DataLink> text) {
9392

9493
@Override
9594
public void handleEvent(Event arg0) {
96-
l.open(finder.getGoToIndex());
95+
l.open(10);
9796
}
9897
});
9998
}

dataTool/src/dataTool/ui/NavigationUpBox.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ public void handleEvent(Event arg0) {
8989
}
9090

9191
public void setText(ArrayList<DataLink> text) {
92-
Finder finder = Finder.getInstance();
9392
Composite composite = new Composite(shell, SWT.NULL);
9493
composite.setLayout(new RowLayout());
9594
if(text != null) {
@@ -102,7 +101,7 @@ public void setText(ArrayList<DataLink> text) {
102101
link.addListener(SWT.Selection, new Listener() {
103102
@Override
104103
public void handleEvent(Event arg0) {
105-
l.open(finder.getGoToIndex());
104+
l.open(10);
106105
}
107106
});
108107
Label blank = new Label(composite, SWT.NULL);

0 commit comments

Comments
 (0)