summaryrefslogtreecommitdiff
path: root/src/test/java/cuchaz/enigma/TokenChecker.java
diff options
context:
space:
mode:
authorGravatar Gegy2019-01-30 21:05:32 +0200
committerGravatar GitHub2019-01-30 21:05:32 +0200
commitba7a354efae7d49833c887cf147ac940c975a1fa (patch)
tree02e14fda81dd5984e24f2df392c57c6e829fc875 /src/test/java/cuchaz/enigma/TokenChecker.java
parentRewrite the Jenkinsfile to use the new declarative pipeline syntax, lets hope... (diff)
downloadenigma-fork-ba7a354efae7d49833c887cf147ac940c975a1fa.tar.gz
enigma-fork-ba7a354efae7d49833c887cf147ac940c975a1fa.tar.xz
enigma-fork-ba7a354efae7d49833c887cf147ac940c975a1fa.zip
Remap sources (#106)
* Source remapping beginnings * Fix navigation to remapped classes * Translate identifier info reference * Remap local variables with default names in source * Caching translator * Fix lack of highlighting for first opened class * Fix unicode variable names * Unicode checker shouldn't be checking just alphanumeric * Fix package tree being built from obf names * Don't index `this` as method call for method::reference * Apply proposed names * Fix source export issues * Replace unicode var names at bytecode level uniquely * Drop imports from editor source * Class selector fixes * Delta keep track of base mappings to enable lookup of old names * Optimize source remapping by remapping source with a StringBuffer instead of copying * Bump version
Diffstat (limited to 'src/test/java/cuchaz/enigma/TokenChecker.java')
-rw-r--r--src/test/java/cuchaz/enigma/TokenChecker.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/test/java/cuchaz/enigma/TokenChecker.java b/src/test/java/cuchaz/enigma/TokenChecker.java
index aac2866..c4670a2 100644
--- a/src/test/java/cuchaz/enigma/TokenChecker.java
+++ b/src/test/java/cuchaz/enigma/TokenChecker.java
@@ -34,11 +34,12 @@ public class TokenChecker {
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.getContainingClass().getFullName()); 37 SourceProvider sourceProvider = deobfuscator.getObfSourceProvider();
38 CompilationUnit tree = sourceProvider.getSources(entry.getContainingClass().getFullName());
38 // DEBUG 39 // DEBUG
39 // tree.acceptVisitor( new TreeDumpVisitor( new File( "tree." + entry.getClassName().replace( '/', '.' ) + ".txt" ) ), null ); 40 // tree.acceptVisitor( new TreeDumpVisitor( new File( "tree." + entry.getClassName().replace( '/', '.' ) + ".txt" ) ), null );
40 String source = deobfuscator.getSource(tree); 41 String source = sourceProvider.writeSourceToString(tree);
41 SourceIndex index = deobfuscator.getSourceIndex(tree, source); 42 SourceIndex index = SourceIndex.buildIndex(source, tree, true);
42 43
43 // get the token value 44 // get the token value
44 Token token = index.getDeclarationToken(entry); 45 Token token = index.getDeclarationToken(entry);
@@ -51,9 +52,10 @@ public class TokenChecker {
51 @SuppressWarnings("unchecked") 52 @SuppressWarnings("unchecked")
52 protected Collection<String> getReferenceTokens(EntryReference<? extends Entry<?>, ? extends Entry<?>> reference) { 53 protected Collection<String> getReferenceTokens(EntryReference<? extends Entry<?>, ? extends Entry<?>> reference) {
53 // decompile the class 54 // decompile the class
54 CompilationUnit tree = deobfuscator.getSourceTree(reference.context.getContainingClass().getFullName()); 55 SourceProvider sourceProvider = deobfuscator.getObfSourceProvider();
55 String source = deobfuscator.getSource(tree); 56 CompilationUnit tree = sourceProvider.getSources(reference.context.getContainingClass().getFullName());
56 SourceIndex index = deobfuscator.getSourceIndex(tree, source); 57 String source = sourceProvider.writeSourceToString(tree);
58 SourceIndex index = SourceIndex.buildIndex(source, tree, true);
57 59
58 // get the token values 60 // get the token values
59 List<String> values = Lists.newArrayList(); 61 List<String> values = Lists.newArrayList();