diff options
| author | 2020-03-09 06:04:08 -0400 | |
|---|---|---|
| committer | 2020-03-09 10:04:08 +0000 | |
| commit | 58c0aeb15a65324de08a914dfa62cc68a516a4e3 (patch) | |
| tree | f45e8141c0864692051149a478c5a0a6bbe68686 /src/test/java/cuchaz/enigma/TestSourceIndex.java | |
| parent | Made Enigma gui translatable (#193) (diff) | |
| download | enigma-fork-58c0aeb15a65324de08a914dfa62cc68a516a4e3.tar.gz enigma-fork-58c0aeb15a65324de08a914dfa62cc68a516a4e3.tar.xz enigma-fork-58c0aeb15a65324de08a914dfa62cc68a516a4e3.zip | |
CFR support (#192)
* Add decompiler API
* Add CFR support
Diffstat (limited to 'src/test/java/cuchaz/enigma/TestSourceIndex.java')
| -rw-r--r-- | src/test/java/cuchaz/enigma/TestSourceIndex.java | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/test/java/cuchaz/enigma/TestSourceIndex.java b/src/test/java/cuchaz/enigma/TestSourceIndex.java index b1d1182..b201608 100644 --- a/src/test/java/cuchaz/enigma/TestSourceIndex.java +++ b/src/test/java/cuchaz/enigma/TestSourceIndex.java | |||
| @@ -12,9 +12,8 @@ | |||
| 12 | package cuchaz.enigma; | 12 | 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; | ||
| 16 | import cuchaz.enigma.analysis.ClassCache; | 15 | import cuchaz.enigma.analysis.ClassCache; |
| 17 | import cuchaz.enigma.analysis.SourceIndex; | 16 | import cuchaz.enigma.source.*; |
| 18 | import cuchaz.enigma.analysis.index.JarIndex; | 17 | import cuchaz.enigma.analysis.index.JarIndex; |
| 19 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 18 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 20 | import org.junit.Test; | 19 | import org.junit.Test; |
| @@ -53,8 +52,7 @@ public class TestSourceIndex { | |||
| 53 | ClassCache classCache = project.getClassCache(); | 52 | ClassCache classCache = project.getClassCache(); |
| 54 | JarIndex index = project.getJarIndex(); | 53 | JarIndex index = project.getJarIndex(); |
| 55 | 54 | ||
| 56 | CompiledSourceTypeLoader typeLoader = new CompiledSourceTypeLoader(classCache); | 55 | Decompiler decompiler = Decompilers.PROCYON.create(classCache, new SourceSettings(false, false)); |
| 57 | SourceProvider sourceProvider = new SourceProvider(SourceProvider.createSettings(), typeLoader); | ||
| 58 | 56 | ||
| 59 | // get all classes that aren't inner classes | 57 | // get all classes that aren't inner classes |
| 60 | Set<ClassEntry> classEntries = Sets.newHashSet(); | 58 | Set<ClassEntry> classEntries = Sets.newHashSet(); |
| @@ -66,10 +64,8 @@ public class TestSourceIndex { | |||
| 66 | 64 | ||
| 67 | for (ClassEntry obfClassEntry : classEntries) { | 65 | for (ClassEntry obfClassEntry : classEntries) { |
| 68 | try { | 66 | try { |
| 69 | CompilationUnit tree = sourceProvider.getSources(obfClassEntry.getName()); | 67 | Source source = decompiler.getSource(obfClassEntry.getName()); |
| 70 | String source = sourceProvider.writeSourceToString(tree); | 68 | source.index(); |
| 71 | |||
| 72 | SourceIndex.buildIndex(source, tree, true); | ||
| 73 | } catch (Throwable t) { | 69 | } catch (Throwable t) { |
| 74 | throw new Error("Unable to index " + obfClassEntry, t); | 70 | throw new Error("Unable to index " + obfClassEntry, t); |
| 75 | } | 71 | } |