From 164843a824988600e8dd042875685d5a441c825c Mon Sep 17 00:00:00 2001 From: Cody <6558800+Bl3nd@users.noreply.github.com> Date: Sat, 12 Oct 2024 23:48:45 -0600 Subject: [PATCH] Update GoToAction --- .../gui/components/actions/GoToAction.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/actions/GoToAction.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/actions/GoToAction.java index 74bb16f7a..ff728c7ea 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/actions/GoToAction.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/actions/GoToAction.java @@ -53,7 +53,7 @@ public void actionPerformed(ActionEvent e) // Open the class that is associated with the field's owner. if (!field.owner.equals(container.getName())) { - open(textArea, false, true, false); + find(textArea, false, true, false); return; } @@ -136,7 +136,7 @@ public void actionPerformed(ActionEvent e) } }); - open(textArea, false, false, true); + find(textArea, false, false, true); } } })); @@ -166,7 +166,7 @@ public void actionPerformed(ActionEvent e) }); // Should not really do anything when the class is already open - open(textArea, true, false, false); + find(textArea, true, false, false); } } })); @@ -184,7 +184,9 @@ private ClassFileContainer openClass(String lexeme, boolean field, boolean metho if (field) { + ClassFieldLocation fieldLocation = container.getFieldLocationsFor(lexeme).get(0); String className = container.getClassForField(lexeme); + ClassReferenceLocation referenceLocation = container.getClassReferenceLocationsFor(fieldLocation.owner).get(0); // If the field we want to go to wasn't an expression like Class.field. For example param.field or // variable.field @@ -203,7 +205,12 @@ private ClassFileContainer openClass(String lexeme, boolean field, boolean metho return null; if (!packagePath.isEmpty()) - className = packagePath + "/" + className; + className = packagePath + "/" + className.substring(className.lastIndexOf('/') + 1); + } + + if (!fieldLocation.owner.equals(referenceLocation.owner)) + { + className = referenceLocation.packagePath + "/" + referenceLocation.owner; } if (resourceContainer.resourceClasses.containsKey(className)) @@ -261,6 +268,11 @@ else if (method) resourceName = packagePath + "/" + lexeme; } + if (!classReferenceLocation.owner.equals(container.getName())) + { + resourceName = packagePath + "/" + classReferenceLocation.owner; + } + if (resourceContainer.resourceClasses.containsKey(resourceName)) { BytecodeViewer.viewer.workPane.addClassResource(resourceContainer, resourceName + ".class"); @@ -273,7 +285,7 @@ else if (method) return null; } - private void open(RSyntaxTextArea textArea, boolean isClass, boolean isField, boolean isMethod) + private void find(RSyntaxTextArea textArea, boolean isClass, boolean isField, boolean isMethod) { Thread thread = new Thread(() -> {