summaryrefslogtreecommitdiff
path: root/src/test/java/cuchaz/enigma/TestSourceIndex.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/cuchaz/enigma/TestSourceIndex.java')
-rw-r--r--src/test/java/cuchaz/enigma/TestSourceIndex.java74
1 files changed, 0 insertions, 74 deletions
diff --git a/src/test/java/cuchaz/enigma/TestSourceIndex.java b/src/test/java/cuchaz/enigma/TestSourceIndex.java
deleted file mode 100644
index b201608..0000000
--- a/src/test/java/cuchaz/enigma/TestSourceIndex.java
+++ /dev/null
@@ -1,74 +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 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import com.google.common.collect.Sets;
15import cuchaz.enigma.analysis.ClassCache;
16import cuchaz.enigma.source.*;
17import cuchaz.enigma.analysis.index.JarIndex;
18import cuchaz.enigma.translation.representation.entry.ClassEntry;
19import org.junit.Test;
20
21import java.nio.file.Path;
22import java.nio.file.Paths;
23import java.util.Set;
24
25public class TestSourceIndex {
26 @Test
27 public void indexEverything()
28 throws Exception {
29 // Figure out where Minecraft is...
30 final String mcDir = System.getProperty("enigma.test.minecraftdir");
31 Path mcJar = null;
32 if (mcDir == null) {
33 String osname = System.getProperty("os.name").toLowerCase();
34 if (osname.contains("nix") || osname.contains("nux") || osname.contains("solaris")) {
35 mcJar = Paths.get(System.getProperty("user.home"), ".minecraft/versions/1.8.3/1.8.3.jar");
36 } else if (osname.contains("mac") || osname.contains("darwin")) {
37 mcJar = Paths.get(System.getProperty("user.home"), "Library/Application Support/minecraft/versions/1.8.3/1.8.3.jar");
38 } else if (osname.contains("win")) {
39 mcJar = Paths.get(System.getenv("AppData"), ".minecraft/versions/1.8.3/1.8.3.jar");
40 }
41 } else {
42 mcJar = Paths.get(mcDir, "versions/1.8.3/1.8.3.jar");
43 }
44
45 if (mcJar == null) {
46 throw new NullPointerException("Couldn't find jar");
47 }
48
49 Enigma enigma = Enigma.create();
50 EnigmaProject project = enigma.openJar(mcJar, ProgressListener.none());
51
52 ClassCache classCache = project.getClassCache();
53 JarIndex index = project.getJarIndex();
54
55 Decompiler decompiler = Decompilers.PROCYON.create(classCache, new SourceSettings(false, false));
56
57 // get all classes that aren't inner classes
58 Set<ClassEntry> classEntries = Sets.newHashSet();
59 for (ClassEntry obfClassEntry : index.getEntryIndex().getClasses()) {
60 if (!obfClassEntry.isInnerClass()) {
61 classEntries.add(obfClassEntry);
62 }
63 }
64
65 for (ClassEntry obfClassEntry : classEntries) {
66 try {
67 Source source = decompiler.getSource(obfClassEntry.getName());
68 source.index();
69 } catch (Throwable t) {
70 throw new Error("Unable to index " + obfClassEntry, t);
71 }
72 }
73 }
74}