From acd8b326dbde3912e3a102b514bf451350452c7e Mon Sep 17 00:00:00 2001 From: Yanis48 Date: Wed, 7 Apr 2021 12:01:04 +0200 Subject: Reorganize entry names --- .../representation/entry/ClassEntry.java | 28 ++++++---- .../translation/representation/entry/Entry.java | 60 ++++++++++++++++++++++ .../representation/entry/ParentedEntry.java | 17 +++++- 3 files changed, 95 insertions(+), 10 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 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 implements Comparable< return this.name; } + @Override + public String getSimpleName() { + int packagePos = name.lastIndexOf('/'); + if (packagePos > 0) { + return name.substring(packagePos + 1); + } + return name; + } + + @Override public String getFullName() { - return fullName; + return this.fullName; + } + + @Override + public String getContextualName() { + if (this.isInnerClass()) { + return this.parent.getSimpleName() + "$" + this.name; + } + return this.getSimpleName(); } @Override @@ -126,14 +144,6 @@ public class ClassEntry extends ParentedEntry implements Comparable< return getPackageName(fullName); } - public String getSimpleName() { - int packagePos = name.lastIndexOf('/'); - if (packagePos > 0) { - return name.substring(packagePos + 1); - } - return name; - } - /** * Returns whether this class entry has a parent, and therefore is an inner class. */ 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; import cuchaz.enigma.utils.validation.ValidationContext; public interface Entry

> extends Translatable { + /** + * Returns the default name of this entry. + * + *

For methods, fields and inner classes, it's the same as {@link #getSimpleName()}.

+ *

For other classes, it's the same as {@link #getFullName()}.

+ * + *

Examples:

+ * + */ String getName(); + /** + * Returns the simple name of this entry. + * + *

For methods, fields and inner classes, it's the same as {@link #getName()}.

+ *

For other classes, it's their name without the package name.

+ * + *

Examples:

+ * + */ + String getSimpleName(); + + /** + * Returns the full name of this entry. + * + *

For methods, fields and inner classes, it's their name prefixed with the full name + * of their parent entry.

+ *

For other classes, it's their name prefixed with their package name.

+ * + *

Examples:

+ * + */ + String getFullName(); + + /** + * Returns the contextual name of this entry. + * + *

For methods, fields and inner classes, it's their name prefixed with the contextual + * name of their parent entry.

+ *

For other classes, it's only their simple name.

+ * + *

Examples:

+ * + */ + String getContextualName(); + String getJavadocs(); 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 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

> implements Entry

{ @Override public String getName() { - return name; + return this.name; + } + + @Override + public String getSimpleName() { + return this.name; + } + + @Override + public String getFullName() { + return this.parent.getFullName() + "." + this.name; + } + + @Override + public String getContextualName() { + return this.parent.getContextualName() + "." + this.name; } @Override -- cgit v1.2.3