@@ -97,62 +97,30 @@ public void mouseUp(MouseEvent arg0) {
9797 if (searchResultsUp != null ) {
9898 search .addAll (searchResultsUp );
9999 }
100- /*load = false;
101- Object[] search;
102- IMethod im;
103- if(linkNode.getInvocationMethod() != null) {
104- search = searchResultsDown.toArray();
105- for(Object o: search) {
106- im = (IMethod) o;
107- if(im.getElementName().equals(linkNode.getInvocationMethod().getName().getIdentifier())) {
108- try {
109- if(im.getParameters().length > 0)
110- JavaUI.openInEditor(im.getParameters()[linkNode.getParameterIndex()], true, true);
111- else {
112- JavaUI.openInEditor(im, true, true);
113- }
114- load = true;
115- } catch (PartInitException | JavaModelException e) {
116- // Auto-generated catch block
117- e.printStackTrace();
118- }
119- }
120- }
121- }
122- else if(linkNode.getDeclarationMethod() != null) {
123- try {
124- search = searchResultsUp.toArray();
125- im = (IMethod)search[0];
126- searchMethod = linkNode.getDeclarationMethod().getName().getIdentifier();
127- if(im.getParameters().length > 0) {
128- JavaUI.openInEditor(im.getParameters()[linkNode.getParameterIndex()], true, true);
129- load = true;
130- }
131- else {
132- editor = JavaUI.openInEditor(im, true, true);
133- if(editor != null) {
134- String code = JDTUtils.getCUSource((AbstractTextEditor) editor);
135- lineSearch(code.toCharArray(), im);
136- goToLine(editor);
137- }
138- load = true;
139- }
140- } catch (Exception e) {
141- // Auto-generated catch block
142- e.printStackTrace();
143- }
144- }*/
100+
145101 IMethod i = null ;
146- if (linkNode .getInvocationMethod () != null && linkNode .getDeclarationMethod () == null ) {
102+ if (linkNode .getInvocationMethod () == null ) {
103+ up = false ;
104+ }
105+ else if (linkNode .getDeclarationMethod () == null ) {
106+ up = true ;
107+ }
108+ else if (click - linkNode .getDeclarationMethod ().getName ().getStartPosition () >
109+ click - linkNode .getInvocationMethod ().getName ().getStartPosition ()) {
110+ up = false ;
111+ }
112+ else {
113+ up = true ;
114+ }
115+ if (linkNode .getInvocationMethod () != null && !up ) {
147116 for (IMethod im : search ) {
148117 if (im .getElementName ().equals (linkNode .getInvocationMethod ().getName ().getIdentifier ())) {
149118 i = im ;
150119 break ;
151120 }
152121 }
153-
154122 }
155- if (i == null || linkNode .getDeclarationMethod () != null ) {
123+ else if (linkNode .getDeclarationMethod () != null ) {
156124 if (searchResultsUp != null ) {
157125 i = (IMethod ) searchResultsUp .toArray ()[0 ];
158126 searchMethod = linkNode .getDeclarationMethod ().getName ().getIdentifier ();
@@ -162,30 +130,31 @@ else if (i == null){
162130 return ;
163131 }
164132 }
165- IEditorPart editor = null ;
166- try {
167- if (i .getParameters ().length > 0 && linkNode .getParameterIndex () >= 0 && !up ) {
168- editor = JavaUI .openInEditor (i .getParameters ()[linkNode .getParameterIndex ()], true , true );
169- load = true ;
170- }
171- else {
172- editor = JavaUI .openInEditor (i , true , true );
173- load = true ;
174- if (searchMethod != null && editor != null ) {
175- String code = ((AbstractTextEditor )editor ).getDocumentProvider ().getDocument (editor .getEditorInput ()).get ();
176- lineSearch (code .toCharArray (), i );
177- goToLine ( editor ) ;
178- }
133+ IEditorPart editor = null ;
134+ try {
135+ if (i .getParameters ().length > 0 && linkNode .getParameterIndex () >= 0 && !up ) {
136+ editor = JavaUI .openInEditor (i .getParameters ()[linkNode .getParameterIndex ()], true , true );
137+ load = true ;
138+ }
139+ else {
140+ editor = JavaUI .openInEditor (i , true , true );
141+ load = true ;
142+ if (searchMethod != null && editor != null ) {
143+ String code = ((AbstractTextEditor )editor ).getDocumentProvider ().getDocument (editor .getEditorInput ()).get ();
144+ lineSearch (code .toCharArray (), i );
145+ ASTNode temp = searchResult ;
146+ goToLine ( editor );
179147 }
180- } catch (JavaModelException e ) {
181- // Auto-generated catch block
182- e .printStackTrace ();
183- } catch (PartInitException e ) {
184- // TODO Auto-generated catch block
185- e .printStackTrace ();
186148 }
149+ } catch (JavaModelException e ) {
150+ // Auto-generated catch block
151+ e .printStackTrace ();
152+ } catch (PartInitException e ) {
153+ // TODO Auto-generated catch block
154+ e .printStackTrace ();
187155 }
188156 }
157+ }
189158 });
190159 }
191160
@@ -201,7 +170,7 @@ public boolean visit(MethodDeclaration md) {
201170 public boolean visit (MethodInvocation m ) {
202171 if (method .getElementName ().equals (methodName )) {
203172 if (m .getName ().getIdentifier ().equals (searchMethod )) {
204- searchResult = (SimpleName ) m .arguments ().get (linkNode .getParameterIndex ());
173+ searchResult = (ASTNode ) m .arguments ().get (linkNode .getParameterIndex ());
205174 }
206175 }
207176 return true ;
0 commit comments