Skip to content

Commit b96aee8

Browse files
author
Chris
committed
Fixed issue #30- whenever a variable is clicked all declared and invoked methods using the data are displayed as linked.
1 parent 41f476f commit b96aee8

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

dataTool/src/dataTool/AnnotationManager.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,14 @@ public void selectionChanged(ITextSelection selection) {
9696
DataCallHierarchy call = new DataCallHierarchy();
9797
Set<IMethod> searchUp = null;
9898
Set<IMethod> searchDown = null;
99-
if((finder.upSearch(one) != null || finder.downSearch(one) != null || one.getInvocationMethod() != null) && currentSearch != null) {
99+
if((finder.upSearch(one) != null || finder.downSearch(one) != null ||
100+
one.getInvocationMethod() != null || one.getDeclarationMethod() != null) && currentSearch != null) {
100101
searchUp = call.searchProject(one, Finder.UP);
101102
searchDown = call.searchProject(one, Finder.DOWN);
102-
if(one.isParameterSelected(selection.getOffset())) {
103-
linkAnnotation.searchResultsDown = searchDown;
104-
linkAnnotation.searchResultsUp = searchUp;
105-
linkAnnotation.setDataNode(one);
106-
addLinkAnnotation(one);
107-
}
103+
linkAnnotation.searchResultsDown = searchDown;
104+
linkAnnotation.searchResultsUp = searchUp;
105+
linkAnnotation.setDataNode(one);
106+
addLinkAnnotation(one);
108107
}
109108

110109
//Adds all occurrences of data node off screen

dataTool/src/dataTool/annotations/LinkAnnotation.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ public static StyleRange removeAnnotation(StyleRange old) {
197197
return clear;
198198
}
199199

200+
/**
201+
* Sets the data node to be the current selected text
202+
* @param node: Current DataNode selected by user
203+
*/
200204
public void setDataNode(DataNode node) {
201205
linkNode = node;
202206
}

dataTool/src/dataTool/annotations/ProgramNavigationPainter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public class ProgramNavigationPainter extends AnnotationPainter {
6262
private Map<ISelfDrawingAnnotation, Position> anns = new HashMap<ISelfDrawingAnnotation, Position>();
6363
private boolean isActive = false;
6464
private boolean painted = false;
65+
private LinkAnnotation linkAnnotation = new LinkAnnotation();
6566

6667

6768
public ProgramNavigationPainter(SourceViewer v) {
@@ -228,6 +229,14 @@ public void paintControl(PaintEvent e) {
228229
// Highlight all instances in class
229230
for (DataNode node : finder.getOccurrences(word, p)) {
230231
ann.draw(e.gc, viewer.getTextWidget(), node.getStartPosition(), node.getLength());
232+
if(node.getInvocationMethod() != null) {
233+
linkAnnotation.draw(e.gc, viewer.getTextWidget(),
234+
node.getInvocationMethod().getName().getStartPosition(), node.getInvocationMethod().getName().getLength());
235+
}
236+
if(node.getDeclarationMethod() != null) {
237+
linkAnnotation.draw(e.gc, viewer.getTextWidget(),
238+
node.getDeclarationMethod().getName().getStartPosition(), node.getDeclarationMethod().getName().getLength());
239+
}
231240
}
232241
}
233242
}

0 commit comments

Comments
 (0)