diff options
Diffstat (limited to 'test/cuchaz/enigma/TestSourceIndex.java')
| -rw-r--r-- | test/cuchaz/enigma/TestSourceIndex.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/cuchaz/enigma/TestSourceIndex.java b/test/cuchaz/enigma/TestSourceIndex.java new file mode 100644 index 0000000..70a5ee4 --- /dev/null +++ b/test/cuchaz/enigma/TestSourceIndex.java | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2014 Jeff Martin. | ||
| 3 | * | ||
| 4 | * All rights reserved. This program and the accompanying materials | ||
| 5 | * are made available under the terms of the GNU Public License v3.0 | ||
| 6 | * which accompanies this distribution, and is available at | ||
| 7 | * http://www.gnu.org/licenses/gpl.html | ||
| 8 | * | ||
| 9 | * Contributors: | ||
| 10 | * Jeff Martin - initial API and implementation | ||
| 11 | ******************************************************************************/ | ||
| 12 | package cuchaz.enigma; | ||
| 13 | |||
| 14 | import java.util.Set; | ||
| 15 | import java.util.jar.JarFile; | ||
| 16 | |||
| 17 | import org.junit.Test; | ||
| 18 | |||
| 19 | import com.google.common.collect.Sets; | ||
| 20 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; | ||
| 21 | |||
| 22 | import cuchaz.enigma.mapping.ClassEntry; | ||
| 23 | |||
| 24 | public class TestSourceIndex { | ||
| 25 | |||
| 26 | // TEMP | ||
| 27 | @Test | ||
| 28 | public void indexEverything() throws Exception { | ||
| 29 | Deobfuscator deobfuscator = new Deobfuscator(new JarFile("input/1.8.jar")); | ||
| 30 | |||
| 31 | // get all classes that aren't inner classes | ||
| 32 | Set<ClassEntry> classEntries = Sets.newHashSet(); | ||
| 33 | for (ClassEntry obfClassEntry : deobfuscator.getJarIndex().getObfClassEntries()) { | ||
| 34 | if (!obfClassEntry.isInnerClass()) { | ||
| 35 | classEntries.add(obfClassEntry); | ||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | for (ClassEntry obfClassEntry : classEntries) { | ||
| 40 | try { | ||
| 41 | CompilationUnit tree = deobfuscator.getSourceTree(obfClassEntry.getName()); | ||
| 42 | String source = deobfuscator.getSource(tree); | ||
| 43 | deobfuscator.getSourceIndex(tree, source); | ||
| 44 | } catch (Throwable t) { | ||
| 45 | throw new Error("Unable to index " + obfClassEntry, t); | ||
| 46 | } | ||
| 47 | } | ||
| 48 | } | ||
| 49 | } | ||