diff options
Diffstat (limited to 'enigma/src/main/java')
7 files changed, 100 insertions, 19 deletions
diff --git a/enigma/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java b/enigma/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java index b09f7ac..4633ace 100644 --- a/enigma/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java +++ b/enigma/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java | |||
| @@ -60,9 +60,7 @@ public class MethodImplementationsTreeNode extends DefaultMutableTreeNode { | |||
| 60 | @Override | 60 | @Override |
| 61 | public String toString() { | 61 | public String toString() { |
| 62 | MethodEntry translatedEntry = translator.translate(entry); | 62 | MethodEntry translatedEntry = translator.translate(entry); |
| 63 | String className = translatedEntry.getParent().getFullName(); | 63 | return translatedEntry.getFullName() + "()"; |
| 64 | String methodName = translatedEntry.getName(); | ||
| 65 | return className + "." + methodName + "()"; | ||
| 66 | } | 64 | } |
| 67 | 65 | ||
| 68 | public void load(JarIndex index) { | 66 | public void load(JarIndex index) { |
diff --git a/enigma/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java b/enigma/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java index 7bee4dc..455456f 100644 --- a/enigma/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java +++ b/enigma/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java | |||
| @@ -62,13 +62,11 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { | |||
| 62 | @Override | 62 | @Override |
| 63 | public String toString() { | 63 | public String toString() { |
| 64 | MethodEntry translatedEntry = translator.translate(entry); | 64 | MethodEntry translatedEntry = translator.translate(entry); |
| 65 | String className = translatedEntry.getContainingClass().getFullName(); | ||
| 66 | 65 | ||
| 67 | if (!this.implemented) { | 66 | if (!this.implemented) { |
| 68 | return className; | 67 | return translatedEntry.getParent().getFullName(); |
| 69 | } else { | 68 | } else { |
| 70 | String methodName = translatedEntry.getName(); | 69 | return translatedEntry.getFullName() + "()"; |
| 71 | return className + "." + methodName + "()"; | ||
| 72 | } | 70 | } |
| 73 | } | 71 | } |
| 74 | 72 | ||
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 47319e0..fe56611 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 6fd412a..8a81c54 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/FieldEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/FieldEntry.java index 3c54468..5ddd33d 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/FieldEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/FieldEntry.java | |||
| @@ -93,7 +93,7 @@ public class FieldEntry extends ParentedEntry<ClassEntry> implements Comparable< | |||
| 93 | 93 | ||
| 94 | @Override | 94 | @Override |
| 95 | public String toString() { | 95 | public String toString() { |
| 96 | return this.parent.getFullName() + "." + this.name + ":" + this.desc; | 96 | return this.getFullName() + ":" + this.desc; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | @Override | 99 | @Override |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/MethodEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/MethodEntry.java index 4698aa4..864a580 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/MethodEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/MethodEntry.java | |||
| @@ -102,7 +102,7 @@ public class MethodEntry extends ParentedEntry<ClassEntry> implements Comparable | |||
| 102 | 102 | ||
| 103 | @Override | 103 | @Override |
| 104 | public String toString() { | 104 | public String toString() { |
| 105 | return this.parent.getFullName() + "." + this.name + this.descriptor; | 105 | return this.getFullName() + this.descriptor; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | @Override | 108 | @Override |
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 b12f9d0..5634891 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 |