summaryrefslogtreecommitdiff
path: root/src/test/java/cuchaz/enigma/TokenChecker.java
diff options
context:
space:
mode:
authorGravatar gegy10002019-06-18 20:20:40 +0200
committerGravatar gegy10002019-06-18 20:20:40 +0200
commit42243fa65e1d87f6a0498f6e2d83505605409411 (patch)
treec4127d7928c752360639b42b221c96678cdc5807 /src/test/java/cuchaz/enigma/TokenChecker.java
parentPlugin rework along with API rework: Enigma split from EnigmaProject; plugins... (diff)
parentfix unwanted declaration navigation during Quick Find (diff)
downloadenigma-fork-42243fa65e1d87f6a0498f6e2d83505605409411.tar.gz
enigma-fork-42243fa65e1d87f6a0498f6e2d83505605409411.tar.xz
enigma-fork-42243fa65e1d87f6a0498f6e2d83505605409411.zip
Mostly resolve test failures
Diffstat (limited to 'src/test/java/cuchaz/enigma/TokenChecker.java')
-rw-r--r--src/test/java/cuchaz/enigma/TokenChecker.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/test/java/cuchaz/enigma/TokenChecker.java b/src/test/java/cuchaz/enigma/TokenChecker.java
index 9e0c696..1dde034 100644
--- a/src/test/java/cuchaz/enigma/TokenChecker.java
+++ b/src/test/java/cuchaz/enigma/TokenChecker.java
@@ -13,28 +13,30 @@ package cuchaz.enigma;
13 13
14import com.google.common.collect.Lists; 14import com.google.common.collect.Lists;
15import com.strobel.decompiler.languages.java.ast.CompilationUnit; 15import com.strobel.decompiler.languages.java.ast.CompilationUnit;
16import cuchaz.enigma.analysis.ClassCache;
16import cuchaz.enigma.analysis.EntryReference; 17import cuchaz.enigma.analysis.EntryReference;
17import cuchaz.enigma.analysis.SourceIndex; 18import cuchaz.enigma.analysis.SourceIndex;
18import cuchaz.enigma.analysis.Token; 19import cuchaz.enigma.analysis.Token;
19import cuchaz.enigma.translation.representation.entry.Entry; 20import cuchaz.enigma.translation.representation.entry.Entry;
20 21
21import java.io.IOException; 22import java.io.IOException;
23import java.nio.file.Path;
22import java.util.Collection; 24import java.util.Collection;
23import java.util.List; 25import java.util.List;
24import java.util.jar.JarFile;
25 26
26public class TokenChecker { 27public class TokenChecker {
27 28
28 private Enigma enigma; 29 private SourceProvider sourceProvider;
29 30
30 protected TokenChecker(JarFile jarFile) 31 protected TokenChecker(Path path) throws IOException {
31 throws IOException { 32 ClassCache classCache = ClassCache.of(path);
32 enigma = new Enigma(jarFile); 33
34 CompiledSourceTypeLoader typeLoader = new CompiledSourceTypeLoader(classCache);
35 sourceProvider = new SourceProvider(SourceProvider.createSettings(), typeLoader);
33 } 36 }
34 37
35 protected String getDeclarationToken(Entry<?> entry) { 38 protected String getDeclarationToken(Entry<?> entry) {
36 // decompile the class 39 // decompile the class
37 SourceProvider sourceProvider = enigma.getObfSourceProvider();
38 CompilationUnit tree = sourceProvider.getSources(entry.getContainingClass().getFullName()); 40 CompilationUnit tree = sourceProvider.getSources(entry.getContainingClass().getFullName());
39 // DEBUG 41 // DEBUG
40 // tree.acceptVisitor( new TreeDumpVisitor( new File( "tree." + entry.getClassName().replace( '/', '.' ) + ".txt" ) ), null ); 42 // tree.acceptVisitor( new TreeDumpVisitor( new File( "tree." + entry.getClassName().replace( '/', '.' ) + ".txt" ) ), null );
@@ -52,7 +54,6 @@ public class TokenChecker {
52 @SuppressWarnings("unchecked") 54 @SuppressWarnings("unchecked")
53 protected Collection<String> getReferenceTokens(EntryReference<? extends Entry<?>, ? extends Entry<?>> reference) { 55 protected Collection<String> getReferenceTokens(EntryReference<? extends Entry<?>, ? extends Entry<?>> reference) {
54 // decompile the class 56 // decompile the class
55 SourceProvider sourceProvider = enigma.getObfSourceProvider();
56 CompilationUnit tree = sourceProvider.getSources(reference.context.getContainingClass().getFullName()); 57 CompilationUnit tree = sourceProvider.getSources(reference.context.getContainingClass().getFullName());
57 String source = sourceProvider.writeSourceToString(tree); 58 String source = sourceProvider.writeSourceToString(tree);
58 SourceIndex index = SourceIndex.buildIndex(source, tree, true); 59 SourceIndex index = SourceIndex.buildIndex(source, tree, true);