@@ -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 ) {
0 commit comments