From 9c736848fb7aa82d295b3aa2946e6cd132ee998f Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Wed, 14 Sep 2022 13:12:55 +0100 Subject: Add checkstyle (#460) --- enigma/src/test/java/cuchaz/enigma/ConfigTest.java | 32 ++---- .../cuchaz/enigma/PackageVisibilityIndexTest.java | 43 ++++---- .../src/test/java/cuchaz/enigma/TestDeobfed.java | 54 +++------- .../test/java/cuchaz/enigma/TestDeobfuscator.java | 30 +++--- .../test/java/cuchaz/enigma/TestEntryFactory.java | 22 ++-- .../test/java/cuchaz/enigma/TestInnerClasses.java | 49 ++++----- .../enigma/TestJarIndexConstructorReferences.java | 79 ++++++-------- .../cuchaz/enigma/TestJarIndexInheritanceTree.java | 114 +++++++------------- .../java/cuchaz/enigma/TestJarIndexLoneClass.java | 69 ++++++------ .../java/cuchaz/enigma/TestMethodDescriptor.java | 116 ++++++++------------- .../java/cuchaz/enigma/TestTokensConstructors.java | 98 ++++++----------- .../test/java/cuchaz/enigma/TestTranslator.java | 31 +++--- .../java/cuchaz/enigma/TestTypeDescriptor.java | 29 +++--- .../src/test/java/cuchaz/enigma/TokenChecker.java | 40 ++++--- .../src/test/java/cuchaz/enigma/inputs/Keep.java | 18 ++-- .../enigma/inputs/constructors/BaseClass.java | 19 ++-- .../cuchaz/enigma/inputs/constructors/Caller.java | 19 ++-- .../inputs/constructors/DefaultConstructable.java | 18 ++-- .../enigma/inputs/constructors/SubClass.java | 19 ++-- .../enigma/inputs/constructors/SubSubClass.java | 19 ++-- .../enigma/inputs/inheritanceTree/BaseClass.java | 19 ++-- .../enigma/inputs/inheritanceTree/SubclassA.java | 19 ++-- .../enigma/inputs/inheritanceTree/SubclassB.java | 19 ++-- .../inputs/inheritanceTree/SubsubclassAA.java | 19 ++-- .../enigma/inputs/innerClasses/A_Anonymous.java | 19 ++-- .../innerClasses/B_AnonymousWithScopeArgs.java | 19 ++-- .../inputs/innerClasses/C_ConstructorArgs.java | 22 ++-- .../enigma/inputs/innerClasses/D_Simple.java | 19 ++-- .../innerClasses/E_AnonymousWithOuterAccess.java | 19 ++-- .../enigma/inputs/innerClasses/F_ClassTree.java | 22 ++-- .../cuchaz/enigma/inputs/loneClass/LoneClass.java | 19 ++-- .../inputs/packageAccess/SamePackageChild.java | 1 - .../packageAccess/sub/OtherPackageChild.java | 1 - .../cuchaz/enigma/inputs/translation/A_Basic.java | 19 ++-- .../enigma/inputs/translation/B_BaseClass.java | 19 ++-- .../enigma/inputs/translation/C_SubClass.java | 19 ++-- .../inputs/translation/D_AnonymousTesting.java | 19 ++-- .../enigma/inputs/translation/E_Bridges.java | 19 ++-- .../enigma/inputs/translation/F_ObjectMethods.java | 22 ++-- .../enigma/inputs/translation/G_OuterClass.java | 27 +++-- .../enigma/inputs/translation/H_NamelessClass.java | 33 +++--- .../enigma/inputs/translation/I_Generics.java | 19 ++-- .../enigma/translation/mapping/TestComments.java | 38 ++++--- .../translation/mapping/TestReadWriteCycle.java | 43 +++----- .../mapping/TestTinyV2InnerClasses.java | 27 +++-- .../enigma/translation/mapping/TestV2Main.java | 6 +- .../translation/mapping/serde/recaf/TestRecaf.java | 52 ++++----- 47 files changed, 653 insertions(+), 844 deletions(-) (limited to 'enigma/src/test/java') diff --git a/enigma/src/test/java/cuchaz/enigma/ConfigTest.java b/enigma/src/test/java/cuchaz/enigma/ConfigTest.java index a44f037..95689f8 100644 --- a/enigma/src/test/java/cuchaz/enigma/ConfigTest.java +++ b/enigma/src/test/java/cuchaz/enigma/ConfigTest.java @@ -1,13 +1,12 @@ package cuchaz.enigma; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import cuchaz.enigma.config.ConfigContainer; -import static org.junit.Assert.assertEquals; - public class ConfigTest { - @Test public void serialize() { ConfigContainer cc = new ConfigContainer(); @@ -17,15 +16,7 @@ public class ConfigTest { cc.data().section("a").section("b").section("c").setInt("c", 5); cc.data().section("a").section("b").section("c").setDouble("d", 3.5); cc.data().section("a").section("b").section("c").setRgbColor("e", 0x123456); - assertEquals("a=a\n" + - "\n" + - "[a][b][c]\n" + - "a=abcd\n" + - "b=true\n" + - "c=5\n" + - "d=3.5\n" + - "e=#123456\n", - cc.serialize()); + assertEquals("a=a\n" + "\n" + "[a][b][c]\n" + "a=abcd\n" + "b=true\n" + "c=5\n" + "d=3.5\n" + "e=#123456\n", cc.serialize()); } @Test @@ -37,14 +28,7 @@ public class ConfigTest { cc.data().section("a").section("b").section("c").setInt("c", 5); cc.data().section("a").section("b").section("c").setDouble("d", 3.5); cc.data().section("a").section("b").section("c").setRgbColor("e", 0x123456); - assertEquals(ConfigContainer.parse("a=a\n" + - "\n" + - "[a][b][c]\n" + - "a=abcd\n" + - "b=true\n" + - "c=5\n" + - "d=3.5\n" + - "e=#123456\n").data(), cc.data()); + assertEquals(ConfigContainer.parse("a=a\n" + "\n" + "[a][b][c]\n" + "a=abcd\n" + "b=true\n" + "c=5\n" + "d=3.5\n" + "e=#123456\n").data(), cc.data()); } @Test @@ -52,12 +36,10 @@ public class ConfigTest { ConfigContainer cc = new ConfigContainer(); String thing = "\\[],\\,./'\"`~!@#$%^&*()_+-=|}{\n\\\\\r\b\u0000\uffff\u1234"; cc.data().section(thing).setString(thing, thing); - cc.data().section(thing).setArray("arr", new String[] { thing, thing, thing, thing }); + cc.data().section(thing).setArray("arr", new String[]{thing, thing, thing, thing}); assertEquals( - "[\\\\[\\],\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234]\n" + - "\\\\\\[],\\\\,./'\"`~!@#$%^&*()_+-\\=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234=\\\\[],\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234\n" + - "arr=\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234,\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234,\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234,\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234\n", + "[\\\\[\\],\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234]\n" + "\\\\\\[],\\\\,./'\"`~!@#$%^&*()_+-\\=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234=\\\\[],\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234\n" + "arr=\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234,\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234,\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234,\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234\n", cc.serialize()); ConfigContainer cc1 = ConfigContainer.parse(cc.serialize()); @@ -77,10 +59,8 @@ public class ConfigTest { assertEquals("", ConfigContainer.parse("[").serialize()); assertEquals("[a]\na=b\nc=d\n", ConfigContainer.parse("[a]\na=b\n[\nc=d").serialize()); - // not technically syntax errors but never something that gets generated assertEquals("", ConfigContainer.parse("[a]").serialize()); assertEquals("", ConfigContainer.parse("[a]\n[b]").serialize()); } - } diff --git a/enigma/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java b/enigma/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java index 1251535..1678f59 100644 --- a/enigma/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java +++ b/enigma/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java @@ -1,30 +1,31 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the GNU Lesser General Public +* License v3.0 which accompanies this distribution, and is available at +* http://www.gnu.org/licenses/lgpl.html +* +*
Contributors: +* Jeff Martin - initial API and implementation +******************************************************************************/ package cuchaz.enigma; -import cuchaz.enigma.analysis.index.JarIndex; -import cuchaz.enigma.analysis.index.PackageVisibilityIndex; -import cuchaz.enigma.classprovider.JarClassProvider; -import cuchaz.enigma.translation.representation.entry.ClassEntry; -import org.junit.Test; - -import java.nio.file.Path; -import java.nio.file.Paths; - import static cuchaz.enigma.TestEntryFactory.newClass; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.Test; + +import cuchaz.enigma.analysis.index.JarIndex; +import cuchaz.enigma.analysis.index.PackageVisibilityIndex; +import cuchaz.enigma.classprovider.JarClassProvider; +import cuchaz.enigma.translation.representation.entry.ClassEntry; + public class PackageVisibilityIndexTest { public static final Path JAR = Paths.get("build/test-obf/packageAccess.jar"); private static final ClassEntry KEEP = newClass("cuchaz/enigma/inputs/Keep"); @@ -46,10 +47,6 @@ public class PackageVisibilityIndexTest { PackageVisibilityIndex visibilityIndex = jarIndex.getPackageVisibilityIndex(); assertThat(visibilityIndex.getPartition(BASE), containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER)); System.out.println(visibilityIndex.getPartitions()); - assertThat(visibilityIndex.getPartitions(), containsInAnyOrder( - containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER), - containsInAnyOrder(OTHER_PACKAGE_CHILD, OTHER_PACKAGE_CHILD_INNER), - contains(KEEP) - )); + assertThat(visibilityIndex.getPartitions(), containsInAnyOrder(containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER), containsInAnyOrder(OTHER_PACKAGE_CHILD, OTHER_PACKAGE_CHILD_INNER), contains(KEEP))); } } diff --git a/enigma/src/test/java/cuchaz/enigma/TestDeobfed.java b/enigma/src/test/java/cuchaz/enigma/TestDeobfed.java index 2584d58..b19aa77 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestDeobfed.java +++ b/enigma/src/test/java/cuchaz/enigma/TestDeobfed.java @@ -1,16 +1,20 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the GNU Lesser General Public +* License v3.0 which accompanies this distribution, and is available at +* http://www.gnu.org/licenses/lgpl.html +* +*
Contributors: +* Jeff Martin - initial API and implementation +******************************************************************************/ package cuchaz.enigma; +import static cuchaz.enigma.TestEntryFactory.newClass; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; + import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -23,10 +27,6 @@ import cuchaz.enigma.source.Decompiler; import cuchaz.enigma.source.Decompilers; import cuchaz.enigma.source.SourceSettings; -import static cuchaz.enigma.TestEntryFactory.newClass; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsInAnyOrder; - public class TestDeobfed { public static final Path OBF = Paths.get("build/test-obf/translation.jar"); public static final Path DEOBF = Paths.get("build/test-deobf/translation.jar"); @@ -45,31 +45,9 @@ public class TestDeobfed { @Test public void obfEntries() { - assertThat(deobfProject.getJarIndex().getEntryIndex().getClasses(), containsInAnyOrder( - newClass("cuchaz/enigma/inputs/Keep"), - newClass("a"), - newClass("b"), - newClass("c"), - newClass("d"), - newClass("d$1"), - newClass("e"), - newClass("f"), - newClass("g"), - newClass("g$a"), - newClass("g$a$a"), - newClass("g$b"), - newClass("g$b$a"), - newClass("h"), - newClass("h$a"), - newClass("h$a$a"), - newClass("h$b"), - newClass("h$b$a"), - newClass("h$b$a$a"), - newClass("h$b$a$b"), - newClass("i"), - newClass("i$a"), - newClass("i$b") - )); + assertThat(deobfProject.getJarIndex().getEntryIndex().getClasses(), + containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), newClass("a"), newClass("b"), newClass("c"), newClass("d"), newClass("d$1"), newClass("e"), newClass("f"), newClass("g"), newClass("g$a"), newClass("g$a$a"), newClass("g$b"), newClass("g$b$a"), newClass("h"), + newClass("h$a"), newClass("h$a$a"), newClass("h$b"), newClass("h$b$a"), newClass("h$b$a$a"), newClass("h$b$a$b"), newClass("i"), newClass("i$a"), newClass("i$b"))); } @Test diff --git a/enigma/src/test/java/cuchaz/enigma/TestDeobfuscator.java b/enigma/src/test/java/cuchaz/enigma/TestDeobfuscator.java index 38940ca..587494e 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestDeobfuscator.java +++ b/enigma/src/test/java/cuchaz/enigma/TestDeobfuscator.java @@ -1,24 +1,25 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the GNU Lesser General Public +* License v3.0 which accompanies this distribution, and is available at +* http://www.gnu.org/licenses/lgpl.html +* +*
Contributors: +* Jeff Martin - initial API and implementation +******************************************************************************/ package cuchaz.enigma; +import java.io.IOException; +import java.nio.file.Paths; + +import org.junit.Test; + import cuchaz.enigma.classprovider.ClasspathClassProvider; import cuchaz.enigma.source.Decompiler; import cuchaz.enigma.source.Decompilers; import cuchaz.enigma.source.SourceSettings; -import org.junit.Test; - -import java.io.IOException; -import java.nio.file.Paths; public class TestDeobfuscator { private EnigmaProject openProject() throws IOException { @@ -27,8 +28,7 @@ public class TestDeobfuscator { } @Test - public void loadJar() - throws Exception { + public void loadJar() throws Exception { openProject(); } diff --git a/enigma/src/test/java/cuchaz/enigma/TestEntryFactory.java b/enigma/src/test/java/cuchaz/enigma/TestEntryFactory.java index 9e1425a..833e217 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestEntryFactory.java +++ b/enigma/src/test/java/cuchaz/enigma/TestEntryFactory.java @@ -1,24 +1,24 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the GNU Lesser General Public +* License v3.0 which accompanies this distribution, and is available at +* http://www.gnu.org/licenses/lgpl.html +* +*
Contributors: +* Jeff Martin - initial API and implementation +******************************************************************************/ package cuchaz.enigma; import cuchaz.enigma.analysis.EntryReference; -import cuchaz.enigma.translation.representation.*; +import cuchaz.enigma.translation.representation.MethodDescriptor; +import cuchaz.enigma.translation.representation.TypeDescriptor; import cuchaz.enigma.translation.representation.entry.ClassEntry; import cuchaz.enigma.translation.representation.entry.FieldEntry; import cuchaz.enigma.translation.representation.entry.MethodEntry; public class TestEntryFactory { - public static ClassEntry newClass(String name) { return new ClassEntry(name); } diff --git a/enigma/src/test/java/cuchaz/enigma/TestInnerClasses.java b/enigma/src/test/java/cuchaz/enigma/TestInnerClasses.java index 6b60994..46086e5 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestInnerClasses.java +++ b/enigma/src/test/java/cuchaz/enigma/TestInnerClasses.java @@ -1,16 +1,25 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the GNU Lesser General Public +* License v3.0 which accompanies this distribution, and is available at +* http://www.gnu.org/licenses/lgpl.html +* +*
Contributors: +* Jeff Martin - initial API and implementation +******************************************************************************/ package cuchaz.enigma; +import static cuchaz.enigma.TestEntryFactory.newClass; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.Test; + import cuchaz.enigma.analysis.index.JarIndex; import cuchaz.enigma.classprovider.CachingClassProvider; import cuchaz.enigma.classprovider.JarClassProvider; @@ -18,17 +27,8 @@ import cuchaz.enigma.source.Decompiler; import cuchaz.enigma.source.Decompilers; import cuchaz.enigma.source.SourceSettings; import cuchaz.enigma.translation.representation.entry.ClassEntry; -import org.junit.Test; - -import java.nio.file.Path; -import java.nio.file.Paths; - -import static cuchaz.enigma.TestEntryFactory.newClass; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; public class TestInnerClasses { - private static final ClassEntry SimpleOuter = newClass("d"); private static final ClassEntry SimpleInner = newClass("d$a"); private static final ClassEntry ConstructorArgsOuter = newClass("c"); @@ -61,26 +61,19 @@ public class TestInnerClasses { @Test public void classTree() { - // root level assertThat(index.getEntryIndex().hasClass(ClassTreeRoot), is(true)); // level 1 - ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName() - + "$" + ClassTreeLevel1.getSimpleName()); + ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName() + "$" + ClassTreeLevel1.getSimpleName()); assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); // level 2 - fullClassEntry = new ClassEntry(ClassTreeRoot.getName() - + "$" + ClassTreeLevel1.getSimpleName() - + "$" + ClassTreeLevel2.getSimpleName()); + fullClassEntry = new ClassEntry(ClassTreeRoot.getName() + "$" + ClassTreeLevel1.getSimpleName() + "$" + ClassTreeLevel2.getSimpleName()); assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); // level 3 - fullClassEntry = new ClassEntry(ClassTreeRoot.getName() - + "$" + ClassTreeLevel1.getSimpleName() - + "$" + ClassTreeLevel2.getSimpleName() - + "$" + ClassTreeLevel3.getSimpleName()); + fullClassEntry = new ClassEntry(ClassTreeRoot.getName() + "$" + ClassTreeLevel1.getSimpleName() + "$" + ClassTreeLevel2.getSimpleName() + "$" + ClassTreeLevel3.getSimpleName()); assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); } diff --git a/enigma/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java b/enigma/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java index 0790193..05565b6 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java +++ b/enigma/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java @@ -1,16 +1,30 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the GNU Lesser General Public +* License v3.0 which accompanies this distribution, and is available at +* http://www.gnu.org/licenses/lgpl.html +* +*
Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma;
+import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod;
+import static cuchaz.enigma.TestEntryFactory.newClass;
+import static cuchaz.enigma.TestEntryFactory.newMethod;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.is;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collection;
+
+import org.junit.Test;
+
import cuchaz.enigma.analysis.EntryReference;
import cuchaz.enigma.analysis.index.JarIndex;
import cuchaz.enigma.classprovider.CachingClassProvider;
@@ -18,18 +32,8 @@ import cuchaz.enigma.classprovider.JarClassProvider;
import cuchaz.enigma.translation.representation.entry.ClassEntry;
import cuchaz.enigma.translation.representation.entry.MethodDefEntry;
import cuchaz.enigma.translation.representation.entry.MethodEntry;
-import org.junit.Test;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collection;
-
-import static cuchaz.enigma.TestEntryFactory.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
public class TestJarIndexConstructorReferences {
-
public static final Path JAR = Paths.get("build/test-obf/constructors.jar");
private JarIndex index;
@@ -47,8 +51,7 @@ public class TestJarIndexConstructorReferences {
@Test
public void obfEntries() {
- assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass,
- subClass, subsubClass, defaultClass, callerClass));
+ assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClass, subsubClass, defaultClass, callerClass));
}
@Test
@@ -56,50 +59,36 @@ public class TestJarIndexConstructorReferences {
public void baseDefault() {
MethodEntry source = newMethod(baseClass, " Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma;
+import static cuchaz.enigma.TestEntryFactory.newClass;
+import static cuchaz.enigma.TestEntryFactory.newField;
+import static cuchaz.enigma.TestEntryFactory.newMethod;
+import static cuchaz.enigma.TestEntryFactory.newFieldReferenceByMethod;
+import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.is;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.objectweb.asm.Opcodes;
+
import cuchaz.enigma.analysis.EntryReference;
import cuchaz.enigma.analysis.index.EntryIndex;
import cuchaz.enigma.analysis.index.InheritanceIndex;
@@ -24,19 +42,8 @@ import cuchaz.enigma.translation.representation.entry.ClassEntry;
import cuchaz.enigma.translation.representation.entry.FieldEntry;
import cuchaz.enigma.translation.representation.entry.MethodDefEntry;
import cuchaz.enigma.translation.representation.entry.MethodEntry;
-import org.junit.Test;
-import org.objectweb.asm.Opcodes;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collection;
-
-import static cuchaz.enigma.TestEntryFactory.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
public class TestJarIndexInheritanceTree {
-
public static final Path JAR = Paths.get("build/test-obf/inheritanceTree.jar");
private JarIndex index;
@@ -55,21 +62,17 @@ public class TestJarIndexInheritanceTree {
@Test
public void obfEntries() {
- assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(
- newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClassA, subClassAA, subClassB
- ));
+ assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClassA, subClassAA, subClassB));
}
@Test
public void translationIndex() {
-
InheritanceIndex index = this.index.getInheritanceIndex();
// base class
assertThat(index.getParents(baseClass), is(empty()));
assertThat(index.getAncestors(baseClass), is(empty()));
- assertThat(index.getChildren(baseClass), containsInAnyOrder(subClassA, subClassB
- ));
+ assertThat(index.getChildren(baseClass), containsInAnyOrder(subClassA, subClassB));
// subclass a
assertThat(index.getParents(subClassA), contains(baseClass));
@@ -95,41 +98,22 @@ public class TestJarIndexInheritanceTree {
@Test
public void relatedMethodImplementations() {
-
Collection Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma;
-import cuchaz.enigma.analysis.*;
+import static cuchaz.enigma.TestEntryFactory.newClass;
+import static cuchaz.enigma.TestEntryFactory.newField;
+import static cuchaz.enigma.TestEntryFactory.newFieldReferenceByMethod;
+import static cuchaz.enigma.TestEntryFactory.newMethod;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collection;
+import java.util.List;
+
+import org.junit.Test;
+
+import cuchaz.enigma.analysis.ClassImplementationsTreeNode;
+import cuchaz.enigma.analysis.ClassInheritanceTreeNode;
+import cuchaz.enigma.analysis.EntryReference;
+import cuchaz.enigma.analysis.IndexTreeBuilder;
+import cuchaz.enigma.analysis.MethodImplementationsTreeNode;
+import cuchaz.enigma.analysis.MethodInheritanceTreeNode;
import cuchaz.enigma.analysis.index.EntryIndex;
import cuchaz.enigma.analysis.index.InheritanceIndex;
import cuchaz.enigma.analysis.index.JarIndex;
@@ -23,19 +47,8 @@ import cuchaz.enigma.translation.representation.entry.ClassEntry;
import cuchaz.enigma.translation.representation.entry.FieldEntry;
import cuchaz.enigma.translation.representation.entry.MethodDefEntry;
import cuchaz.enigma.translation.representation.entry.MethodEntry;
-import org.junit.Test;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collection;
-import java.util.List;
-
-import static cuchaz.enigma.TestEntryFactory.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
public class TestJarIndexLoneClass {
-
public static final Path JAR = Paths.get("build/test-obf/loneClass.jar");
private JarIndex index;
@@ -47,10 +60,7 @@ public class TestJarIndexLoneClass {
@Test
public void obfEntries() {
- assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(
- newClass("cuchaz/enigma/inputs/Keep"),
- newClass("a")
- ));
+ assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), newClass("a")));
}
@Test
@@ -112,9 +122,7 @@ public class TestJarIndexLoneClass {
@Test
public void relatedMethodImplementations() {
Collection Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma;
-import cuchaz.enigma.translation.representation.MethodDescriptor;
-import cuchaz.enigma.translation.representation.TypeDescriptor;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+
import org.junit.Test;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
+import cuchaz.enigma.translation.representation.MethodDescriptor;
+import cuchaz.enigma.translation.representation.TypeDescriptor;
public class TestMethodDescriptor {
-
@Test
public void easiest() {
final MethodDescriptor sig = new MethodDescriptor("()V");
@@ -31,26 +34,19 @@ public class TestMethodDescriptor {
public void primitives() {
{
final MethodDescriptor sig = new MethodDescriptor("(I)V");
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("I")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
}
+
{
final MethodDescriptor sig = new MethodDescriptor("(I)I");
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("I")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("I")));
}
+
{
final MethodDescriptor sig = new MethodDescriptor("(IBCJ)Z");
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("I"),
- new TypeDescriptor("B"),
- new TypeDescriptor("C"),
- new TypeDescriptor("J")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"), new TypeDescriptor("B"), new TypeDescriptor("C"), new TypeDescriptor("J")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("Z")));
}
}
@@ -63,20 +59,16 @@ public class TestMethodDescriptor {
assertThat(sig.getArgumentDescs().get(0), is(new TypeDescriptor("[LFoo;")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
}
+
{
final MethodDescriptor sig = new MethodDescriptor("(LFoo;)LBar;");
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("LFoo;")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("LFoo;")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LBar;")));
}
+
{
final MethodDescriptor sig = new MethodDescriptor("(LFoo;LMoo;LZoo;)LBar;");
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("LFoo;"),
- new TypeDescriptor("LMoo;"),
- new TypeDescriptor("LZoo;")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("LFoo;"), new TypeDescriptor("LMoo;"), new TypeDescriptor("LZoo;")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LBar;")));
}
}
@@ -85,25 +77,19 @@ public class TestMethodDescriptor {
public void arrays() {
{
final MethodDescriptor sig = new MethodDescriptor("([I)V");
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("[I")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("[I")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
}
+
{
final MethodDescriptor sig = new MethodDescriptor("([I)[J");
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("[I")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("[I")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[J")));
}
+
{
final MethodDescriptor sig = new MethodDescriptor("([I[Z[F)[D");
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("[I"),
- new TypeDescriptor("[Z"),
- new TypeDescriptor("[F")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("[I"), new TypeDescriptor("[Z"), new TypeDescriptor("[F")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[D")));
}
}
@@ -112,20 +98,13 @@ public class TestMethodDescriptor {
public void mixed() {
{
final MethodDescriptor sig = new MethodDescriptor("(I[JLFoo;)Z");
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("I"),
- new TypeDescriptor("[J"),
- new TypeDescriptor("LFoo;")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"), new TypeDescriptor("[J"), new TypeDescriptor("LFoo;")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("Z")));
}
+
{
final MethodDescriptor sig = new MethodDescriptor("(III)[LFoo;");
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("I"),
- new TypeDescriptor("I"),
- new TypeDescriptor("I")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"), new TypeDescriptor("I"), new TypeDescriptor("I")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[LFoo;")));
}
}
@@ -138,42 +117,37 @@ public class TestMethodDescriptor {
assertThat(sig.getArgumentDescs(), is(empty()));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
}
+
{
final MethodDescriptor oldSig = new MethodDescriptor("(IJLFoo;)V");
final MethodDescriptor sig = oldSig.remap(s -> null);
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("I"),
- new TypeDescriptor("J"),
- new TypeDescriptor("LFoo;")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"), new TypeDescriptor("J"), new TypeDescriptor("LFoo;")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
}
+
{
final MethodDescriptor oldSig = new MethodDescriptor("(LFoo;LBar;)LMoo;");
final MethodDescriptor sig = oldSig.remap(s -> {
if (s.equals("Foo")) {
return "Bar";
}
+
return null;
});
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("LBar;"),
- new TypeDescriptor("LBar;")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("LBar;"), new TypeDescriptor("LBar;")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LMoo;")));
}
+
{
final MethodDescriptor oldSig = new MethodDescriptor("(LFoo;LBar;)LMoo;");
final MethodDescriptor sig = oldSig.remap(s -> {
if (s.equals("Moo")) {
return "Cow";
}
+
return null;
});
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("LFoo;"),
- new TypeDescriptor("LBar;")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("LFoo;"), new TypeDescriptor("LBar;")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LCow;")));
}
}
@@ -188,18 +162,16 @@ public class TestMethodDescriptor {
} else if (s.equals("Bar")) {
return "Beer";
}
+
return null;
});
- assertThat(sig.getArgumentDescs(), contains(
- new TypeDescriptor("[LFood;")
- ));
+ assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("[LFood;")));
assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[[[LBeer;")));
}
}
@Test
public void equals() {
-
// base
assertThat(new MethodDescriptor("()V"), is(new MethodDescriptor("()V")));
diff --git a/enigma/src/test/java/cuchaz/enigma/TestTokensConstructors.java b/enigma/src/test/java/cuchaz/enigma/TestTokensConstructors.java
index a5e8367..8017ab6 100644
--- a/enigma/src/test/java/cuchaz/enigma/TestTokensConstructors.java
+++ b/enigma/src/test/java/cuchaz/enigma/TestTokensConstructors.java
@@ -1,31 +1,33 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma;
-import cuchaz.enigma.translation.representation.entry.MethodEntry;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.nio.file.Paths;
-
import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod;
import static cuchaz.enigma.TestEntryFactory.newMethod;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
-public class TestTokensConstructors extends TokenChecker {
+import java.nio.file.Paths;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import cuchaz.enigma.translation.representation.entry.MethodEntry;
- public TestTokensConstructors()
- throws Exception {
+public class TestTokensConstructors extends TokenChecker {
+ public TestTokensConstructors() throws Exception {
super(Paths.get("build/test-obf/constructors.jar"));
}
@@ -57,17 +59,10 @@ public class TestTokensConstructors extends TokenChecker {
@Ignore // TODO needs fixing, broke when compiling against J16
public void baseDefaultReferences() {
MethodEntry source = newMethod("a", " Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma;
-import cuchaz.enigma.translation.representation.entry.Entry;
+import static cuchaz.enigma.TestEntryFactory.newClass;
+import static cuchaz.enigma.TestEntryFactory.newField;
+import static cuchaz.enigma.TestEntryFactory.newMethod;
+
import org.junit.BeforeClass;
import org.junit.Test;
-import static cuchaz.enigma.TestEntryFactory.*;
+import cuchaz.enigma.translation.representation.entry.Entry;
public class TestTranslator {
-
@BeforeClass
- public static void beforeClass()
- throws Exception {
+ public static void beforeClass() throws Exception {
//TODO FIx
//deobfuscator = new Enigma(new JarFile("build/test-obf/translation.jar"));
//try (InputStream in = TestTranslator.class.getResourceAsStream("/cuchaz/enigma/resources/translation.mappings")) {
@@ -94,7 +95,6 @@ public class TestTranslator {
@Test
public void innerClasses() {
-
// classes
assertMapping(newClass("g"), newClass("deobf/G_OuterClass"));
assertMapping(newClass("g$a"), newClass("deobf/G_OuterClass$A_InnerClass"));
@@ -120,7 +120,6 @@ public class TestTranslator {
@Test
public void testGenerics() {
-
// classes
assertMapping(newClass("i"), newClass("deobf/I_Generics"));
assertMapping(newClass("i$a"), newClass("deobf/I_Generics$A_Type"));
diff --git a/enigma/src/test/java/cuchaz/enigma/TestTypeDescriptor.java b/enigma/src/test/java/cuchaz/enigma/TestTypeDescriptor.java
index b9ebe55..280dadc 100644
--- a/enigma/src/test/java/cuchaz/enigma/TestTypeDescriptor.java
+++ b/enigma/src/test/java/cuchaz/enigma/TestTypeDescriptor.java
@@ -1,26 +1,26 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma;
-import cuchaz.enigma.translation.representation.TypeDescriptor;
-import org.junit.Test;
-
import static cuchaz.enigma.TestEntryFactory.newClass;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
-public class TestTypeDescriptor {
+import org.junit.Test;
+import cuchaz.enigma.translation.representation.TypeDescriptor;
+
+public class TestTypeDescriptor {
@Test
public void isVoid() {
assertThat(new TypeDescriptor("V").isVoid(), is(true));
@@ -161,6 +161,7 @@ public class TestTypeDescriptor {
assertThat(TypeDescriptor.parseFirst("LFoo;LFoo;"), is(answer));
assertThat(TypeDescriptor.parseFirst("LFoo;[LFoo;"), is(answer));
}
+
{
final String answer = "Ljava/lang/String;";
assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;"), is(answer));
@@ -182,6 +183,7 @@ public class TestTypeDescriptor {
assertThat(TypeDescriptor.parseFirst("[I[I"), is(answer));
assertThat(TypeDescriptor.parseFirst("[ILFoo;"), is(answer));
}
+
{
final String answer = "[[I";
assertThat(TypeDescriptor.parseFirst("[[I"), is(answer));
@@ -190,6 +192,7 @@ public class TestTypeDescriptor {
assertThat(TypeDescriptor.parseFirst("[[I[I"), is(answer));
assertThat(TypeDescriptor.parseFirst("[[ILFoo;"), is(answer));
}
+
{
final String answer = "[LFoo;";
assertThat(TypeDescriptor.parseFirst("[LFoo;"), is(answer));
diff --git a/enigma/src/test/java/cuchaz/enigma/TokenChecker.java b/enigma/src/test/java/cuchaz/enigma/TokenChecker.java
index fb3a8da..5f510a4 100644
--- a/enigma/src/test/java/cuchaz/enigma/TokenChecker.java
+++ b/enigma/src/test/java/cuchaz/enigma/TokenChecker.java
@@ -1,28 +1,34 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.List;
+
import com.google.common.collect.Lists;
+
import cuchaz.enigma.analysis.EntryReference;
import cuchaz.enigma.classprovider.CachingClassProvider;
import cuchaz.enigma.classprovider.JarClassProvider;
-import cuchaz.enigma.source.*;
+import cuchaz.enigma.source.Decompiler;
+import cuchaz.enigma.source.Decompilers;
+import cuchaz.enigma.source.Source;
+import cuchaz.enigma.source.SourceIndex;
+import cuchaz.enigma.source.SourceSettings;
+import cuchaz.enigma.source.Token;
import cuchaz.enigma.translation.representation.entry.Entry;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.List;
-
public class TokenChecker {
private final Decompiler decompiler;
@@ -41,9 +47,11 @@ public class TokenChecker {
// get the token value
Token token = index.getDeclarationToken(entry);
+
if (token == null) {
return null;
}
+
return string.substring(token.start, token.end);
}
@@ -56,9 +64,11 @@ public class TokenChecker {
// get the token values
List Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs;
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java
index f07e1f8..a82db77 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java
@@ -1,19 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.constructors;
// a
public class BaseClass {
-
// Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.constructors;
// b
public class Caller {
-
// a()V
public void callBaseDefault() {
// a. Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.constructors;
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java
index bc56b3b..1a90eba 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java
@@ -1,19 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.constructors;
// d extends a
public class SubClass extends BaseClass {
-
// Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.constructors;
// e extends d
public class SubSubClass extends SubClass {
-
// Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.inheritanceTree;
// a
public abstract class BaseClass {
-
// a
private String name;
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java
index 50e963c..ba8c1b7 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java
@@ -1,19 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.inheritanceTree;
// b extends a
public abstract class SubclassA extends BaseClass {
-
// Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.inheritanceTree;
// c extends a
public class SubclassB extends BaseClass {
-
// a
private int numThings;
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java
index c584570..d3bb62e 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java
@@ -1,19 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.inheritanceTree;
// d extends b
public class SubsubclassAA extends SubclassA {
-
protected SubsubclassAA() {
// call to b. Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.innerClasses;
public class A_Anonymous {
-
public void foo() {
Runnable runnable = new Runnable() {
@Override
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java
index d1b7601..6ec27ac 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java
@@ -1,18 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.innerClasses;
public class B_AnonymousWithScopeArgs {
-
public static void foo(final D_Simple arg) {
System.out.println(new Object() {
@Override
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java
index 94061fa..223c424 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java
@@ -1,19 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.innerClasses;
@SuppressWarnings("unused")
public class C_ConstructorArgs {
-
Inner i;
public void foo() {
@@ -21,10 +20,9 @@ public class C_ConstructorArgs {
}
class Inner {
-
private int a;
- public Inner(int a) {
+ Inner(int a) {
this.a = a;
}
}
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java
index 71b3a6d..f401d5f 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java
@@ -1,18 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.innerClasses;
public class D_Simple {
-
class Inner {
// nothing to do
}
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java
index 976ec42..0056bc6 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java
@@ -1,18 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.innerClasses;
public class E_AnonymousWithOuterAccess {
-
// reproduction of error case documented at:
// https://bitbucket.org/cuchaz/enigma/issue/61/stackoverflowerror-when-deobfuscating
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java
index b1de3c9..b2e9e2d 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java
@@ -1,28 +1,24 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.innerClasses;
public class F_ClassTree {
-
public class Level1 {
-
public int f1;
public class Level2 {
-
public int f2;
public class Level3 {
-
public int f3;
}
}
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java
index ddc4e31..e50d37f 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java
@@ -1,18 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.loneClass;
public class LoneClass {
-
private String name;
public LoneClass(String name) {
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java b/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java
index cf0f657..aa8de19 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java
@@ -1,7 +1,6 @@
package cuchaz.enigma.inputs.packageAccess;
public class SamePackageChild extends Base {
-
class Inner {
final int value;
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java b/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java
index 19fb19c..5bcb763 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java
@@ -3,7 +3,6 @@ package cuchaz.enigma.inputs.packageAccess.sub;
import cuchaz.enigma.inputs.packageAccess.Base;
public class OtherPackageChild extends Base {
-
class Inner {
final int value;
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java
index 26f3718..b411e0a 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java
@@ -1,18 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.translation;
public class A_Basic {
-
public int one;
public float two;
public String three;
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java
index fd7f6e7..d5e9a25 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java
@@ -1,18 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.translation;
public class B_BaseClass {
-
public int f1;
public char f2;
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java
index 9d74e44..fd9e217 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java
@@ -1,18 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.translation;
public class C_SubClass extends B_BaseClass {
-
public char f2; // shadows B_BaseClass.f2
public int f3;
public int f4;
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java
index 99c83bb..56cccc7 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
+* Copyright (c) 2015 Jeff Martin.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the GNU Lesser General Public
+* License v3.0 which accompanies this distribution, and is available at
+* http://www.gnu.org/licenses/lgpl.html
+*
+* Contributors:
+* Jeff Martin - initial API and implementation
+******************************************************************************/
package cuchaz.enigma.inputs.translation;
@@ -15,7 +15,6 @@ import java.util.ArrayList;
import java.util.List;
public class D_AnonymousTesting {
-
public List