diff options
| author | 2021-04-07 12:01:04 +0200 | |
|---|---|---|
| committer | 2021-04-07 12:01:04 +0200 | |
| commit | acd8b326dbde3912e3a102b514bf451350452c7e (patch) | |
| tree | 3909ed3cee244e380ece4f655ca7404b0e713f3d | |
| parent | Bump version (diff) | |
| download | enigma-acd8b326dbde3912e3a102b514bf451350452c7e.tar.gz enigma-acd8b326dbde3912e3a102b514bf451350452c7e.tar.xz enigma-acd8b326dbde3912e3a102b514bf451350452c7e.zip | |
Reorganize entry names
3 files changed, 95 insertions, 10 deletions
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 47319e0d..fe56611b 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 | |||
| @@ -59,8 +59,26 @@ public class ClassEntry extends ParentedEntry<ClassEntry> implements Comparable< | |||
| 59 | return this.name; | 59 | return this.name; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | @Override | ||
| 63 | public String getSimpleName() { | ||
| 64 | int packagePos = name.lastIndexOf('/'); | ||
| 65 | if (packagePos > 0) { | ||
| 66 | return name.substring(packagePos + 1); | ||
| 67 | } | ||
| 68 | return name; | ||
| 69 | } | ||
| 70 | |||
| 71 | @Override | ||
| 62 | public String getFullName() { | 72 | public String getFullName() { |
| 63 | return fullName; | 73 | return this.fullName; |
| 74 | } | ||
| 75 | |||
| 76 | @Override | ||
| 77 | public String getContextualName() { | ||
| 78 | if (this.isInnerClass()) { | ||
| 79 | return this.parent.getSimpleName() + "$" + this.name; | ||
| 80 | } | ||
| 81 | return this.getSimpleName(); | ||
| 64 | } | 82 | } |
| 65 | 83 | ||
| 66 | @Override | 84 | @Override |
| @@ -126,14 +144,6 @@ public class ClassEntry extends ParentedEntry<ClassEntry> implements Comparable< | |||
| 126 | return getPackageName(fullName); | 144 | return getPackageName(fullName); |
| 127 | } | 145 | } |
| 128 | 146 | ||
| 129 | public String getSimpleName() { | ||
| 130 | int packagePos = name.lastIndexOf('/'); | ||
| 131 | if (packagePos > 0) { | ||
| 132 | return name.substring(packagePos + 1); | ||
| 133 | } | ||
| 134 | return name; | ||
| 135 | } | ||
| 136 | |||
| 137 | /** | 147 | /** |
| 138 | * Returns whether this class entry has a parent, and therefore is an inner class. | 148 | * Returns whether this class entry has a parent, and therefore is an inner class. |
| 139 | */ | 149 | */ |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/Entry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/Entry.java index 6fd412a0..8a81c54a 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/Entry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/Entry.java | |||
| @@ -21,8 +21,68 @@ import cuchaz.enigma.translation.mapping.IdentifierValidation; | |||
| 21 | import cuchaz.enigma.utils.validation.ValidationContext; | 21 | import cuchaz.enigma.utils.validation.ValidationContext; |
| 22 | 22 | ||
| 23 | public interface Entry<P extends Entry<?>> extends Translatable { | 23 | public interface Entry<P extends Entry<?>> extends Translatable { |
| 24 | /** | ||
| 25 | * Returns the default name of this entry. | ||
| 26 | * | ||
| 27 | * <p>For methods, fields and inner classes, it's the same as {@link #getSimpleName()}.</p> | ||
| 28 | * <p>For other classes, it's the same as {@link #getFullName()}.</p> | ||
| 29 | * | ||
| 30 | * <br><p>Examples:</p> | ||
| 31 | * <ul> | ||
| 32 | * <li>Outer class: "domain.name.ClassA"</li> | ||
| 33 | * <li>Inner class: "ClassB"</li> | ||
| 34 | * <li>Method: "methodC"</li> | ||
| 35 | * </ul> | ||
| 36 | */ | ||
| 24 | String getName(); | 37 | String getName(); |
| 25 | 38 | ||
| 39 | /** | ||
| 40 | * Returns the simple name of this entry. | ||
| 41 | * | ||
| 42 | * <p>For methods, fields and inner classes, it's the same as {@link #getName()}.</p> | ||
| 43 | * <p>For other classes, it's their name without the package name.</p> | ||
| 44 | * | ||
| 45 | * <br><p>Examples:</p> | ||
| 46 | * <ul> | ||
| 47 | * <li>Outer class: "ClassA"</li> | ||
| 48 | * <li>Inner class: "ClassB"</li> | ||
| 49 | * <li>Method: "methodC"</li> | ||
| 50 | * </ul> | ||
| 51 | */ | ||
| 52 | String getSimpleName(); | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Returns the full name of this entry. | ||
| 56 | * | ||
| 57 | * <p>For methods, fields and inner classes, it's their name prefixed with the full name | ||
| 58 | * of their parent entry.</p> | ||
| 59 | * <p>For other classes, it's their name prefixed with their package name.</p> | ||
| 60 | * | ||
| 61 | * <br><p>Examples:</p> | ||
| 62 | * <ul> | ||
| 63 | * <li>Outer class: "domain.name.ClassA"</li> | ||
| 64 | * <li>Inner class: "domain.name.ClassA$ClassB"</li> | ||
| 65 | * <li>Method: "domain.name.ClassA.methodC"</li> | ||
| 66 | * </ul> | ||
| 67 | */ | ||
| 68 | String getFullName(); | ||
| 69 | |||
| 70 | /** | ||
| 71 | * Returns the contextual name of this entry. | ||
| 72 | * | ||
| 73 | * <p>For methods, fields and inner classes, it's their name prefixed with the contextual | ||
| 74 | * name of their parent entry.</p> | ||
| 75 | * <p>For other classes, it's only their simple name.</p> | ||
| 76 | * | ||
| 77 | * <br><p>Examples:</p> | ||
| 78 | * <ul> | ||
| 79 | * <li>Outer class: "ClassA"</li> | ||
| 80 | * <li>Inner class: "ClassA$ClassB"</li> | ||
| 81 | * <li>Method: "ClassA.methodC"</li> | ||
| 82 | * </ul> | ||
| 83 | */ | ||
| 84 | String getContextualName(); | ||
| 85 | |||
| 26 | String getJavadocs(); | 86 | String getJavadocs(); |
| 27 | 87 | ||
| 28 | default String getSourceRemapName() { | 88 | default String getSourceRemapName() { |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ParentedEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ParentedEntry.java index b12f9d01..56348915 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ParentedEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ParentedEntry.java | |||
| @@ -45,7 +45,22 @@ public abstract class ParentedEntry<P extends Entry<?>> implements Entry<P> { | |||
| 45 | 45 | ||
| 46 | @Override | 46 | @Override |
| 47 | public String getName() { | 47 | public String getName() { |
| 48 | return name; | 48 | return this.name; |
| 49 | } | ||
| 50 | |||
| 51 | @Override | ||
| 52 | public String getSimpleName() { | ||
| 53 | return this.name; | ||
| 54 | } | ||
| 55 | |||
| 56 | @Override | ||
| 57 | public String getFullName() { | ||
| 58 | return this.parent.getFullName() + "." + this.name; | ||
| 59 | } | ||
| 60 | |||
| 61 | @Override | ||
| 62 | public String getContextualName() { | ||
| 63 | return this.parent.getContextualName() + "." + this.name; | ||
| 49 | } | 64 | } |
| 50 | 65 | ||
| 51 | @Override | 66 | @Override |