diff options
| author | 2019-01-24 14:48:32 +0200 | |
|---|---|---|
| committer | 2019-01-24 13:48:32 +0100 | |
| commit | 00fcd0550fcdda621c2e4662f6ddd55ce673b931 (patch) | |
| tree | 6f9e4c24dbcc6d118fceec56adf7bf9d747a485c /src/test | |
| parent | mark as 0.13.0-SNAPSHOT for preliminary development (diff) | |
| download | enigma-00fcd0550fcdda621c2e4662f6ddd55ce673b931.tar.gz enigma-00fcd0550fcdda621c2e4662f6ddd55ce673b931.tar.xz enigma-00fcd0550fcdda621c2e4662f6ddd55ce673b931.zip | |
[WIP] Mapping rework (#91)
* Move packages
* Mapping & entry refactor: first pass
* Fix deobf -> obf tree remapping
* Resolve various issues
* Give all entries the potential for parents and treat inner classes as children
* Deobf UI tree elements
* Tests pass
* Sort mapping output
* Fix delta tracking
* Index separation and first pass for #97
* Keep track of remapped jar index
* Fix child entries not being remapped
* Drop non-root entries
* Track dropped mappings
* Fix enigma mapping ordering
* EntryTreeNode interface
* Small tweaks
* Naive full index remap on rename
* Entries can resolve to more than one root entry
* Support alternative resolution strategies
* Bridge method resolution
* Tests pass
* Fix mappings being used where there are none
* Fix methods with different descriptors being considered unique. closes #89
Diffstat (limited to 'src/test')
13 files changed, 167 insertions, 177 deletions
diff --git a/src/test/java/cuchaz/enigma/TestDeobfed.java b/src/test/java/cuchaz/enigma/TestDeobfed.java index 9babf1e3..25cb60c5 100644 --- a/src/test/java/cuchaz/enigma/TestDeobfed.java +++ b/src/test/java/cuchaz/enigma/TestDeobfed.java | |||
| @@ -11,9 +11,8 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.analysis.JarIndex; | ||
| 15 | import cuchaz.enigma.analysis.ParsedJar; | 14 | import cuchaz.enigma.analysis.ParsedJar; |
| 16 | import cuchaz.enigma.mapping.entry.ReferencedEntryPool; | 15 | import cuchaz.enigma.analysis.index.JarIndex; |
| 17 | import org.junit.BeforeClass; | 16 | import org.junit.BeforeClass; |
| 18 | import org.junit.Test; | 17 | import org.junit.Test; |
| 19 | 18 | ||
| @@ -32,13 +31,13 @@ public class TestDeobfed { | |||
| 32 | public static void beforeClass() | 31 | public static void beforeClass() |
| 33 | throws Exception { | 32 | throws Exception { |
| 34 | jar = new ParsedJar(new JarFile("build/test-deobf/translation.jar")); | 33 | jar = new ParsedJar(new JarFile("build/test-deobf/translation.jar")); |
| 35 | index = new JarIndex(new ReferencedEntryPool()); | 34 | index = JarIndex.empty(); |
| 36 | index.indexJar(jar, true); | 35 | index.indexJar(jar, s -> {}); |
| 37 | } | 36 | } |
| 38 | 37 | ||
| 39 | @Test | 38 | @Test |
| 40 | public void obfEntries() { | 39 | public void obfEntries() { |
| 41 | assertThat(index.getObfClassEntries(), containsInAnyOrder( | 40 | assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder( |
| 42 | newClass("cuchaz/enigma/inputs/Keep"), | 41 | newClass("cuchaz/enigma/inputs/Keep"), |
| 43 | newClass("a"), | 42 | newClass("a"), |
| 44 | newClass("b"), | 43 | newClass("b"), |
diff --git a/src/test/java/cuchaz/enigma/TestDeobfuscator.java b/src/test/java/cuchaz/enigma/TestDeobfuscator.java index 63a6f552..5f117213 100644 --- a/src/test/java/cuchaz/enigma/TestDeobfuscator.java +++ b/src/test/java/cuchaz/enigma/TestDeobfuscator.java | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import com.google.common.collect.Lists; | 14 | import com.google.common.collect.Lists; |
| 15 | import cuchaz.enigma.mapping.entry.ClassEntry; | 15 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 16 | import org.junit.Test; | 16 | import org.junit.Test; |
| 17 | 17 | ||
| 18 | import java.io.IOException; | 18 | import java.io.IOException; |
diff --git a/src/test/java/cuchaz/enigma/TestEntryFactory.java b/src/test/java/cuchaz/enigma/TestEntryFactory.java index 4f52609e..9e1425a2 100644 --- a/src/test/java/cuchaz/enigma/TestEntryFactory.java +++ b/src/test/java/cuchaz/enigma/TestEntryFactory.java | |||
| @@ -12,10 +12,10 @@ | |||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.analysis.EntryReference; | 14 | import cuchaz.enigma.analysis.EntryReference; |
| 15 | import cuchaz.enigma.mapping.*; | 15 | import cuchaz.enigma.translation.representation.*; |
| 16 | import cuchaz.enigma.mapping.entry.ClassEntry; | 16 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 17 | import cuchaz.enigma.mapping.entry.FieldEntry; | 17 | import cuchaz.enigma.translation.representation.entry.FieldEntry; |
| 18 | import cuchaz.enigma.mapping.entry.MethodEntry; | 18 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| 19 | 19 | ||
| 20 | public class TestEntryFactory { | 20 | public class TestEntryFactory { |
| 21 | 21 | ||
diff --git a/src/test/java/cuchaz/enigma/TestInnerClasses.java b/src/test/java/cuchaz/enigma/TestInnerClasses.java index 843a63c7..0319cf61 100644 --- a/src/test/java/cuchaz/enigma/TestInnerClasses.java +++ b/src/test/java/cuchaz/enigma/TestInnerClasses.java | |||
| @@ -11,20 +11,16 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.analysis.JarIndex; | ||
| 15 | import cuchaz.enigma.analysis.ParsedJar; | 14 | import cuchaz.enigma.analysis.ParsedJar; |
| 16 | import cuchaz.enigma.mapping.entry.ClassEntry; | 15 | import cuchaz.enigma.analysis.index.JarIndex; |
| 17 | import cuchaz.enigma.mapping.entry.ReferencedEntryPool; | 16 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 18 | import org.junit.Test; | 17 | import org.junit.Test; |
| 19 | 18 | ||
| 20 | import java.util.jar.JarFile; | 19 | import java.util.jar.JarFile; |
| 21 | 20 | ||
| 22 | import static cuchaz.enigma.TestEntryFactory.newClass; | 21 | import static cuchaz.enigma.TestEntryFactory.newClass; |
| 23 | import static org.hamcrest.MatcherAssert.assertThat; | 22 | import static org.hamcrest.MatcherAssert.assertThat; |
| 24 | import static org.hamcrest.Matchers.containsInAnyOrder; | ||
| 25 | import static org.hamcrest.Matchers.empty; | ||
| 26 | import static org.hamcrest.Matchers.is; | 23 | import static org.hamcrest.Matchers.is; |
| 27 | import static org.hamcrest.Matchers.nullValue; | ||
| 28 | 24 | ||
| 29 | public class TestInnerClasses { | 25 | public class TestInnerClasses { |
| 30 | 26 | ||
| @@ -41,23 +37,19 @@ public class TestInnerClasses { | |||
| 41 | 37 | ||
| 42 | public TestInnerClasses() | 38 | public TestInnerClasses() |
| 43 | throws Exception { | 39 | throws Exception { |
| 44 | index = new JarIndex(new ReferencedEntryPool()); | 40 | index = JarIndex.empty(); |
| 45 | ParsedJar jar = new ParsedJar(new JarFile("build/test-obf/innerClasses.jar")); | 41 | ParsedJar jar = new ParsedJar(new JarFile("build/test-obf/innerClasses.jar")); |
| 46 | index.indexJar(jar, true); | 42 | index.indexJar(jar, s -> {}); |
| 47 | deobfuscator = new Deobfuscator(jar); | 43 | deobfuscator = new Deobfuscator(jar); |
| 48 | } | 44 | } |
| 49 | 45 | ||
| 50 | @Test | 46 | @Test |
| 51 | public void simple() { | 47 | public void simple() { |
| 52 | assertThat(index.getOuterClass(SimpleInner), is(SimpleOuter)); | ||
| 53 | assertThat(index.getInnerClasses(SimpleOuter), containsInAnyOrder(SimpleInner)); | ||
| 54 | decompile(SimpleOuter); | 48 | decompile(SimpleOuter); |
| 55 | } | 49 | } |
| 56 | 50 | ||
| 57 | @Test | 51 | @Test |
| 58 | public void constructorArgs() { | 52 | public void constructorArgs() { |
| 59 | assertThat(index.getOuterClass(ConstructorArgsInner), is(ConstructorArgsOuter)); | ||
| 60 | assertThat(index.getInnerClasses(ConstructorArgsOuter), containsInAnyOrder(ConstructorArgsInner)); | ||
| 61 | decompile(ConstructorArgsOuter); | 53 | decompile(ConstructorArgsOuter); |
| 62 | } | 54 | } |
| 63 | 55 | ||
| @@ -65,33 +57,25 @@ public class TestInnerClasses { | |||
| 65 | public void classTree() { | 57 | public void classTree() { |
| 66 | 58 | ||
| 67 | // root level | 59 | // root level |
| 68 | assertThat(index.containsObfClass(ClassTreeRoot), is(true)); | 60 | assertThat(index.getEntryIndex().hasClass(ClassTreeRoot), is(true)); |
| 69 | assertThat(index.getOuterClass(ClassTreeRoot), is(nullValue())); | ||
| 70 | assertThat(index.getInnerClasses(ClassTreeRoot), containsInAnyOrder(ClassTreeLevel1)); | ||
| 71 | 61 | ||
| 72 | // level 1 | 62 | // level 1 |
| 73 | ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName() | 63 | ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName() |
| 74 | + "$" + ClassTreeLevel1.getInnermostClassName()); | 64 | + "$" + ClassTreeLevel1.getSimpleName()); |
| 75 | assertThat(index.containsObfClass(fullClassEntry), is(true)); | 65 | assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); |
| 76 | assertThat(index.getOuterClass(ClassTreeLevel1), is(ClassTreeRoot)); | ||
| 77 | assertThat(index.getInnerClasses(ClassTreeLevel1), containsInAnyOrder(ClassTreeLevel2)); | ||
| 78 | 66 | ||
| 79 | // level 2 | 67 | // level 2 |
| 80 | fullClassEntry = new ClassEntry(ClassTreeRoot.getName() | 68 | fullClassEntry = new ClassEntry(ClassTreeRoot.getName() |
| 81 | + "$" + ClassTreeLevel1.getInnermostClassName() | 69 | + "$" + ClassTreeLevel1.getSimpleName() |
| 82 | + "$" + ClassTreeLevel2.getInnermostClassName()); | 70 | + "$" + ClassTreeLevel2.getSimpleName()); |
| 83 | assertThat(index.containsObfClass(fullClassEntry), is(true)); | 71 | assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); |
| 84 | assertThat(index.getOuterClass(ClassTreeLevel2), is(ClassTreeLevel1)); | ||
| 85 | assertThat(index.getInnerClasses(ClassTreeLevel2), containsInAnyOrder(ClassTreeLevel3)); | ||
| 86 | 72 | ||
| 87 | // level 3 | 73 | // level 3 |
| 88 | fullClassEntry = new ClassEntry(ClassTreeRoot.getName() | 74 | fullClassEntry = new ClassEntry(ClassTreeRoot.getName() |
| 89 | + "$" + ClassTreeLevel1.getInnermostClassName() | 75 | + "$" + ClassTreeLevel1.getSimpleName() |
| 90 | + "$" + ClassTreeLevel2.getInnermostClassName() | 76 | + "$" + ClassTreeLevel2.getSimpleName() |
| 91 | + "$" + ClassTreeLevel3.getInnermostClassName()); | 77 | + "$" + ClassTreeLevel3.getSimpleName()); |
| 92 | assertThat(index.containsObfClass(fullClassEntry), is(true)); | 78 | assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); |
| 93 | assertThat(index.getOuterClass(ClassTreeLevel3), is(ClassTreeLevel2)); | ||
| 94 | assertThat(index.getInnerClasses(ClassTreeLevel3), is(empty())); | ||
| 95 | } | 79 | } |
| 96 | 80 | ||
| 97 | private void decompile(ClassEntry classEntry) { | 81 | private void decompile(ClassEntry classEntry) { |
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java b/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java index 763639a4..c3f3b669 100644 --- a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java +++ b/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java | |||
| @@ -12,12 +12,11 @@ | |||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.analysis.EntryReference; | 14 | import cuchaz.enigma.analysis.EntryReference; |
| 15 | import cuchaz.enigma.analysis.JarIndex; | ||
| 16 | import cuchaz.enigma.analysis.ParsedJar; | 15 | import cuchaz.enigma.analysis.ParsedJar; |
| 17 | import cuchaz.enigma.mapping.entry.ClassEntry; | 16 | import cuchaz.enigma.analysis.index.JarIndex; |
| 18 | import cuchaz.enigma.mapping.entry.MethodDefEntry; | 17 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 19 | import cuchaz.enigma.mapping.entry.MethodEntry; | 18 | import cuchaz.enigma.translation.representation.entry.MethodDefEntry; |
| 20 | import cuchaz.enigma.mapping.entry.ReferencedEntryPool; | 19 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| 21 | import org.junit.Test; | 20 | import org.junit.Test; |
| 22 | 21 | ||
| 23 | import java.io.File; | 22 | import java.io.File; |
| @@ -41,13 +40,13 @@ public class TestJarIndexConstructorReferences { | |||
| 41 | public TestJarIndexConstructorReferences() | 40 | public TestJarIndexConstructorReferences() |
| 42 | throws Exception { | 41 | throws Exception { |
| 43 | File jarFile = new File("build/test-obf/constructors.jar"); | 42 | File jarFile = new File("build/test-obf/constructors.jar"); |
| 44 | index = new JarIndex(new ReferencedEntryPool()); | 43 | index = JarIndex.empty(); |
| 45 | index.indexJar(new ParsedJar(new JarFile(jarFile)), false); | 44 | index.indexJar(new ParsedJar(new JarFile(jarFile)), s -> {}); |
| 46 | } | 45 | } |
| 47 | 46 | ||
| 48 | @Test | 47 | @Test |
| 49 | public void obfEntries() { | 48 | public void obfEntries() { |
| 50 | assertThat(index.getObfClassEntries(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, | 49 | assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, |
| 51 | subClass, subsubClass, defaultClass, callerClass)); | 50 | subClass, subsubClass, defaultClass, callerClass)); |
| 52 | } | 51 | } |
| 53 | 52 | ||
| @@ -55,7 +54,7 @@ public class TestJarIndexConstructorReferences { | |||
| 55 | @SuppressWarnings("unchecked") | 54 | @SuppressWarnings("unchecked") |
| 56 | public void baseDefault() { | 55 | public void baseDefault() { |
| 57 | MethodEntry source = newMethod(baseClass, "<init>", "()V"); | 56 | MethodEntry source = newMethod(baseClass, "<init>", "()V"); |
| 58 | Collection<EntryReference<MethodEntry, MethodDefEntry>> references = index.getMethodsReferencing(source); | 57 | Collection<EntryReference<MethodEntry, MethodDefEntry>> references = index.getReferenceIndex().getReferencesToMethod(source); |
| 59 | assertThat(references, containsInAnyOrder( | 58 | assertThat(references, containsInAnyOrder( |
| 60 | newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"), | 59 | newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"), |
| 61 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "()V"), | 60 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "()V"), |
| @@ -67,7 +66,7 @@ public class TestJarIndexConstructorReferences { | |||
| 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.getMethodsReferencing(source), containsInAnyOrder( | 69 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( |
| 71 | newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V") | 70 | newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V") |
| 72 | )); | 71 | )); |
| 73 | } | 72 | } |
| @@ -76,7 +75,7 @@ public class TestJarIndexConstructorReferences { | |||
| 76 | @SuppressWarnings("unchecked") | 75 | @SuppressWarnings("unchecked") |
| 77 | public void subDefault() { | 76 | public void subDefault() { |
| 78 | MethodEntry source = newMethod(subClass, "<init>", "()V"); | 77 | MethodEntry source = newMethod(subClass, "<init>", "()V"); |
| 79 | assertThat(index.getMethodsReferencing(source), containsInAnyOrder( | 78 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( |
| 80 | newBehaviorReferenceByMethod(source, callerClass.getName(), "c", "()V"), | 79 | newBehaviorReferenceByMethod(source, callerClass.getName(), "c", "()V"), |
| 81 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(I)V") | 80 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(I)V") |
| 82 | )); | 81 | )); |
| @@ -86,7 +85,7 @@ public class TestJarIndexConstructorReferences { | |||
| 86 | @SuppressWarnings("unchecked") | 85 | @SuppressWarnings("unchecked") |
| 87 | public void subInt() { | 86 | public void subInt() { |
| 88 | MethodEntry source = newMethod(subClass, "<init>", "(I)V"); | 87 | MethodEntry source = newMethod(subClass, "<init>", "(I)V"); |
| 89 | assertThat(index.getMethodsReferencing(source), containsInAnyOrder( | 88 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( |
| 90 | newBehaviorReferenceByMethod(source, callerClass.getName(), "d", "()V"), | 89 | newBehaviorReferenceByMethod(source, callerClass.getName(), "d", "()V"), |
| 91 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(II)V"), | 90 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(II)V"), |
| 92 | newBehaviorReferenceByMethod(source, subsubClass.getName(), "<init>", "(I)V") | 91 | newBehaviorReferenceByMethod(source, subsubClass.getName(), "<init>", "(I)V") |
| @@ -97,7 +96,7 @@ public class TestJarIndexConstructorReferences { | |||
| 97 | @SuppressWarnings("unchecked") | 96 | @SuppressWarnings("unchecked") |
| 98 | public void subIntInt() { | 97 | public void subIntInt() { |
| 99 | MethodEntry source = newMethod(subClass, "<init>", "(II)V"); | 98 | MethodEntry source = newMethod(subClass, "<init>", "(II)V"); |
| 100 | assertThat(index.getMethodsReferencing(source), containsInAnyOrder( | 99 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( |
| 101 | newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V") | 100 | newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V") |
| 102 | )); | 101 | )); |
| 103 | } | 102 | } |
| @@ -105,14 +104,14 @@ public class TestJarIndexConstructorReferences { | |||
| 105 | @Test | 104 | @Test |
| 106 | public void subIntIntInt() { | 105 | public void subIntIntInt() { |
| 107 | MethodEntry source = newMethod(subClass, "<init>", "(III)V"); | 106 | MethodEntry source = newMethod(subClass, "<init>", "(III)V"); |
| 108 | assertThat(index.getMethodsReferencing(source), is(empty())); | 107 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), is(empty())); |
| 109 | } | 108 | } |
| 110 | 109 | ||
| 111 | @Test | 110 | @Test |
| 112 | @SuppressWarnings("unchecked") | 111 | @SuppressWarnings("unchecked") |
| 113 | public void subsubInt() { | 112 | public void subsubInt() { |
| 114 | MethodEntry source = newMethod(subsubClass, "<init>", "(I)V"); | 113 | MethodEntry source = newMethod(subsubClass, "<init>", "(I)V"); |
| 115 | assertThat(index.getMethodsReferencing(source), containsInAnyOrder( | 114 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( |
| 116 | newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V") | 115 | newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V") |
| 117 | )); | 116 | )); |
| 118 | } | 117 | } |
| @@ -121,7 +120,7 @@ public class TestJarIndexConstructorReferences { | |||
| 121 | @SuppressWarnings("unchecked") | 120 | @SuppressWarnings("unchecked") |
| 122 | public void defaultConstructable() { | 121 | public void defaultConstructable() { |
| 123 | MethodEntry source = newMethod(defaultClass, "<init>", "()V"); | 122 | MethodEntry source = newMethod(defaultClass, "<init>", "()V"); |
| 124 | assertThat(index.getMethodsReferencing(source), containsInAnyOrder( | 123 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( |
| 125 | newBehaviorReferenceByMethod(source, callerClass.getName(), "g", "()V") | 124 | newBehaviorReferenceByMethod(source, callerClass.getName(), "g", "()V") |
| 126 | )); | 125 | )); |
| 127 | } | 126 | } |
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java b/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java index 23df1a99..36595a3b 100644 --- a/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java +++ b/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java | |||
| @@ -11,12 +11,22 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.analysis.*; | 14 | import cuchaz.enigma.analysis.EntryReference; |
| 15 | import cuchaz.enigma.mapping.entry.*; | 15 | import cuchaz.enigma.analysis.ParsedJar; |
| 16 | import cuchaz.enigma.analysis.index.EntryIndex; | ||
| 17 | import cuchaz.enigma.analysis.index.InheritanceIndex; | ||
| 18 | import cuchaz.enigma.analysis.index.JarIndex; | ||
| 19 | import cuchaz.enigma.translation.mapping.EntryResolver; | ||
| 20 | import cuchaz.enigma.translation.mapping.IndexEntryResolver; | ||
| 21 | import cuchaz.enigma.translation.representation.AccessFlags; | ||
| 22 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | ||
| 23 | import cuchaz.enigma.translation.representation.entry.FieldEntry; | ||
| 24 | import cuchaz.enigma.translation.representation.entry.MethodDefEntry; | ||
| 25 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | ||
| 16 | import org.junit.Test; | 26 | import org.junit.Test; |
| 27 | import org.objectweb.asm.Opcodes; | ||
| 17 | 28 | ||
| 18 | import java.util.Collection; | 29 | import java.util.Collection; |
| 19 | import java.util.Set; | ||
| 20 | import java.util.jar.JarFile; | 30 | import java.util.jar.JarFile; |
| 21 | 31 | ||
| 22 | import static cuchaz.enigma.TestEntryFactory.*; | 32 | import static cuchaz.enigma.TestEntryFactory.*; |
| @@ -27,7 +37,6 @@ public class TestJarIndexInheritanceTree { | |||
| 27 | 37 | ||
| 28 | private JarIndex index; | 38 | private JarIndex index; |
| 29 | 39 | ||
| 30 | private ClassEntry objectClass = newClass("java/lang/Object"); | ||
| 31 | private ClassEntry baseClass = newClass("a"); | 40 | private ClassEntry baseClass = newClass("a"); |
| 32 | private ClassEntry subClassA = newClass("b"); | 41 | private ClassEntry subClassA = newClass("b"); |
| 33 | private ClassEntry subClassAA = newClass("d"); | 42 | private ClassEntry subClassAA = newClass("d"); |
| @@ -37,13 +46,13 @@ public class TestJarIndexInheritanceTree { | |||
| 37 | 46 | ||
| 38 | public TestJarIndexInheritanceTree() | 47 | public TestJarIndexInheritanceTree() |
| 39 | throws Exception { | 48 | throws Exception { |
| 40 | index = new JarIndex(new ReferencedEntryPool()); | 49 | index = JarIndex.empty(); |
| 41 | index.indexJar(new ParsedJar(new JarFile("build/test-obf/inheritanceTree.jar")), false); | 50 | index.indexJar(new ParsedJar(new JarFile("build/test-obf/inheritanceTree.jar")), s -> {}); |
| 42 | } | 51 | } |
| 43 | 52 | ||
| 44 | @Test | 53 | @Test |
| 45 | public void obfEntries() { | 54 | public void obfEntries() { |
| 46 | assertThat(index.getObfClassEntries(), containsInAnyOrder( | 55 | assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder( |
| 47 | newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClassA, subClassAA, subClassB | 56 | newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClassA, subClassAA, subClassB |
| 48 | )); | 57 | )); |
| 49 | } | 58 | } |
| @@ -51,67 +60,68 @@ public class TestJarIndexInheritanceTree { | |||
| 51 | @Test | 60 | @Test |
| 52 | public void translationIndex() { | 61 | public void translationIndex() { |
| 53 | 62 | ||
| 54 | TranslationIndex index = this.index.getTranslationIndex(); | 63 | InheritanceIndex index = this.index.getInheritanceIndex(); |
| 55 | 64 | ||
| 56 | // base class | 65 | // base class |
| 57 | assertThat(index.getSuperclass(baseClass), is(objectClass)); | 66 | assertThat(index.getParents(baseClass), is(empty())); |
| 58 | assertThat(index.getAncestry(baseClass), contains(objectClass)); | 67 | assertThat(index.getAncestors(baseClass), is(empty())); |
| 59 | assertThat(index.getSubclass(baseClass), containsInAnyOrder(subClassA, subClassB | 68 | assertThat(index.getChildren(baseClass), containsInAnyOrder(subClassA, subClassB |
| 60 | )); | 69 | )); |
| 61 | 70 | ||
| 62 | // subclass a | 71 | // subclass a |
| 63 | assertThat(index.getSuperclass(subClassA), is(baseClass)); | 72 | assertThat(index.getParents(subClassA), contains(baseClass)); |
| 64 | assertThat(index.getAncestry(subClassA), contains(baseClass, objectClass)); | 73 | assertThat(index.getAncestors(subClassA), containsInAnyOrder(baseClass)); |
| 65 | assertThat(index.getSubclass(subClassA), contains(subClassAA)); | 74 | assertThat(index.getChildren(subClassA), contains(subClassAA)); |
| 66 | 75 | ||
| 67 | // subclass aa | 76 | // subclass aa |
| 68 | assertThat(index.getSuperclass(subClassAA), is(subClassA)); | 77 | assertThat(index.getParents(subClassAA), contains(subClassA)); |
| 69 | assertThat(index.getAncestry(subClassAA), contains(subClassA, baseClass, objectClass)); | 78 | assertThat(index.getAncestors(subClassAA), containsInAnyOrder(subClassA, baseClass)); |
| 70 | assertThat(index.getSubclass(subClassAA), is(empty())); | 79 | assertThat(index.getChildren(subClassAA), is(empty())); |
| 71 | 80 | ||
| 72 | // subclass b | 81 | // subclass b |
| 73 | assertThat(index.getSuperclass(subClassB), is(baseClass)); | 82 | assertThat(index.getParents(subClassB), contains(baseClass)); |
| 74 | assertThat(index.getAncestry(subClassB), contains(baseClass, objectClass)); | 83 | assertThat(index.getAncestors(subClassB), containsInAnyOrder(baseClass)); |
| 75 | assertThat(index.getSubclass(subClassB), is(empty())); | 84 | assertThat(index.getChildren(subClassB), is(empty())); |
| 76 | } | 85 | } |
| 77 | 86 | ||
| 78 | @Test | 87 | @Test |
| 79 | public void access() { | 88 | public void access() { |
| 80 | assertThat(index.getAccess(nameField), is(Access.PRIVATE)); | 89 | assertThat(index.getEntryIndex().getFieldAccess(nameField), is(new AccessFlags(Opcodes.ACC_PRIVATE))); |
| 81 | assertThat(index.getAccess(numThingsField), is(Access.PRIVATE)); | 90 | assertThat(index.getEntryIndex().getFieldAccess(numThingsField), is(new AccessFlags(Opcodes.ACC_PRIVATE))); |
| 82 | } | 91 | } |
| 83 | 92 | ||
| 84 | @Test | 93 | @Test |
| 85 | public void relatedMethodImplementations() { | 94 | public void relatedMethodImplementations() { |
| 86 | 95 | ||
| 87 | Set<MethodEntry> entries; | 96 | Collection<MethodEntry> entries; |
| 88 | 97 | ||
| 98 | EntryResolver resolver = new IndexEntryResolver(index); | ||
| 89 | // getName() | 99 | // getName() |
| 90 | entries = index.getRelatedMethodImplementations(newMethod(baseClass, "a", "()Ljava/lang/String;")); | 100 | entries = resolver.resolveEquivalentMethods(newMethod(baseClass, "a", "()Ljava/lang/String;")); |
| 91 | assertThat(entries, containsInAnyOrder( | 101 | assertThat(entries, containsInAnyOrder( |
| 92 | newMethod(baseClass, "a", "()Ljava/lang/String;"), | 102 | newMethod(baseClass, "a", "()Ljava/lang/String;"), |
| 93 | newMethod(subClassAA, "a", "()Ljava/lang/String;") | 103 | newMethod(subClassAA, "a", "()Ljava/lang/String;") |
| 94 | )); | 104 | )); |
| 95 | entries = index.getRelatedMethodImplementations(newMethod(subClassAA, "a", "()Ljava/lang/String;")); | 105 | entries = resolver.resolveEquivalentMethods(newMethod(subClassAA, "a", "()Ljava/lang/String;")); |
| 96 | assertThat(entries, containsInAnyOrder( | 106 | assertThat(entries, containsInAnyOrder( |
| 97 | newMethod(baseClass, "a", "()Ljava/lang/String;"), | 107 | newMethod(baseClass, "a", "()Ljava/lang/String;"), |
| 98 | newMethod(subClassAA, "a", "()Ljava/lang/String;") | 108 | newMethod(subClassAA, "a", "()Ljava/lang/String;") |
| 99 | )); | 109 | )); |
| 100 | 110 | ||
| 101 | // doBaseThings() | 111 | // doBaseThings() |
| 102 | entries = index.getRelatedMethodImplementations(newMethod(baseClass, "a", "()V")); | 112 | entries = resolver.resolveEquivalentMethods(newMethod(baseClass, "a", "()V")); |
| 103 | assertThat(entries, containsInAnyOrder( | 113 | assertThat(entries, containsInAnyOrder( |
| 104 | newMethod(baseClass, "a", "()V"), | 114 | newMethod(baseClass, "a", "()V"), |
| 105 | newMethod(subClassAA, "a", "()V"), | 115 | newMethod(subClassAA, "a", "()V"), |
| 106 | newMethod(subClassB, "a", "()V") | 116 | newMethod(subClassB, "a", "()V") |
| 107 | )); | 117 | )); |
| 108 | entries = index.getRelatedMethodImplementations(newMethod(subClassAA, "a", "()V")); | 118 | entries = resolver.resolveEquivalentMethods(newMethod(subClassAA, "a", "()V")); |
| 109 | assertThat(entries, containsInAnyOrder( | 119 | assertThat(entries, containsInAnyOrder( |
| 110 | newMethod(baseClass, "a", "()V"), | 120 | newMethod(baseClass, "a", "()V"), |
| 111 | newMethod(subClassAA, "a", "()V"), | 121 | newMethod(subClassAA, "a", "()V"), |
| 112 | newMethod(subClassB, "a", "()V") | 122 | newMethod(subClassB, "a", "()V") |
| 113 | )); | 123 | )); |
| 114 | entries = index.getRelatedMethodImplementations(newMethod(subClassB, "a", "()V")); | 124 | entries = resolver.resolveEquivalentMethods(newMethod(subClassB, "a", "()V")); |
| 115 | assertThat(entries, containsInAnyOrder( | 125 | assertThat(entries, containsInAnyOrder( |
| 116 | newMethod(baseClass, "a", "()V"), | 126 | newMethod(baseClass, "a", "()V"), |
| 117 | newMethod(subClassAA, "a", "()V"), | 127 | newMethod(subClassAA, "a", "()V"), |
| @@ -119,7 +129,7 @@ public class TestJarIndexInheritanceTree { | |||
| 119 | )); | 129 | )); |
| 120 | 130 | ||
| 121 | // doBThings | 131 | // doBThings |
| 122 | entries = index.getRelatedMethodImplementations(newMethod(subClassB, "b", "()V")); | 132 | entries = resolver.resolveEquivalentMethods(newMethod(subClassB, "b", "()V")); |
| 123 | assertThat(entries, containsInAnyOrder(newMethod(subClassB, "b", "()V"))); | 133 | assertThat(entries, containsInAnyOrder(newMethod(subClassB, "b", "()V"))); |
| 124 | } | 134 | } |
| 125 | 135 | ||
| @@ -129,14 +139,14 @@ public class TestJarIndexInheritanceTree { | |||
| 129 | Collection<EntryReference<FieldEntry, MethodDefEntry>> references; | 139 | Collection<EntryReference<FieldEntry, MethodDefEntry>> references; |
| 130 | 140 | ||
| 131 | // name | 141 | // name |
| 132 | references = index.getFieldReferences(nameField); | 142 | references = index.getReferenceIndex().getReferencesToField(nameField); |
| 133 | assertThat(references, containsInAnyOrder( | 143 | assertThat(references, containsInAnyOrder( |
| 134 | newFieldReferenceByMethod(nameField, baseClass.getName(), "<init>", "(Ljava/lang/String;)V"), | 144 | newFieldReferenceByMethod(nameField, baseClass.getName(), "<init>", "(Ljava/lang/String;)V"), |
| 135 | newFieldReferenceByMethod(nameField, baseClass.getName(), "a", "()Ljava/lang/String;") | 145 | newFieldReferenceByMethod(nameField, baseClass.getName(), "a", "()Ljava/lang/String;") |
| 136 | )); | 146 | )); |
| 137 | 147 | ||
| 138 | // numThings | 148 | // numThings |
| 139 | references = index.getFieldReferences(numThingsField); | 149 | references = index.getReferenceIndex().getReferencesToField(numThingsField); |
| 140 | assertThat(references, containsInAnyOrder( | 150 | assertThat(references, containsInAnyOrder( |
| 141 | newFieldReferenceByMethod(numThingsField, subClassB.getName(), "<init>", "()V"), | 151 | newFieldReferenceByMethod(numThingsField, subClassB.getName(), "<init>", "()V"), |
| 142 | newFieldReferenceByMethod(numThingsField, subClassB.getName(), "b", "()V") | 152 | newFieldReferenceByMethod(numThingsField, subClassB.getName(), "b", "()V") |
| @@ -152,7 +162,7 @@ public class TestJarIndexInheritanceTree { | |||
| 152 | 162 | ||
| 153 | // baseClass constructor | 163 | // baseClass constructor |
| 154 | source = newMethod(baseClass, "<init>", "(Ljava/lang/String;)V"); | 164 | source = newMethod(baseClass, "<init>", "(Ljava/lang/String;)V"); |
| 155 | references = index.getMethodsReferencing(source); | 165 | references = index.getReferenceIndex().getReferencesToMethod(source); |
| 156 | assertThat(references, containsInAnyOrder( | 166 | assertThat(references, containsInAnyOrder( |
| 157 | newBehaviorReferenceByMethod(source, subClassA.getName(), "<init>", "(Ljava/lang/String;)V"), | 167 | newBehaviorReferenceByMethod(source, subClassA.getName(), "<init>", "(Ljava/lang/String;)V"), |
| 158 | newBehaviorReferenceByMethod(source, subClassB.getName(), "<init>", "()V") | 168 | newBehaviorReferenceByMethod(source, subClassB.getName(), "<init>", "()V") |
| @@ -160,14 +170,14 @@ public class TestJarIndexInheritanceTree { | |||
| 160 | 170 | ||
| 161 | // subClassA constructor | 171 | // subClassA constructor |
| 162 | source = newMethod(subClassA, "<init>", "(Ljava/lang/String;)V"); | 172 | source = newMethod(subClassA, "<init>", "(Ljava/lang/String;)V"); |
| 163 | references = index.getMethodsReferencing(source); | 173 | references = index.getReferenceIndex().getReferencesToMethod(source); |
| 164 | assertThat(references, containsInAnyOrder( | 174 | assertThat(references, containsInAnyOrder( |
| 165 | newBehaviorReferenceByMethod(source, subClassAA.getName(), "<init>", "()V") | 175 | newBehaviorReferenceByMethod(source, subClassAA.getName(), "<init>", "()V") |
| 166 | )); | 176 | )); |
| 167 | 177 | ||
| 168 | // baseClass.getName() | 178 | // baseClass.getName() |
| 169 | source = newMethod(baseClass, "a", "()Ljava/lang/String;"); | 179 | source = newMethod(baseClass, "a", "()Ljava/lang/String;"); |
| 170 | references = index.getMethodsReferencing(source); | 180 | references = index.getReferenceIndex().getReferencesToMethod(source); |
| 171 | assertThat(references, containsInAnyOrder( | 181 | assertThat(references, containsInAnyOrder( |
| 172 | newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()Ljava/lang/String;"), | 182 | newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()Ljava/lang/String;"), |
| 173 | newBehaviorReferenceByMethod(source, subClassB.getName(), "a", "()V") | 183 | newBehaviorReferenceByMethod(source, subClassB.getName(), "a", "()V") |
| @@ -175,7 +185,7 @@ public class TestJarIndexInheritanceTree { | |||
| 175 | 185 | ||
| 176 | // subclassAA.getName() | 186 | // subclassAA.getName() |
| 177 | source = newMethod(subClassAA, "a", "()Ljava/lang/String;"); | 187 | source = newMethod(subClassAA, "a", "()Ljava/lang/String;"); |
| 178 | references = index.getMethodsReferencing(source); | 188 | references = index.getReferenceIndex().getReferencesToMethod(source); |
| 179 | assertThat(references, containsInAnyOrder( | 189 | assertThat(references, containsInAnyOrder( |
| 180 | newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()V") | 190 | newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()V") |
| 181 | )); | 191 | )); |
| @@ -183,35 +193,35 @@ public class TestJarIndexInheritanceTree { | |||
| 183 | 193 | ||
| 184 | @Test | 194 | @Test |
| 185 | public void containsEntries() { | 195 | public void containsEntries() { |
| 186 | 196 | EntryIndex entryIndex = index.getEntryIndex(); | |
| 187 | // classes | 197 | // classes |
| 188 | assertThat(index.containsObfClass(baseClass), is(true)); | 198 | assertThat(entryIndex.hasClass(baseClass), is(true)); |
| 189 | assertThat(index.containsObfClass(subClassA), is(true)); | 199 | assertThat(entryIndex.hasClass(subClassA), is(true)); |
| 190 | assertThat(index.containsObfClass(subClassAA), is(true)); | 200 | assertThat(entryIndex.hasClass(subClassAA), is(true)); |
| 191 | assertThat(index.containsObfClass(subClassB), is(true)); | 201 | assertThat(entryIndex.hasClass(subClassB), is(true)); |
| 192 | 202 | ||
| 193 | // fields | 203 | // fields |
| 194 | assertThat(index.containsObfField(nameField), is(true)); | 204 | assertThat(entryIndex.hasField(nameField), is(true)); |
| 195 | assertThat(index.containsObfField(numThingsField), is(true)); | 205 | assertThat(entryIndex.hasField(numThingsField), is(true)); |
| 196 | 206 | ||
| 197 | // methods | 207 | // methods |
| 198 | // getName() | 208 | // getName() |
| 199 | assertThat(index.containsObfMethod(newMethod(baseClass, "a", "()Ljava/lang/String;")), is(true)); | 209 | assertThat(entryIndex.hasMethod(newMethod(baseClass, "a", "()Ljava/lang/String;")), is(true)); |
| 200 | assertThat(index.containsObfMethod(newMethod(subClassA, "a", "()Ljava/lang/String;")), is(false)); | 210 | assertThat(entryIndex.hasMethod(newMethod(subClassA, "a", "()Ljava/lang/String;")), is(false)); |
| 201 | assertThat(index.containsObfMethod(newMethod(subClassAA, "a", "()Ljava/lang/String;")), is(true)); | 211 | assertThat(entryIndex.hasMethod(newMethod(subClassAA, "a", "()Ljava/lang/String;")), is(true)); |
| 202 | assertThat(index.containsObfMethod(newMethod(subClassB, "a", "()Ljava/lang/String;")), is(false)); | 212 | assertThat(entryIndex.hasMethod(newMethod(subClassB, "a", "()Ljava/lang/String;")), is(false)); |
| 203 | 213 | ||
| 204 | // doBaseThings() | 214 | // doBaseThings() |
| 205 | assertThat(index.containsObfMethod(newMethod(baseClass, "a", "()V")), is(true)); | 215 | assertThat(entryIndex.hasMethod(newMethod(baseClass, "a", "()V")), is(true)); |
| 206 | assertThat(index.containsObfMethod(newMethod(subClassA, "a", "()V")), is(false)); | 216 | assertThat(entryIndex.hasMethod(newMethod(subClassA, "a", "()V")), is(false)); |
| 207 | assertThat(index.containsObfMethod(newMethod(subClassAA, "a", "()V")), is(true)); | 217 | assertThat(entryIndex.hasMethod(newMethod(subClassAA, "a", "()V")), is(true)); |
| 208 | assertThat(index.containsObfMethod(newMethod(subClassB, "a", "()V")), is(true)); | 218 | assertThat(entryIndex.hasMethod(newMethod(subClassB, "a", "()V")), is(true)); |
| 209 | 219 | ||
| 210 | // doBThings() | 220 | // doBThings() |
| 211 | assertThat(index.containsObfMethod(newMethod(baseClass, "b", "()V")), is(false)); | 221 | assertThat(entryIndex.hasMethod(newMethod(baseClass, "b", "()V")), is(false)); |
| 212 | assertThat(index.containsObfMethod(newMethod(subClassA, "b", "()V")), is(false)); | 222 | assertThat(entryIndex.hasMethod(newMethod(subClassA, "b", "()V")), is(false)); |
| 213 | assertThat(index.containsObfMethod(newMethod(subClassAA, "b", "()V")), is(false)); | 223 | assertThat(entryIndex.hasMethod(newMethod(subClassAA, "b", "()V")), is(false)); |
| 214 | assertThat(index.containsObfMethod(newMethod(subClassB, "b", "()V")), is(true)); | 224 | assertThat(entryIndex.hasMethod(newMethod(subClassB, "b", "()V")), is(true)); |
| 215 | 225 | ||
| 216 | } | 226 | } |
| 217 | } | 227 | } |
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java b/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java index b4529ddc..1299bccc 100644 --- a/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java +++ b/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java | |||
| @@ -12,12 +12,19 @@ | |||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.analysis.*; | 14 | import cuchaz.enigma.analysis.*; |
| 15 | import cuchaz.enigma.mapping.*; | 15 | import cuchaz.enigma.analysis.index.EntryIndex; |
| 16 | import cuchaz.enigma.mapping.entry.*; | 16 | import cuchaz.enigma.analysis.index.InheritanceIndex; |
| 17 | import cuchaz.enigma.analysis.index.JarIndex; | ||
| 18 | import cuchaz.enigma.translation.VoidTranslator; | ||
| 19 | import cuchaz.enigma.translation.representation.AccessFlags; | ||
| 20 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | ||
| 21 | import cuchaz.enigma.translation.representation.entry.FieldEntry; | ||
| 22 | import cuchaz.enigma.translation.representation.entry.MethodDefEntry; | ||
| 23 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | ||
| 17 | import org.junit.Test; | 24 | import org.junit.Test; |
| 18 | 25 | ||
| 19 | import java.util.Collection; | 26 | import java.util.Collection; |
| 20 | import java.util.Set; | 27 | import java.util.List; |
| 21 | import java.util.jar.JarFile; | 28 | import java.util.jar.JarFile; |
| 22 | 29 | ||
| 23 | import static cuchaz.enigma.TestEntryFactory.*; | 30 | import static cuchaz.enigma.TestEntryFactory.*; |
| @@ -30,13 +37,13 @@ public class TestJarIndexLoneClass { | |||
| 30 | 37 | ||
| 31 | public TestJarIndexLoneClass() | 38 | public TestJarIndexLoneClass() |
| 32 | throws Exception { | 39 | throws Exception { |
| 33 | index = new JarIndex(new ReferencedEntryPool()); | 40 | index = JarIndex.empty(); |
| 34 | index.indexJar(new ParsedJar(new JarFile("build/test-obf/loneClass.jar")), false); | 41 | index.indexJar(new ParsedJar(new JarFile("build/test-obf/loneClass.jar")), s -> {}); |
| 35 | } | 42 | } |
| 36 | 43 | ||
| 37 | @Test | 44 | @Test |
| 38 | public void obfEntries() { | 45 | public void obfEntries() { |
| 39 | assertThat(index.getObfClassEntries(), containsInAnyOrder( | 46 | assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder( |
| 40 | newClass("cuchaz/enigma/inputs/Keep"), | 47 | newClass("cuchaz/enigma/inputs/Keep"), |
| 41 | newClass("a") | 48 | newClass("a") |
| 42 | )); | 49 | )); |
| @@ -44,25 +51,28 @@ public class TestJarIndexLoneClass { | |||
| 44 | 51 | ||
| 45 | @Test | 52 | @Test |
| 46 | public void translationIndex() { | 53 | public void translationIndex() { |
| 47 | assertThat(index.getTranslationIndex().getSuperclass(new ClassEntry("a")), is(new ClassEntry("java/lang/Object"))); | 54 | InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); |
| 48 | assertThat(index.getTranslationIndex().getSuperclass(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(new ClassEntry("java/lang/Object"))); | 55 | assertThat(inheritanceIndex.getParents(new ClassEntry("a")), is(empty())); |
| 49 | assertThat(index.getTranslationIndex().getAncestry(new ClassEntry("a")), contains(new ClassEntry("java/lang/Object"))); | 56 | assertThat(inheritanceIndex.getParents(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty())); |
| 50 | assertThat(index.getTranslationIndex().getAncestry(new ClassEntry("cuchaz/enigma/inputs/Keep")), contains(new ClassEntry("java/lang/Object"))); | 57 | assertThat(inheritanceIndex.getAncestors(new ClassEntry("a")), is(empty())); |
| 51 | assertThat(index.getTranslationIndex().getSubclass(new ClassEntry("a")), is(empty())); | 58 | assertThat(inheritanceIndex.getAncestors(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty())); |
| 52 | assertThat(index.getTranslationIndex().getSubclass(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty())); | 59 | assertThat(inheritanceIndex.getChildren(new ClassEntry("a")), is(empty())); |
| 60 | assertThat(inheritanceIndex.getChildren(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty())); | ||
| 53 | } | 61 | } |
| 54 | 62 | ||
| 55 | @Test | 63 | @Test |
| 56 | public void access() { | 64 | public void access() { |
| 57 | assertThat(index.getAccess(newField("a", "a", "Ljava/lang/String;")), is(Access.PRIVATE)); | 65 | EntryIndex entryIndex = index.getEntryIndex(); |
| 58 | assertThat(index.getAccess(newMethod("a", "a", "()Ljava/lang/String;")), is(Access.PUBLIC)); | 66 | assertThat(entryIndex.getFieldAccess(newField("a", "a", "Ljava/lang/String;")), is(AccessFlags.PRIVATE)); |
| 59 | assertThat(index.getAccess(newField("a", "b", "Ljava/lang/String;")), is(nullValue())); | 67 | assertThat(entryIndex.getMethodAccess(newMethod("a", "a", "()Ljava/lang/String;")), is(AccessFlags.PUBLIC)); |
| 60 | assertThat(index.getAccess(newField("a", "a", "LFoo;")), is(nullValue())); | 68 | assertThat(entryIndex.getFieldAccess(newField("a", "b", "Ljava/lang/String;")), is(nullValue())); |
| 69 | assertThat(entryIndex.getFieldAccess(newField("a", "a", "LFoo;")), is(nullValue())); | ||
| 61 | } | 70 | } |
| 62 | 71 | ||
| 63 | @Test | 72 | @Test |
| 64 | public void classInheritance() { | 73 | public void classInheritance() { |
| 65 | ClassInheritanceTreeNode node = index.getClassInheritance(new DirectionalTranslator(new ReferencedEntryPool()), newClass("a")); | 74 | IndexTreeBuilder treeBuilder = new IndexTreeBuilder(index); |
| 75 | ClassInheritanceTreeNode node = treeBuilder.buildClassInheritance(VoidTranslator.INSTANCE, newClass("a")); | ||
| 66 | assertThat(node, is(not(nullValue()))); | 76 | assertThat(node, is(not(nullValue()))); |
| 67 | assertThat(node.getObfClassName(), is("a")); | 77 | assertThat(node.getObfClassName(), is("a")); |
| 68 | assertThat(node.getChildCount(), is(0)); | 78 | assertThat(node.getChildCount(), is(0)); |
| @@ -70,8 +80,9 @@ public class TestJarIndexLoneClass { | |||
| 70 | 80 | ||
| 71 | @Test | 81 | @Test |
| 72 | public void methodInheritance() { | 82 | public void methodInheritance() { |
| 83 | IndexTreeBuilder treeBuilder = new IndexTreeBuilder(index); | ||
| 73 | MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); | 84 | MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); |
| 74 | MethodInheritanceTreeNode node = index.getMethodInheritance(new DirectionalTranslator(new ReferencedEntryPool()), source); | 85 | MethodInheritanceTreeNode node = treeBuilder.buildMethodInheritance(VoidTranslator.INSTANCE, source); |
| 75 | assertThat(node, is(not(nullValue()))); | 86 | assertThat(node, is(not(nullValue()))); |
| 76 | assertThat(node.getMethodEntry(), is(source)); | 87 | assertThat(node.getMethodEntry(), is(source)); |
| 77 | assertThat(node.getChildCount(), is(0)); | 88 | assertThat(node.getChildCount(), is(0)); |
| @@ -79,19 +90,24 @@ public class TestJarIndexLoneClass { | |||
| 79 | 90 | ||
| 80 | @Test | 91 | @Test |
| 81 | public void classImplementations() { | 92 | public void classImplementations() { |
| 82 | ClassImplementationsTreeNode node = index.getClassImplementations(new DirectionalTranslator(new ReferencedEntryPool()), newClass("a")); | 93 | IndexTreeBuilder treeBuilder = new IndexTreeBuilder(index); |
| 94 | ClassImplementationsTreeNode node = treeBuilder.buildClassImplementations(VoidTranslator.INSTANCE, newClass("a")); | ||
| 83 | assertThat(node, is(nullValue())); | 95 | assertThat(node, is(nullValue())); |
| 84 | } | 96 | } |
| 85 | 97 | ||
| 86 | @Test | 98 | @Test |
| 87 | public void methodImplementations() { | 99 | public void methodImplementations() { |
| 100 | IndexTreeBuilder treeBuilder = new IndexTreeBuilder(index); | ||
| 88 | MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); | 101 | MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); |
| 89 | assertThat(index.getMethodImplementations(new DirectionalTranslator(new ReferencedEntryPool()), source), is(empty())); | 102 | |
| 103 | List<MethodImplementationsTreeNode> nodes = treeBuilder.buildMethodImplementations(VoidTranslator.INSTANCE, source); | ||
| 104 | assertThat(nodes, hasSize(1)); | ||
| 105 | assertThat(nodes.get(0).getMethodEntry(), is(source)); | ||
| 90 | } | 106 | } |
| 91 | 107 | ||
| 92 | @Test | 108 | @Test |
| 93 | public void relatedMethodImplementations() { | 109 | public void relatedMethodImplementations() { |
| 94 | Set<MethodEntry> entries = index.getRelatedMethodImplementations(newMethod("a", "a", "()Ljava/lang/String;")); | 110 | Collection<MethodEntry> entries = index.getEntryResolver().resolveEquivalentMethods(newMethod("a", "a", "()Ljava/lang/String;")); |
| 95 | assertThat(entries, containsInAnyOrder( | 111 | assertThat(entries, containsInAnyOrder( |
| 96 | newMethod("a", "a", "()Ljava/lang/String;") | 112 | newMethod("a", "a", "()Ljava/lang/String;") |
| 97 | )); | 113 | )); |
| @@ -101,7 +117,7 @@ public class TestJarIndexLoneClass { | |||
| 101 | @SuppressWarnings("unchecked") | 117 | @SuppressWarnings("unchecked") |
| 102 | public void fieldReferences() { | 118 | public void fieldReferences() { |
| 103 | FieldEntry source = newField("a", "a", "Ljava/lang/String;"); | 119 | FieldEntry source = newField("a", "a", "Ljava/lang/String;"); |
| 104 | Collection<EntryReference<FieldEntry, MethodDefEntry>> references = index.getFieldReferences(source); | 120 | Collection<EntryReference<FieldEntry, MethodDefEntry>> references = index.getReferenceIndex().getReferencesToField(source); |
| 105 | assertThat(references, containsInAnyOrder( | 121 | assertThat(references, containsInAnyOrder( |
| 106 | newFieldReferenceByMethod(source, "a", "<init>", "(Ljava/lang/String;)V"), | 122 | newFieldReferenceByMethod(source, "a", "<init>", "(Ljava/lang/String;)V"), |
| 107 | newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;") | 123 | newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;") |
| @@ -110,42 +126,33 @@ public class TestJarIndexLoneClass { | |||
| 110 | 126 | ||
| 111 | @Test | 127 | @Test |
| 112 | public void behaviorReferences() { | 128 | public void behaviorReferences() { |
| 113 | assertThat(index.getMethodsReferencing(newMethod("a", "a", "()Ljava/lang/String;")), is(empty())); | 129 | assertThat(index.getReferenceIndex().getReferencesToMethod(newMethod("a", "a", "()Ljava/lang/String;")), is(empty())); |
| 114 | } | ||
| 115 | |||
| 116 | @Test | ||
| 117 | public void innerClasses() { | ||
| 118 | assertThat(index.getInnerClasses(newClass("a")), is(empty())); | ||
| 119 | } | ||
| 120 | |||
| 121 | @Test | ||
| 122 | public void outerClass() { | ||
| 123 | assertThat(index.getOuterClass(newClass("a")), is(nullValue())); | ||
| 124 | } | 130 | } |
| 125 | 131 | ||
| 126 | @Test | 132 | @Test |
| 127 | public void interfaces() { | 133 | public void interfaces() { |
| 128 | assertThat(index.getInterfaces("a"), is(empty())); | 134 | assertThat(index.getInheritanceIndex().getParents(new ClassEntry("a")), is(empty())); |
| 129 | } | 135 | } |
| 130 | 136 | ||
| 131 | @Test | 137 | @Test |
| 132 | public void implementingClasses() { | 138 | public void implementingClasses() { |
| 133 | assertThat(index.getImplementingClasses("a"), is(empty())); | 139 | assertThat(index.getInheritanceIndex().getChildren(new ClassEntry("a")), is(empty())); |
| 134 | } | 140 | } |
| 135 | 141 | ||
| 136 | @Test | 142 | @Test |
| 137 | public void isInterface() { | 143 | public void isInterface() { |
| 138 | assertThat(index.isInterface("a"), is(false)); | 144 | assertThat(index.getInheritanceIndex().isParent(new ClassEntry("a")), is(false)); |
| 139 | } | 145 | } |
| 140 | 146 | ||
| 141 | @Test | 147 | @Test |
| 142 | public void testContains() { | 148 | public void testContains() { |
| 143 | assertThat(index.containsObfClass(newClass("a")), is(true)); | 149 | EntryIndex entryIndex = index.getEntryIndex(); |
| 144 | assertThat(index.containsObfClass(newClass("b")), is(false)); | 150 | assertThat(entryIndex.hasClass(newClass("a")), is(true)); |
| 145 | assertThat(index.containsObfField(newField("a", "a", "Ljava/lang/String;")), is(true)); | 151 | assertThat(entryIndex.hasClass(newClass("b")), is(false)); |
| 146 | assertThat(index.containsObfField(newField("a", "b", "Ljava/lang/String;")), is(false)); | 152 | assertThat(entryIndex.hasField(newField("a", "a", "Ljava/lang/String;")), is(true)); |
| 147 | assertThat(index.containsObfField(newField("a", "a", "LFoo;")), is(false)); | 153 | assertThat(entryIndex.hasField(newField("a", "b", "Ljava/lang/String;")), is(false)); |
| 148 | assertThat(index.containsObfMethod(newMethod("a", "a", "()Ljava/lang/String;")), is(true)); | 154 | assertThat(entryIndex.hasField(newField("a", "a", "LFoo;")), is(false)); |
| 149 | assertThat(index.containsObfMethod(newMethod("a", "b", "()Ljava/lang/String;")), is(false)); | 155 | assertThat(entryIndex.hasMethod(newMethod("a", "a", "()Ljava/lang/String;")), is(true)); |
| 156 | assertThat(entryIndex.hasMethod(newMethod("a", "b", "()Ljava/lang/String;")), is(false)); | ||
| 150 | } | 157 | } |
| 151 | } | 158 | } |
diff --git a/src/test/java/cuchaz/enigma/TestMethodDescriptor.java b/src/test/java/cuchaz/enigma/TestMethodDescriptor.java index 48c46e52..a73880dd 100644 --- a/src/test/java/cuchaz/enigma/TestMethodDescriptor.java +++ b/src/test/java/cuchaz/enigma/TestMethodDescriptor.java | |||
| @@ -11,8 +11,8 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.mapping.MethodDescriptor; | 14 | import cuchaz.enigma.translation.representation.MethodDescriptor; |
| 15 | import cuchaz.enigma.mapping.TypeDescriptor; | 15 | import cuchaz.enigma.translation.representation.TypeDescriptor; |
| 16 | import org.junit.Test; | 16 | import org.junit.Test; |
| 17 | 17 | ||
| 18 | import static org.hamcrest.MatcherAssert.assertThat; | 18 | import static org.hamcrest.MatcherAssert.assertThat; |
diff --git a/src/test/java/cuchaz/enigma/TestSourceIndex.java b/src/test/java/cuchaz/enigma/TestSourceIndex.java index 07542753..a5f5f712 100644 --- a/src/test/java/cuchaz/enigma/TestSourceIndex.java +++ b/src/test/java/cuchaz/enigma/TestSourceIndex.java | |||
| @@ -13,7 +13,7 @@ package cuchaz.enigma; | |||
| 13 | 13 | ||
| 14 | import com.google.common.collect.Sets; | 14 | import com.google.common.collect.Sets; |
| 15 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; | 15 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; |
| 16 | import cuchaz.enigma.mapping.entry.ClassEntry; | 16 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 17 | import org.junit.Test; | 17 | import org.junit.Test; |
| 18 | 18 | ||
| 19 | import java.io.File; | 19 | import java.io.File; |
| @@ -44,7 +44,7 @@ public class TestSourceIndex { | |||
| 44 | 44 | ||
| 45 | // get all classes that aren't inner classes | 45 | // get all classes that aren't inner classes |
| 46 | Set<ClassEntry> classEntries = Sets.newHashSet(); | 46 | Set<ClassEntry> classEntries = Sets.newHashSet(); |
| 47 | for (ClassEntry obfClassEntry : deobfuscator.getJarIndex().getObfClassEntries()) { | 47 | for (ClassEntry obfClassEntry : deobfuscator.getJarIndex().getEntryIndex().getClasses()) { |
| 48 | if (!obfClassEntry.isInnerClass()) { | 48 | if (!obfClassEntry.isInnerClass()) { |
| 49 | classEntries.add(obfClassEntry); | 49 | classEntries.add(obfClassEntry); |
| 50 | } | 50 | } |
diff --git a/src/test/java/cuchaz/enigma/TestTokensConstructors.java b/src/test/java/cuchaz/enigma/TestTokensConstructors.java index 0e98da7f..1ee0bde1 100644 --- a/src/test/java/cuchaz/enigma/TestTokensConstructors.java +++ b/src/test/java/cuchaz/enigma/TestTokensConstructors.java | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.mapping.entry.MethodEntry; | 14 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| 15 | import org.junit.Test; | 15 | import org.junit.Test; |
| 16 | 16 | ||
| 17 | import java.util.jar.JarFile; | 17 | import java.util.jar.JarFile; |
diff --git a/src/test/java/cuchaz/enigma/TestTranslator.java b/src/test/java/cuchaz/enigma/TestTranslator.java index 9b6eb916..b9781297 100644 --- a/src/test/java/cuchaz/enigma/TestTranslator.java +++ b/src/test/java/cuchaz/enigma/TestTranslator.java | |||
| @@ -11,23 +11,14 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.mapping.entry.Entry; | 14 | import cuchaz.enigma.translation.representation.entry.Entry; |
| 15 | import cuchaz.enigma.mapping.Mappings; | ||
| 16 | import cuchaz.enigma.mapping.Translator; | ||
| 17 | import org.junit.BeforeClass; | 15 | import org.junit.BeforeClass; |
| 18 | import org.junit.Test; | 16 | import org.junit.Test; |
| 19 | 17 | ||
| 20 | import static cuchaz.enigma.TestEntryFactory.newClass; | 18 | import static cuchaz.enigma.TestEntryFactory.*; |
| 21 | import static cuchaz.enigma.TestEntryFactory.newField; | ||
| 22 | import static cuchaz.enigma.TestEntryFactory.newMethod; | ||
| 23 | 19 | ||
| 24 | public class TestTranslator { | 20 | public class TestTranslator { |
| 25 | 21 | ||
| 26 | private static Deobfuscator deobfuscator; | ||
| 27 | private static Mappings mappings; | ||
| 28 | private static Translator deobfTranslator; | ||
| 29 | private static Translator obfTranslator; | ||
| 30 | |||
| 31 | @BeforeClass | 22 | @BeforeClass |
| 32 | public static void beforeClass() | 23 | public static void beforeClass() |
| 33 | throws Exception { | 24 | throws Exception { |
| @@ -147,7 +138,7 @@ public class TestTranslator { | |||
| 147 | assertMapping(newMethod("i$b", "a", "()Ljava/lang/Object;"), newMethod("deobf/I_Generics$B_Generic", "m1", "()Ljava/lang/Object;")); | 138 | assertMapping(newMethod("i$b", "a", "()Ljava/lang/Object;"), newMethod("deobf/I_Generics$B_Generic", "m1", "()Ljava/lang/Object;")); |
| 148 | } | 139 | } |
| 149 | 140 | ||
| 150 | private void assertMapping(Entry obf, Entry deobf) { | 141 | private void assertMapping(Entry<?> obf, Entry<?> deobf) { |
| 151 | //assertThat(deobfTranslator.translateEntry(obf), is(deobf)); | 142 | //assertThat(deobfTranslator.translateEntry(obf), is(deobf)); |
| 152 | //assertThat(obfTranslator.translateEntry(deobf), is(obf)); | 143 | //assertThat(obfTranslator.translateEntry(deobf), is(obf)); |
| 153 | 144 | ||
diff --git a/src/test/java/cuchaz/enigma/TestTypeDescriptor.java b/src/test/java/cuchaz/enigma/TestTypeDescriptor.java index 8172848c..b9ebe559 100644 --- a/src/test/java/cuchaz/enigma/TestTypeDescriptor.java +++ b/src/test/java/cuchaz/enigma/TestTypeDescriptor.java | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.mapping.TypeDescriptor; | 14 | import cuchaz.enigma.translation.representation.TypeDescriptor; |
| 15 | import org.junit.Test; | 15 | import org.junit.Test; |
| 16 | 16 | ||
| 17 | import static cuchaz.enigma.TestEntryFactory.newClass; | 17 | import static cuchaz.enigma.TestEntryFactory.newClass; |
diff --git a/src/test/java/cuchaz/enigma/TokenChecker.java b/src/test/java/cuchaz/enigma/TokenChecker.java index d863a5ae..aac28662 100644 --- a/src/test/java/cuchaz/enigma/TokenChecker.java +++ b/src/test/java/cuchaz/enigma/TokenChecker.java | |||
| @@ -16,7 +16,7 @@ import com.strobel.decompiler.languages.java.ast.CompilationUnit; | |||
| 16 | import cuchaz.enigma.analysis.EntryReference; | 16 | import cuchaz.enigma.analysis.EntryReference; |
| 17 | import cuchaz.enigma.analysis.SourceIndex; | 17 | import cuchaz.enigma.analysis.SourceIndex; |
| 18 | import cuchaz.enigma.analysis.Token; | 18 | import cuchaz.enigma.analysis.Token; |
| 19 | import cuchaz.enigma.mapping.entry.Entry; | 19 | import cuchaz.enigma.translation.representation.entry.Entry; |
| 20 | 20 | ||
| 21 | import java.io.IOException; | 21 | import java.io.IOException; |
| 22 | import java.util.Collection; | 22 | import java.util.Collection; |
| @@ -32,9 +32,9 @@ public class TokenChecker { | |||
| 32 | deobfuscator = new Deobfuscator(jarFile); | 32 | deobfuscator = new Deobfuscator(jarFile); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | protected String getDeclarationToken(Entry entry) { | 35 | protected String getDeclarationToken(Entry<?> entry) { |
| 36 | // decompile the class | 36 | // decompile the class |
| 37 | CompilationUnit tree = deobfuscator.getSourceTree(entry.getClassName()); | 37 | CompilationUnit tree = deobfuscator.getSourceTree(entry.getContainingClass().getFullName()); |
| 38 | // DEBUG | 38 | // DEBUG |
| 39 | // tree.acceptVisitor( new TreeDumpVisitor( new File( "tree." + entry.getClassName().replace( '/', '.' ) + ".txt" ) ), null ); | 39 | // tree.acceptVisitor( new TreeDumpVisitor( new File( "tree." + entry.getClassName().replace( '/', '.' ) + ".txt" ) ), null ); |
| 40 | String source = deobfuscator.getSource(tree); | 40 | String source = deobfuscator.getSource(tree); |
| @@ -49,15 +49,15 @@ public class TokenChecker { | |||
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | @SuppressWarnings("unchecked") | 51 | @SuppressWarnings("unchecked") |
| 52 | protected Collection<String> getReferenceTokens(EntryReference<? extends Entry, ? extends Entry> reference) { | 52 | protected Collection<String> getReferenceTokens(EntryReference<? extends Entry<?>, ? extends Entry<?>> reference) { |
| 53 | // decompile the class | 53 | // decompile the class |
| 54 | CompilationUnit tree = deobfuscator.getSourceTree(reference.context.getClassName()); | 54 | CompilationUnit tree = deobfuscator.getSourceTree(reference.context.getContainingClass().getFullName()); |
| 55 | String source = deobfuscator.getSource(tree); | 55 | String source = deobfuscator.getSource(tree); |
| 56 | SourceIndex index = deobfuscator.getSourceIndex(tree, source); | 56 | SourceIndex index = deobfuscator.getSourceIndex(tree, source); |
| 57 | 57 | ||
| 58 | // get the token values | 58 | // get the token values |
| 59 | List<String> values = Lists.newArrayList(); | 59 | List<String> values = Lists.newArrayList(); |
| 60 | for (Token token : index.getReferenceTokens((EntryReference<Entry, Entry>) reference)) { | 60 | for (Token token : index.getReferenceTokens((EntryReference<Entry<?>, Entry<?>>) reference)) { |
| 61 | values.add(source.substring(token.start, token.end)); | 61 | values.add(source.substring(token.start, token.end)); |
| 62 | } | 62 | } |
| 63 | return values; | 63 | return values; |