diff options
| author | 2020-04-18 09:02:12 -0400 | |
|---|---|---|
| committer | 2020-04-18 14:02:12 +0100 | |
| commit | aad12650ea7394e315ebe170ceebb345c739577d (patch) | |
| tree | 130e544e082ec16be80fb17a3855dcead43af957 /src/main | |
| parent | Added zoom for PanelEditor (#209) (diff) | |
| download | enigma-aad12650ea7394e315ebe170ceebb345c739577d.tar.gz enigma-aad12650ea7394e315ebe170ceebb345c739577d.tar.xz enigma-aad12650ea7394e315ebe170ceebb345c739577d.zip | |
Fix a few bugs (#219)
* Update Gradle and replace deprecated Gradle features
* Allow naming class in default package (fixes #215)
* Fix CFR crash (fixes #207)
* Update README.md
Co-Authored-By: liach <7806504+liach@users.noreply.github.com>
Co-authored-by: liach <7806504+liach@users.noreply.github.com>
Diffstat (limited to 'src/main')
3 files changed, 10 insertions, 7 deletions
diff --git a/src/main/java/cuchaz/enigma/source/cfr/EnigmaDumper.java b/src/main/java/cuchaz/enigma/source/cfr/EnigmaDumper.java index e265d9d1..09e0a9b2 100644 --- a/src/main/java/cuchaz/enigma/source/cfr/EnigmaDumper.java +++ b/src/main/java/cuchaz/enigma/source/cfr/EnigmaDumper.java | |||
| @@ -43,7 +43,13 @@ public class EnigmaDumper implements Dumper { | |||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | private String getDesc(JavaTypeInstance type) { | 45 | private String getDesc(JavaTypeInstance type) { |
| 46 | type = type.getDeGenerifiedType(); | 46 | if (!type.isUsableType() && type != RawJavaType.VOID) { |
| 47 | throw new IllegalArgumentException(type.toString()); | ||
| 48 | } | ||
| 49 | |||
| 50 | if (type instanceof JavaGenericBaseInstance) { | ||
| 51 | return getDesc(type.getDeGenerifiedType()); | ||
| 52 | } | ||
| 47 | 53 | ||
| 48 | if (type instanceof JavaRefTypeInstance) { | 54 | if (type instanceof JavaRefTypeInstance) { |
| 49 | return "L" + type.getRawName().replace('.', '/') + ";"; | 55 | return "L" + type.getRawName().replace('.', '/') + ";"; |
diff --git a/src/main/java/cuchaz/enigma/translation/mapping/NameValidator.java b/src/main/java/cuchaz/enigma/translation/mapping/NameValidator.java index 19473ead..5bc2f67a 100644 --- a/src/main/java/cuchaz/enigma/translation/mapping/NameValidator.java +++ b/src/main/java/cuchaz/enigma/translation/mapping/NameValidator.java | |||
| @@ -26,7 +26,7 @@ public class NameValidator { | |||
| 26 | "boolean", "do", "if", "private", "this", "break", "double", "implements", "protected", "throw", "byte", | 26 | "boolean", "do", "if", "private", "this", "break", "double", "implements", "protected", "throw", "byte", |
| 27 | "else", "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", "catch", | 27 | "else", "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", "catch", |
| 28 | "extends", "int", "short", "try", "char", "final", "interface", "static", "void", "class", "finally", | 28 | "extends", "int", "short", "try", "char", "final", "interface", "static", "void", "class", "finally", |
| 29 | "long", "strictfp", "volatile", "const", "float", "native", "super", "while" | 29 | "long", "strictfp", "volatile", "const", "float", "native", "super", "while", "_" |
| 30 | ); | 30 | ); |
| 31 | 31 | ||
| 32 | static { | 32 | static { |
| @@ -35,13 +35,10 @@ public class NameValidator { | |||
| 35 | CLASS_PATTERN = Pattern.compile(String.format("^(%s(\\.|/))*(%s)$", identifierRegex, identifierRegex)); | 35 | CLASS_PATTERN = Pattern.compile(String.format("^(%s(\\.|/))*(%s)$", identifierRegex, identifierRegex)); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | public static void validateClassName(String name, boolean packageRequired) { | 38 | public static void validateClassName(String name) { |
| 39 | if (!CLASS_PATTERN.matcher(name).matches() || ILLEGAL_IDENTIFIERS.contains(name)) { | 39 | if (!CLASS_PATTERN.matcher(name).matches() || ILLEGAL_IDENTIFIERS.contains(name)) { |
| 40 | throw new IllegalNameException(name, "This doesn't look like a legal class name"); | 40 | throw new IllegalNameException(name, "This doesn't look like a legal class name"); |
| 41 | } | 41 | } |
| 42 | if (packageRequired && ClassEntry.getPackageName(name) == null) { | ||
| 43 | throw new IllegalNameException(name, "Class must be in a package"); | ||
| 44 | } | ||
| 45 | } | 42 | } |
| 46 | 43 | ||
| 47 | public static void validateIdentifier(String name) { | 44 | public static void validateIdentifier(String name) { |
diff --git a/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java b/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java index 74298e43..d6171f11 100644 --- a/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java +++ b/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java | |||
| @@ -98,7 +98,7 @@ public class ClassEntry extends ParentedEntry<ClassEntry> implements Comparable< | |||
| 98 | 98 | ||
| 99 | @Override | 99 | @Override |
| 100 | public void validateName(String name) throws IllegalNameException { | 100 | public void validateName(String name) throws IllegalNameException { |
| 101 | NameValidator.validateClassName(name, !isInnerClass()); | 101 | NameValidator.validateClassName(name); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | @Override | 104 | @Override |