@@ -53,7 +53,7 @@ public void actionPerformed(ActionEvent e)
5353 // Open the class that is associated with the field's owner.
5454 if (!field .owner .equals (container .getName ()))
5555 {
56- open (textArea , false , true , false );
56+ find (textArea , false , true , false );
5757 return ;
5858 }
5959
@@ -136,7 +136,7 @@ public void actionPerformed(ActionEvent e)
136136 }
137137 });
138138
139- open (textArea , false , false , true );
139+ find (textArea , false , false , true );
140140 }
141141 }
142142 }));
@@ -166,7 +166,7 @@ public void actionPerformed(ActionEvent e)
166166 });
167167
168168 // Should not really do anything when the class is already open
169- open (textArea , true , false , false );
169+ find (textArea , true , false , false );
170170 }
171171 }
172172 }));
@@ -184,7 +184,9 @@ private ClassFileContainer openClass(String lexeme, boolean field, boolean metho
184184
185185 if (field )
186186 {
187+ ClassFieldLocation fieldLocation = container .getFieldLocationsFor (lexeme ).get (0 );
187188 String className = container .getClassForField (lexeme );
189+ ClassReferenceLocation referenceLocation = container .getClassReferenceLocationsFor (fieldLocation .owner ).get (0 );
188190
189191 // If the field we want to go to wasn't an expression like Class.field. For example param.field or
190192 // variable.field
@@ -203,7 +205,12 @@ private ClassFileContainer openClass(String lexeme, boolean field, boolean metho
203205 return null ;
204206
205207 if (!packagePath .isEmpty ())
206- className = packagePath + "/" + className ;
208+ className = packagePath + "/" + className .substring (className .lastIndexOf ('/' ) + 1 );
209+ }
210+
211+ if (!fieldLocation .owner .equals (referenceLocation .owner ))
212+ {
213+ className = referenceLocation .packagePath + "/" + referenceLocation .owner ;
207214 }
208215
209216 if (resourceContainer .resourceClasses .containsKey (className ))
@@ -261,6 +268,11 @@ else if (method)
261268 resourceName = packagePath + "/" + lexeme ;
262269 }
263270
271+ if (!classReferenceLocation .owner .equals (container .getName ()))
272+ {
273+ resourceName = packagePath + "/" + classReferenceLocation .owner ;
274+ }
275+
264276 if (resourceContainer .resourceClasses .containsKey (resourceName ))
265277 {
266278 BytecodeViewer .viewer .workPane .addClassResource (resourceContainer , resourceName + ".class" );
@@ -273,7 +285,7 @@ else if (method)
273285 return null ;
274286 }
275287
276- private void open (RSyntaxTextArea textArea , boolean isClass , boolean isField , boolean isMethod )
288+ private void find (RSyntaxTextArea textArea , boolean isClass , boolean isField , boolean isMethod )
277289 {
278290 Thread thread = new Thread (() ->
279291 {
0 commit comments