diff options
| author | 2019-06-18 20:20:40 +0200 | |
|---|---|---|
| committer | 2019-06-18 20:20:40 +0200 | |
| commit | 42243fa65e1d87f6a0498f6e2d83505605409411 (patch) | |
| tree | c4127d7928c752360639b42b221c96678cdc5807 /src/test/java/cuchaz/enigma/TokenChecker.java | |
| parent | Plugin rework along with API rework: Enigma split from EnigmaProject; plugins... (diff) | |
| parent | fix unwanted declaration navigation during Quick Find (diff) | |
| download | enigma-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.java | 15 |
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 | ||
| 14 | import com.google.common.collect.Lists; | 14 | import com.google.common.collect.Lists; |
| 15 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; | 15 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; |
| 16 | import cuchaz.enigma.analysis.ClassCache; | ||
| 16 | import cuchaz.enigma.analysis.EntryReference; | 17 | import cuchaz.enigma.analysis.EntryReference; |
| 17 | import cuchaz.enigma.analysis.SourceIndex; | 18 | import cuchaz.enigma.analysis.SourceIndex; |
| 18 | import cuchaz.enigma.analysis.Token; | 19 | import cuchaz.enigma.analysis.Token; |
| 19 | import cuchaz.enigma.translation.representation.entry.Entry; | 20 | import cuchaz.enigma.translation.representation.entry.Entry; |
| 20 | 21 | ||
| 21 | import java.io.IOException; | 22 | import java.io.IOException; |
| 23 | import java.nio.file.Path; | ||
| 22 | import java.util.Collection; | 24 | import java.util.Collection; |
| 23 | import java.util.List; | 25 | import java.util.List; |
| 24 | import java.util.jar.JarFile; | ||
| 25 | 26 | ||
| 26 | public class TokenChecker { | 27 | public 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); |