summaryrefslogtreecommitdiff
path: root/test/cuchaz/enigma/TestSourceIndex.java
diff options
context:
space:
mode:
authorGravatar lclc982016-06-30 00:49:21 +1000
committerGravatar GitHub2016-06-30 00:49:21 +1000
commit4be005617b3b8c3578cca07c5d085d12916f0d1d (patch)
treedb163431f38703e26da417ef05eaea2b27a498b9 /test/cuchaz/enigma/TestSourceIndex.java
parentSome small changes to fix idea importing (diff)
downloadenigma-fork-4be005617b3b8c3578cca07c5d085d12916f0d1d.tar.gz
enigma-fork-4be005617b3b8c3578cca07c5d085d12916f0d1d.tar.xz
enigma-fork-4be005617b3b8c3578cca07c5d085d12916f0d1d.zip
Json format (#2)
* Added new format * Fixed bug * Updated Version
Diffstat (limited to 'test/cuchaz/enigma/TestSourceIndex.java')
-rw-r--r--test/cuchaz/enigma/TestSourceIndex.java67
1 files changed, 0 insertions, 67 deletions
diff --git a/test/cuchaz/enigma/TestSourceIndex.java b/test/cuchaz/enigma/TestSourceIndex.java
deleted file mode 100644
index 58d9ca9..0000000
--- a/test/cuchaz/enigma/TestSourceIndex.java
+++ /dev/null
@@ -1,67 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11package cuchaz.enigma;
12
13import java.io.File;
14import java.util.Set;
15import java.util.jar.JarFile;
16
17import org.junit.Test;
18
19import com.google.common.collect.Sets;
20import com.strobel.decompiler.languages.java.ast.CompilationUnit;
21
22import cuchaz.enigma.mapping.ClassEntry;
23
24public class TestSourceIndex {
25 @Test
26 public void indexEverything()
27 throws Exception {
28 // Figure out where Minecraft is...
29 final String mcDir = System.getProperty("enigma.test.minecraftdir");
30 File mcJar = null;
31 if (mcDir == null) {
32 String osname = System.getProperty("os.name").toLowerCase();
33 if (osname.contains("nix") || osname.contains("nux") || osname.contains("solaris")) {
34 mcJar = new File(System.getProperty("user.home"), ".minecraft/versions/1.8.3/1.8.3.jar");
35 }
36 else if (osname.contains("mac") || osname.contains("darwin")) {
37 mcJar = new File(System.getProperty("user.home"), "Library/Application Support/minecraft/versions/1.8.3/1.8.3.jar");
38 }
39 else if (osname.contains("win")) {
40 mcJar = new File(System.getenv("AppData"), ".minecraft/versions/1.8.3/1.8.3.jar");
41 }
42 }
43 else {
44 mcJar = new File(mcDir, "versions/1.8.3/1.8.3.jar");
45 }
46
47 Deobfuscator deobfuscator = new Deobfuscator(new JarFile(mcJar));
48
49 // get all classes that aren't inner classes
50 Set<ClassEntry> classEntries = Sets.newHashSet();
51 for (ClassEntry obfClassEntry : deobfuscator.getJarIndex().getObfClassEntries()) {
52 if (!obfClassEntry.isInnerClass()) {
53 classEntries.add(obfClassEntry);
54 }
55 }
56
57 for (ClassEntry obfClassEntry : classEntries) {
58 try {
59 CompilationUnit tree = deobfuscator.getSourceTree(obfClassEntry.getName());
60 String source = deobfuscator.getSource(tree);
61 deobfuscator.getSourceIndex(tree, source);
62 } catch (Throwable t) {
63 throw new Error("Unable to index " + obfClassEntry, t);
64 }
65 }
66 }
67}