diff options
| author | 2014-09-24 01:00:54 -0400 | |
|---|---|---|
| committer | 2014-09-24 01:00:54 -0400 | |
| commit | 8776a8ba38123c822530e5f659c626c8db616217 (patch) | |
| tree | 8138a4e4447552e598bb99cfd8fb23a5f27f840b /test/cuchaz/enigma/TestSourceIndex.java | |
| parent | trying to figure out why some mappings to correspond to anything in the jar f... (diff) | |
| download | enigma-fork-8776a8ba38123c822530e5f659c626c8db616217.tar.gz enigma-fork-8776a8ba38123c822530e5f659c626c8db616217.tar.xz enigma-fork-8776a8ba38123c822530e5f659c626c8db616217.zip | |
HOW DO I WRITE SO MANY BUGS?!?
Diffstat (limited to 'test/cuchaz/enigma/TestSourceIndex.java')
| -rw-r--r-- | test/cuchaz/enigma/TestSourceIndex.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/cuchaz/enigma/TestSourceIndex.java b/test/cuchaz/enigma/TestSourceIndex.java new file mode 100644 index 0000000..dc6ca7e --- /dev/null +++ b/test/cuchaz/enigma/TestSourceIndex.java | |||
| @@ -0,0 +1,56 @@ | |||
| 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.io.File; | ||
| 15 | import java.util.Set; | ||
| 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 | @Test | ||
| 27 | public void indexEverything( ) | ||
| 28 | throws Exception | ||
| 29 | { | ||
| 30 | Deobfuscator deobfuscator = new Deobfuscator( new File( "input/1.8.jar" ) ); | ||
| 31 | |||
| 32 | // get all classes that aren't inner classes | ||
| 33 | Set<ClassEntry> classEntries = Sets.newHashSet(); | ||
| 34 | for( ClassEntry obfClassEntry : deobfuscator.getJarIndex().getObfClassEntries() ) | ||
| 35 | { | ||
| 36 | if( !obfClassEntry.isInnerClass() ) | ||
| 37 | { | ||
| 38 | classEntries.add( obfClassEntry ); | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | for( ClassEntry obfClassEntry : classEntries ) | ||
| 43 | { | ||
| 44 | try | ||
| 45 | { | ||
| 46 | CompilationUnit tree = deobfuscator.getSourceTree( obfClassEntry.getName() ); | ||
| 47 | String source = deobfuscator.getSource( tree ); | ||
| 48 | deobfuscator.getSourceIndex( tree, source ); | ||
| 49 | } | ||
| 50 | catch( Throwable t ) | ||
| 51 | { | ||
| 52 | throw new Error( "Unable to index " + obfClassEntry, t ); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | } | ||
| 56 | } | ||