3535import org .eclipse .jdt .core .dom .CompilationUnit ;
3636import org .eclipse .jdt .core .dom .MethodDeclaration ;
3737import org .eclipse .jdt .core .dom .MethodInvocation ;
38+ import org .eclipse .jdt .core .dom .SimpleName ;
3839import org .eclipse .jdt .ui .JavaUI ;
3940
4041import dataTool .DataCallHierarchy ;
@@ -51,7 +52,7 @@ public class LinkAnnotation extends Annotation implements ISelfDrawingAnnotation
5152 private static ASTNode searchResult ;
5253 public static Set <IMethod > searchResultsUp ;
5354 public static Set <IMethod > searchResultsDown ;
54- public IMethod searchMethod = null ;
55+ public String searchMethod = null ;
5556 private IEditorPart editor = null ;
5657 private boolean load = true ;
5758
@@ -84,6 +85,8 @@ public void mouseDown(MouseEvent arg0) {
8485 public void mouseUp (MouseEvent arg0 ) {
8586 int click = textWidget .getOffsetAtLocation (new Point (arg0 .x ,arg0 .y ));
8687 if (click >= style .start && click <= style .start +style .length && load ){
88+ load = false ;
89+ boolean up = false ;
8790 if (linkNode == null ) {
8891 return ;
8992 }
@@ -140,30 +143,34 @@ else if(linkNode.getDeclarationMethod() != null) {
140143 }
141144 }*/
142145 IMethod i = null ;
143- for ( IMethod im : search ) {
144- if ( linkNode . getInvocationMethod () != null ) {
146+ if ( linkNode . getInvocationMethod () != null && linkNode . getDeclarationMethod () == null ) {
147+ for ( IMethod im : search ) {
145148 if (im .getElementName ().equals (linkNode .getInvocationMethod ().getName ().getIdentifier ())) {
146149 i = im ;
147150 break ;
148151 }
149152 }
150153
151154 }
152- if (i == null ) {
153- if (linkNode .getDeclarationMethod () != null && searchResultsUp != null ) {
154- i = search .get (0 );
155+ if (i == null || linkNode .getDeclarationMethod () != null ) {
156+ if (searchResultsUp != null ) {
157+ i = (IMethod ) searchResultsUp .toArray ()[0 ];
158+ searchMethod = linkNode .getDeclarationMethod ().getName ().getIdentifier ();
159+ up = true ;
155160 }
156- else {
161+ else if ( i == null ) {
157162 return ;
158163 }
159164 }
160165 IEditorPart editor = null ;
161166 try {
162- if (i .getParameters ().length > 0 && linkNode .getParameterIndex () >= 0 ) {
167+ if (i .getParameters ().length > 0 && linkNode .getParameterIndex () >= 0 && ! up ) {
163168 editor = JavaUI .openInEditor (i .getParameters ()[linkNode .getParameterIndex ()], true , true );
169+ load = true ;
164170 }
165171 else {
166172 editor = JavaUI .openInEditor (i , true , true );
173+ load = true ;
167174 if (searchMethod != null && editor != null ) {
168175 String code = ((AbstractTextEditor )editor ).getDocumentProvider ().getDocument (editor .getEditorInput ()).get ();
169176 lineSearch (code .toCharArray (), i );
@@ -194,7 +201,7 @@ public boolean visit(MethodDeclaration md) {
194201 public boolean visit (MethodInvocation m ) {
195202 if (method .getElementName ().equals (methodName )) {
196203 if (m .getName ().getIdentifier ().equals (searchMethod )) {
197- searchResult = m ;
204+ searchResult = ( SimpleName ) m . arguments (). get ( linkNode . getParameterIndex ()) ;
198205 }
199206 }
200207 return true ;
@@ -246,7 +253,7 @@ public void setDataNode(DataNode node) {
246253 }
247254
248255 public void setSearchMethod (IMethod currentMethod ) {
249- searchMethod = currentMethod ;
256+ searchMethod = currentMethod . getElementName () ;
250257 }
251258
252259}
0 commit comments