2323import org .eclipse .ui .PartInitException ;
2424import org .eclipse .ui .texteditor .AbstractTextEditor ;
2525import org .eclipse .ui .texteditor .ITextEditor ;
26+ import org .eclipse .jdt .core .IJavaElement ;
27+ import org .eclipse .jdt .core .ILocalVariable ;
2628import org .eclipse .jdt .core .IMethod ;
2729import org .eclipse .jdt .core .JavaModelException ;
2830import org .eclipse .jdt .core .dom .AST ;
@@ -51,7 +53,7 @@ public class LinkAnnotation extends Annotation implements ISelfDrawingAnnotation
5153 public static Set <IMethod > searchResultsDown ;
5254 public String searchMethod = "" ;
5355 private IEditorPart editor = null ;
54- private boolean load = true ;
56+ private static boolean load = true ;
5557
5658 public static final String INVALID = "Method not in scope of project." ;
5759
@@ -90,8 +92,14 @@ public void mouseUp(MouseEvent arg0) {
9092 im = (IMethod ) o ;
9193 if (im .getElementName ().equals (linkNode .getInvocationMethod ().getName ().getIdentifier ())) {
9294 try {
93- JavaUI .openInEditor (im , true , true );
94- load = true ;
95+ if (im .getParameters ().length > 0 ) {
96+ editor = JavaUI .openInEditor (im .getParameters ()[linkNode .getParameterIndex ()], true , true );
97+ load = true ;
98+ }
99+ else {
100+ JavaUI .openInEditor (im , true , true );
101+ load = true ;
102+ }
95103 } catch (PartInitException | JavaModelException e ) {
96104 // Auto-generated catch block
97105 e .printStackTrace ();
@@ -104,13 +112,20 @@ else if(linkNode.getDeclarationMethod() != null) {
104112 search = searchResultsUp .toArray ();
105113 im = (IMethod )search [0 ];
106114 searchMethod = linkNode .getDeclarationMethod ().getName ().getIdentifier ();
107- editor = JavaUI .openInEditor (im , true , true );
108- if (editor != null ) {
109- String code = JDTUtils .getCUSource ((AbstractTextEditor ) editor );
110- lineSearch (code .toCharArray (), im );
111- goToLine (editor );
115+ if (im .getParameters ().length > 0 ) {
116+ editor = JavaUI .openInEditor (im .getParameters ()[linkNode .getParameterIndex ()], true , true );
112117 load = true ;
113118 }
119+ else {
120+ editor = JavaUI .openInEditor (im , true , true );
121+ if (editor != null ) {
122+ String code = JDTUtils .getCUSource ((AbstractTextEditor ) editor );
123+ lineSearch (code .toCharArray (), im );
124+ goToLine (editor );
125+ load = true ;
126+ }
127+ }
128+
114129 } catch (Exception e ) {
115130 // Auto-generated catch block
116131 e .printStackTrace ();
@@ -138,12 +153,13 @@ public boolean visit(MethodInvocation m) {
138153 }
139154 return true ;
140155 }
141- public boolean visit (ClassInstanceCreation c ) {
156+ //TODO if we need it
157+ /*public boolean visit(ClassInstanceCreation c) {
142158 if(c.getType().toString().equals(searchMethod)) {
143159 searchResult = c;
144160 }
145161 return true;
146- }
162+ }*/
147163 });
148164 return true ;
149165 }
@@ -163,6 +179,7 @@ private static void goToLine(IEditorPart editorPart) {
163179 ITextEditor editor = (ITextEditor ) editorPart ;
164180 IDocument document = editor .getDocumentProvider ().getDocument (editor .getEditorInput ());
165181 if (document != null && searchResult != null ) {
182+ //searchResult.
166183 editor .selectAndReveal (searchResult .getStartPosition (), searchResult .getLength ());
167184 }
168185 }
0 commit comments