From 0a80622efae2fd54df3ed991eb856b3718d6820c Mon Sep 17 00:00:00 2001 From: ramidzkh Date: Tue, 13 Sep 2022 03:28:25 +1000 Subject: Nested packages in Swing UI (#458) * WIP nested packages * Fix deobfuscated panel package having obfuscated packages * Remove stream * Mass toggle classes obfuscation status from selector * Fix deobfuscated classes with the same name being hidden from class selectors * Open classes by pressing enter--- .../representation/entry/ClassEntry.java | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'enigma/src') diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java index ec5294e..b0adb2c 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java @@ -11,12 +11,6 @@ package cuchaz.enigma.translation.representation.entry; -import java.util.List; -import java.util.Objects; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import cuchaz.enigma.source.RenamableTokenType; import cuchaz.enigma.translation.TranslateResult; import cuchaz.enigma.translation.Translator; @@ -25,6 +19,11 @@ import cuchaz.enigma.translation.mapping.IdentifierValidation; import cuchaz.enigma.translation.representation.TypeDescriptor; import cuchaz.enigma.utils.validation.ValidationContext; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.List; +import java.util.Objects; + public class ClassEntry extends ParentedEntry implements Comparable { private final String fullName; @@ -141,7 +140,7 @@ public class ClassEntry extends ParentedEntry implements Comparable< } public String getPackageName() { - return getPackageName(fullName); + return getParentPackage(fullName); } /** @@ -187,7 +186,7 @@ public class ClassEntry extends ParentedEntry implements Comparable< return packageName != null && (packageName.startsWith("java/") || packageName.startsWith("javax/")); } - public static String getPackageName(String name) { + public static String getParentPackage(String name) { int pos = name.lastIndexOf('/'); if (pos > 0) { return name.substring(0, pos); @@ -195,6 +194,20 @@ public class ClassEntry extends ParentedEntry implements Comparable< return null; } + public static String getNameInPackage(String name) { + int pos = name.lastIndexOf('/'); + + if (pos == name.length() - 1) { + return "(empty)"; + } + + if (pos > 0) { + return name.substring(pos + 1); + } + + return name; + } + @Nullable public static ClassEntry getOuterClass(String name) { if (name.charAt(0) == '[') { -- cgit v1.2.3