summaryrefslogtreecommitdiff
path: root/enigma/src/test/java/cuchaz
diff options
context:
space:
mode:
Diffstat (limited to 'enigma/src/test/java/cuchaz')
-rw-r--r--enigma/src/test/java/cuchaz/enigma/ConfigTest.java32
-rw-r--r--enigma/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java43
-rw-r--r--enigma/src/test/java/cuchaz/enigma/TestDeobfed.java54
-rw-r--r--enigma/src/test/java/cuchaz/enigma/TestDeobfuscator.java30
-rw-r--r--enigma/src/test/java/cuchaz/enigma/TestEntryFactory.java22
-rw-r--r--enigma/src/test/java/cuchaz/enigma/TestInnerClasses.java49
-rw-r--r--enigma/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java79
-rw-r--r--enigma/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java114
-rw-r--r--enigma/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java69
-rw-r--r--enigma/src/test/java/cuchaz/enigma/TestMethodDescriptor.java116
-rw-r--r--enigma/src/test/java/cuchaz/enigma/TestTokensConstructors.java98
-rw-r--r--enigma/src/test/java/cuchaz/enigma/TestTranslator.java31
-rw-r--r--enigma/src/test/java/cuchaz/enigma/TestTypeDescriptor.java29
-rw-r--r--enigma/src/test/java/cuchaz/enigma/TokenChecker.java40
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/Keep.java18
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java18
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java22
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java22
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java1
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java1
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java22
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java27
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java33
-rw-r--r--enigma/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java19
-rw-r--r--enigma/src/test/java/cuchaz/enigma/translation/mapping/TestComments.java38
-rw-r--r--enigma/src/test/java/cuchaz/enigma/translation/mapping/TestReadWriteCycle.java43
-rw-r--r--enigma/src/test/java/cuchaz/enigma/translation/mapping/TestTinyV2InnerClasses.java27
-rw-r--r--enigma/src/test/java/cuchaz/enigma/translation/mapping/TestV2Main.java6
-rw-r--r--enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java52
47 files changed, 653 insertions, 844 deletions
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 @@
1package cuchaz.enigma; 1package cuchaz.enigma;
2 2
3import static org.junit.Assert.assertEquals;
4
3import org.junit.Test; 5import org.junit.Test;
4 6
5import cuchaz.enigma.config.ConfigContainer; 7import cuchaz.enigma.config.ConfigContainer;
6 8
7import static org.junit.Assert.assertEquals;
8
9public class ConfigTest { 9public class ConfigTest {
10
11 @Test 10 @Test
12 public void serialize() { 11 public void serialize() {
13 ConfigContainer cc = new ConfigContainer(); 12 ConfigContainer cc = new ConfigContainer();
@@ -17,15 +16,7 @@ public class ConfigTest {
17 cc.data().section("a").section("b").section("c").setInt("c", 5); 16 cc.data().section("a").section("b").section("c").setInt("c", 5);
18 cc.data().section("a").section("b").section("c").setDouble("d", 3.5); 17 cc.data().section("a").section("b").section("c").setDouble("d", 3.5);
19 cc.data().section("a").section("b").section("c").setRgbColor("e", 0x123456); 18 cc.data().section("a").section("b").section("c").setRgbColor("e", 0x123456);
20 assertEquals("a=a\n" + 19 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());
21 "\n" +
22 "[a][b][c]\n" +
23 "a=abcd\n" +
24 "b=true\n" +
25 "c=5\n" +
26 "d=3.5\n" +
27 "e=#123456\n",
28 cc.serialize());
29 } 20 }
30 21
31 @Test 22 @Test
@@ -37,14 +28,7 @@ public class ConfigTest {
37 cc.data().section("a").section("b").section("c").setInt("c", 5); 28 cc.data().section("a").section("b").section("c").setInt("c", 5);
38 cc.data().section("a").section("b").section("c").setDouble("d", 3.5); 29 cc.data().section("a").section("b").section("c").setDouble("d", 3.5);
39 cc.data().section("a").section("b").section("c").setRgbColor("e", 0x123456); 30 cc.data().section("a").section("b").section("c").setRgbColor("e", 0x123456);
40 assertEquals(ConfigContainer.parse("a=a\n" + 31 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());
41 "\n" +
42 "[a][b][c]\n" +
43 "a=abcd\n" +
44 "b=true\n" +
45 "c=5\n" +
46 "d=3.5\n" +
47 "e=#123456\n").data(), cc.data());
48 } 32 }
49 33
50 @Test 34 @Test
@@ -52,12 +36,10 @@ public class ConfigTest {
52 ConfigContainer cc = new ConfigContainer(); 36 ConfigContainer cc = new ConfigContainer();
53 String thing = "\\[],\\,./'\"`~!@#$%^&*()_+-=|}{\n\\\\\r\b\u0000\uffff\u1234"; 37 String thing = "\\[],\\,./'\"`~!@#$%^&*()_+-=|}{\n\\\\\r\b\u0000\uffff\u1234";
54 cc.data().section(thing).setString(thing, thing); 38 cc.data().section(thing).setString(thing, thing);
55 cc.data().section(thing).setArray("arr", new String[] { thing, thing, thing, thing }); 39 cc.data().section(thing).setArray("arr", new String[]{thing, thing, thing, thing});
56 40
57 assertEquals( 41 assertEquals(
58 "[\\\\[\\],\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234]\n" + 42 "[\\\\[\\],\\\\,./'\"`~!@#$%^&*()_+-=|}{\\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",
59 "\\\\\\[],\\\\,./'\"`~!@#$%^&*()_+-\\=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234=\\\\[],\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234\n" +
60 "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",
61 cc.serialize()); 43 cc.serialize());
62 44
63 ConfigContainer cc1 = ConfigContainer.parse(cc.serialize()); 45 ConfigContainer cc1 = ConfigContainer.parse(cc.serialize());
@@ -77,10 +59,8 @@ public class ConfigTest {
77 assertEquals("", ConfigContainer.parse("[").serialize()); 59 assertEquals("", ConfigContainer.parse("[").serialize());
78 assertEquals("[a]\na=b\nc=d\n", ConfigContainer.parse("[a]\na=b\n[\nc=d").serialize()); 60 assertEquals("[a]\na=b\nc=d\n", ConfigContainer.parse("[a]\na=b\n[\nc=d").serialize());
79 61
80
81 // not technically syntax errors but never something that gets generated 62 // not technically syntax errors but never something that gets generated
82 assertEquals("", ConfigContainer.parse("[a]").serialize()); 63 assertEquals("", ConfigContainer.parse("[a]").serialize());
83 assertEquals("", ConfigContainer.parse("[a]\n[b]").serialize()); 64 assertEquals("", ConfigContainer.parse("[a]\n[b]").serialize());
84 } 65 }
85
86} 66}
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma; 12package cuchaz.enigma;
13 13
14import cuchaz.enigma.analysis.index.JarIndex;
15import cuchaz.enigma.analysis.index.PackageVisibilityIndex;
16import cuchaz.enigma.classprovider.JarClassProvider;
17import cuchaz.enigma.translation.representation.entry.ClassEntry;
18import org.junit.Test;
19
20import java.nio.file.Path;
21import java.nio.file.Paths;
22
23import static cuchaz.enigma.TestEntryFactory.newClass; 14import static cuchaz.enigma.TestEntryFactory.newClass;
24import static org.hamcrest.MatcherAssert.assertThat; 15import static org.hamcrest.MatcherAssert.assertThat;
25import static org.hamcrest.Matchers.contains; 16import static org.hamcrest.Matchers.contains;
26import static org.hamcrest.Matchers.containsInAnyOrder; 17import static org.hamcrest.Matchers.containsInAnyOrder;
27 18
19import java.nio.file.Path;
20import java.nio.file.Paths;
21
22import org.junit.Test;
23
24import cuchaz.enigma.analysis.index.JarIndex;
25import cuchaz.enigma.analysis.index.PackageVisibilityIndex;
26import cuchaz.enigma.classprovider.JarClassProvider;
27import cuchaz.enigma.translation.representation.entry.ClassEntry;
28
28public class PackageVisibilityIndexTest { 29public class PackageVisibilityIndexTest {
29 public static final Path JAR = Paths.get("build/test-obf/packageAccess.jar"); 30 public static final Path JAR = Paths.get("build/test-obf/packageAccess.jar");
30 private static final ClassEntry KEEP = newClass("cuchaz/enigma/inputs/Keep"); 31 private static final ClassEntry KEEP = newClass("cuchaz/enigma/inputs/Keep");
@@ -46,10 +47,6 @@ public class PackageVisibilityIndexTest {
46 PackageVisibilityIndex visibilityIndex = jarIndex.getPackageVisibilityIndex(); 47 PackageVisibilityIndex visibilityIndex = jarIndex.getPackageVisibilityIndex();
47 assertThat(visibilityIndex.getPartition(BASE), containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER)); 48 assertThat(visibilityIndex.getPartition(BASE), containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER));
48 System.out.println(visibilityIndex.getPartitions()); 49 System.out.println(visibilityIndex.getPartitions());
49 assertThat(visibilityIndex.getPartitions(), containsInAnyOrder( 50 assertThat(visibilityIndex.getPartitions(), containsInAnyOrder(containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER), containsInAnyOrder(OTHER_PACKAGE_CHILD, OTHER_PACKAGE_CHILD_INNER), contains(KEEP)));
50 containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER),
51 containsInAnyOrder(OTHER_PACKAGE_CHILD, OTHER_PACKAGE_CHILD_INNER),
52 contains(KEEP)
53 ));
54 } 51 }
55} 52}
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma; 12package cuchaz.enigma;
13 13
14import static cuchaz.enigma.TestEntryFactory.newClass;
15import static org.hamcrest.MatcherAssert.assertThat;
16import static org.hamcrest.Matchers.containsInAnyOrder;
17
14import java.nio.file.Files; 18import java.nio.file.Files;
15import java.nio.file.Path; 19import java.nio.file.Path;
16import java.nio.file.Paths; 20import java.nio.file.Paths;
@@ -23,10 +27,6 @@ import cuchaz.enigma.source.Decompiler;
23import cuchaz.enigma.source.Decompilers; 27import cuchaz.enigma.source.Decompilers;
24import cuchaz.enigma.source.SourceSettings; 28import cuchaz.enigma.source.SourceSettings;
25 29
26import static cuchaz.enigma.TestEntryFactory.newClass;
27import static org.hamcrest.MatcherAssert.assertThat;
28import static org.hamcrest.Matchers.containsInAnyOrder;
29
30public class TestDeobfed { 30public class TestDeobfed {
31 public static final Path OBF = Paths.get("build/test-obf/translation.jar"); 31 public static final Path OBF = Paths.get("build/test-obf/translation.jar");
32 public static final Path DEOBF = Paths.get("build/test-deobf/translation.jar"); 32 public static final Path DEOBF = Paths.get("build/test-deobf/translation.jar");
@@ -45,31 +45,9 @@ public class TestDeobfed {
45 45
46 @Test 46 @Test
47 public void obfEntries() { 47 public void obfEntries() {
48 assertThat(deobfProject.getJarIndex().getEntryIndex().getClasses(), containsInAnyOrder( 48 assertThat(deobfProject.getJarIndex().getEntryIndex().getClasses(),
49 newClass("cuchaz/enigma/inputs/Keep"), 49 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"),
50 newClass("a"), 50 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")));
51 newClass("b"),
52 newClass("c"),
53 newClass("d"),
54 newClass("d$1"),
55 newClass("e"),
56 newClass("f"),
57 newClass("g"),
58 newClass("g$a"),
59 newClass("g$a$a"),
60 newClass("g$b"),
61 newClass("g$b$a"),
62 newClass("h"),
63 newClass("h$a"),
64 newClass("h$a$a"),
65 newClass("h$b"),
66 newClass("h$b$a"),
67 newClass("h$b$a$a"),
68 newClass("h$b$a$b"),
69 newClass("i"),
70 newClass("i$a"),
71 newClass("i$b")
72 ));
73 } 51 }
74 52
75 @Test 53 @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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma; 12package cuchaz.enigma;
13 13
14import java.io.IOException;
15import java.nio.file.Paths;
16
17import org.junit.Test;
18
14import cuchaz.enigma.classprovider.ClasspathClassProvider; 19import cuchaz.enigma.classprovider.ClasspathClassProvider;
15import cuchaz.enigma.source.Decompiler; 20import cuchaz.enigma.source.Decompiler;
16import cuchaz.enigma.source.Decompilers; 21import cuchaz.enigma.source.Decompilers;
17import cuchaz.enigma.source.SourceSettings; 22import cuchaz.enigma.source.SourceSettings;
18import org.junit.Test;
19
20import java.io.IOException;
21import java.nio.file.Paths;
22 23
23public class TestDeobfuscator { 24public class TestDeobfuscator {
24 private EnigmaProject openProject() throws IOException { 25 private EnigmaProject openProject() throws IOException {
@@ -27,8 +28,7 @@ public class TestDeobfuscator {
27 } 28 }
28 29
29 @Test 30 @Test
30 public void loadJar() 31 public void loadJar() throws Exception {
31 throws Exception {
32 openProject(); 32 openProject();
33 } 33 }
34 34
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma; 12package cuchaz.enigma;
13 13
14import cuchaz.enigma.analysis.EntryReference; 14import cuchaz.enigma.analysis.EntryReference;
15import cuchaz.enigma.translation.representation.*; 15import cuchaz.enigma.translation.representation.MethodDescriptor;
16import cuchaz.enigma.translation.representation.TypeDescriptor;
16import cuchaz.enigma.translation.representation.entry.ClassEntry; 17import cuchaz.enigma.translation.representation.entry.ClassEntry;
17import cuchaz.enigma.translation.representation.entry.FieldEntry; 18import cuchaz.enigma.translation.representation.entry.FieldEntry;
18import cuchaz.enigma.translation.representation.entry.MethodEntry; 19import cuchaz.enigma.translation.representation.entry.MethodEntry;
19 20
20public class TestEntryFactory { 21public class TestEntryFactory {
21
22 public static ClassEntry newClass(String name) { 22 public static ClassEntry newClass(String name) {
23 return new ClassEntry(name); 23 return new ClassEntry(name);
24 } 24 }
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma; 12package cuchaz.enigma;
13 13
14import static cuchaz.enigma.TestEntryFactory.newClass;
15import static org.hamcrest.MatcherAssert.assertThat;
16import static org.hamcrest.Matchers.is;
17
18import java.nio.file.Path;
19import java.nio.file.Paths;
20
21import org.junit.Test;
22
14import cuchaz.enigma.analysis.index.JarIndex; 23import cuchaz.enigma.analysis.index.JarIndex;
15import cuchaz.enigma.classprovider.CachingClassProvider; 24import cuchaz.enigma.classprovider.CachingClassProvider;
16import cuchaz.enigma.classprovider.JarClassProvider; 25import cuchaz.enigma.classprovider.JarClassProvider;
@@ -18,17 +27,8 @@ import cuchaz.enigma.source.Decompiler;
18import cuchaz.enigma.source.Decompilers; 27import cuchaz.enigma.source.Decompilers;
19import cuchaz.enigma.source.SourceSettings; 28import cuchaz.enigma.source.SourceSettings;
20import cuchaz.enigma.translation.representation.entry.ClassEntry; 29import cuchaz.enigma.translation.representation.entry.ClassEntry;
21import org.junit.Test;
22
23import java.nio.file.Path;
24import java.nio.file.Paths;
25
26import static cuchaz.enigma.TestEntryFactory.newClass;
27import static org.hamcrest.MatcherAssert.assertThat;
28import static org.hamcrest.Matchers.is;
29 30
30public class TestInnerClasses { 31public class TestInnerClasses {
31
32 private static final ClassEntry SimpleOuter = newClass("d"); 32 private static final ClassEntry SimpleOuter = newClass("d");
33 private static final ClassEntry SimpleInner = newClass("d$a"); 33 private static final ClassEntry SimpleInner = newClass("d$a");
34 private static final ClassEntry ConstructorArgsOuter = newClass("c"); 34 private static final ClassEntry ConstructorArgsOuter = newClass("c");
@@ -61,26 +61,19 @@ public class TestInnerClasses {
61 61
62 @Test 62 @Test
63 public void classTree() { 63 public void classTree() {
64
65 // root level 64 // root level
66 assertThat(index.getEntryIndex().hasClass(ClassTreeRoot), is(true)); 65 assertThat(index.getEntryIndex().hasClass(ClassTreeRoot), is(true));
67 66
68 // level 1 67 // level 1
69 ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName() 68 ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName() + "$" + ClassTreeLevel1.getSimpleName());
70 + "$" + ClassTreeLevel1.getSimpleName());
71 assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); 69 assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true));
72 70
73 // level 2 71 // level 2
74 fullClassEntry = new ClassEntry(ClassTreeRoot.getName() 72 fullClassEntry = new ClassEntry(ClassTreeRoot.getName() + "$" + ClassTreeLevel1.getSimpleName() + "$" + ClassTreeLevel2.getSimpleName());
75 + "$" + ClassTreeLevel1.getSimpleName()
76 + "$" + ClassTreeLevel2.getSimpleName());
77 assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); 73 assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true));
78 74
79 // level 3 75 // level 3
80 fullClassEntry = new ClassEntry(ClassTreeRoot.getName() 76 fullClassEntry = new ClassEntry(ClassTreeRoot.getName() + "$" + ClassTreeLevel1.getSimpleName() + "$" + ClassTreeLevel2.getSimpleName() + "$" + ClassTreeLevel3.getSimpleName());
81 + "$" + ClassTreeLevel1.getSimpleName()
82 + "$" + ClassTreeLevel2.getSimpleName()
83 + "$" + ClassTreeLevel3.getSimpleName());
84 assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); 77 assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true));
85 } 78 }
86 79
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma; 12package cuchaz.enigma;
13 13
14import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod;
15import static cuchaz.enigma.TestEntryFactory.newClass;
16import static cuchaz.enigma.TestEntryFactory.newMethod;
17import static org.hamcrest.MatcherAssert.assertThat;
18import static org.hamcrest.Matchers.containsInAnyOrder;
19import static org.hamcrest.Matchers.empty;
20import static org.hamcrest.Matchers.is;
21
22import java.nio.file.Path;
23import java.nio.file.Paths;
24import java.util.Collection;
25
26import org.junit.Test;
27
14import cuchaz.enigma.analysis.EntryReference; 28import cuchaz.enigma.analysis.EntryReference;
15import cuchaz.enigma.analysis.index.JarIndex; 29import cuchaz.enigma.analysis.index.JarIndex;
16import cuchaz.enigma.classprovider.CachingClassProvider; 30import cuchaz.enigma.classprovider.CachingClassProvider;
@@ -18,18 +32,8 @@ import cuchaz.enigma.classprovider.JarClassProvider;
18import cuchaz.enigma.translation.representation.entry.ClassEntry; 32import cuchaz.enigma.translation.representation.entry.ClassEntry;
19import cuchaz.enigma.translation.representation.entry.MethodDefEntry; 33import cuchaz.enigma.translation.representation.entry.MethodDefEntry;
20import cuchaz.enigma.translation.representation.entry.MethodEntry; 34import cuchaz.enigma.translation.representation.entry.MethodEntry;
21import org.junit.Test;
22
23import java.nio.file.Path;
24import java.nio.file.Paths;
25import java.util.Collection;
26
27import static cuchaz.enigma.TestEntryFactory.*;
28import static org.hamcrest.MatcherAssert.assertThat;
29import static org.hamcrest.Matchers.*;
30 35
31public class TestJarIndexConstructorReferences { 36public class TestJarIndexConstructorReferences {
32
33 public static final Path JAR = Paths.get("build/test-obf/constructors.jar"); 37 public static final Path JAR = Paths.get("build/test-obf/constructors.jar");
34 private JarIndex index; 38 private JarIndex index;
35 39
@@ -47,8 +51,7 @@ public class TestJarIndexConstructorReferences {
47 51
48 @Test 52 @Test
49 public void obfEntries() { 53 public void obfEntries() {
50 assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, 54 assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClass, subsubClass, defaultClass, callerClass));
51 subClass, subsubClass, defaultClass, callerClass));
52 } 55 }
53 56
54 @Test 57 @Test
@@ -56,50 +59,36 @@ public class TestJarIndexConstructorReferences {
56 public void baseDefault() { 59 public void baseDefault() {
57 MethodEntry source = newMethod(baseClass, "<init>", "()V"); 60 MethodEntry source = newMethod(baseClass, "<init>", "()V");
58 Collection<EntryReference<MethodEntry, MethodDefEntry>> references = index.getReferenceIndex().getReferencesToMethod(source); 61 Collection<EntryReference<MethodEntry, MethodDefEntry>> references = index.getReferenceIndex().getReferencesToMethod(source);
59 assertThat(references, containsInAnyOrder( 62 assertThat(references, containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"), newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "()V"), newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(III)V")));
60 newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"),
61 newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "()V"),
62 newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(III)V")
63 ));
64 } 63 }
65 64
66 @Test 65 @Test
67 @SuppressWarnings("unchecked") 66 @SuppressWarnings("unchecked")
68 public void baseInt() { 67 public void baseInt() {
69 MethodEntry source = newMethod(baseClass, "<init>", "(I)V"); 68 MethodEntry source = newMethod(baseClass, "<init>", "(I)V");
70 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( 69 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V")));
71 newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V")
72 ));
73 } 70 }
74 71
75 @Test 72 @Test
76 @SuppressWarnings("unchecked") 73 @SuppressWarnings("unchecked")
77 public void subDefault() { 74 public void subDefault() {
78 MethodEntry source = newMethod(subClass, "<init>", "()V"); 75 MethodEntry source = newMethod(subClass, "<init>", "()V");
79 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( 76 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "c", "()V"), newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(I)V")));
80 newBehaviorReferenceByMethod(source, callerClass.getName(), "c", "()V"),
81 newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(I)V")
82 ));
83 } 77 }
84 78
85 @Test 79 @Test
86 @SuppressWarnings("unchecked") 80 @SuppressWarnings("unchecked")
87 public void subInt() { 81 public void subInt() {
88 MethodEntry source = newMethod(subClass, "<init>", "(I)V"); 82 MethodEntry source = newMethod(subClass, "<init>", "(I)V");
89 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( 83 assertThat(index.getReferenceIndex().getReferencesToMethod(source),
90 newBehaviorReferenceByMethod(source, callerClass.getName(), "d", "()V"), 84 containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "d", "()V"), newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(II)V"), newBehaviorReferenceByMethod(source, subsubClass.getName(), "<init>", "(I)V")));
91 newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(II)V"),
92 newBehaviorReferenceByMethod(source, subsubClass.getName(), "<init>", "(I)V")
93 ));
94 } 85 }
95 86
96 @Test 87 @Test
97 @SuppressWarnings("unchecked") 88 @SuppressWarnings("unchecked")
98 public void subIntInt() { 89 public void subIntInt() {
99 MethodEntry source = newMethod(subClass, "<init>", "(II)V"); 90 MethodEntry source = newMethod(subClass, "<init>", "(II)V");
100 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( 91 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V")));
101 newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V")
102 ));
103 } 92 }
104 93
105 @Test 94 @Test
@@ -112,17 +101,13 @@ public class TestJarIndexConstructorReferences {
112 @SuppressWarnings("unchecked") 101 @SuppressWarnings("unchecked")
113 public void subsubInt() { 102 public void subsubInt() {
114 MethodEntry source = newMethod(subsubClass, "<init>", "(I)V"); 103 MethodEntry source = newMethod(subsubClass, "<init>", "(I)V");
115 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( 104 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V")));
116 newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V")
117 ));
118 } 105 }
119 106
120 @Test 107 @Test
121 @SuppressWarnings("unchecked") 108 @SuppressWarnings("unchecked")
122 public void defaultConstructable() { 109 public void defaultConstructable() {
123 MethodEntry source = newMethod(defaultClass, "<init>", "()V"); 110 MethodEntry source = newMethod(defaultClass, "<init>", "()V");
124 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( 111 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "g", "()V")));
125 newBehaviorReferenceByMethod(source, callerClass.getName(), "g", "()V")
126 ));
127 } 112 }
128} 113}
diff --git a/enigma/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java b/enigma/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java
index a9045f9..3f6f151 100644
--- a/enigma/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java
+++ b/enigma/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java
@@ -1,16 +1,34 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma; 12package cuchaz.enigma;
13 13
14import static cuchaz.enigma.TestEntryFactory.newClass;
15import static cuchaz.enigma.TestEntryFactory.newField;
16import static cuchaz.enigma.TestEntryFactory.newMethod;
17import static cuchaz.enigma.TestEntryFactory.newFieldReferenceByMethod;
18import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod;
19import static org.hamcrest.MatcherAssert.assertThat;
20import static org.hamcrest.Matchers.contains;
21import static org.hamcrest.Matchers.containsInAnyOrder;
22import static org.hamcrest.Matchers.empty;
23import static org.hamcrest.Matchers.is;
24
25import java.nio.file.Path;
26import java.nio.file.Paths;
27import java.util.Collection;
28
29import org.junit.Test;
30import org.objectweb.asm.Opcodes;
31
14import cuchaz.enigma.analysis.EntryReference; 32import cuchaz.enigma.analysis.EntryReference;
15import cuchaz.enigma.analysis.index.EntryIndex; 33import cuchaz.enigma.analysis.index.EntryIndex;
16import cuchaz.enigma.analysis.index.InheritanceIndex; 34import cuchaz.enigma.analysis.index.InheritanceIndex;
@@ -24,19 +42,8 @@ import cuchaz.enigma.translation.representation.entry.ClassEntry;
24import cuchaz.enigma.translation.representation.entry.FieldEntry; 42import cuchaz.enigma.translation.representation.entry.FieldEntry;
25import cuchaz.enigma.translation.representation.entry.MethodDefEntry; 43import cuchaz.enigma.translation.representation.entry.MethodDefEntry;
26import cuchaz.enigma.translation.representation.entry.MethodEntry; 44import cuchaz.enigma.translation.representation.entry.MethodEntry;
27import org.junit.Test;
28import org.objectweb.asm.Opcodes;
29
30import java.nio.file.Path;
31import java.nio.file.Paths;
32import java.util.Collection;
33
34import static cuchaz.enigma.TestEntryFactory.*;
35import static org.hamcrest.MatcherAssert.assertThat;
36import static org.hamcrest.Matchers.*;
37 45
38public class TestJarIndexInheritanceTree { 46public class TestJarIndexInheritanceTree {
39
40 public static final Path JAR = Paths.get("build/test-obf/inheritanceTree.jar"); 47 public static final Path JAR = Paths.get("build/test-obf/inheritanceTree.jar");
41 private JarIndex index; 48 private JarIndex index;
42 49
@@ -55,21 +62,17 @@ public class TestJarIndexInheritanceTree {
55 62
56 @Test 63 @Test
57 public void obfEntries() { 64 public void obfEntries() {
58 assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder( 65 assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClassA, subClassAA, subClassB));
59 newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClassA, subClassAA, subClassB
60 ));
61 } 66 }
62 67
63 @Test 68 @Test
64 public void translationIndex() { 69 public void translationIndex() {
65
66 InheritanceIndex index = this.index.getInheritanceIndex(); 70 InheritanceIndex index = this.index.getInheritanceIndex();
67 71
68 // base class 72 // base class
69 assertThat(index.getParents(baseClass), is(empty())); 73 assertThat(index.getParents(baseClass), is(empty()));
70 assertThat(index.getAncestors(baseClass), is(empty())); 74 assertThat(index.getAncestors(baseClass), is(empty()));
71 assertThat(index.getChildren(baseClass), containsInAnyOrder(subClassA, subClassB 75 assertThat(index.getChildren(baseClass), containsInAnyOrder(subClassA, subClassB));
72 ));
73 76
74 // subclass a 77 // subclass a
75 assertThat(index.getParents(subClassA), contains(baseClass)); 78 assertThat(index.getParents(subClassA), contains(baseClass));
@@ -95,41 +98,22 @@ public class TestJarIndexInheritanceTree {
95 98
96 @Test 99 @Test
97 public void relatedMethodImplementations() { 100 public void relatedMethodImplementations() {
98
99 Collection<MethodEntry> entries; 101 Collection<MethodEntry> entries;
100 102
101 EntryResolver resolver = new IndexEntryResolver(index); 103 EntryResolver resolver = new IndexEntryResolver(index);
102 // getName() 104 // getName()
103 entries = resolver.resolveEquivalentMethods(newMethod(baseClass, "a", "()Ljava/lang/String;")); 105 entries = resolver.resolveEquivalentMethods(newMethod(baseClass, "a", "()Ljava/lang/String;"));
104 assertThat(entries, containsInAnyOrder( 106 assertThat(entries, containsInAnyOrder(newMethod(baseClass, "a", "()Ljava/lang/String;"), newMethod(subClassAA, "a", "()Ljava/lang/String;")));
105 newMethod(baseClass, "a", "()Ljava/lang/String;"),
106 newMethod(subClassAA, "a", "()Ljava/lang/String;")
107 ));
108 entries = resolver.resolveEquivalentMethods(newMethod(subClassAA, "a", "()Ljava/lang/String;")); 107 entries = resolver.resolveEquivalentMethods(newMethod(subClassAA, "a", "()Ljava/lang/String;"));
109 assertThat(entries, containsInAnyOrder( 108 assertThat(entries, containsInAnyOrder(newMethod(baseClass, "a", "()Ljava/lang/String;"), newMethod(subClassAA, "a", "()Ljava/lang/String;")));
110 newMethod(baseClass, "a", "()Ljava/lang/String;"),
111 newMethod(subClassAA, "a", "()Ljava/lang/String;")
112 ));
113 109
114 // doBaseThings() 110 // doBaseThings()
115 entries = resolver.resolveEquivalentMethods(newMethod(baseClass, "a", "()V")); 111 entries = resolver.resolveEquivalentMethods(newMethod(baseClass, "a", "()V"));
116 assertThat(entries, containsInAnyOrder( 112 assertThat(entries, containsInAnyOrder(newMethod(baseClass, "a", "()V"), newMethod(subClassAA, "a", "()V"), newMethod(subClassB, "a", "()V")));
117 newMethod(baseClass, "a", "()V"),
118 newMethod(subClassAA, "a", "()V"),
119 newMethod(subClassB, "a", "()V")
120 ));
121 entries = resolver.resolveEquivalentMethods(newMethod(subClassAA, "a", "()V")); 113 entries = resolver.resolveEquivalentMethods(newMethod(subClassAA, "a", "()V"));
122 assertThat(entries, containsInAnyOrder( 114 assertThat(entries, containsInAnyOrder(newMethod(baseClass, "a", "()V"), newMethod(subClassAA, "a", "()V"), newMethod(subClassB, "a", "()V")));
123 newMethod(baseClass, "a", "()V"),
124 newMethod(subClassAA, "a", "()V"),
125 newMethod(subClassB, "a", "()V")
126 ));
127 entries = resolver.resolveEquivalentMethods(newMethod(subClassB, "a", "()V")); 115 entries = resolver.resolveEquivalentMethods(newMethod(subClassB, "a", "()V"));
128 assertThat(entries, containsInAnyOrder( 116 assertThat(entries, containsInAnyOrder(newMethod(baseClass, "a", "()V"), newMethod(subClassAA, "a", "()V"), newMethod(subClassB, "a", "()V")));
129 newMethod(baseClass, "a", "()V"),
130 newMethod(subClassAA, "a", "()V"),
131 newMethod(subClassB, "a", "()V")
132 ));
133 117
134 // doBThings 118 // doBThings
135 entries = resolver.resolveEquivalentMethods(newMethod(subClassB, "b", "()V")); 119 entries = resolver.resolveEquivalentMethods(newMethod(subClassB, "b", "()V"));
@@ -143,55 +127,38 @@ public class TestJarIndexInheritanceTree {
143 127
144 // name 128 // name
145 references = index.getReferenceIndex().getReferencesToField(nameField); 129 references = index.getReferenceIndex().getReferencesToField(nameField);
146 assertThat(references, containsInAnyOrder( 130 assertThat(references, containsInAnyOrder(newFieldReferenceByMethod(nameField, baseClass.getName(), "<init>", "(Ljava/lang/String;)V"), newFieldReferenceByMethod(nameField, baseClass.getName(), "a", "()Ljava/lang/String;")));
147 newFieldReferenceByMethod(nameField, baseClass.getName(), "<init>", "(Ljava/lang/String;)V"),
148 newFieldReferenceByMethod(nameField, baseClass.getName(), "a", "()Ljava/lang/String;")
149 ));
150 131
151 // numThings 132 // numThings
152 references = index.getReferenceIndex().getReferencesToField(numThingsField); 133 references = index.getReferenceIndex().getReferencesToField(numThingsField);
153 assertThat(references, containsInAnyOrder( 134 assertThat(references, containsInAnyOrder(newFieldReferenceByMethod(numThingsField, subClassB.getName(), "<init>", "()V"), newFieldReferenceByMethod(numThingsField, subClassB.getName(), "b", "()V")));
154 newFieldReferenceByMethod(numThingsField, subClassB.getName(), "<init>", "()V"),
155 newFieldReferenceByMethod(numThingsField, subClassB.getName(), "b", "()V")
156 ));
157 } 135 }
158 136
159 @Test 137 @Test
160 @SuppressWarnings("unchecked") 138 @SuppressWarnings("unchecked")
161 public void behaviorReferences() { 139 public void behaviorReferences() {
162
163 MethodEntry source; 140 MethodEntry source;
164 Collection<EntryReference<MethodEntry, MethodDefEntry>> references; 141 Collection<EntryReference<MethodEntry, MethodDefEntry>> references;
165 142
166 // baseClass constructor 143 // baseClass constructor
167 source = newMethod(baseClass, "<init>", "(Ljava/lang/String;)V"); 144 source = newMethod(baseClass, "<init>", "(Ljava/lang/String;)V");
168 references = index.getReferenceIndex().getReferencesToMethod(source); 145 references = index.getReferenceIndex().getReferencesToMethod(source);
169 assertThat(references, containsInAnyOrder( 146 assertThat(references, containsInAnyOrder(newBehaviorReferenceByMethod(source, subClassA.getName(), "<init>", "(Ljava/lang/String;)V"), newBehaviorReferenceByMethod(source, subClassB.getName(), "<init>", "()V")));
170 newBehaviorReferenceByMethod(source, subClassA.getName(), "<init>", "(Ljava/lang/String;)V"),
171 newBehaviorReferenceByMethod(source, subClassB.getName(), "<init>", "()V")
172 ));
173 147
174 // subClassA constructor 148 // subClassA constructor
175 source = newMethod(subClassA, "<init>", "(Ljava/lang/String;)V"); 149 source = newMethod(subClassA, "<init>", "(Ljava/lang/String;)V");
176 references = index.getReferenceIndex().getReferencesToMethod(source); 150 references = index.getReferenceIndex().getReferencesToMethod(source);
177 assertThat(references, containsInAnyOrder( 151 assertThat(references, containsInAnyOrder(newBehaviorReferenceByMethod(source, subClassAA.getName(), "<init>", "()V")));
178 newBehaviorReferenceByMethod(source, subClassAA.getName(), "<init>", "()V")
179 ));
180 152
181 // baseClass.getName() 153 // baseClass.getName()
182 source = newMethod(baseClass, "a", "()Ljava/lang/String;"); 154 source = newMethod(baseClass, "a", "()Ljava/lang/String;");
183 references = index.getReferenceIndex().getReferencesToMethod(source); 155 references = index.getReferenceIndex().getReferencesToMethod(source);
184 assertThat(references, containsInAnyOrder( 156 assertThat(references, containsInAnyOrder(newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()Ljava/lang/String;"), newBehaviorReferenceByMethod(source, subClassB.getName(), "a", "()V")));
185 newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()Ljava/lang/String;"),
186 newBehaviorReferenceByMethod(source, subClassB.getName(), "a", "()V")
187 ));
188 157
189 // subclassAA.getName() 158 // subclassAA.getName()
190 source = newMethod(subClassAA, "a", "()Ljava/lang/String;"); 159 source = newMethod(subClassAA, "a", "()Ljava/lang/String;");
191 references = index.getReferenceIndex().getReferencesToMethod(source); 160 references = index.getReferenceIndex().getReferencesToMethod(source);
192 assertThat(references, containsInAnyOrder( 161 assertThat(references, containsInAnyOrder(newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()V")));
193 newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()V")
194 ));
195 } 162 }
196 163
197 @Test 164 @Test
@@ -225,6 +192,5 @@ public class TestJarIndexInheritanceTree {
225 assertThat(entryIndex.hasMethod(newMethod(subClassA, "b", "()V")), is(false)); 192 assertThat(entryIndex.hasMethod(newMethod(subClassA, "b", "()V")), is(false));
226 assertThat(entryIndex.hasMethod(newMethod(subClassAA, "b", "()V")), is(false)); 193 assertThat(entryIndex.hasMethod(newMethod(subClassAA, "b", "()V")), is(false));
227 assertThat(entryIndex.hasMethod(newMethod(subClassB, "b", "()V")), is(true)); 194 assertThat(entryIndex.hasMethod(newMethod(subClassB, "b", "()V")), is(true));
228
229 } 195 }
230} 196}
diff --git a/enigma/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java b/enigma/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java
index 6e3755c..dcbe95f 100644
--- a/enigma/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java
+++ b/enigma/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java
@@ -1,17 +1,41 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma; 12package cuchaz.enigma;
13 13
14import cuchaz.enigma.analysis.*; 14import static cuchaz.enigma.TestEntryFactory.newClass;
15import static cuchaz.enigma.TestEntryFactory.newField;
16import static cuchaz.enigma.TestEntryFactory.newFieldReferenceByMethod;
17import static cuchaz.enigma.TestEntryFactory.newMethod;
18import static org.hamcrest.MatcherAssert.assertThat;
19import static org.hamcrest.Matchers.containsInAnyOrder;
20import static org.hamcrest.Matchers.empty;
21import static org.hamcrest.Matchers.hasSize;
22import static org.hamcrest.Matchers.is;
23import static org.hamcrest.Matchers.not;
24import static org.hamcrest.Matchers.nullValue;
25
26import java.nio.file.Path;
27import java.nio.file.Paths;
28import java.util.Collection;
29import java.util.List;
30
31import org.junit.Test;
32
33import cuchaz.enigma.analysis.ClassImplementationsTreeNode;
34import cuchaz.enigma.analysis.ClassInheritanceTreeNode;
35import cuchaz.enigma.analysis.EntryReference;
36import cuchaz.enigma.analysis.IndexTreeBuilder;
37import cuchaz.enigma.analysis.MethodImplementationsTreeNode;
38import cuchaz.enigma.analysis.MethodInheritanceTreeNode;
15import cuchaz.enigma.analysis.index.EntryIndex; 39import cuchaz.enigma.analysis.index.EntryIndex;
16import cuchaz.enigma.analysis.index.InheritanceIndex; 40import cuchaz.enigma.analysis.index.InheritanceIndex;
17import cuchaz.enigma.analysis.index.JarIndex; 41import cuchaz.enigma.analysis.index.JarIndex;
@@ -23,19 +47,8 @@ import cuchaz.enigma.translation.representation.entry.ClassEntry;
23import cuchaz.enigma.translation.representation.entry.FieldEntry; 47import cuchaz.enigma.translation.representation.entry.FieldEntry;
24import cuchaz.enigma.translation.representation.entry.MethodDefEntry; 48import cuchaz.enigma.translation.representation.entry.MethodDefEntry;
25import cuchaz.enigma.translation.representation.entry.MethodEntry; 49import cuchaz.enigma.translation.representation.entry.MethodEntry;
26import org.junit.Test;
27
28import java.nio.file.Path;
29import java.nio.file.Paths;
30import java.util.Collection;
31import java.util.List;
32
33import static cuchaz.enigma.TestEntryFactory.*;
34import static org.hamcrest.MatcherAssert.assertThat;
35import static org.hamcrest.Matchers.*;
36 50
37public class TestJarIndexLoneClass { 51public class TestJarIndexLoneClass {
38
39 public static final Path JAR = Paths.get("build/test-obf/loneClass.jar"); 52 public static final Path JAR = Paths.get("build/test-obf/loneClass.jar");
40 private JarIndex index; 53 private JarIndex index;
41 54
@@ -47,10 +60,7 @@ public class TestJarIndexLoneClass {
47 60
48 @Test 61 @Test
49 public void obfEntries() { 62 public void obfEntries() {
50 assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder( 63 assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), newClass("a")));
51 newClass("cuchaz/enigma/inputs/Keep"),
52 newClass("a")
53 ));
54 } 64 }
55 65
56 @Test 66 @Test
@@ -112,9 +122,7 @@ public class TestJarIndexLoneClass {
112 @Test 122 @Test
113 public void relatedMethodImplementations() { 123 public void relatedMethodImplementations() {
114 Collection<MethodEntry> entries = index.getEntryResolver().resolveEquivalentMethods(newMethod("a", "a", "()Ljava/lang/String;")); 124 Collection<MethodEntry> entries = index.getEntryResolver().resolveEquivalentMethods(newMethod("a", "a", "()Ljava/lang/String;"));
115 assertThat(entries, containsInAnyOrder( 125 assertThat(entries, containsInAnyOrder(newMethod("a", "a", "()Ljava/lang/String;")));
116 newMethod("a", "a", "()Ljava/lang/String;")
117 ));
118 } 126 }
119 127
120 @Test 128 @Test
@@ -122,10 +130,7 @@ public class TestJarIndexLoneClass {
122 public void fieldReferences() { 130 public void fieldReferences() {
123 FieldEntry source = newField("a", "a", "Ljava/lang/String;"); 131 FieldEntry source = newField("a", "a", "Ljava/lang/String;");
124 Collection<EntryReference<FieldEntry, MethodDefEntry>> references = index.getReferenceIndex().getReferencesToField(source); 132 Collection<EntryReference<FieldEntry, MethodDefEntry>> references = index.getReferenceIndex().getReferencesToField(source);
125 assertThat(references, containsInAnyOrder( 133 assertThat(references, containsInAnyOrder(newFieldReferenceByMethod(source, "a", "<init>", "(Ljava/lang/String;)V"), newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;")));
126 newFieldReferenceByMethod(source, "a", "<init>", "(Ljava/lang/String;)V"),
127 newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;")
128 ));
129 } 134 }
130 135
131 @Test 136 @Test
diff --git a/enigma/src/test/java/cuchaz/enigma/TestMethodDescriptor.java b/enigma/src/test/java/cuchaz/enigma/TestMethodDescriptor.java
index a73880d..918466b 100644
--- a/enigma/src/test/java/cuchaz/enigma/TestMethodDescriptor.java
+++ b/enigma/src/test/java/cuchaz/enigma/TestMethodDescriptor.java
@@ -1,25 +1,28 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma; 12package cuchaz.enigma;
13 13
14import cuchaz.enigma.translation.representation.MethodDescriptor; 14import static org.hamcrest.MatcherAssert.assertThat;
15import cuchaz.enigma.translation.representation.TypeDescriptor; 15import static org.hamcrest.Matchers.contains;
16import static org.hamcrest.Matchers.empty;
17import static org.hamcrest.Matchers.is;
18import static org.hamcrest.Matchers.not;
19
16import org.junit.Test; 20import org.junit.Test;
17 21
18import static org.hamcrest.MatcherAssert.assertThat; 22import cuchaz.enigma.translation.representation.MethodDescriptor;
19import static org.hamcrest.Matchers.*; 23import cuchaz.enigma.translation.representation.TypeDescriptor;
20 24
21public class TestMethodDescriptor { 25public class TestMethodDescriptor {
22
23 @Test 26 @Test
24 public void easiest() { 27 public void easiest() {
25 final MethodDescriptor sig = new MethodDescriptor("()V"); 28 final MethodDescriptor sig = new MethodDescriptor("()V");
@@ -31,26 +34,19 @@ public class TestMethodDescriptor {
31 public void primitives() { 34 public void primitives() {
32 { 35 {
33 final MethodDescriptor sig = new MethodDescriptor("(I)V"); 36 final MethodDescriptor sig = new MethodDescriptor("(I)V");
34 assertThat(sig.getArgumentDescs(), contains( 37 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I")));
35 new TypeDescriptor("I")
36 ));
37 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); 38 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
38 } 39 }
40
39 { 41 {
40 final MethodDescriptor sig = new MethodDescriptor("(I)I"); 42 final MethodDescriptor sig = new MethodDescriptor("(I)I");
41 assertThat(sig.getArgumentDescs(), contains( 43 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I")));
42 new TypeDescriptor("I")
43 ));
44 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("I"))); 44 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("I")));
45 } 45 }
46
46 { 47 {
47 final MethodDescriptor sig = new MethodDescriptor("(IBCJ)Z"); 48 final MethodDescriptor sig = new MethodDescriptor("(IBCJ)Z");
48 assertThat(sig.getArgumentDescs(), contains( 49 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"), new TypeDescriptor("B"), new TypeDescriptor("C"), new TypeDescriptor("J")));
49 new TypeDescriptor("I"),
50 new TypeDescriptor("B"),
51 new TypeDescriptor("C"),
52 new TypeDescriptor("J")
53 ));
54 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("Z"))); 50 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("Z")));
55 } 51 }
56 } 52 }
@@ -63,20 +59,16 @@ public class TestMethodDescriptor {
63 assertThat(sig.getArgumentDescs().get(0), is(new TypeDescriptor("[LFoo;"))); 59 assertThat(sig.getArgumentDescs().get(0), is(new TypeDescriptor("[LFoo;")));
64 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); 60 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
65 } 61 }
62
66 { 63 {
67 final MethodDescriptor sig = new MethodDescriptor("(LFoo;)LBar;"); 64 final MethodDescriptor sig = new MethodDescriptor("(LFoo;)LBar;");
68 assertThat(sig.getArgumentDescs(), contains( 65 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("LFoo;")));
69 new TypeDescriptor("LFoo;")
70 ));
71 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LBar;"))); 66 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LBar;")));
72 } 67 }
68
73 { 69 {
74 final MethodDescriptor sig = new MethodDescriptor("(LFoo;LMoo;LZoo;)LBar;"); 70 final MethodDescriptor sig = new MethodDescriptor("(LFoo;LMoo;LZoo;)LBar;");
75 assertThat(sig.getArgumentDescs(), contains( 71 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("LFoo;"), new TypeDescriptor("LMoo;"), new TypeDescriptor("LZoo;")));
76 new TypeDescriptor("LFoo;"),
77 new TypeDescriptor("LMoo;"),
78 new TypeDescriptor("LZoo;")
79 ));
80 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LBar;"))); 72 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LBar;")));
81 } 73 }
82 } 74 }
@@ -85,25 +77,19 @@ public class TestMethodDescriptor {
85 public void arrays() { 77 public void arrays() {
86 { 78 {
87 final MethodDescriptor sig = new MethodDescriptor("([I)V"); 79 final MethodDescriptor sig = new MethodDescriptor("([I)V");
88 assertThat(sig.getArgumentDescs(), contains( 80 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("[I")));
89 new TypeDescriptor("[I")
90 ));
91 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); 81 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
92 } 82 }
83
93 { 84 {
94 final MethodDescriptor sig = new MethodDescriptor("([I)[J"); 85 final MethodDescriptor sig = new MethodDescriptor("([I)[J");
95 assertThat(sig.getArgumentDescs(), contains( 86 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("[I")));
96 new TypeDescriptor("[I")
97 ));
98 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[J"))); 87 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[J")));
99 } 88 }
89
100 { 90 {
101 final MethodDescriptor sig = new MethodDescriptor("([I[Z[F)[D"); 91 final MethodDescriptor sig = new MethodDescriptor("([I[Z[F)[D");
102 assertThat(sig.getArgumentDescs(), contains( 92 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("[I"), new TypeDescriptor("[Z"), new TypeDescriptor("[F")));
103 new TypeDescriptor("[I"),
104 new TypeDescriptor("[Z"),
105 new TypeDescriptor("[F")
106 ));
107 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[D"))); 93 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[D")));
108 } 94 }
109 } 95 }
@@ -112,20 +98,13 @@ public class TestMethodDescriptor {
112 public void mixed() { 98 public void mixed() {
113 { 99 {
114 final MethodDescriptor sig = new MethodDescriptor("(I[JLFoo;)Z"); 100 final MethodDescriptor sig = new MethodDescriptor("(I[JLFoo;)Z");
115 assertThat(sig.getArgumentDescs(), contains( 101 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"), new TypeDescriptor("[J"), new TypeDescriptor("LFoo;")));
116 new TypeDescriptor("I"),
117 new TypeDescriptor("[J"),
118 new TypeDescriptor("LFoo;")
119 ));
120 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("Z"))); 102 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("Z")));
121 } 103 }
104
122 { 105 {
123 final MethodDescriptor sig = new MethodDescriptor("(III)[LFoo;"); 106 final MethodDescriptor sig = new MethodDescriptor("(III)[LFoo;");
124 assertThat(sig.getArgumentDescs(), contains( 107 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"), new TypeDescriptor("I"), new TypeDescriptor("I")));
125 new TypeDescriptor("I"),
126 new TypeDescriptor("I"),
127 new TypeDescriptor("I")
128 ));
129 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[LFoo;"))); 108 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[LFoo;")));
130 } 109 }
131 } 110 }
@@ -138,42 +117,37 @@ public class TestMethodDescriptor {
138 assertThat(sig.getArgumentDescs(), is(empty())); 117 assertThat(sig.getArgumentDescs(), is(empty()));
139 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); 118 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
140 } 119 }
120
141 { 121 {
142 final MethodDescriptor oldSig = new MethodDescriptor("(IJLFoo;)V"); 122 final MethodDescriptor oldSig = new MethodDescriptor("(IJLFoo;)V");
143 final MethodDescriptor sig = oldSig.remap(s -> null); 123 final MethodDescriptor sig = oldSig.remap(s -> null);
144 assertThat(sig.getArgumentDescs(), contains( 124 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"), new TypeDescriptor("J"), new TypeDescriptor("LFoo;")));
145 new TypeDescriptor("I"),
146 new TypeDescriptor("J"),
147 new TypeDescriptor("LFoo;")
148 ));
149 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); 125 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
150 } 126 }
127
151 { 128 {
152 final MethodDescriptor oldSig = new MethodDescriptor("(LFoo;LBar;)LMoo;"); 129 final MethodDescriptor oldSig = new MethodDescriptor("(LFoo;LBar;)LMoo;");
153 final MethodDescriptor sig = oldSig.remap(s -> { 130 final MethodDescriptor sig = oldSig.remap(s -> {
154 if (s.equals("Foo")) { 131 if (s.equals("Foo")) {
155 return "Bar"; 132 return "Bar";
156 } 133 }
134
157 return null; 135 return null;
158 }); 136 });
159 assertThat(sig.getArgumentDescs(), contains( 137 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("LBar;"), new TypeDescriptor("LBar;")));
160 new TypeDescriptor("LBar;"),
161 new TypeDescriptor("LBar;")
162 ));
163 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LMoo;"))); 138 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LMoo;")));
164 } 139 }
140
165 { 141 {
166 final MethodDescriptor oldSig = new MethodDescriptor("(LFoo;LBar;)LMoo;"); 142 final MethodDescriptor oldSig = new MethodDescriptor("(LFoo;LBar;)LMoo;");
167 final MethodDescriptor sig = oldSig.remap(s -> { 143 final MethodDescriptor sig = oldSig.remap(s -> {
168 if (s.equals("Moo")) { 144 if (s.equals("Moo")) {
169 return "Cow"; 145 return "Cow";
170 } 146 }
147
171 return null; 148 return null;
172 }); 149 });
173 assertThat(sig.getArgumentDescs(), contains( 150 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("LFoo;"), new TypeDescriptor("LBar;")));
174 new TypeDescriptor("LFoo;"),
175 new TypeDescriptor("LBar;")
176 ));
177 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LCow;"))); 151 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LCow;")));
178 } 152 }
179 } 153 }
@@ -188,18 +162,16 @@ public class TestMethodDescriptor {
188 } else if (s.equals("Bar")) { 162 } else if (s.equals("Bar")) {
189 return "Beer"; 163 return "Beer";
190 } 164 }
165
191 return null; 166 return null;
192 }); 167 });
193 assertThat(sig.getArgumentDescs(), contains( 168 assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("[LFood;")));
194 new TypeDescriptor("[LFood;")
195 ));
196 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[[[LBeer;"))); 169 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[[[LBeer;")));
197 } 170 }
198 } 171 }
199 172
200 @Test 173 @Test
201 public void equals() { 174 public void equals() {
202
203 // base 175 // base
204 assertThat(new MethodDescriptor("()V"), is(new MethodDescriptor("()V"))); 176 assertThat(new MethodDescriptor("()V"), is(new MethodDescriptor("()V")));
205 177
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma; 12package cuchaz.enigma;
13 13
14import cuchaz.enigma.translation.representation.entry.MethodEntry;
15import org.junit.Ignore;
16import org.junit.Test;
17
18import java.nio.file.Paths;
19
20import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod; 14import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod;
21import static cuchaz.enigma.TestEntryFactory.newMethod; 15import static cuchaz.enigma.TestEntryFactory.newMethod;
22import static org.hamcrest.MatcherAssert.assertThat; 16import static org.hamcrest.MatcherAssert.assertThat;
23import static org.hamcrest.Matchers.*; 17import static org.hamcrest.Matchers.containsInAnyOrder;
18import static org.hamcrest.Matchers.empty;
19import static org.hamcrest.Matchers.is;
20import static org.hamcrest.Matchers.nullValue;
24 21
25public class TestTokensConstructors extends TokenChecker { 22import java.nio.file.Paths;
23
24import org.junit.Ignore;
25import org.junit.Test;
26
27import cuchaz.enigma.translation.representation.entry.MethodEntry;
26 28
27 public TestTokensConstructors() 29public class TestTokensConstructors extends TokenChecker {
28 throws Exception { 30 public TestTokensConstructors() throws Exception {
29 super(Paths.get("build/test-obf/constructors.jar")); 31 super(Paths.get("build/test-obf/constructors.jar"));
30 } 32 }
31 33
@@ -57,17 +59,10 @@ public class TestTokensConstructors extends TokenChecker {
57 @Ignore // TODO needs fixing, broke when compiling against J16 59 @Ignore // TODO needs fixing, broke when compiling against J16
58 public void baseDefaultReferences() { 60 public void baseDefaultReferences() {
59 MethodEntry source = newMethod("a", "<init>", "()V"); 61 MethodEntry source = newMethod("a", "<init>", "()V");
60 assertThat( 62 assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "a", "()V")), containsInAnyOrder("a"));
61 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "a", "()V")), 63 assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "()V")), is(empty()) // implicit call, not decompiled to token
62 containsInAnyOrder("a")
63 );
64 assertThat(
65 getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "()V")),
66 is(empty()) // implicit call, not decompiled to token
67 ); 64 );
68 assertThat( 65 assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "(III)V")), is(empty()) // implicit call, not decompiled to token
69 getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "(III)V")),
70 is(empty()) // implicit call, not decompiled to token
71 ); 66 );
72 } 67 }
73 68
@@ -75,71 +70,44 @@ public class TestTokensConstructors extends TokenChecker {
75 @Ignore // TODO needs fixing, broke when compiling against J16 70 @Ignore // TODO needs fixing, broke when compiling against J16
76 public void baseIntReferences() { 71 public void baseIntReferences() {
77 MethodEntry source = newMethod("a", "<init>", "(I)V"); 72 MethodEntry source = newMethod("a", "<init>", "(I)V");
78 assertThat( 73 assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "b", "()V")), containsInAnyOrder("a"));
79 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "b", "()V")),
80 containsInAnyOrder("a")
81 );
82 } 74 }
83 75
84 @Test 76 @Test
85 @Ignore // TODO needs fixing, broke when compiling against J16 77 @Ignore // TODO needs fixing, broke when compiling against J16
86 public void subDefaultReferences() { 78 public void subDefaultReferences() {
87 MethodEntry source = newMethod("d", "<init>", "()V"); 79 MethodEntry source = newMethod("d", "<init>", "()V");
88 assertThat( 80 assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "c", "()V")), containsInAnyOrder("d"));
89 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "c", "()V")), 81 assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "(I)V")), containsInAnyOrder("this"));
90 containsInAnyOrder("d")
91 );
92 assertThat(
93 getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "(I)V")),
94 containsInAnyOrder("this")
95 );
96 } 82 }
97 83
98 @Test 84 @Test
99 @Ignore // TODO needs fixing, broke when compiling against J16 85 @Ignore // TODO needs fixing, broke when compiling against J16
100 public void subIntReferences() { 86 public void subIntReferences() {
101 MethodEntry source = newMethod("d", "<init>", "(I)V"); 87 MethodEntry source = newMethod("d", "<init>", "(I)V");
102 assertThat(getReferenceTokens( 88 assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "d", "()V")), containsInAnyOrder("d"));
103 newBehaviorReferenceByMethod(source, "b", "d", "()V")), 89 assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "(II)V")), containsInAnyOrder("this"));
104 containsInAnyOrder("d") 90 assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "e", "<init>", "(I)V")), containsInAnyOrder("super"));
105 );
106 assertThat(getReferenceTokens(
107 newBehaviorReferenceByMethod(source, "d", "<init>", "(II)V")),
108 containsInAnyOrder("this")
109 );
110 assertThat(getReferenceTokens(
111 newBehaviorReferenceByMethod(source, "e", "<init>", "(I)V")),
112 containsInAnyOrder("super")
113 );
114 } 91 }
115 92
116 @Test 93 @Test
117 @Ignore // TODO needs fixing, broke when compiling against J16 94 @Ignore // TODO needs fixing, broke when compiling against J16
118 public void subIntIntReferences() { 95 public void subIntIntReferences() {
119 MethodEntry source = newMethod("d", "<init>", "(II)V"); 96 MethodEntry source = newMethod("d", "<init>", "(II)V");
120 assertThat( 97 assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "e", "()V")), containsInAnyOrder("d"));
121 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "e", "()V")),
122 containsInAnyOrder("d")
123 );
124 } 98 }
125 99
126 @Test 100 @Test
127 @Ignore // TODO needs fixing, broke when compiling against J16 101 @Ignore // TODO needs fixing, broke when compiling against J16
128 public void subsubIntReferences() { 102 public void subsubIntReferences() {
129 MethodEntry source = newMethod("e", "<init>", "(I)V"); 103 MethodEntry source = newMethod("e", "<init>", "(I)V");
130 assertThat( 104 assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "f", "()V")), containsInAnyOrder("e"));
131 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "f", "()V")),
132 containsInAnyOrder("e")
133 );
134 } 105 }
135 106
136 @Test 107 @Test
137 @Ignore // TODO needs fixing, broke when compiling against J16 108 @Ignore // TODO needs fixing, broke when compiling against J16
138 public void defaultConstructableReferences() { 109 public void defaultConstructableReferences() {
139 MethodEntry source = newMethod("c", "<init>", "()V"); 110 MethodEntry source = newMethod("c", "<init>", "()V");
140 assertThat( 111 assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "g", "()V")), containsInAnyOrder("c"));
141 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "g", "()V")),
142 containsInAnyOrder("c")
143 );
144 } 112 }
145} 113}
diff --git a/enigma/src/test/java/cuchaz/enigma/TestTranslator.java b/enigma/src/test/java/cuchaz/enigma/TestTranslator.java
index a420afe..93b7017 100644
--- a/enigma/src/test/java/cuchaz/enigma/TestTranslator.java
+++ b/enigma/src/test/java/cuchaz/enigma/TestTranslator.java
@@ -1,27 +1,28 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma; 12package cuchaz.enigma;
13 13
14import cuchaz.enigma.translation.representation.entry.Entry; 14import static cuchaz.enigma.TestEntryFactory.newClass;
15import static cuchaz.enigma.TestEntryFactory.newField;
16import static cuchaz.enigma.TestEntryFactory.newMethod;
17
15import org.junit.BeforeClass; 18import org.junit.BeforeClass;
16import org.junit.Test; 19import org.junit.Test;
17 20
18import static cuchaz.enigma.TestEntryFactory.*; 21import cuchaz.enigma.translation.representation.entry.Entry;
19 22
20public class TestTranslator { 23public class TestTranslator {
21
22 @BeforeClass 24 @BeforeClass
23 public static void beforeClass() 25 public static void beforeClass() throws Exception {
24 throws Exception {
25 //TODO FIx 26 //TODO FIx
26 //deobfuscator = new Enigma(new JarFile("build/test-obf/translation.jar")); 27 //deobfuscator = new Enigma(new JarFile("build/test-obf/translation.jar"));
27 //try (InputStream in = TestTranslator.class.getResourceAsStream("/cuchaz/enigma/resources/translation.mappings")) { 28 //try (InputStream in = TestTranslator.class.getResourceAsStream("/cuchaz/enigma/resources/translation.mappings")) {
@@ -94,7 +95,6 @@ public class TestTranslator {
94 95
95 @Test 96 @Test
96 public void innerClasses() { 97 public void innerClasses() {
97
98 // classes 98 // classes
99 assertMapping(newClass("g"), newClass("deobf/G_OuterClass")); 99 assertMapping(newClass("g"), newClass("deobf/G_OuterClass"));
100 assertMapping(newClass("g$a"), newClass("deobf/G_OuterClass$A_InnerClass")); 100 assertMapping(newClass("g$a"), newClass("deobf/G_OuterClass$A_InnerClass"));
@@ -120,7 +120,6 @@ public class TestTranslator {
120 120
121 @Test 121 @Test
122 public void testGenerics() { 122 public void testGenerics() {
123
124 // classes 123 // classes
125 assertMapping(newClass("i"), newClass("deobf/I_Generics")); 124 assertMapping(newClass("i"), newClass("deobf/I_Generics"));
126 assertMapping(newClass("i$a"), newClass("deobf/I_Generics$A_Type")); 125 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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma; 12package cuchaz.enigma;
13 13
14import cuchaz.enigma.translation.representation.TypeDescriptor;
15import org.junit.Test;
16
17import static cuchaz.enigma.TestEntryFactory.newClass; 14import static cuchaz.enigma.TestEntryFactory.newClass;
18import static org.hamcrest.MatcherAssert.assertThat; 15import static org.hamcrest.MatcherAssert.assertThat;
19import static org.hamcrest.Matchers.is; 16import static org.hamcrest.Matchers.is;
20import static org.hamcrest.Matchers.not; 17import static org.hamcrest.Matchers.not;
21 18
22public class TestTypeDescriptor { 19import org.junit.Test;
23 20
21import cuchaz.enigma.translation.representation.TypeDescriptor;
22
23public class TestTypeDescriptor {
24 @Test 24 @Test
25 public void isVoid() { 25 public void isVoid() {
26 assertThat(new TypeDescriptor("V").isVoid(), is(true)); 26 assertThat(new TypeDescriptor("V").isVoid(), is(true));
@@ -161,6 +161,7 @@ public class TestTypeDescriptor {
161 assertThat(TypeDescriptor.parseFirst("LFoo;LFoo;"), is(answer)); 161 assertThat(TypeDescriptor.parseFirst("LFoo;LFoo;"), is(answer));
162 assertThat(TypeDescriptor.parseFirst("LFoo;[LFoo;"), is(answer)); 162 assertThat(TypeDescriptor.parseFirst("LFoo;[LFoo;"), is(answer));
163 } 163 }
164
164 { 165 {
165 final String answer = "Ljava/lang/String;"; 166 final String answer = "Ljava/lang/String;";
166 assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;"), is(answer)); 167 assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;"), is(answer));
@@ -182,6 +183,7 @@ public class TestTypeDescriptor {
182 assertThat(TypeDescriptor.parseFirst("[I[I"), is(answer)); 183 assertThat(TypeDescriptor.parseFirst("[I[I"), is(answer));
183 assertThat(TypeDescriptor.parseFirst("[ILFoo;"), is(answer)); 184 assertThat(TypeDescriptor.parseFirst("[ILFoo;"), is(answer));
184 } 185 }
186
185 { 187 {
186 final String answer = "[[I"; 188 final String answer = "[[I";
187 assertThat(TypeDescriptor.parseFirst("[[I"), is(answer)); 189 assertThat(TypeDescriptor.parseFirst("[[I"), is(answer));
@@ -190,6 +192,7 @@ public class TestTypeDescriptor {
190 assertThat(TypeDescriptor.parseFirst("[[I[I"), is(answer)); 192 assertThat(TypeDescriptor.parseFirst("[[I[I"), is(answer));
191 assertThat(TypeDescriptor.parseFirst("[[ILFoo;"), is(answer)); 193 assertThat(TypeDescriptor.parseFirst("[[ILFoo;"), is(answer));
192 } 194 }
195
193 { 196 {
194 final String answer = "[LFoo;"; 197 final String answer = "[LFoo;";
195 assertThat(TypeDescriptor.parseFirst("[LFoo;"), is(answer)); 198 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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma; 12package cuchaz.enigma;
13 13
14import java.io.IOException;
15import java.nio.file.Path;
16import java.util.Collection;
17import java.util.List;
18
14import com.google.common.collect.Lists; 19import com.google.common.collect.Lists;
20
15import cuchaz.enigma.analysis.EntryReference; 21import cuchaz.enigma.analysis.EntryReference;
16import cuchaz.enigma.classprovider.CachingClassProvider; 22import cuchaz.enigma.classprovider.CachingClassProvider;
17import cuchaz.enigma.classprovider.JarClassProvider; 23import cuchaz.enigma.classprovider.JarClassProvider;
18import cuchaz.enigma.source.*; 24import cuchaz.enigma.source.Decompiler;
25import cuchaz.enigma.source.Decompilers;
26import cuchaz.enigma.source.Source;
27import cuchaz.enigma.source.SourceIndex;
28import cuchaz.enigma.source.SourceSettings;
29import cuchaz.enigma.source.Token;
19import cuchaz.enigma.translation.representation.entry.Entry; 30import cuchaz.enigma.translation.representation.entry.Entry;
20 31
21import java.io.IOException;
22import java.nio.file.Path;
23import java.util.Collection;
24import java.util.List;
25
26public class TokenChecker { 32public class TokenChecker {
27 private final Decompiler decompiler; 33 private final Decompiler decompiler;
28 34
@@ -41,9 +47,11 @@ public class TokenChecker {
41 47
42 // get the token value 48 // get the token value
43 Token token = index.getDeclarationToken(entry); 49 Token token = index.getDeclarationToken(entry);
50
44 if (token == null) { 51 if (token == null) {
45 return null; 52 return null;
46 } 53 }
54
47 return string.substring(token.start, token.end); 55 return string.substring(token.start, token.end);
48 } 56 }
49 57
@@ -56,9 +64,11 @@ public class TokenChecker {
56 64
57 // get the token values 65 // get the token values
58 List<String> values = Lists.newArrayList(); 66 List<String> values = Lists.newArrayList();
67
59 for (Token token : index.getReferenceTokens((EntryReference<Entry<?>, Entry<?>>) reference)) { 68 for (Token token : index.getReferenceTokens((EntryReference<Entry<?>, Entry<?>>) reference)) {
60 values.add(string.substring(token.start, token.end)); 69 values.add(string.substring(token.start, token.end));
61 } 70 }
71
62 return values; 72 return values;
63 } 73 }
64} 74}
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/Keep.java b/enigma/src/test/java/cuchaz/enigma/inputs/Keep.java
index 4dbe8e2..46d5380 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/Keep.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/Keep.java
@@ -1,13 +1,13 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs; 12package cuchaz.enigma.inputs;
13 13
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.constructors; 12package cuchaz.enigma.inputs.constructors;
13 13
14// a 14// a
15public class BaseClass { 15public class BaseClass {
16
17 // <init>()V 16 // <init>()V
18 public BaseClass() { 17 public BaseClass() {
19 System.out.println("Default constructor"); 18 System.out.println("Default constructor");
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java
index 71439fd..e81df1b 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java
@@ -1,19 +1,18 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.constructors; 12package cuchaz.enigma.inputs.constructors;
13 13
14// b 14// b
15public class Caller { 15public class Caller {
16
17 // a()V 16 // a()V
18 public void callBaseDefault() { 17 public void callBaseDefault() {
19 // a.<init>()V 18 // a.<init>()V
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java
index c3d4170..55aa767 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java
@@ -1,13 +1,13 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.constructors; 12package cuchaz.enigma.inputs.constructors;
13 13
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.constructors; 12package cuchaz.enigma.inputs.constructors;
13 13
14// d extends a 14// d extends a
15public class SubClass extends BaseClass { 15public class SubClass extends BaseClass {
16
17 // <init>()V 16 // <init>()V
18 public SubClass() { 17 public SubClass() {
19 // a.<init>()V 18 // a.<init>()V
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java
index 87b69d3..ec5ac44 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java
@@ -1,19 +1,18 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.constructors; 12package cuchaz.enigma.inputs.constructors;
13 13
14// e extends d 14// e extends d
15public class SubSubClass extends SubClass { 15public class SubSubClass extends SubClass {
16
17 // <init>(I)V 16 // <init>(I)V
18 public SubSubClass(int i) { 17 public SubSubClass(int i) {
19 // c.<init>(I)V 18 // c.<init>(I)V
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java
index b9c4929..87e849f 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java
@@ -1,19 +1,18 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.inheritanceTree; 12package cuchaz.enigma.inputs.inheritanceTree;
13 13
14// a 14// a
15public abstract class BaseClass { 15public abstract class BaseClass {
16
17 // a 16 // a
18 private String name; 17 private String name;
19 18
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.inheritanceTree; 12package cuchaz.enigma.inputs.inheritanceTree;
13 13
14// b extends a 14// b extends a
15public abstract class SubclassA extends BaseClass { 15public abstract class SubclassA extends BaseClass {
16
17 // <init>(Ljava/lang/String;)V 16 // <init>(Ljava/lang/String;)V
18 protected SubclassA(String name) { 17 protected SubclassA(String name) {
19 // call to a.<init>(Ljava/lang/String)V 18 // call to a.<init>(Ljava/lang/String)V
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java
index d0dd664..cfc696a 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java
@@ -1,19 +1,18 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.inheritanceTree; 12package cuchaz.enigma.inputs.inheritanceTree;
13 13
14// c extends a 14// c extends a
15public class SubclassB extends BaseClass { 15public class SubclassB extends BaseClass {
16
17 // a 16 // a
18 private int numThings; 17 private int numThings;
19 18
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.inheritanceTree; 12package cuchaz.enigma.inputs.inheritanceTree;
13 13
14// d extends b 14// d extends b
15public class SubsubclassAA extends SubclassA { 15public class SubsubclassAA extends SubclassA {
16
17 protected SubsubclassAA() { 16 protected SubsubclassAA() {
18 // call to b.<init>(Ljava/lang/String;)V 17 // call to b.<init>(Ljava/lang/String;)V
19 super("AA"); 18 super("AA");
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java
index f652d87..515205a 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java
@@ -1,18 +1,17 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.innerClasses; 12package cuchaz.enigma.inputs.innerClasses;
13 13
14public class A_Anonymous { 14public class A_Anonymous {
15
16 public void foo() { 15 public void foo() {
17 Runnable runnable = new Runnable() { 16 Runnable runnable = new Runnable() {
18 @Override 17 @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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.innerClasses; 12package cuchaz.enigma.inputs.innerClasses;
13 13
14public class B_AnonymousWithScopeArgs { 14public class B_AnonymousWithScopeArgs {
15
16 public static void foo(final D_Simple arg) { 15 public static void foo(final D_Simple arg) {
17 System.out.println(new Object() { 16 System.out.println(new Object() {
18 @Override 17 @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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.innerClasses; 12package cuchaz.enigma.inputs.innerClasses;
13 13
14@SuppressWarnings("unused") 14@SuppressWarnings("unused")
15public class C_ConstructorArgs { 15public class C_ConstructorArgs {
16
17 Inner i; 16 Inner i;
18 17
19 public void foo() { 18 public void foo() {
@@ -21,10 +20,9 @@ public class C_ConstructorArgs {
21 } 20 }
22 21
23 class Inner { 22 class Inner {
24
25 private int a; 23 private int a;
26 24
27 public Inner(int a) { 25 Inner(int a) {
28 this.a = a; 26 this.a = a;
29 } 27 }
30 } 28 }
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.innerClasses; 12package cuchaz.enigma.inputs.innerClasses;
13 13
14public class D_Simple { 14public class D_Simple {
15
16 class Inner { 15 class Inner {
17 // nothing to do 16 // nothing to do
18 } 17 }
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.innerClasses; 12package cuchaz.enigma.inputs.innerClasses;
13 13
14public class E_AnonymousWithOuterAccess { 14public class E_AnonymousWithOuterAccess {
15
16 // reproduction of error case documented at: 15 // reproduction of error case documented at:
17 // https://bitbucket.org/cuchaz/enigma/issue/61/stackoverflowerror-when-deobfuscating 16 // https://bitbucket.org/cuchaz/enigma/issue/61/stackoverflowerror-when-deobfuscating
18 17
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.innerClasses; 12package cuchaz.enigma.inputs.innerClasses;
13 13
14public class F_ClassTree { 14public class F_ClassTree {
15
16 public class Level1 { 15 public class Level1 {
17
18 public int f1; 16 public int f1;
19 17
20 public class Level2 { 18 public class Level2 {
21
22 public int f2; 19 public int f2;
23 20
24 public class Level3 { 21 public class Level3 {
25
26 public int f3; 22 public int f3;
27 } 23 }
28 } 24 }
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.loneClass; 12package cuchaz.enigma.inputs.loneClass;
13 13
14public class LoneClass { 14public class LoneClass {
15
16 private String name; 15 private String name;
17 16
18 public LoneClass(String name) { 17 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 @@
1package cuchaz.enigma.inputs.packageAccess; 1package cuchaz.enigma.inputs.packageAccess;
2 2
3public class SamePackageChild extends Base { 3public class SamePackageChild extends Base {
4
5 class Inner { 4 class Inner {
6 final int value; 5 final int value;
7 6
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;
3import cuchaz.enigma.inputs.packageAccess.Base; 3import cuchaz.enigma.inputs.packageAccess.Base;
4 4
5public class OtherPackageChild extends Base { 5public class OtherPackageChild extends Base {
6
7 class Inner { 6 class Inner {
8 final int value; 7 final int value;
9 8
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
13 13
14public class A_Basic { 14public class A_Basic {
15
16 public int one; 15 public int one;
17 public float two; 16 public float two;
18 public String three; 17 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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
13 13
14public class B_BaseClass { 14public class B_BaseClass {
15
16 public int f1; 15 public int f1;
17 public char f2; 16 public char f2;
18 17
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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
13 13
14public class C_SubClass extends B_BaseClass { 14public class C_SubClass extends B_BaseClass {
15
16 public char f2; // shadows B_BaseClass.f2 15 public char f2; // shadows B_BaseClass.f2
17 public int f3; 16 public int f3;
18 public int f4; 17 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 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
13 13
@@ -15,7 +15,6 @@ import java.util.ArrayList;
15import java.util.List; 15import java.util.List;
16 16
17public class D_AnonymousTesting { 17public class D_AnonymousTesting {
18
19 public List<Object> getObjs() { 18 public List<Object> getObjs() {
20 List<Object> objs = new ArrayList<Object>(); 19 List<Object> objs = new ArrayList<Object>();
21 objs.add(new Object() { 20 objs.add(new Object() {
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java
index 0b8cf2a..f44bdbf 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java
@@ -1,20 +1,19 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
13 13
14import java.util.Iterator; 14import java.util.Iterator;
15 15
16public class E_Bridges implements Iterator<Object> { 16public class E_Bridges implements Iterator<Object> {
17
18 @Override 17 @Override
19 public boolean hasNext() { 18 public boolean hasNext() {
20 return false; 19 return false;
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java
index 8a92792..ac1d7b5 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java
@@ -1,21 +1,19 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
13 13
14@SuppressWarnings("FinalizeCalledExplicitly") 14@SuppressWarnings("FinalizeCalledExplicitly")
15public class F_ObjectMethods { 15public class F_ObjectMethods {
16 16 public void callEmAll() throws Throwable {
17 public void callEmAll()
18 throws Throwable {
19 clone(); 17 clone();
20 equals(this); 18 equals(this);
21 finalize(); 19 finalize();
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java
index a1e6a85..4d99235 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java
@@ -1,30 +1,29 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
13 13
14public class G_OuterClass { 14public class G_OuterClass {
15
16 public class A_InnerClass { 15 public class A_InnerClass {
17
18 public int f1; 16 public int f1;
19 public String f2; 17 public String f2;
20 18
21 public void m1() {} 19 public void m1() {
20 }
22 21
23 public class A_InnerInnerClass { 22 public class A_InnerInnerClass {
24
25 public int f3; 23 public int f3;
26 24
27 public void m2() {} 25 public void m2() {
26 }
28 } 27 }
29 } 28 }
30 29
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java
index 013c55a..d996dc8 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java
@@ -1,30 +1,29 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
13 13
14public class H_NamelessClass { 14public class H_NamelessClass {
15
16 public class A_InnerClass { 15 public class A_InnerClass {
17
18 public int f1; 16 public int f1;
19 public String f2; 17 public String f2;
20 18
21 public void m1() {} 19 public void m1() {
20 }
22 21
23 public class A_InnerInnerClass { 22 public class A_InnerInnerClass {
24
25 public int f3; 23 public int f3;
26 24
27 public void m2() {} 25 public void m2() {
26 }
28 } 27 }
29 } 28 }
30 29
@@ -32,9 +31,11 @@ public class H_NamelessClass {
32 public class A_NamedInnerClass { 31 public class A_NamedInnerClass {
33 public int f4; 32 public int f4;
34 33
35 public class A_AnotherInnerClass {} 34 public class A_AnotherInnerClass {
35 }
36 36
37 public class B_YetAnotherInnerClass {} 37 public class B_YetAnotherInnerClass {
38 }
38 } 39 }
39 } 40 }
40} 41}
diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java
index fd2ebdd..9a9048c 100644
--- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java
+++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java
@@ -1,13 +1,13 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
13 13
@@ -15,7 +15,6 @@ import java.util.List;
15import java.util.Map; 15import java.util.Map;
16 16
17public class I_Generics { 17public class I_Generics {
18
19 public List<Integer> f1; 18 public List<Integer> f1;
20 public List<A_Type> f2; 19 public List<A_Type> f2;
21 public Map<A_Type, A_Type> f3; 20 public Map<A_Type, A_Type> f3;
diff --git a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestComments.java b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestComments.java
index e831943..15ec44e 100644
--- a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestComments.java
+++ b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestComments.java
@@ -5,6 +5,8 @@ import java.net.URISyntaxException;
5import java.nio.file.Path; 5import java.nio.file.Path;
6import java.nio.file.Paths; 6import java.nio.file.Paths;
7 7
8import org.junit.Test;
9
8import cuchaz.enigma.ProgressListener; 10import cuchaz.enigma.ProgressListener;
9import cuchaz.enigma.translation.mapping.serde.MappingFileNameFormat; 11import cuchaz.enigma.translation.mapping.serde.MappingFileNameFormat;
10import cuchaz.enigma.translation.mapping.serde.MappingParseException; 12import cuchaz.enigma.translation.mapping.serde.MappingParseException;
@@ -12,28 +14,24 @@ import cuchaz.enigma.translation.mapping.serde.MappingSaveParameters;
12import cuchaz.enigma.translation.mapping.serde.enigma.EnigmaMappingsReader; 14import cuchaz.enigma.translation.mapping.serde.enigma.EnigmaMappingsReader;
13import cuchaz.enigma.translation.mapping.serde.tinyv2.TinyV2Writer; 15import cuchaz.enigma.translation.mapping.serde.tinyv2.TinyV2Writer;
14import cuchaz.enigma.translation.mapping.tree.EntryTree; 16import cuchaz.enigma.translation.mapping.tree.EntryTree;
15import org.junit.Test;
16 17
17public class TestComments { 18public class TestComments {
18 private static Path DIRECTORY; 19 private static Path DIRECTORY;
19
20 static {
21 try {
22 DIRECTORY = Paths.get(TestTinyV2InnerClasses.class.getResource("/comments/").toURI());
23 } catch (URISyntaxException e) {
24 throw new RuntimeException(e);
25 }
26 }
27 20
28 @Test 21 static {
29 public void testParseAndWrite() throws IOException, MappingParseException { 22 try {
30 ProgressListener progressListener = ProgressListener.none(); 23 DIRECTORY = Paths.get(TestTinyV2InnerClasses.class.getResource("/comments/").toURI());
31 MappingSaveParameters params = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF); 24 } catch (URISyntaxException e) {
32 EntryTree<EntryMapping> mappings = EnigmaMappingsReader.DIRECTORY.read( 25 throw new RuntimeException(e);
33 DIRECTORY, progressListener, params); 26 }
27 }
34 28
35 new TinyV2Writer("intermediary", "named") 29 @Test
36 .write(mappings, DIRECTORY.resolve("convertedtiny.tiny"), progressListener, params); 30 public void testParseAndWrite() throws IOException, MappingParseException {
37 } 31 ProgressListener progressListener = ProgressListener.none();
32 MappingSaveParameters params = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF);
33 EntryTree<EntryMapping> mappings = EnigmaMappingsReader.DIRECTORY.read(DIRECTORY, progressListener, params);
38 34
39} \ No newline at end of file 35 new TinyV2Writer("intermediary", "named").write(mappings, DIRECTORY.resolve("convertedtiny.tiny"), progressListener, params);
36 }
37}
diff --git a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestReadWriteCycle.java b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestReadWriteCycle.java
index 510dd3c..681fd3f 100644
--- a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestReadWriteCycle.java
+++ b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestReadWriteCycle.java
@@ -1,5 +1,11 @@
1package cuchaz.enigma.translation.mapping; 1package cuchaz.enigma.translation.mapping;
2 2
3import java.io.File;
4import java.io.IOException;
5
6import org.junit.Assert;
7import org.junit.Test;
8
3import cuchaz.enigma.ProgressListener; 9import cuchaz.enigma.ProgressListener;
4import cuchaz.enigma.translation.mapping.serde.MappingFileNameFormat; 10import cuchaz.enigma.translation.mapping.serde.MappingFileNameFormat;
5import cuchaz.enigma.translation.mapping.serde.MappingFormat; 11import cuchaz.enigma.translation.mapping.serde.MappingFormat;
@@ -12,46 +18,25 @@ import cuchaz.enigma.translation.representation.entry.Entry;
12import cuchaz.enigma.translation.representation.entry.FieldEntry; 18import cuchaz.enigma.translation.representation.entry.FieldEntry;
13import cuchaz.enigma.translation.representation.entry.MethodEntry; 19import cuchaz.enigma.translation.representation.entry.MethodEntry;
14import cuchaz.enigma.utils.Pair; 20import cuchaz.enigma.utils.Pair;
15import org.junit.Assert;
16import org.junit.Test;
17
18import java.io.File;
19import java.io.IOException;
20 21
21/** 22/**
22 * Tests that a MappingFormat can write out a fixed set of mappings and read them back without losing any information. 23 * Tests that a MappingFormat can write out a fixed set of mappings and read them back without losing any information.
23 * Javadoc skipped for Tiny (v1) as it doesn't support them. 24 * Javadoc skipped for Tiny (v1) as it doesn't support them.
24 */ 25 */
25public class TestReadWriteCycle { 26public class TestReadWriteCycle {
26
27 private final MappingSaveParameters parameters = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF); 27 private final MappingSaveParameters parameters = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF);
28 28
29 private final Pair<ClassEntry, EntryMapping> testClazz = new Pair<>( 29 private final Pair<ClassEntry, EntryMapping> testClazz = new Pair<>(new ClassEntry("a/b/c"), new EntryMapping("alpha/beta/charlie", "this is a test class"));
30 new ClassEntry("a/b/c"),
31 new EntryMapping("alpha/beta/charlie", "this is a test class")
32 );
33 30
34 private final Pair<FieldEntry, EntryMapping> testField1 = new Pair<>( 31 private final Pair<FieldEntry, EntryMapping> testField1 = new Pair<>(FieldEntry.parse("a/b/c", "field1", "I"), new EntryMapping("mapped1", "this is field 1"));
35 FieldEntry.parse("a/b/c", "field1", "I"),
36 new EntryMapping("mapped1", "this is field 1")
37 );
38 32
39 private final Pair<FieldEntry, EntryMapping> testField2 = new Pair<>( 33 private final Pair<FieldEntry, EntryMapping> testField2 = new Pair<>(FieldEntry.parse("a/b/c", "field2", "I"), new EntryMapping("mapped2", "this is field 2"));
40 FieldEntry.parse("a/b/c", "field2", "I"),
41 new EntryMapping("mapped2", "this is field 2")
42 );
43 34
44 private final Pair<MethodEntry, EntryMapping> testMethod1 = new Pair<>( 35 private final Pair<MethodEntry, EntryMapping> testMethod1 = new Pair<>(MethodEntry.parse("a/b/c", "method1", "()V"), new EntryMapping("mapped3", "this is method1"));
45 MethodEntry.parse("a/b/c", "method1", "()V"),
46 new EntryMapping("mapped3", "this is method1")
47 );
48 36
49 private final Pair<MethodEntry, EntryMapping> testMethod2 = new Pair<>( 37 private final Pair<MethodEntry, EntryMapping> testMethod2 = new Pair<>(MethodEntry.parse("a/b/c", "method2", "()V"), new EntryMapping("mapped4", "this is method 2"));
50 MethodEntry.parse("a/b/c", "method2", "()V"),
51 new EntryMapping("mapped4", "this is method 2")
52 );
53 38
54 private void insertMapping(EntryTree<EntryMapping> mappings, Pair<? extends Entry<?>, EntryMapping> mappingPair){ 39 private void insertMapping(EntryTree<EntryMapping> mappings, Pair<? extends Entry<?>, EntryMapping> mappingPair) {
55 mappings.insert(mappingPair.a, mappingPair.b); 40 mappings.insert(mappingPair.a, mappingPair.b);
56 } 41 }
57 42
@@ -71,8 +56,8 @@ public class TestReadWriteCycle {
71 Assert.assertTrue("Test mapping insertion failed: testMethod2", testMappings.contains(testMethod2.a)); 56 Assert.assertTrue("Test mapping insertion failed: testMethod2", testMappings.contains(testMethod2.a));
72 57
73 File tempFile = File.createTempFile("readWriteCycle", tmpNameSuffix); 58 File tempFile = File.createTempFile("readWriteCycle", tmpNameSuffix);
74 tempFile.delete();//remove the auto created file 59 //remove the auto created file
75 60 tempFile.delete();
76 61
77 mappingFormat.write(testMappings, tempFile.toPath(), ProgressListener.none(), parameters); 62 mappingFormat.write(testMappings, tempFile.toPath(), ProgressListener.none(), parameters);
78 Assert.assertTrue("Written file not created", tempFile.exists()); 63 Assert.assertTrue("Written file not created", tempFile.exists());
diff --git a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestTinyV2InnerClasses.java b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestTinyV2InnerClasses.java
index 60c70b7..659ac53 100644
--- a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestTinyV2InnerClasses.java
+++ b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestTinyV2InnerClasses.java
@@ -1,25 +1,25 @@
1/******************************************************************************* 1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin. 2* Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials 3* All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public 4* are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5* License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6* http://www.gnu.org/licenses/lgpl.html
7 * 7*
8 * Contributors: 8* <p>Contributors:
9 * Jeff Martin - initial API and implementation 9* Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10******************************************************************************/
11 11
12package cuchaz.enigma.translation.mapping; 12package cuchaz.enigma.translation.mapping;
13 13
14import java.nio.file.Path;
15import java.nio.file.Paths;
16
14import cuchaz.enigma.Enigma; 17import cuchaz.enigma.Enigma;
15import cuchaz.enigma.EnigmaProject; 18import cuchaz.enigma.EnigmaProject;
16import cuchaz.enigma.ProgressListener; 19import cuchaz.enigma.ProgressListener;
17import cuchaz.enigma.classprovider.ClasspathClassProvider; 20import cuchaz.enigma.classprovider.ClasspathClassProvider;
18import cuchaz.enigma.translation.mapping.serde.enigma.EnigmaMappingsReader; 21import cuchaz.enigma.translation.mapping.serde.enigma.EnigmaMappingsReader;
19 22
20import java.nio.file.Path;
21import java.nio.file.Paths;
22
23public final class TestTinyV2InnerClasses { 23public final class TestTinyV2InnerClasses {
24 private Path jar; 24 private Path jar;
25 private Path mappings; 25 private Path mappings;
@@ -29,10 +29,9 @@ public final class TestTinyV2InnerClasses {
29 mappings = Paths.get(TestTinyV2InnerClasses.class.getResource("/tinyV2InnerClasses/").toURI()); 29 mappings = Paths.get(TestTinyV2InnerClasses.class.getResource("/tinyV2InnerClasses/").toURI());
30 } 30 }
31 31
32// @Test 32 // @Test
33 public void testMappings() throws Exception { 33 public void testMappings() throws Exception {
34 EnigmaProject project = Enigma.create().openJar(jar, new ClasspathClassProvider(), ProgressListener.none()); 34 EnigmaProject project = Enigma.create().openJar(jar, new ClasspathClassProvider(), ProgressListener.none());
35 project.setMappings(EnigmaMappingsReader.DIRECTORY.read(mappings, ProgressListener.none(), project.getEnigma().getProfile().getMappingSaveParameters())); 35 project.setMappings(EnigmaMappingsReader.DIRECTORY.read(mappings, ProgressListener.none(), project.getEnigma().getProfile().getMappingSaveParameters()));
36
37 } 36 }
38} 37}
diff --git a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestV2Main.java b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestV2Main.java
index 6e4d7b9..cc08b85 100644
--- a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestV2Main.java
+++ b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestV2Main.java
@@ -1,5 +1,8 @@
1package cuchaz.enigma.translation.mapping; 1package cuchaz.enigma.translation.mapping;
2 2
3import java.nio.file.Path;
4import java.nio.file.Paths;
5
3import cuchaz.enigma.ProgressListener; 6import cuchaz.enigma.ProgressListener;
4import cuchaz.enigma.translation.mapping.serde.MappingFileNameFormat; 7import cuchaz.enigma.translation.mapping.serde.MappingFileNameFormat;
5import cuchaz.enigma.translation.mapping.serde.MappingSaveParameters; 8import cuchaz.enigma.translation.mapping.serde.MappingSaveParameters;
@@ -7,9 +10,6 @@ import cuchaz.enigma.translation.mapping.serde.enigma.EnigmaMappingsReader;
7import cuchaz.enigma.translation.mapping.serde.tinyv2.TinyV2Writer; 10import cuchaz.enigma.translation.mapping.serde.tinyv2.TinyV2Writer;
8import cuchaz.enigma.translation.mapping.tree.EntryTree; 11import cuchaz.enigma.translation.mapping.tree.EntryTree;
9 12
10import java.nio.file.Path;
11import java.nio.file.Paths;
12
13public final class TestV2Main { 13public final class TestV2Main {
14 public static void main(String... args) throws Exception { 14 public static void main(String... args) throws Exception {
15 Path path = Paths.get(TestV2Main.class.getResource("/tinyV2InnerClasses/").toURI()); 15 Path path = Paths.get(TestV2Main.class.getResource("/tinyV2InnerClasses/").toURI());
diff --git a/enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java b/enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java
index 1026f57..bd1ec20 100644
--- a/enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java
+++ b/enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java
@@ -1,11 +1,6 @@
1package cuchaz.enigma.translation.mapping.serde.recaf; 1package cuchaz.enigma.translation.mapping.serde.recaf;
2 2
3import com.google.common.collect.Sets; 3import static org.junit.Assert.assertEquals;
4import com.google.common.jimfs.Jimfs;
5import cuchaz.enigma.ProgressListener;
6import cuchaz.enigma.translation.mapping.EntryMapping;
7import cuchaz.enigma.translation.mapping.tree.EntryTree;
8import org.junit.Test;
9 4
10import java.io.InputStream; 5import java.io.InputStream;
11import java.nio.charset.StandardCharsets; 6import java.nio.charset.StandardCharsets;
@@ -15,32 +10,37 @@ import java.nio.file.Path;
15import java.util.HashSet; 10import java.util.HashSet;
16import java.util.Set; 11import java.util.Set;
17 12
18import static org.junit.Assert.assertEquals; 13import com.google.common.collect.Sets;
14import com.google.common.jimfs.Jimfs;
15import org.junit.Test;
19 16
20public class TestRecaf { 17import cuchaz.enigma.ProgressListener;
18import cuchaz.enigma.translation.mapping.EntryMapping;
19import cuchaz.enigma.translation.mapping.tree.EntryTree;
21 20
22 @Test 21public class TestRecaf {
23 public void testIntegrity() throws Exception { 22 @Test
24 Set<String> contents; 23 public void testIntegrity() throws Exception {
25 try (InputStream in = getClass().getResourceAsStream("/recaf.mappings")) { 24 Set<String> contents;
26 contents = Sets.newHashSet(new String(in.readAllBytes(), StandardCharsets.UTF_8).split("\\R"));
27 }
28 25
29 try (FileSystem fs = Jimfs.newFileSystem()) { 26 try (InputStream in = getClass().getResourceAsStream("/recaf.mappings")) {
27 contents = Sets.newHashSet(new String(in.readAllBytes(), StandardCharsets.UTF_8).split("\\R"));
28 }
30 29
31 Path path = fs.getPath("recaf.mappings"); 30 try (FileSystem fs = Jimfs.newFileSystem()) {
32 Files.writeString(path, String.join("\n", contents)); 31 Path path = fs.getPath("recaf.mappings");
32 Files.writeString(path, String.join("\n", contents));
33 33
34 RecafMappingsWriter writer = RecafMappingsWriter.INSTANCE; 34 RecafMappingsWriter writer = RecafMappingsWriter.INSTANCE;
35 RecafMappingsReader reader = RecafMappingsReader.INSTANCE; 35 RecafMappingsReader reader = RecafMappingsReader.INSTANCE;
36 36
37 EntryTree<EntryMapping> mappings = reader.read(path, ProgressListener.none(), null); 37 EntryTree<EntryMapping> mappings = reader.read(path, ProgressListener.none(), null);
38 writer.write(mappings, path, ProgressListener.none(), null); 38 writer.write(mappings, path, ProgressListener.none(), null);
39 39
40 reader.read(path, ProgressListener.none(), null); 40 reader.read(path, ProgressListener.none(), null);
41 Set<String> newContents = new HashSet<>(Files.readAllLines(path)); 41 Set<String> newContents = new HashSet<>(Files.readAllLines(path));
42 42
43 assertEquals(contents, newContents); 43 assertEquals(contents, newContents);
44 } 44 }
45 } 45 }
46} 46}