diff options
| author | 2020-06-03 13:39:42 -0400 | |
|---|---|---|
| committer | 2020-06-03 18:39:42 +0100 | |
| commit | 0f47403d0220757fed189b76e2071e25b1025cb8 (patch) | |
| tree | 879bf72c4476f0a5e0d82da99d7ff2b2276bcaca /src/test/java/cuchaz/enigma/TestSourceIndex.java | |
| parent | Fix search dialog hanging for a short time sometimes (#250) (diff) | |
| download | enigma-fork-0f47403d0220757fed189b76e2071e25b1025cb8.tar.gz enigma-fork-0f47403d0220757fed189b76e2071e25b1025cb8.tar.xz enigma-fork-0f47403d0220757fed189b76e2071e25b1025cb8.zip | |
Split GUI code to separate module (#242)
* Split into modules
* Post merge compile fixes
Co-authored-by: modmuss50 <modmuss50@gmail.com>
Diffstat (limited to 'src/test/java/cuchaz/enigma/TestSourceIndex.java')
| -rw-r--r-- | src/test/java/cuchaz/enigma/TestSourceIndex.java | 74 |
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 | |||
| 12 | package cuchaz.enigma; | ||
| 13 | |||
| 14 | import com.google.common.collect.Sets; | ||
| 15 | import cuchaz.enigma.analysis.ClassCache; | ||
| 16 | import cuchaz.enigma.source.*; | ||
| 17 | import cuchaz.enigma.analysis.index.JarIndex; | ||
| 18 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | ||
| 19 | import org.junit.Test; | ||
| 20 | |||
| 21 | import java.nio.file.Path; | ||
| 22 | import java.nio.file.Paths; | ||
| 23 | import java.util.Set; | ||
| 24 | |||
| 25 | public 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 | } | ||