Skip to content

Commit

Permalink
Update GoToAction
Browse files Browse the repository at this point in the history
  • Loading branch information
Bl3nd committed Oct 13, 2024
1 parent 789ceda commit 164843a
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -136,7 +136,7 @@ public void actionPerformed(ActionEvent e)
}
});

open(textArea, false, false, true);
find(textArea, false, false, true);
}
}
}));
Expand Down Expand Up @@ -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);
}
}
}));
Expand All @@ -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
Expand All @@ -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))
Expand Down Expand Up @@ -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");
Expand All @@ -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(() ->
{
Expand Down

0 comments on commit 164843a

Please sign in to comment.