From 3ddbccdf447c86a6432bc9751532ce3bd8d43e75 Mon Sep 17 00:00:00 2001 From: ix0rai Date: Tue, 10 Oct 2023 17:51:50 -0500 Subject: [PATCH] add mappings indexing (#156) * add mappings indexing * add package name index * add reindexing * add translations * clean up mappings indexing, implement @iotabread's suggestion * implement new system for getting indexers onto JarIndex * fix commands --- .../enigma/command/CheckMappingsCommand.java | 5 +- .../org/quiltmc/enigma/command/Command.java | 4 +- .../command/FillClassMappingsCommand.java | 2 +- .../InsertProposedMappingsCommand.java | 4 +- .../command/MapSpecializedMethodsCommand.java | 6 +- .../enigma/network/DedicatedEnigmaServer.java | 2 +- .../org/quiltmc/enigma/gui/GuiController.java | 12 +- .../enigma/gui/dialog/SearchDialog.java | 4 +- .../enigma/gui/docker/DockerManager.java | 2 +- .../org/quiltmc/enigma/gui/util/GuiUtil.java | 4 +- .../java/org/quiltmc/enigma/api/Enigma.java | 2 +- .../org/quiltmc/enigma/api/EnigmaProject.java | 39 +++-- .../index/{ => jar}/BridgeMethodIndex.java | 2 +- .../index/{ => jar}/EnclosingMethodIndex.java | 2 +- .../analysis/index/{ => jar}/EntryIndex.java | 2 +- .../index/{ => jar}/InheritanceIndex.java | 2 +- .../analysis/index/{ => jar}/JarIndex.java | 106 ++++++------ .../analysis/index/{ => jar}/JarIndexer.java | 7 +- .../{ => jar}/PackageVisibilityIndex.java | 8 +- .../index/{ => jar}/ReferenceIndex.java | 2 +- .../analysis/index/mapping/MappingsIndex.java | 151 ++++++++++++++++++ .../index/mapping/MappingsIndexer.java | 46 ++++++ .../analysis/index/mapping/PackageIndex.java | 49 ++++++ .../tree/ClassImplementationsTreeNode.java | 6 +- .../tree/ClassInheritanceTreeNode.java | 2 +- .../analysis/tree/ClassReferenceTreeNode.java | 6 +- .../analysis/tree/FieldReferenceTreeNode.java | 6 +- .../tree/MethodImplementationsTreeNode.java | 10 +- .../tree/MethodInheritanceTreeNode.java | 10 +- .../tree/MethodReferenceTreeNode.java | 6 +- .../api/class_handle/ClassHandleProvider.java | 3 +- .../ObfuscationFixClassProvider.java | 2 +- .../enigma/api/service/JarIndexerService.java | 2 +- .../enigma/api/stats/StatsGenerator.java | 4 +- .../translation/mapping/EntryRemapper.java | 24 ++- .../mapping/IndexEntryResolver.java | 14 +- .../translation/mapping/MappingValidator.java | 44 +++-- .../representation/entry/MethodEntry.java | 2 +- .../enigma/impl/analysis/BuiltinPlugin.java | 4 +- .../impl/analysis/IndexSimpleVerifier.java | 4 +- .../impl/analysis/IndexTreeBuilder.java | 14 +- .../analysis/index/IndexClassVisitor.java | 4 +- .../analysis/index/IndexReferenceVisitor.java | 6 +- .../bytecode/translator/SourceFixVisitor.java | 6 +- .../translation/mapping/MappingsChecker.java | 5 +- .../enigma/util/validation/Message.java | 1 + enigma/src/main/resources/lang/en_us.json | 7 + .../enigma/PackageVisibilityIndexTest.java | 6 +- .../java/org/quiltmc/enigma/TestDeobfed.java | 3 +- .../org/quiltmc/enigma/TestInnerClasses.java | 11 +- .../enigma/TestJarIndexBridgeMethods.java | 15 +- .../TestJarIndexConstructorReferences.java | 22 +-- .../enigma/TestJarIndexInheritanceTree.java | 29 ++-- .../quiltmc/enigma/TestJarIndexLoneClass.java | 25 +-- .../quiltmc/enigma/TestStatsGeneration.java | 13 +- .../org/quiltmc/enigma/TestTranslator.java | 2 +- .../mapping/TestMappingValidator.java | 2 +- .../mapping/TestTinyV2InnerClasses.java | 2 +- 58 files changed, 544 insertions(+), 241 deletions(-) rename enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/{ => jar}/BridgeMethodIndex.java (99%) rename enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/{ => jar}/EnclosingMethodIndex.java (94%) rename enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/{ => jar}/EntryIndex.java (98%) rename enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/{ => jar}/InheritanceIndex.java (98%) rename enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/{ => jar}/JarIndex.java (69%) rename enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/{ => jar}/JarIndexer.java (87%) rename enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/{ => jar}/PackageVisibilityIndex.java (95%) rename enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/{ => jar}/ReferenceIndex.java (99%) create mode 100644 enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/mapping/MappingsIndex.java create mode 100644 enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/mapping/MappingsIndexer.java create mode 100644 enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/mapping/PackageIndex.java diff --git a/enigma-cli/src/main/java/org/quiltmc/enigma/command/CheckMappingsCommand.java b/enigma-cli/src/main/java/org/quiltmc/enigma/command/CheckMappingsCommand.java index 922c6eed4..b4bb9d23b 100644 --- a/enigma-cli/src/main/java/org/quiltmc/enigma/command/CheckMappingsCommand.java +++ b/enigma-cli/src/main/java/org/quiltmc/enigma/command/CheckMappingsCommand.java @@ -1,7 +1,8 @@ package org.quiltmc.enigma.command; import org.quiltmc.enigma.api.EnigmaProject; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.PackageVisibilityIndex; import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; import org.tinylog.Logger; @@ -38,7 +39,7 @@ public static void run(Path fileJarIn, Path fileMappings) throws Exception { boolean error = false; - for (Set partition : idx.getPackageVisibilityIndex().getPartitions()) { + for (Set partition : idx.getIndex(PackageVisibilityIndex.class).getPartitions()) { long packages = partition.stream() .map(project.getMapper()::deobfuscate) .map(ClassEntry::getPackageName) diff --git a/enigma-cli/src/main/java/org/quiltmc/enigma/command/Command.java b/enigma-cli/src/main/java/org/quiltmc/enigma/command/Command.java index c8975d767..a8f6ef0ce 100644 --- a/enigma-cli/src/main/java/org/quiltmc/enigma/command/Command.java +++ b/enigma-cli/src/main/java/org/quiltmc/enigma/command/Command.java @@ -4,7 +4,7 @@ import org.quiltmc.enigma.api.EnigmaProfile; import org.quiltmc.enigma.api.EnigmaProject; import org.quiltmc.enigma.api.ProgressListener; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.EnigmaPlugin; import org.quiltmc.enigma.api.class_provider.CachingClassProvider; import org.quiltmc.enigma.api.class_provider.ClasspathClassProvider; @@ -155,7 +155,7 @@ public static EnigmaProject openProject(Path fileJarIn, Path fileMappings, Enigm EntryTree mappings = readMappings(fileMappings, progress); - project.setMappings(mappings); + project.setMappings(mappings, new ConsoleProgressListener()); } return project; diff --git a/enigma-cli/src/main/java/org/quiltmc/enigma/command/FillClassMappingsCommand.java b/enigma-cli/src/main/java/org/quiltmc/enigma/command/FillClassMappingsCommand.java index 272d07d55..888bb173a 100644 --- a/enigma-cli/src/main/java/org/quiltmc/enigma/command/FillClassMappingsCommand.java +++ b/enigma-cli/src/main/java/org/quiltmc/enigma/command/FillClassMappingsCommand.java @@ -1,7 +1,7 @@ package org.quiltmc.enigma.command; import org.quiltmc.enigma.api.ProgressListener; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.translation.mapping.EntryMapping; import org.quiltmc.enigma.api.translation.mapping.serde.MappingFileNameFormat; import org.quiltmc.enigma.api.translation.mapping.serde.MappingSaveParameters; diff --git a/enigma-cli/src/main/java/org/quiltmc/enigma/command/InsertProposedMappingsCommand.java b/enigma-cli/src/main/java/org/quiltmc/enigma/command/InsertProposedMappingsCommand.java index a937b5811..d2072f0ad 100644 --- a/enigma-cli/src/main/java/org/quiltmc/enigma/command/InsertProposedMappingsCommand.java +++ b/enigma-cli/src/main/java/org/quiltmc/enigma/command/InsertProposedMappingsCommand.java @@ -4,7 +4,7 @@ import org.quiltmc.enigma.api.EnigmaProfile; import org.quiltmc.enigma.api.EnigmaProject; import org.quiltmc.enigma.api.ProgressListener; -import org.quiltmc.enigma.api.analysis.index.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; import org.quiltmc.enigma.api.EnigmaPlugin; import org.quiltmc.enigma.api.service.NameProposalService; import org.quiltmc.enigma.api.translation.ProposingTranslator; @@ -95,7 +95,7 @@ public static EntryTree exec(NameProposalService[] nameProposalSer EntryRemapper mapper = project.getMapper(); Translator translator = new ProposingTranslator(mapper, nameProposalServices); - EntryIndex index = project.getJarIndex().getEntryIndex(); + EntryIndex index = project.getJarIndex().getIndex(EntryIndex.class); Logger.info("Proposing class names..."); int classes = 0; diff --git a/enigma-cli/src/main/java/org/quiltmc/enigma/command/MapSpecializedMethodsCommand.java b/enigma-cli/src/main/java/org/quiltmc/enigma/command/MapSpecializedMethodsCommand.java index 0792ab8a7..67f049446 100644 --- a/enigma-cli/src/main/java/org/quiltmc/enigma/command/MapSpecializedMethodsCommand.java +++ b/enigma-cli/src/main/java/org/quiltmc/enigma/command/MapSpecializedMethodsCommand.java @@ -1,7 +1,7 @@ package org.quiltmc.enigma.command; -import org.quiltmc.enigma.api.analysis.index.BridgeMethodIndex; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.BridgeMethodIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.translation.MappingTranslator; import org.quiltmc.enigma.api.translation.Translator; import org.quiltmc.enigma.api.translation.mapping.EntryMapping; @@ -71,7 +71,7 @@ public static void run(Path jar, Path sourcePath, String resultFormat, Path outp public static EntryTree run(JarIndex jarIndex, EntryTree source, boolean trackDelta) throws IOException, MappingParseException { EntryTree result = new HashEntryTree<>(); - BridgeMethodIndex bridgeMethodIndex = jarIndex.getBridgeMethodIndex(); + BridgeMethodIndex bridgeMethodIndex = jarIndex.getIndex(BridgeMethodIndex.class); Translator translator = new MappingTranslator(source, jarIndex.getEntryResolver()); // Copy all non-specialized methods diff --git a/enigma-server/src/main/java/org/quiltmc/enigma/network/DedicatedEnigmaServer.java b/enigma-server/src/main/java/org/quiltmc/enigma/network/DedicatedEnigmaServer.java index 0552882e7..a2e631be2 100644 --- a/enigma-server/src/main/java/org/quiltmc/enigma/network/DedicatedEnigmaServer.java +++ b/enigma-server/src/main/java/org/quiltmc/enigma/network/DedicatedEnigmaServer.java @@ -120,7 +120,7 @@ public static void main(String[] args) { mappings = EntryRemapper.empty(project.getJarIndex()); } else { Logger.info("Reading mappings..."); - mappings = EntryRemapper.mapped(project.getJarIndex(), mappingFormat.read(mappingsFile)); + mappings = EntryRemapper.mapped(project.getJarIndex(), project.getMappingsIndex(), mappingFormat.read(mappingsFile)); } PrintWriter log = new PrintWriter(Files.newBufferedWriter(logFile)); diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/GuiController.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/GuiController.java index bcd93faa9..94a739412 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/GuiController.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/GuiController.java @@ -5,6 +5,8 @@ import org.quiltmc.enigma.api.Enigma; import org.quiltmc.enigma.api.EnigmaProfile; import org.quiltmc.enigma.api.EnigmaProject; +import org.quiltmc.enigma.api.ProgressListener; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; import org.quiltmc.enigma.api.analysis.tree.ClassImplementationsTreeNode; import org.quiltmc.enigma.api.analysis.tree.ClassInheritanceTreeNode; import org.quiltmc.enigma.api.analysis.tree.ClassReferenceTreeNode; @@ -157,7 +159,7 @@ public CompletableFuture openMappings(MappingFormat format, Path path) { return ProgressDialog.runOffThread(this.gui, progress -> { try { EntryTree mappings = format.read(path); - this.project.setMappings(mappings); + this.project.setMappings(mappings, progress); this.loadedMappingFormat = format; this.loadedMappingPath = path; @@ -175,7 +177,7 @@ public CompletableFuture openMappings(MappingFormat format, Path path) { public void openMappings(EntryTree mappings) { if (this.project == null) return; - this.project.setMappings(mappings); + this.project.setMappings(mappings, new ProgressDialog(this.gui.getFrame())); this.refreshClasses(); this.chp.invalidateJavadoc(); } @@ -225,7 +227,7 @@ public CompletableFuture saveMappings(Path path, MappingFormat format) { public void closeMappings() { if (this.project == null) return; - this.project.setMappings(null); + this.project.setMappings(null, ProgressListener.none()); this.gui.setMappingsFile(null); this.refreshClasses(); @@ -408,7 +410,7 @@ public void refreshClasses() { public void addSeparatedClasses(List obfClasses, List deobfClasses) { EntryRemapper mapper = this.project.getMapper(); - Collection classes = this.project.getJarIndex().getEntryIndex().getClasses(); + Collection classes = this.project.getJarIndex().getIndex(EntryIndex.class).getClasses(); Stream visibleClasses = classes.stream() .filter(entry -> !entry.isInnerClass()); @@ -613,7 +615,7 @@ public void createClient(String username, String ip, int port, char[] password) } public void createServer(int port, char[] password) throws IOException { - this.server = new IntegratedEnigmaServer(this.project.getJarChecksum(), password, EntryRemapper.mapped(this.project.getJarIndex(), new HashEntryTree<>(this.project.getMapper().getObfToDeobf())), port); + this.server = new IntegratedEnigmaServer(this.project.getJarChecksum(), password, EntryRemapper.mapped(this.project.getJarIndex(), this.project.getMappingsIndex(), new HashEntryTree<>(this.project.getMapper().getObfToDeobf())), port); this.server.start(); this.client = new EnigmaClient(this, "127.0.0.1", port); this.client.connect(); diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/dialog/SearchDialog.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/dialog/SearchDialog.java index ae2853ed8..f1d7f41b1 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/dialog/SearchDialog.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/dialog/SearchDialog.java @@ -1,6 +1,6 @@ package org.quiltmc.enigma.gui.dialog; -import org.quiltmc.enigma.api.analysis.index.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; import org.quiltmc.enigma.gui.Gui; import org.quiltmc.enigma.gui.GuiController; import org.quiltmc.enigma.gui.config.keybind.KeyBinds; @@ -200,7 +200,7 @@ public void show(boolean clear, Type... types) { this.searchedTypes.addAll(Arrays.asList(types)); - final EntryIndex entryIndex = this.gui.getController().getProject().getJarIndex().getEntryIndex(); + final EntryIndex entryIndex = this.gui.getController().getProject().getJarIndex().getIndex(EntryIndex.class); for (Type searchedType : this.searchedTypes) { this.getCheckBox(searchedType).setSelected(true); diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/docker/DockerManager.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/docker/DockerManager.java index 3d32296d2..a791d6214 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/docker/DockerManager.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/docker/DockerManager.java @@ -104,7 +104,7 @@ public void registerDocker(Docker docker) { public T getDocker(Class clazz) { Docker panel = this.dockers.get(clazz); if (panel != null) { - return (T) this.dockers.get(clazz); + return (T) panel; } else { throw new IllegalArgumentException("no docker registered for class " + clazz); } diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/util/GuiUtil.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/util/GuiUtil.java index 0d4e9fd06..6b71d436e 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/util/GuiUtil.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/util/GuiUtil.java @@ -1,7 +1,7 @@ package org.quiltmc.enigma.gui.util; import com.formdev.flatlaf.extras.FlatSVGIcon; -import org.quiltmc.enigma.api.analysis.index.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; import org.quiltmc.enigma.gui.Gui; import org.quiltmc.enigma.gui.config.LookAndFeel; import org.quiltmc.enigma.api.stats.ProjectStatsResult; @@ -148,7 +148,7 @@ public static Icon loadIcon(String name) { } public static Icon getClassIcon(Gui gui, ClassEntry entry) { - EntryIndex entryIndex = gui.getController().getProject().getJarIndex().getEntryIndex(); + EntryIndex entryIndex = gui.getController().getProject().getJarIndex().getIndex(EntryIndex.class); AccessFlags access = entryIndex.getClassAccess(entry); if (access != null) { diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/Enigma.java b/enigma/src/main/java/org/quiltmc/enigma/api/Enigma.java index fb9e14558..e9d6e99d1 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/Enigma.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/Enigma.java @@ -1,6 +1,6 @@ package org.quiltmc.enigma.api; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.service.EnigmaService; import org.quiltmc.enigma.api.service.EnigmaServiceContext; import org.quiltmc.enigma.api.service.EnigmaServiceFactory; diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/EnigmaProject.java b/enigma/src/main/java/org/quiltmc/enigma/api/EnigmaProject.java index f7e01c37a..757e87cd1 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/EnigmaProject.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/EnigmaProject.java @@ -3,8 +3,10 @@ import com.google.common.base.Functions; import com.google.common.base.Preconditions; import org.quiltmc.enigma.api.analysis.EntryReference; -import org.quiltmc.enigma.api.analysis.index.EnclosingMethodIndex; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EnclosingMethodIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; +import org.quiltmc.enigma.api.analysis.index.mapping.MappingsIndex; import org.quiltmc.enigma.api.service.NameProposalService; import org.quiltmc.enigma.api.service.ObfuscationTestService; import org.quiltmc.enigma.impl.bytecode.translator.TranslationClassVisitor; @@ -71,6 +73,7 @@ public class EnigmaProject { private final Path jarPath; private final ClassProvider classProvider; private final JarIndex jarIndex; + private MappingsIndex mappingsIndex; private final byte[] jarChecksum; private EntryRemapper mapper; @@ -84,11 +87,21 @@ public EnigmaProject(Enigma enigma, Path jarPath, ClassProvider classProvider, J this.jarChecksum = jarChecksum; this.mapper = EntryRemapper.empty(jarIndex); + this.mappingsIndex = MappingsIndex.empty(); } - public void setMappings(EntryTree mappings) { + /** + * Sets the current mappings of this project. + * Note that this triggers an index of the mappings, which may be expensive. + * @param mappings the new mappings + * @param progress a progress listener for indexing + */ + public void setMappings(EntryTree mappings, ProgressListener progress) { + this.mappingsIndex = MappingsIndex.empty(); + if (mappings != null) { - this.mapper = EntryRemapper.mapped(this.jarIndex, mappings); + this.mappingsIndex.indexMappings(mappings, progress); + this.mapper = EntryRemapper.mapped(this.jarIndex, this.mappingsIndex, mappings); } else { this.mapper = EntryRemapper.empty(this.jarIndex); } @@ -110,6 +123,10 @@ public JarIndex getJarIndex() { return this.jarIndex; } + public MappingsIndex getMappingsIndex() { + return this.mappingsIndex; + } + public byte[] getJarChecksum() { return this.jarChecksum; } @@ -155,7 +172,7 @@ public boolean isNavigable(Entry obfEntry) { return false; } - return this.jarIndex.getEntryIndex().hasEntry(obfEntry); + return this.jarIndex.getIndex(EntryIndex.class).hasEntry(obfEntry); } public boolean isRenamable(Entry obfEntry) { @@ -177,7 +194,7 @@ public boolean isRenamable(Entry obfEntry) { } } - ClassDefEntry parent = this.jarIndex.getEntryIndex().getDefinition(obfMethodEntry.getParent()); + ClassDefEntry parent = this.jarIndex.getIndex(EntryIndex.class).getDefinition(obfMethodEntry.getParent()); if (parent != null && parent.isEnum() && ((name.equals("values") && sig.equals("()[L" + parent.getFullName() + ";")) || (name.equals("valueOf") && sig.equals("(Ljava/lang/String;)L" + parent.getFullName() + ";")))) { @@ -187,7 +204,7 @@ public boolean isRenamable(Entry obfEntry) { return false; } else if (obfEntry instanceof LocalVariableEntry localEntry && localEntry.isArgument()) { MethodEntry method = localEntry.getParent(); - ClassDefEntry parent = this.jarIndex.getEntryIndex().getDefinition(method.getParent()); + ClassDefEntry parent = this.jarIndex.getIndex(EntryIndex.class).getDefinition(method.getParent()); // if this is the valueOf method of an enum class, the argument shouldn't be able to be renamed. if (parent.isEnum() && method.getName().equals("valueOf") && method.getDesc().toString().equals("(Ljava/lang/String;)L" + parent.getFullName() + ";")) { @@ -197,7 +214,7 @@ public boolean isRenamable(Entry obfEntry) { return false; } - return this.jarIndex.getEntryIndex().hasEntry(obfEntry); + return this.jarIndex.getIndex(EntryIndex.class).hasEntry(obfEntry); } public boolean isRenamable(EntryReference, Entry> obfReference) { @@ -236,17 +253,17 @@ public boolean hasProposedName(Entry entry) { } public boolean isSynthetic(Entry entry) { - return this.jarIndex.getEntryIndex().hasEntry(entry) && this.jarIndex.getEntryIndex().getEntryAccess(entry).isSynthetic(); + return this.jarIndex.getIndex(EntryIndex.class).hasEntry(entry) && this.jarIndex.getIndex(EntryIndex.class).getEntryAccess(entry).isSynthetic(); } public boolean isAnonymousOrLocal(ClassEntry classEntry) { - EnclosingMethodIndex enclosingMethodIndex = this.jarIndex.getEnclosingMethodIndex(); + EnclosingMethodIndex enclosingMethodIndex = this.jarIndex.getIndex(EnclosingMethodIndex.class); // Only local and anonymous classes may have the EnclosingMethod attribute return enclosingMethodIndex.hasEnclosingMethod(classEntry); } public JarExport exportRemappedJar(ProgressListener progress) { - Collection classEntries = this.jarIndex.getEntryIndex().getClasses(); + Collection classEntries = this.jarIndex.getIndex(EntryIndex.class).getClasses(); ClassProvider fixingClassProvider = new ObfuscationFixClassProvider(this.classProvider, this.jarIndex); NameProposalService[] nameProposalServices = this.getEnigma().getServices().get(NameProposalService.TYPE).toArray(new NameProposalService[0]); diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/BridgeMethodIndex.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/BridgeMethodIndex.java similarity index 99% rename from enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/BridgeMethodIndex.java rename to enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/BridgeMethodIndex.java index 2a723881d..61abd3137 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/BridgeMethodIndex.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/BridgeMethodIndex.java @@ -1,4 +1,4 @@ -package org.quiltmc.enigma.api.analysis.index; +package org.quiltmc.enigma.api.analysis.index.jar; import com.google.common.collect.Maps; import org.quiltmc.enigma.api.translation.representation.AccessFlags; diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/EnclosingMethodIndex.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/EnclosingMethodIndex.java similarity index 94% rename from enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/EnclosingMethodIndex.java rename to enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/EnclosingMethodIndex.java index 64306c5c8..9538007b7 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/EnclosingMethodIndex.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/EnclosingMethodIndex.java @@ -1,4 +1,4 @@ -package org.quiltmc.enigma.api.analysis.index; +package org.quiltmc.enigma.api.analysis.index.jar; import org.quiltmc.enigma.api.translation.representation.entry.ClassDefEntry; import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/EntryIndex.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/EntryIndex.java similarity index 98% rename from enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/EntryIndex.java rename to enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/EntryIndex.java index ea4bfd899..fd11760d6 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/EntryIndex.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/EntryIndex.java @@ -1,4 +1,4 @@ -package org.quiltmc.enigma.api.analysis.index; +package org.quiltmc.enigma.api.analysis.index.jar; import org.quiltmc.enigma.api.translation.mapping.EntryMapping; import org.quiltmc.enigma.api.translation.mapping.tree.EntryTree; diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/InheritanceIndex.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/InheritanceIndex.java similarity index 98% rename from enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/InheritanceIndex.java rename to enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/InheritanceIndex.java index b17e445e3..07deb5cdd 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/InheritanceIndex.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/InheritanceIndex.java @@ -1,4 +1,4 @@ -package org.quiltmc.enigma.api.analysis.index; +package org.quiltmc.enigma.api.analysis.index.jar; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/JarIndex.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/JarIndex.java similarity index 69% rename from enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/JarIndex.java rename to enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/JarIndex.java index bc12abdb0..41316549c 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/JarIndex.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/JarIndex.java @@ -1,4 +1,4 @@ -package org.quiltmc.enigma.api.analysis.index; +package org.quiltmc.enigma.api.analysis.index.jar; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.HashMultimap; @@ -22,40 +22,39 @@ import org.quiltmc.enigma.api.translation.representation.entry.ParentedEntry; import org.quiltmc.enigma.util.I18n; -import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; -import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.Set; public class JarIndex implements JarIndexer { private final Set indexedClasses = new HashSet<>(); - private final EntryIndex entryIndex; - private final InheritanceIndex inheritanceIndex; - private final ReferenceIndex referenceIndex; - private final BridgeMethodIndex bridgeMethodIndex; - private final PackageVisibilityIndex packageVisibilityIndex; - private final EnclosingMethodIndex enclosingMethodIndex; - private final EntryResolver entryResolver; - - private final Collection indexers; + private final Map, JarIndexer> indexers = new HashMap<>(); + private final IndexEntryResolver entryResolver; private final Multimap methodImplementations = HashMultimap.create(); private final ListMultimap> childrenByClass; private ProgressListener progress; - public JarIndex(EntryIndex entryIndex, InheritanceIndex inheritanceIndex, ReferenceIndex referenceIndex, BridgeMethodIndex bridgeMethodIndex, PackageVisibilityIndex packageVisibilityIndex, EnclosingMethodIndex enclosingMethodIndex) { - this.entryIndex = entryIndex; - this.inheritanceIndex = inheritanceIndex; - this.referenceIndex = referenceIndex; - this.bridgeMethodIndex = bridgeMethodIndex; - this.packageVisibilityIndex = packageVisibilityIndex; - this.enclosingMethodIndex = enclosingMethodIndex; - this.indexers = List.of(entryIndex, inheritanceIndex, referenceIndex, bridgeMethodIndex, packageVisibilityIndex, enclosingMethodIndex); + /** + * Creates a new empty index with all provided indexers. + * @param indexers the indexers to use + */ + public JarIndex(JarIndexer... indexers) { + for (JarIndexer indexer : indexers) { + this.indexers.put(indexer.getClass(), indexer); + } + this.entryResolver = new IndexEntryResolver(this); this.childrenByClass = ArrayListMultimap.create(); } + /** + * Creates an empty index, configured to use all built-in indexers. + * @return the newly created index + */ public static JarIndex empty() { EntryIndex entryIndex = new EntryIndex(); InheritanceIndex inheritanceIndex = new InheritanceIndex(entryIndex); @@ -66,6 +65,27 @@ public static JarIndex empty() { return new JarIndex(entryIndex, inheritanceIndex, referenceIndex, bridgeMethodIndex, packageVisibilityIndex, enclosingMethodIndex); } + /** + * Gets the index associated with the provided class. + * @param clazz the class of the index desired - for example, {@code PackageIndex.class} + * @return the index + */ + @SuppressWarnings("unchecked") + public T getIndex(Class clazz) { + JarIndexer index = this.indexers.get(clazz); + if (index != null) { + return (T) index; + } else { + throw new IllegalArgumentException("no indexer registered for class " + clazz); + } + } + + /** + * Runs every configured indexer over the provided jar. + * @param classNames the obfuscated names of each class in the jar + * @param classProvider a class provider containing all classes in the jar + * @param progress a progress listener to track index completion + */ public void indexJar(Set classNames, ClassProvider classProvider, ProgressListener progress) { // for use in processIndex this.progress = progress; @@ -76,21 +96,21 @@ public void indexJar(Set classNames, ClassProvider classProvider, Progre this.progress.step(1, I18n.translate("progress.jar.indexing.entries")); for (String className : classNames) { - classProvider.get(className).accept(new IndexClassVisitor(this, Enigma.ASM_VERSION)); + Objects.requireNonNull(classProvider.get(className)).accept(new IndexClassVisitor(this, Enigma.ASM_VERSION)); } this.progress.step(2, I18n.translate("progress.jar.indexing.references")); for (String className : classNames) { try { - classProvider.get(className).accept(new IndexReferenceVisitor(this, this.entryIndex, this.inheritanceIndex, Enigma.ASM_VERSION)); + Objects.requireNonNull(classProvider.get(className)).accept(new IndexReferenceVisitor(this, this.getIndex(EntryIndex.class), this.getIndex(InheritanceIndex.class), Enigma.ASM_VERSION)); } catch (Exception e) { throw new RuntimeException("Exception while indexing class: " + className, e); } } this.progress.step(3, I18n.translate("progress.jar.indexing.methods")); - this.bridgeMethodIndex.findBridgeMethods(); + this.getIndex(BridgeMethodIndex.class).findBridgeMethods(); this.processIndex(this); @@ -101,7 +121,7 @@ public void indexJar(Set classNames, ClassProvider classProvider, Progre public void processIndex(JarIndex index) { this.stepProcessingProgress("progress.jar.indexing.process.jar"); - this.indexers.forEach(indexer -> { + this.indexers.forEach((key, indexer) -> { this.stepProcessingProgress(indexer.getTranslationKey()); indexer.processIndex(index); }); @@ -127,7 +147,7 @@ public void indexClass(ClassDefEntry classEntry) { } } - this.indexers.forEach(indexer -> indexer.indexClass(classEntry)); + this.indexers.forEach((key, indexer) -> indexer.indexClass(classEntry)); if (classEntry.isInnerClass() && !classEntry.getAccess().isSynthetic()) { this.childrenByClass.put(classEntry.getParent(), classEntry); } @@ -139,7 +159,7 @@ public void indexField(FieldDefEntry fieldEntry) { return; } - this.indexers.forEach(indexer -> indexer.indexField(fieldEntry)); + this.indexers.forEach((key, indexer) -> indexer.indexField(fieldEntry)); if (!fieldEntry.getAccess().isSynthetic()) { this.childrenByClass.put(fieldEntry.getParent(), fieldEntry); } @@ -151,7 +171,7 @@ public void indexMethod(MethodDefEntry methodEntry) { return; } - this.indexers.forEach(indexer -> indexer.indexMethod(methodEntry)); + this.indexers.forEach((key, indexer) -> indexer.indexMethod(methodEntry)); if (!methodEntry.getAccess().isSynthetic() && !methodEntry.getName().equals("")) { this.childrenByClass.put(methodEntry.getParent(), methodEntry); } @@ -167,7 +187,7 @@ public void indexMethodReference(MethodDefEntry callerEntry, MethodEntry referen return; } - this.indexers.forEach(indexer -> indexer.indexMethodReference(callerEntry, referencedEntry, targetType)); + this.indexers.forEach((key, indexer) -> indexer.indexMethodReference(callerEntry, referencedEntry, targetType)); } @Override @@ -176,7 +196,7 @@ public void indexFieldReference(MethodDefEntry callerEntry, FieldEntry reference return; } - this.indexers.forEach(indexer -> indexer.indexFieldReference(callerEntry, referencedEntry, targetType)); + this.indexers.forEach((key, indexer) -> indexer.indexFieldReference(callerEntry, referencedEntry, targetType)); } @Override @@ -185,7 +205,7 @@ public void indexLambda(MethodDefEntry callerEntry, Lambda lambda, ReferenceTarg return; } - this.indexers.forEach(indexer -> indexer.indexLambda(callerEntry, lambda, targetType)); + this.indexers.forEach((key, indexer) -> indexer.indexLambda(callerEntry, lambda, targetType)); } @Override @@ -194,7 +214,7 @@ public void indexEnclosingMethod(ClassDefEntry classEntry, EnclosingMethodData e return; } - this.indexers.forEach(indexer -> indexer.indexEnclosingMethod(classEntry, enclosingMethodData)); + this.indexers.forEach((key, indexer) -> indexer.indexEnclosingMethod(classEntry, enclosingMethodData)); } @Override @@ -202,30 +222,6 @@ public String getTranslationKey() { return "progress.jar.indexing.jar"; } - public EntryIndex getEntryIndex() { - return this.entryIndex; - } - - public InheritanceIndex getInheritanceIndex() { - return this.inheritanceIndex; - } - - public ReferenceIndex getReferenceIndex() { - return this.referenceIndex; - } - - public BridgeMethodIndex getBridgeMethodIndex() { - return this.bridgeMethodIndex; - } - - public PackageVisibilityIndex getPackageVisibilityIndex() { - return this.packageVisibilityIndex; - } - - public EnclosingMethodIndex getEnclosingMethodIndex() { - return this.enclosingMethodIndex; - } - public EntryResolver getEntryResolver() { return this.entryResolver; } diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/JarIndexer.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/JarIndexer.java similarity index 87% rename from enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/JarIndexer.java rename to enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/JarIndexer.java index 080b30a71..4d64a2d5c 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/JarIndexer.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/JarIndexer.java @@ -1,4 +1,4 @@ -package org.quiltmc.enigma.api.analysis.index; +package org.quiltmc.enigma.api.analysis.index.jar; import org.quiltmc.enigma.api.analysis.ReferenceTargetType; import org.quiltmc.enigma.api.translation.representation.Lambda; @@ -33,10 +33,7 @@ default void indexEnclosingMethod(ClassDefEntry classEntry, EnclosingMethodData default void processIndex(JarIndex index) { } - default String getTranslationKey() { - // REMOVE IN 2.0: this is a temporary default impl to avoid api breakage - return this.getClass().getSimpleName(); - } + String getTranslationKey(); record EnclosingMethodData(String owner, String name, String descriptor) { public MethodEntry getMethod() { diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/PackageVisibilityIndex.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/PackageVisibilityIndex.java similarity index 95% rename from enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/PackageVisibilityIndex.java rename to enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/PackageVisibilityIndex.java index 797f70f72..f5decb2a6 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/PackageVisibilityIndex.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/PackageVisibilityIndex.java @@ -1,4 +1,4 @@ -package org.quiltmc.enigma.api.analysis.index; +package org.quiltmc.enigma.api.analysis.index.jar; import com.google.common.collect.HashMultimap; import com.google.common.collect.Maps; @@ -147,9 +147,9 @@ public Set getPartition(ClassEntry classEntry) { @Override public void processIndex(JarIndex index) { - EntryIndex entryIndex = index.getEntryIndex(); - ReferenceIndex referenceIndex = index.getReferenceIndex(); - InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); + EntryIndex entryIndex = index.getIndex(EntryIndex.class); + ReferenceIndex referenceIndex = index.getIndex(ReferenceIndex.class); + InheritanceIndex inheritanceIndex = index.getIndex(InheritanceIndex.class); this.addConnections(entryIndex, referenceIndex, inheritanceIndex); this.addPartitions(entryIndex); } diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/ReferenceIndex.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/ReferenceIndex.java similarity index 99% rename from enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/ReferenceIndex.java rename to enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/ReferenceIndex.java index 42916953b..102b260cc 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/ReferenceIndex.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/jar/ReferenceIndex.java @@ -1,4 +1,4 @@ -package org.quiltmc.enigma.api.analysis.index; +package org.quiltmc.enigma.api.analysis.index.jar; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/mapping/MappingsIndex.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/mapping/MappingsIndex.java new file mode 100644 index 000000000..430442c26 --- /dev/null +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/mapping/MappingsIndex.java @@ -0,0 +1,151 @@ +package org.quiltmc.enigma.api.analysis.index.mapping; + +import org.quiltmc.enigma.api.ProgressListener; +import org.quiltmc.enigma.api.translation.mapping.EntryMapping; +import org.quiltmc.enigma.api.translation.mapping.tree.EntryTree; +import org.quiltmc.enigma.api.translation.mapping.tree.EntryTreeNode; +import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; +import org.quiltmc.enigma.api.translation.representation.entry.Entry; +import org.quiltmc.enigma.api.translation.representation.entry.FieldEntry; +import org.quiltmc.enigma.api.translation.representation.entry.LocalVariableEntry; +import org.quiltmc.enigma.api.translation.representation.entry.MethodEntry; +import org.quiltmc.enigma.util.I18n; +import org.quiltmc.enigma.util.Pair; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * A consolidated {@link MappingsIndexer} that can be configured to use as many separate indexers as you like. + */ +public class MappingsIndex implements MappingsIndexer { + private final Map, MappingsIndexer> indexers = new HashMap<>(); + + private ProgressListener progress; + private int work; + + /** + * Creates a new empty index with all provided indexers. + * @param indexers the indexers to use + */ + public MappingsIndex(MappingsIndexer... indexers) { + for (MappingsIndexer indexer : indexers) { + this.indexers.put(indexer.getClass(), indexer); + } + } + + /** + * Creates an empty index, configured to use all built-in indexers. + * @return the newly created index + */ + public static MappingsIndex empty() { + return new MappingsIndex(new PackageIndex()); + } + + /** + * Gets the index associated with the provided class. + * @param clazz the class of the index desired - for example, {@code PackageIndex.class} + * @return the index + */ + @SuppressWarnings("unchecked") + public T getIndex(Class clazz) { + MappingsIndexer index = this.indexers.get(clazz); + if (index != null) { + return (T) index; + } else { + throw new IllegalArgumentException("no indexer registered for class " + clazz); + } + } + + /** + * Runs every configured indexer over each mapping in the tree. + * @param mappings the mappings to index + * @param progress a progress listener to track index completion + */ + public void indexMappings(EntryTree mappings, ProgressListener progress) { + this.progress = progress; + + Set, EntryMapping>> entries = new HashSet<>(); + + mappings.getRootNodes().forEach(node -> handleNode(node, entries)); + + this.work = entries.size(); + this.progress.init(this.work, I18n.translate("progress.mappings.indexing.mappings")); + + for (var pair : entries) { + Entry entry = pair.a(); + EntryMapping mapping = pair.b(); + + if (entry instanceof ClassEntry classEntry) { + this.indexClassMapping(mapping, classEntry); + } else if (entry instanceof MethodEntry methodEntry) { + this.indexMethodMapping(mapping, methodEntry); + } else if (entry instanceof FieldEntry fieldEntry) { + this.indexFieldMapping(mapping, fieldEntry); + } else if (entry instanceof LocalVariableEntry localVariableEntry) { + this.indexLocalVariableMapping(mapping, localVariableEntry); + } + + this.progress.step(this.work++, I18n.translate("progress.mappings.indexing.mappings")); + } + + this.processIndex(this); + + this.progress = null; + this.work = 0; + } + + private static void handleNode(EntryTreeNode node, Set, EntryMapping>> entries) { + if (!node.getChildNodes().isEmpty()) { + node.getChildNodes().forEach(child -> handleNode(child, entries)); + } else { + entries.add(new Pair<>(node.getEntry(), node.getValue())); + } + } + + public void indexClassMapping(EntryMapping mapping, ClassEntry entry) { + this.indexers.forEach((key, indexer) -> indexer.indexClassMapping(mapping, entry)); + } + + public void indexMethodMapping(EntryMapping mapping, MethodEntry entry) { + this.indexers.forEach((key, indexer) -> indexer.indexMethodMapping(mapping, entry)); + } + + public void indexFieldMapping(EntryMapping mapping, FieldEntry entry) { + this.indexers.forEach((key, indexer) -> indexer.indexFieldMapping(mapping, entry)); + } + + public void indexLocalVariableMapping(EntryMapping mapping, LocalVariableEntry entry) { + this.indexers.forEach((key, indexer) -> indexer.indexLocalVariableMapping(mapping, entry)); + } + + @Override + public void processIndex(MappingsIndex index) { + this.stepProcessingProgress("progress.mappings.indexing.process.mappings"); + + this.indexers.forEach((key, indexer) -> { + this.stepProcessingProgress(indexer.getTranslationKey()); + indexer.processIndex(index); + }); + + this.stepProcessingProgress("progress.mappings.indexing.process.done"); + } + + @Override + public void reindexEntry(EntryMapping newMapping, Entry entry) { + this.indexers.forEach((key, indexer) -> indexer.reindexEntry(newMapping, entry)); + } + + private void stepProcessingProgress(String key) { + if (this.progress != null) { + this.progress.step(this.work, I18n.translateFormatted("progress.mappings.indexing.process", I18n.translate(key))); + } + } + + @Override + public String getTranslationKey() { + return "progress.mappings.indexing.mappings"; + } +} diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/mapping/MappingsIndexer.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/mapping/MappingsIndexer.java new file mode 100644 index 000000000..2185a8c4f --- /dev/null +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/mapping/MappingsIndexer.java @@ -0,0 +1,46 @@ +package org.quiltmc.enigma.api.analysis.index.mapping; + +import org.quiltmc.enigma.api.translation.mapping.EntryMapping; +import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; +import org.quiltmc.enigma.api.translation.representation.entry.Entry; +import org.quiltmc.enigma.api.translation.representation.entry.FieldEntry; +import org.quiltmc.enigma.api.translation.representation.entry.LocalVariableEntry; +import org.quiltmc.enigma.api.translation.representation.entry.MethodEntry; + +/** + * An indexer to collect information on a tree of mappings. + */ +public interface MappingsIndexer { + default void indexClassMapping(EntryMapping mapping, ClassEntry entry) { + } + + default void indexMethodMapping(EntryMapping mapping, MethodEntry entry) { + } + + default void indexFieldMapping(EntryMapping mapping, FieldEntry entry) { + } + + default void indexLocalVariableMapping(EntryMapping mapping, LocalVariableEntry entry) { + } + + /** + * Runs post-processing on the completed index. + * @param index the finished index + */ + default void processIndex(MappingsIndex index) { + } + + /** + * Re-indexes the entry, discarding any previously existing data associated with it. + * This should only be called when a previously indexed entry's mapping changes. + * @param newMapping the entry's new mapping + * @param entry the entry to re-index + */ + void reindexEntry(EntryMapping newMapping, Entry entry); + + /** + * A translation key for the title of this indexer. + * @return the translation key + */ + String getTranslationKey(); +} diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/mapping/PackageIndex.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/mapping/PackageIndex.java new file mode 100644 index 000000000..14bc3ce21 --- /dev/null +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/index/mapping/PackageIndex.java @@ -0,0 +1,49 @@ +package org.quiltmc.enigma.api.analysis.index.mapping; + +import org.quiltmc.enigma.api.translation.mapping.EntryMapping; +import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; +import org.quiltmc.enigma.api.translation.representation.entry.Entry; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * An indexer that saves the names of all currently existing packages. + */ +public class PackageIndex implements MappingsIndexer { + private final Map packageNames = new HashMap<>(); + + @Override + public void indexClassMapping(EntryMapping mapping, ClassEntry entry) { + if (mapping.targetName() == null) { + return; + } + + String packageName = ClassEntry.getParentPackage(mapping.targetName()); + if (!entry.isInnerClass() && !this.packageNames.containsValue(packageName)) { + this.packageNames.put(entry, packageName); + } + } + + @Override + public void reindexEntry(EntryMapping newMapping, Entry entry) { + if (entry instanceof ClassEntry classEntry) { + this.packageNames.remove(classEntry); + this.indexClassMapping(newMapping, classEntry); + } + } + + /** + * Gets all distinct package names. + * @return a list of unique package names + */ + public List getPackageNames() { + return this.packageNames.values().stream().distinct().toList(); + } + + @Override + public String getTranslationKey() { + return "progress.mappings.indexing.packages"; + } +} diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/ClassImplementationsTreeNode.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/ClassImplementationsTreeNode.java index 313d7eff8..58e65f6d2 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/ClassImplementationsTreeNode.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/ClassImplementationsTreeNode.java @@ -1,7 +1,7 @@ package org.quiltmc.enigma.api.analysis.tree; -import org.quiltmc.enigma.api.analysis.index.InheritanceIndex; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.InheritanceIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.translation.Translator; import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; import org.quiltmc.enigma.api.translation.representation.entry.MethodEntry; @@ -35,7 +35,7 @@ public static ClassImplementationsTreeNode findNode(ClassImplementationsTreeNode public void load(JarIndex index) { // get all method implementations List nodes = new ArrayList<>(); - InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); + InheritanceIndex inheritanceIndex = index.getIndex(InheritanceIndex.class); Collection inheritors = inheritanceIndex.getChildren(this.entry); for (ClassEntry inheritor : inheritors) { diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/ClassInheritanceTreeNode.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/ClassInheritanceTreeNode.java index 24b0d834c..ce4e5b523 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/ClassInheritanceTreeNode.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/ClassInheritanceTreeNode.java @@ -1,6 +1,6 @@ package org.quiltmc.enigma.api.analysis.tree; -import org.quiltmc.enigma.api.analysis.index.InheritanceIndex; +import org.quiltmc.enigma.api.analysis.index.jar.InheritanceIndex; import org.quiltmc.enigma.api.translation.Translator; import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/ClassReferenceTreeNode.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/ClassReferenceTreeNode.java index 11802ed13..75ec6c2c4 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/ClassReferenceTreeNode.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/ClassReferenceTreeNode.java @@ -1,8 +1,8 @@ package org.quiltmc.enigma.api.analysis.tree; import com.google.common.collect.Sets; -import org.quiltmc.enigma.api.analysis.index.JarIndex; -import org.quiltmc.enigma.api.analysis.index.ReferenceIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.ReferenceIndex; import org.quiltmc.enigma.api.analysis.EntryReference; import org.quiltmc.enigma.api.translation.Translator; import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; @@ -50,7 +50,7 @@ public String toString() { } public void load(JarIndex index, boolean recurse) { - ReferenceIndex referenceIndex = index.getReferenceIndex(); + ReferenceIndex referenceIndex = index.getIndex(ReferenceIndex.class); // get all the child nodes for (EntryReference reference : referenceIndex.getReferencesToClass(this.entry)) { diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/FieldReferenceTreeNode.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/FieldReferenceTreeNode.java index 9908c0bad..5492181ea 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/FieldReferenceTreeNode.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/FieldReferenceTreeNode.java @@ -1,7 +1,7 @@ package org.quiltmc.enigma.api.analysis.tree; -import org.quiltmc.enigma.api.analysis.index.JarIndex; -import org.quiltmc.enigma.api.analysis.index.ReferenceIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.ReferenceIndex; import org.quiltmc.enigma.api.analysis.EntryReference; import org.quiltmc.enigma.api.translation.Translator; import org.quiltmc.enigma.api.translation.representation.entry.FieldEntry; @@ -47,7 +47,7 @@ public String toString() { } public void load(JarIndex index, boolean recurse) { - ReferenceIndex referenceIndex = index.getReferenceIndex(); + ReferenceIndex referenceIndex = index.getIndex(ReferenceIndex.class); // get all the child nodes if (this.reference == null) { diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/MethodImplementationsTreeNode.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/MethodImplementationsTreeNode.java index 3538d38ab..44c8505e2 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/MethodImplementationsTreeNode.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/MethodImplementationsTreeNode.java @@ -1,8 +1,8 @@ package org.quiltmc.enigma.api.analysis.tree; -import org.quiltmc.enigma.api.analysis.index.EntryIndex; -import org.quiltmc.enigma.api.analysis.index.InheritanceIndex; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.InheritanceIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.translation.Translator; import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; import org.quiltmc.enigma.api.translation.representation.entry.MethodEntry; @@ -45,8 +45,8 @@ public String toString() { public void load(JarIndex index) { // get all method implementations List nodes = new ArrayList<>(); - EntryIndex entryIndex = index.getEntryIndex(); - InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); + EntryIndex entryIndex = index.getIndex(EntryIndex.class); + InheritanceIndex inheritanceIndex = index.getIndex(InheritanceIndex.class); Collection descendants = inheritanceIndex.getDescendants(this.entry.getParent()); for (ClassEntry inheritor : descendants) { diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/MethodInheritanceTreeNode.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/MethodInheritanceTreeNode.java index 4f525f7f3..0a0533367 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/MethodInheritanceTreeNode.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/MethodInheritanceTreeNode.java @@ -1,8 +1,8 @@ package org.quiltmc.enigma.api.analysis.tree; -import org.quiltmc.enigma.api.analysis.index.EntryIndex; -import org.quiltmc.enigma.api.analysis.index.InheritanceIndex; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.InheritanceIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.translation.Translator; import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; import org.quiltmc.enigma.api.translation.representation.entry.MethodEntry; @@ -52,8 +52,8 @@ public String toString() { */ public boolean load(JarIndex index) { // get all the child nodes - EntryIndex entryIndex = index.getEntryIndex(); - InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); + EntryIndex entryIndex = index.getIndex(EntryIndex.class); + InheritanceIndex inheritanceIndex = index.getIndex(InheritanceIndex.class); boolean ret = false; for (ClassEntry inheritorEntry : inheritanceIndex.getChildren(this.entry.getParent())) { diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/MethodReferenceTreeNode.java b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/MethodReferenceTreeNode.java index 8d072f003..28653974d 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/MethodReferenceTreeNode.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/analysis/tree/MethodReferenceTreeNode.java @@ -1,8 +1,8 @@ package org.quiltmc.enigma.api.analysis.tree; import com.google.common.collect.Sets; -import org.quiltmc.enigma.api.analysis.index.JarIndex; -import org.quiltmc.enigma.api.analysis.index.ReferenceIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.ReferenceIndex; import org.quiltmc.enigma.api.analysis.EntryReference; import org.quiltmc.enigma.api.translation.Translator; import org.quiltmc.enigma.api.translation.mapping.EntryResolver; @@ -84,7 +84,7 @@ public void load(JarIndex index, boolean recurse, boolean recurseMethod) { } private Collection> getReferences(JarIndex index, boolean recurseMethod) { - ReferenceIndex referenceIndex = index.getReferenceIndex(); + ReferenceIndex referenceIndex = index.getIndex(ReferenceIndex.class); if (recurseMethod) { Collection> references = new ArrayList<>(); diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/class_handle/ClassHandleProvider.java b/enigma/src/main/java/org/quiltmc/enigma/api/class_handle/ClassHandleProvider.java index 25bf8678f..0334ccc76 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/class_handle/ClassHandleProvider.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/class_handle/ClassHandleProvider.java @@ -1,6 +1,7 @@ package org.quiltmc.enigma.api.class_handle; import org.quiltmc.enigma.api.EnigmaProject; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; import org.quiltmc.enigma.api.class_provider.CachingClassProvider; import org.quiltmc.enigma.api.class_provider.ObfuscationFixClassProvider; import org.quiltmc.enigma.api.event.ClassHandleListener; @@ -58,7 +59,7 @@ public ClassHandleProvider(EnigmaProject project, DecompilerService ds) { */ @Nullable public ClassHandle openClass(ClassEntry entry) { - if (!this.project.getJarIndex().getEntryIndex().hasClass(entry)) return null; + if (!this.project.getJarIndex().getIndex(EntryIndex.class).hasClass(entry)) return null; return Utils.withLock(this.lock.writeLock(), () -> { Entry e = this.handles.computeIfAbsent(entry, entry1 -> new Entry(this, entry1)); diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/class_provider/ObfuscationFixClassProvider.java b/enigma/src/main/java/org/quiltmc/enigma/api/class_provider/ObfuscationFixClassProvider.java index 919268dfd..11193c183 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/class_provider/ObfuscationFixClassProvider.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/class_provider/ObfuscationFixClassProvider.java @@ -1,7 +1,7 @@ package org.quiltmc.enigma.api.class_provider; import org.quiltmc.enigma.api.Enigma; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.impl.bytecode.translator.LocalVariableFixVisitor; import org.quiltmc.enigma.impl.bytecode.translator.SourceFixVisitor; import org.objectweb.asm.ClassVisitor; diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/service/JarIndexerService.java b/enigma/src/main/java/org/quiltmc/enigma/api/service/JarIndexerService.java index f89517326..29bfe3f4f 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/service/JarIndexerService.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/service/JarIndexerService.java @@ -1,6 +1,6 @@ package org.quiltmc.enigma.api.service; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.class_provider.ClassProvider; import org.objectweb.asm.ClassVisitor; diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/stats/StatsGenerator.java b/enigma/src/main/java/org/quiltmc/enigma/api/stats/StatsGenerator.java index 0c8fa58c4..abc4b674a 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/stats/StatsGenerator.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/stats/StatsGenerator.java @@ -3,7 +3,7 @@ import com.google.common.base.Preconditions; import org.quiltmc.enigma.api.EnigmaProject; import org.quiltmc.enigma.api.ProgressListener; -import org.quiltmc.enigma.api.analysis.index.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; import org.quiltmc.enigma.api.translation.mapping.EntryResolver; import org.quiltmc.enigma.api.translation.mapping.ResolutionStrategy; import org.quiltmc.enigma.api.translation.representation.ArgumentDescriptor; @@ -39,7 +39,7 @@ public class StatsGenerator { public StatsGenerator(EnigmaProject project) { this.project = project; - this.entryIndex = project.getJarIndex().getEntryIndex(); + this.entryIndex = project.getJarIndex().getIndex(EntryIndex.class); this.entryResolver = project.getJarIndex().getEntryResolver(); } diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/translation/mapping/EntryRemapper.java b/enigma/src/main/java/org/quiltmc/enigma/api/translation/mapping/EntryRemapper.java index b7dc95d6f..d1f9da693 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/translation/mapping/EntryRemapper.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/translation/mapping/EntryRemapper.java @@ -1,6 +1,8 @@ package org.quiltmc.enigma.api.translation.mapping; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; +import org.quiltmc.enigma.api.analysis.index.mapping.MappingsIndex; import org.quiltmc.enigma.api.translation.MappingTranslator; import org.quiltmc.enigma.api.translation.Translatable; import org.quiltmc.enigma.api.translation.TranslateResult; @@ -27,26 +29,28 @@ public class EntryRemapper { private final EntryResolver obfResolver; private final Translator deobfuscator; private final JarIndex jarIndex; + private final MappingsIndex mappingsIndex; private final MappingValidator validator; - private EntryRemapper(JarIndex jarIndex, EntryTree obfToDeobf) { + private EntryRemapper(JarIndex jarIndex, MappingsIndex mappingsIndex, EntryTree obfToDeobf) { this.obfToDeobf = new DeltaTrackingTree<>(obfToDeobf); this.obfResolver = jarIndex.getEntryResolver(); this.deobfuscator = new MappingTranslator(obfToDeobf, this.obfResolver); this.jarIndex = jarIndex; + this.mappingsIndex = mappingsIndex; - this.validator = new MappingValidator(this.deobfuscator, jarIndex); + this.validator = new MappingValidator(this.deobfuscator, jarIndex, mappingsIndex); } - public static EntryRemapper mapped(JarIndex index, EntryTree obfToDeobf) { - return new EntryRemapper(index, obfToDeobf); + public static EntryRemapper mapped(JarIndex jarIndex, MappingsIndex mappingsIndex, EntryTree obfToDeobf) { + return new EntryRemapper(jarIndex, mappingsIndex, obfToDeobf); } public static EntryRemapper empty(JarIndex index) { - return new EntryRemapper(index, new HashEntryTree<>()); + return new EntryRemapper(index, MappingsIndex.empty(), new HashEntryTree<>()); } public void validatePutMapping(ValidationContext vc, Entry obfuscatedEntry, @Nonnull EntryMapping deobfMapping) { @@ -84,18 +88,22 @@ private void doPutMapping(ValidationContext vc, Entry obfuscatedEntry, @Nonnu this.obfToDeobf.insert(resolvedEntry, deobfMapping); } } + + this.mappingsIndex.reindexEntry(deobfMapping, obfuscatedEntry); } // todo this needs to be fixed for hashed mappings! // note: just supressing warnings until it's fixed @SuppressWarnings("all") private void mapRecordComponentGetter(ValidationContext vc, ClassEntry classEntry, FieldEntry fieldEntry, EntryMapping fieldMapping) { - if (!this.jarIndex.getEntryIndex().getDefinition(classEntry).isRecord() || this.jarIndex.getEntryIndex().getFieldAccess(fieldEntry).isStatic()) { + EntryIndex entryIndex = this.jarIndex.getIndex(EntryIndex.class); + + if (!entryIndex.getDefinition(classEntry).isRecord() || entryIndex.getFieldAccess(fieldEntry).isStatic()) { return; } // Find all the methods in this record class - List classMethods = this.jarIndex.getEntryIndex().getMethods().stream() + List classMethods = entryIndex.getMethods().stream() .filter(entry -> classEntry.equals(entry.getParent())) .toList(); diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/translation/mapping/IndexEntryResolver.java b/enigma/src/main/java/org/quiltmc/enigma/api/translation/mapping/IndexEntryResolver.java index e37c498f5..3c5f2cea8 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/translation/mapping/IndexEntryResolver.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/translation/mapping/IndexEntryResolver.java @@ -3,10 +3,10 @@ import org.quiltmc.enigma.impl.analysis.IndexTreeBuilder; import org.quiltmc.enigma.api.analysis.tree.MethodImplementationsTreeNode; import org.quiltmc.enigma.api.analysis.tree.MethodInheritanceTreeNode; -import org.quiltmc.enigma.api.analysis.index.BridgeMethodIndex; -import org.quiltmc.enigma.api.analysis.index.EntryIndex; -import org.quiltmc.enigma.api.analysis.index.InheritanceIndex; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.BridgeMethodIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.InheritanceIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.translation.VoidTranslator; import org.quiltmc.enigma.api.translation.representation.AccessFlags; import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; @@ -28,9 +28,9 @@ public class IndexEntryResolver implements EntryResolver { private final IndexTreeBuilder treeBuilder; public IndexEntryResolver(JarIndex index) { - this.entryIndex = index.getEntryIndex(); - this.inheritanceIndex = index.getInheritanceIndex(); - this.bridgeMethodIndex = index.getBridgeMethodIndex(); + this.entryIndex = index.getIndex(EntryIndex.class); + this.inheritanceIndex = index.getIndex(InheritanceIndex.class); + this.bridgeMethodIndex = index.getIndex(BridgeMethodIndex.class); this.treeBuilder = new IndexTreeBuilder(index); } diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/translation/mapping/MappingValidator.java b/enigma/src/main/java/org/quiltmc/enigma/api/translation/mapping/MappingValidator.java index 15feae664..dd2b79cd4 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/translation/mapping/MappingValidator.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/translation/mapping/MappingValidator.java @@ -1,6 +1,10 @@ package org.quiltmc.enigma.api.translation.mapping; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.InheritanceIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; +import org.quiltmc.enigma.api.analysis.index.mapping.MappingsIndex; +import org.quiltmc.enigma.api.analysis.index.mapping.PackageIndex; import org.quiltmc.enigma.api.translation.Translator; import org.quiltmc.enigma.api.translation.representation.AccessFlags; import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; @@ -23,15 +27,25 @@ public class MappingValidator { private final Translator deobfuscator; - private final JarIndex index; + private final JarIndex jarIndex; + private final MappingsIndex mappingsIndex; - public MappingValidator(Translator deobfuscator, JarIndex index) { + public MappingValidator(Translator deobfuscator, JarIndex jarIndex, MappingsIndex mappingsIndex) { this.deobfuscator = deobfuscator; - this.index = index; + this.jarIndex = jarIndex; + this.mappingsIndex = mappingsIndex; } public void validateRename(ValidationContext vc, Entry entry, String name) { - Collection> equivalentEntries = this.index.getEntryResolver().resolveEquivalentEntries(entry); + PackageIndex packageIndex = this.mappingsIndex.getIndex(PackageIndex.class); + if (entry instanceof ClassEntry) { + String packageName = ClassEntry.getParentPackage(name); + if (!packageIndex.getPackageNames().contains(packageName)) { + vc.raise(Message.NEW_PACKAGE, packageName); + } + } + + Collection> equivalentEntries = this.jarIndex.getEntryResolver().resolveEquivalentEntries(entry); boolean uniquenessIssue = false; for (Entry equivalentEntry : equivalentEntries) { @@ -55,11 +69,11 @@ private boolean validateUnique(ValidationContext context, Entry entry, String return this.validateParameterUniqueness(context, name, parameter); } - List> siblings = new ArrayList<>(this.index.getChildrenByClass().get(containingClass)); + List> siblings = new ArrayList<>(this.jarIndex.getChildrenByClass().get(containingClass)); // add sibling classes if (entry instanceof ClassEntry classEntry) { - siblings.addAll(this.index.getEntryIndex().getClasses().stream().filter(e -> { + siblings.addAll(this.jarIndex.getIndex(EntryIndex.class).getClasses().stream().filter(e -> { if (e.isInnerClass()) { return false; } @@ -74,8 +88,8 @@ private boolean validateUnique(ValidationContext context, Entry entry, String } // add all ancestors - for (ClassEntry ancestor : this.index.getInheritanceIndex().getAncestors(containingClass)) { - siblings.addAll(this.index.getChildrenByClass().get(ancestor)); + for (ClassEntry ancestor : this.jarIndex.getIndex(InheritanceIndex.class).getAncestors(containingClass)) { + siblings.addAll(this.jarIndex.getChildrenByClass().get(ancestor)); } // collect deobfuscated versions @@ -108,7 +122,7 @@ private boolean validateUnique(ValidationContext context, Entry entry, String private boolean validateParameterUniqueness(ValidationContext context, String name, LocalVariableEntry parameter) { MethodEntry parent = parameter.getParent(); if (parent != null) { - Iterator iterator = parent.getParameterIterator(this.index.getEntryIndex(), this.deobfuscator); + Iterator iterator = parent.getParameterIterator(this.jarIndex.getIndex(EntryIndex.class), this.deobfuscator); while (iterator.hasNext()) { if (iterator.next().getName().equals(name)) { this.raiseConflict(context, parent, name, false); @@ -154,8 +168,8 @@ private boolean isMethodUnique(MethodEntry entry, Entry obfEntry, Map getShadowedEntry(Entry entry, Entry obfEntry, Map ancestors = this.index.getInheritanceIndex().getAncestors(obfEntry.getContainingClass()); + Set ancestors = this.jarIndex.getIndex(InheritanceIndex.class).getAncestors(obfEntry.getContainingClass()); ancestors.addAll( ancestors.stream() .map(this.deobfuscator::translate) @@ -194,8 +208,8 @@ private Entry getShadowedEntry(Entry entry, Entry obfEntry, Map (obfEntry, remapper) -> { - BridgeMethodIndex bridgeMethodIndex = remapper.getJarIndex().getBridgeMethodIndex(); + BridgeMethodIndex bridgeMethodIndex = remapper.getJarIndex().getIndex(BridgeMethodIndex.class); if (obfEntry instanceof MethodEntry obfMethod) { if (bridgeMethodIndex.isSpecializedMethod(obfMethod)) { return Optional.ofNullable(bridgeMethodIndex.getBridgeFromSpecialized(obfMethod)).map(ParentedEntry::getName); diff --git a/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/IndexSimpleVerifier.java b/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/IndexSimpleVerifier.java index 4e6fe789a..b1ea15432 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/IndexSimpleVerifier.java +++ b/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/IndexSimpleVerifier.java @@ -1,8 +1,8 @@ package org.quiltmc.enigma.impl.analysis; import org.quiltmc.enigma.api.Enigma; -import org.quiltmc.enigma.api.analysis.index.EntryIndex; -import org.quiltmc.enigma.api.analysis.index.InheritanceIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.InheritanceIndex; import org.quiltmc.enigma.api.translation.representation.AccessFlags; import org.quiltmc.enigma.api.translation.representation.entry.ClassDefEntry; import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; diff --git a/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/IndexTreeBuilder.java b/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/IndexTreeBuilder.java index 8461f4778..99505a2f8 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/IndexTreeBuilder.java +++ b/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/IndexTreeBuilder.java @@ -1,10 +1,12 @@ package org.quiltmc.enigma.impl.analysis; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.InheritanceIndex; import org.quiltmc.enigma.api.analysis.tree.ClassImplementationsTreeNode; import org.quiltmc.enigma.api.analysis.tree.ClassInheritanceTreeNode; import org.quiltmc.enigma.api.analysis.tree.MethodImplementationsTreeNode; import org.quiltmc.enigma.api.analysis.tree.MethodInheritanceTreeNode; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.translation.Translator; import org.quiltmc.enigma.api.translation.mapping.EntryResolver; import org.quiltmc.enigma.api.translation.mapping.ResolutionStrategy; @@ -23,23 +25,25 @@ public IndexTreeBuilder(JarIndex index) { } public ClassInheritanceTreeNode buildClassInheritance(Translator translator, ClassEntry obfClassEntry) { + InheritanceIndex inheritanceIndex = this.index.getIndex(InheritanceIndex.class); + // get the root node List ancestry = new ArrayList<>(); ancestry.add(obfClassEntry.getFullName()); - for (ClassEntry classEntry : this.index.getInheritanceIndex().getAncestors(obfClassEntry)) { + for (ClassEntry classEntry : inheritanceIndex.getAncestors(obfClassEntry)) { ancestry.add(classEntry.getFullName()); } ClassInheritanceTreeNode rootNode = new ClassInheritanceTreeNode(translator, ancestry.get(ancestry.size() - 1)); // expand all children recursively - rootNode.load(this.index.getInheritanceIndex(), true); + rootNode.load(inheritanceIndex, true); return rootNode; } public ClassImplementationsTreeNode buildClassImplementations(Translator translator, ClassEntry obfClassEntry) { - if (this.index.getInheritanceIndex().isParent(obfClassEntry)) { + if (this.index.getIndex(InheritanceIndex.class).isParent(obfClassEntry)) { ClassImplementationsTreeNode node = new ClassImplementationsTreeNode(translator, obfClassEntry); node.load(this.index); return node; @@ -54,7 +58,7 @@ public MethodInheritanceTreeNode buildMethodInheritance(Translator translator, M // make a root node at the base MethodInheritanceTreeNode rootNode = new MethodInheritanceTreeNode( translator, resolvedEntry, - this.index.getEntryIndex().hasMethod(resolvedEntry) + this.index.getIndex(EntryIndex.class).hasMethod(resolvedEntry) ); // expand the full tree diff --git a/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/index/IndexClassVisitor.java b/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/index/IndexClassVisitor.java index 5160cba40..3afc26e9b 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/index/IndexClassVisitor.java +++ b/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/index/IndexClassVisitor.java @@ -1,8 +1,8 @@ package org.quiltmc.enigma.impl.analysis.index; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.impl.analysis.MethodNodeWithAction; -import org.quiltmc.enigma.api.analysis.index.JarIndexer; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndexer; import org.quiltmc.enigma.api.translation.representation.ParameterAccessFlags; import org.quiltmc.enigma.api.translation.representation.entry.ClassDefEntry; import org.quiltmc.enigma.api.translation.representation.entry.FieldDefEntry; diff --git a/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/index/IndexReferenceVisitor.java b/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/index/IndexReferenceVisitor.java index 734463b1f..57ef654db 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/index/IndexReferenceVisitor.java +++ b/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/index/IndexReferenceVisitor.java @@ -1,12 +1,12 @@ package org.quiltmc.enigma.impl.analysis.index; -import org.quiltmc.enigma.api.analysis.index.EntryIndex; -import org.quiltmc.enigma.api.analysis.index.InheritanceIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.InheritanceIndex; import org.quiltmc.enigma.impl.analysis.IndexSimpleVerifier; import org.quiltmc.enigma.impl.analysis.InterpreterPair; import org.quiltmc.enigma.impl.analysis.MethodNodeWithAction; import org.quiltmc.enigma.api.analysis.ReferenceTargetType; -import org.quiltmc.enigma.api.analysis.index.JarIndexer; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndexer; import org.quiltmc.enigma.api.translation.representation.AccessFlags; import org.quiltmc.enigma.api.translation.representation.Lambda; import org.quiltmc.enigma.api.translation.representation.MethodDescriptor; diff --git a/enigma/src/main/java/org/quiltmc/enigma/impl/bytecode/translator/SourceFixVisitor.java b/enigma/src/main/java/org/quiltmc/enigma/impl/bytecode/translator/SourceFixVisitor.java index 657450800..33a76a3b2 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/impl/bytecode/translator/SourceFixVisitor.java +++ b/enigma/src/main/java/org/quiltmc/enigma/impl/bytecode/translator/SourceFixVisitor.java @@ -1,7 +1,7 @@ package org.quiltmc.enigma.impl.bytecode.translator; -import org.quiltmc.enigma.api.analysis.index.BridgeMethodIndex; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.BridgeMethodIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.translation.representation.entry.ClassDefEntry; import org.quiltmc.enigma.api.translation.representation.entry.MethodDefEntry; import org.objectweb.asm.ClassVisitor; @@ -37,7 +37,7 @@ public FieldVisitor visitField(int access, String name, String descriptor, Strin public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { MethodDefEntry methodEntry = MethodDefEntry.parse(this.ownerEntry, access, name, descriptor, signature); - BridgeMethodIndex bridgeIndex = this.index.getBridgeMethodIndex(); + BridgeMethodIndex bridgeIndex = this.index.getIndex(BridgeMethodIndex.class); if (bridgeIndex.isBridgeMethod(methodEntry)) { access |= Opcodes.ACC_BRIDGE; } diff --git a/enigma/src/main/java/org/quiltmc/enigma/impl/translation/mapping/MappingsChecker.java b/enigma/src/main/java/org/quiltmc/enigma/impl/translation/mapping/MappingsChecker.java index c2896d43d..7d15e8ab7 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/impl/translation/mapping/MappingsChecker.java +++ b/enigma/src/main/java/org/quiltmc/enigma/impl/translation/mapping/MappingsChecker.java @@ -1,7 +1,8 @@ package org.quiltmc.enigma.impl.translation.mapping; import org.quiltmc.enigma.api.ProgressListener; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.translation.mapping.EntryMapping; import org.quiltmc.enigma.api.translation.mapping.ResolutionStrategy; import org.quiltmc.enigma.api.translation.mapping.tree.EntryTree; @@ -64,7 +65,7 @@ private void tryDropBrokenEntry(Dropped dropped, Entry entry) { } private boolean shouldDropBrokenEntry(Entry entry) { - if (!this.index.getEntryIndex().hasEntry(entry)) { + if (!this.index.getIndex(EntryIndex.class).hasEntry(entry)) { return true; } diff --git a/enigma/src/main/java/org/quiltmc/enigma/util/validation/Message.java b/enigma/src/main/java/org/quiltmc/enigma/util/validation/Message.java index 418605afe..72eaaa482 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/util/validation/Message.java +++ b/enigma/src/main/java/org/quiltmc/enigma/util/validation/Message.java @@ -18,6 +18,7 @@ public class Message { public static final Message SHADOWED_NAME_CLASS = create(Type.WARNING, "shadowed_name_class"); public static final Message SHADOWED_NAME = create(Type.WARNING, "shadowed_unique_name"); + public static final Message NEW_PACKAGE = create(Type.WARNING, "new_package"); public static final Message SERVER_STARTED = create(Type.INFO, "server_started"); public static final Message CONNECTED_TO_SERVER = create(Type.INFO, "connected_to_server"); diff --git a/enigma/src/main/resources/lang/en_us.json b/enigma/src/main/resources/lang/en_us.json index 7aae112fd..1cc57d6d3 100644 --- a/enigma/src/main/resources/lang/en_us.json +++ b/enigma/src/main/resources/lang/en_us.json @@ -172,6 +172,7 @@ "progress.jar.custom_indexing": "Running custom indexers", "progress.jar.custom_indexing.indexer": "Running %s", "progress.jar.custom_indexing.finished": "Done!", + "progress.jar.indexing.jar": "Indexing JAR...", "progress.jar.indexing.process.jar": "JAR...", "progress.jar.indexing.process.bridge_methods": "Bridge methods...", "progress.jar.indexing.process.references": "Entry references...", @@ -193,6 +194,11 @@ "progress.mappings.tiny_v2.loading": "Loading mapping file", "progress.mappings.srg_file.generating": "Generating mappings", "progress.mappings.srg_file.writing": "Writing mappings", + "progress.mappings.indexing.mappings": "Indexing mappings...", + "progress.mappings.indexing.packages": "Indexing packages...", + "progress.mappings.indexing.process.mappings": "Processing mappings index...", + "progress.mappings.indexing.process": "Running indexer: %s", + "progress.mappings.indexing.process.done": "Done!", "progress.stats": "Generating stats", "progress.stats.for": "Generating stats for: %s", "progress.stats.awaiting": "Awaiting off-thread generation", @@ -257,6 +263,7 @@ "validation.message.field_length_out_of_range": "Value must be less than %d characters long.", "validation.message.non_unique_name_class": "Name '%s' is not unique in '%s'.", "validation.message.non_unique_name": "Name '%s' is not unique.", + "validation.message.new_package": "This rename will create a new package: '%s'", "validation.message.illegal_class_name": "'%s' is not a valid class name.", "validation.message.illegal_identifier": "'%s' is not a valid identifier.", "validation.message.illegal_identifier.long": "Invalid character '%2$s' at position %3$d.", diff --git a/enigma/src/test/java/org/quiltmc/enigma/PackageVisibilityIndexTest.java b/enigma/src/test/java/org/quiltmc/enigma/PackageVisibilityIndexTest.java index 97dceea80..d2376f38c 100644 --- a/enigma/src/test/java/org/quiltmc/enigma/PackageVisibilityIndexTest.java +++ b/enigma/src/test/java/org/quiltmc/enigma/PackageVisibilityIndexTest.java @@ -1,7 +1,7 @@ package org.quiltmc.enigma; -import org.quiltmc.enigma.api.analysis.index.JarIndex; -import org.quiltmc.enigma.api.analysis.index.PackageVisibilityIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.PackageVisibilityIndex; import org.quiltmc.enigma.api.ProgressListener; import org.quiltmc.enigma.api.class_provider.JarClassProvider; import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; @@ -31,7 +31,7 @@ public PackageVisibilityIndexTest() throws Exception { @Test public void test() { - PackageVisibilityIndex visibilityIndex = this.jarIndex.getPackageVisibilityIndex(); + PackageVisibilityIndex visibilityIndex = this.jarIndex.getIndex(PackageVisibilityIndex.class); assertThat(visibilityIndex.getPartition(BASE), containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER)); System.out.println(visibilityIndex.getPartitions()); assertThat(visibilityIndex.getPartitions(), containsInAnyOrder( diff --git a/enigma/src/test/java/org/quiltmc/enigma/TestDeobfed.java b/enigma/src/test/java/org/quiltmc/enigma/TestDeobfed.java index bc8f32b68..e8d584975 100644 --- a/enigma/src/test/java/org/quiltmc/enigma/TestDeobfed.java +++ b/enigma/src/test/java/org/quiltmc/enigma/TestDeobfed.java @@ -3,6 +3,7 @@ import org.quiltmc.enigma.api.Enigma; import org.quiltmc.enigma.api.EnigmaProject; import org.quiltmc.enigma.api.ProgressListener; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; import org.quiltmc.enigma.api.class_provider.ClasspathClassProvider; import org.quiltmc.enigma.api.source.Decompiler; import org.quiltmc.enigma.api.source.Decompilers; @@ -34,7 +35,7 @@ public static void beforeClass() throws Exception { @Test public void obfEntries() { - assertThat(deobfProject.getJarIndex().getEntryIndex().getClasses(), Matchers.containsInAnyOrder( + assertThat(deobfProject.getJarIndex().getIndex(EntryIndex.class).getClasses(), Matchers.containsInAnyOrder( TestEntryFactory.newClass("org/quiltmc/enigma/input/Keep"), TestEntryFactory.newClass("a"), TestEntryFactory.newClass("b"), diff --git a/enigma/src/test/java/org/quiltmc/enigma/TestInnerClasses.java b/enigma/src/test/java/org/quiltmc/enigma/TestInnerClasses.java index a98204fa7..d07f4ec81 100644 --- a/enigma/src/test/java/org/quiltmc/enigma/TestInnerClasses.java +++ b/enigma/src/test/java/org/quiltmc/enigma/TestInnerClasses.java @@ -1,6 +1,7 @@ package org.quiltmc.enigma; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.ProgressListener; import org.quiltmc.enigma.api.class_provider.CachingClassProvider; import org.quiltmc.enigma.api.class_provider.JarClassProvider; @@ -49,25 +50,25 @@ public void constructorArgs() { @Test public void classTree() { // root level - assertTrue(this.index.getEntryIndex().hasClass(CLASS_TREE_ROOT)); + assertTrue(this.index.getIndex(EntryIndex.class).hasClass(CLASS_TREE_ROOT)); // level 1 ClassEntry fullClassEntry = new ClassEntry(CLASS_TREE_ROOT.getName() + "$" + CLASS_TREE_LEVEL_1.getSimpleName()); - assertTrue(this.index.getEntryIndex().hasClass(fullClassEntry)); + assertTrue(this.index.getIndex(EntryIndex.class).hasClass(fullClassEntry)); // level 2 fullClassEntry = new ClassEntry(CLASS_TREE_ROOT.getName() + "$" + CLASS_TREE_LEVEL_1.getSimpleName() + "$" + CLASS_TREE_LEVEL_2.getSimpleName()); - assertTrue(this.index.getEntryIndex().hasClass(fullClassEntry)); + assertTrue(this.index.getIndex(EntryIndex.class).hasClass(fullClassEntry)); // level 3 fullClassEntry = new ClassEntry(CLASS_TREE_ROOT.getName() + "$" + CLASS_TREE_LEVEL_1.getSimpleName() + "$" + CLASS_TREE_LEVEL_2.getSimpleName() + "$" + CLASS_TREE_LEVEL_3.getSimpleName()); - assertTrue(this.index.getEntryIndex().hasClass(fullClassEntry)); + assertTrue(this.index.getIndex(EntryIndex.class).hasClass(fullClassEntry)); } private void decompile(ClassEntry classEntry) { diff --git a/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexBridgeMethods.java b/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexBridgeMethods.java index 773be41dd..c934b92bd 100644 --- a/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexBridgeMethods.java +++ b/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexBridgeMethods.java @@ -1,7 +1,8 @@ package org.quiltmc.enigma; -import org.quiltmc.enigma.api.analysis.index.BridgeMethodIndex; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.BridgeMethodIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.ProgressListener; import org.quiltmc.enigma.api.class_provider.CachingClassProvider; import org.quiltmc.enigma.api.class_provider.JarClassProvider; @@ -43,13 +44,13 @@ public TestJarIndexBridgeMethods() throws Exception { @Test public void obfEntries() { - assertThat(this.index.getEntryIndex().getClasses(), Matchers.containsInAnyOrder(TestEntryFactory.newClass("org/quiltmc/enigma/input/Keep"), this.baseClass, + assertThat(this.index.getIndex(EntryIndex.class).getClasses(), Matchers.containsInAnyOrder(TestEntryFactory.newClass("org/quiltmc/enigma/input/Keep"), this.baseClass, this.otherClass, this.subClass, this.innerSubClass)); } @Test public void testBase() { - BridgeMethodIndex index = this.index.getBridgeMethodIndex(); + BridgeMethodIndex index = this.index.getIndex(BridgeMethodIndex.class); assertThat(index.isBridgeMethod(TestEntryFactory.newMethod(this.baseClass, "a", "()I")), is(false)); assertThat(index.getBridgeFromSpecialized(TestEntryFactory.newMethod(this.baseClass, "a", "()La;")), nullValue()); @@ -59,7 +60,7 @@ public void testBase() { @Test public void testSub() { - BridgeMethodIndex index = this.index.getBridgeMethodIndex(); + BridgeMethodIndex index = this.index.getIndex(BridgeMethodIndex.class); assertThat(index.isBridgeMethod(TestEntryFactory.newMethod(this.subClass, "f", "()Lc;")), is(false)); assertThat(index.isBridgeMethod(TestEntryFactory.newMethod(this.subClass, "d", "()La;")), is(true)); @@ -75,7 +76,7 @@ public void testSub() { @Test public void testInnerSub() { - BridgeMethodIndex index = this.index.getBridgeMethodIndex(); + BridgeMethodIndex index = this.index.getIndex(BridgeMethodIndex.class); assertThat(index.isBridgeMethod(TestEntryFactory.newMethod(this.innerSubClass, "d", "()La;")), is(true)); assertThat(index.getSpecializedFromBridge(TestEntryFactory.newMethod(this.innerSubClass, "a", "(I)La;")), @@ -89,7 +90,7 @@ public void testInnerSub() { @Test public void testOther() { - BridgeMethodIndex index = this.index.getBridgeMethodIndex(); + BridgeMethodIndex index = this.index.getIndex(BridgeMethodIndex.class); assertThat(index.getBridgeFromSpecialized(TestEntryFactory.newMethod(this.otherClass, "a", "()Ljava/lang/Integer;")), Matchers.is(TestEntryFactory.newMethod(this.otherClass, "get", "()Ljava/lang/Object;"))); diff --git a/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexConstructorReferences.java b/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexConstructorReferences.java index 855d9a2cc..026023b55 100644 --- a/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexConstructorReferences.java +++ b/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexConstructorReferences.java @@ -2,7 +2,9 @@ import org.quiltmc.enigma.api.ProgressListener; import org.quiltmc.enigma.api.analysis.EntryReference; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.ReferenceIndex; import org.quiltmc.enigma.api.class_provider.CachingClassProvider; import org.quiltmc.enigma.api.class_provider.JarClassProvider; import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; @@ -36,14 +38,14 @@ public TestJarIndexConstructorReferences() throws Exception { @Test public void obfEntries() { - assertThat(this.index.getEntryIndex().getClasses(), Matchers.containsInAnyOrder(TestEntryFactory.newClass("org/quiltmc/enigma/input/Keep"), BASE_CLASS, + assertThat(this.index.getIndex(EntryIndex.class).getClasses(), Matchers.containsInAnyOrder(TestEntryFactory.newClass("org/quiltmc/enigma/input/Keep"), BASE_CLASS, SUB_CLASS, SUBSUB_CLASS, DEFAULT_CLASS, CALLER_CLASS)); } @Test public void baseDefault() { MethodEntry source = TestEntryFactory.newMethod(BASE_CLASS, "", "()V"); - Collection> references = this.index.getReferenceIndex().getReferencesToMethod(source); + Collection> references = this.index.getIndex(ReferenceIndex.class).getReferencesToMethod(source); assertThat(references, Matchers.containsInAnyOrder( TestEntryFactory.newBehaviorReferenceByMethod(source, CALLER_CLASS.getName(), "a", "()V"), TestEntryFactory.newBehaviorReferenceByMethod(source, SUB_CLASS.getName(), "", "()V"), @@ -54,7 +56,7 @@ public void baseDefault() { @Test public void baseInt() { MethodEntry source = TestEntryFactory.newMethod(BASE_CLASS, "", "(I)V"); - assertThat(this.index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( + assertThat(this.index.getIndex(ReferenceIndex.class).getReferencesToMethod(source), containsInAnyOrder( TestEntryFactory.newBehaviorReferenceByMethod(source, CALLER_CLASS.getName(), "b", "()V") )); } @@ -62,7 +64,7 @@ public void baseInt() { @Test public void subDefault() { MethodEntry source = TestEntryFactory.newMethod(SUB_CLASS, "", "()V"); - assertThat(this.index.getReferenceIndex().getReferencesToMethod(source), Matchers.containsInAnyOrder( + assertThat(this.index.getIndex(ReferenceIndex.class).getReferencesToMethod(source), Matchers.containsInAnyOrder( TestEntryFactory.newBehaviorReferenceByMethod(source, CALLER_CLASS.getName(), "c", "()V"), TestEntryFactory.newBehaviorReferenceByMethod(source, SUB_CLASS.getName(), "", "(I)V") )); @@ -71,7 +73,7 @@ public void subDefault() { @Test public void subInt() { MethodEntry source = TestEntryFactory.newMethod(SUB_CLASS, "", "(I)V"); - assertThat(this.index.getReferenceIndex().getReferencesToMethod(source), Matchers.containsInAnyOrder( + assertThat(this.index.getIndex(ReferenceIndex.class).getReferencesToMethod(source), Matchers.containsInAnyOrder( TestEntryFactory.newBehaviorReferenceByMethod(source, CALLER_CLASS.getName(), "d", "()V"), TestEntryFactory.newBehaviorReferenceByMethod(source, SUB_CLASS.getName(), "", "(II)V"), TestEntryFactory.newBehaviorReferenceByMethod(source, SUBSUB_CLASS.getName(), "", "(I)V") @@ -81,7 +83,7 @@ public void subInt() { @Test public void subIntInt() { MethodEntry source = TestEntryFactory.newMethod(SUB_CLASS, "", "(II)V"); - assertThat(this.index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( + assertThat(this.index.getIndex(ReferenceIndex.class).getReferencesToMethod(source), containsInAnyOrder( TestEntryFactory.newBehaviorReferenceByMethod(source, CALLER_CLASS.getName(), "e", "()V") )); } @@ -89,13 +91,13 @@ public void subIntInt() { @Test public void subIntIntInt() { MethodEntry source = TestEntryFactory.newMethod(SUB_CLASS, "", "(III)V"); - assertThat(this.index.getReferenceIndex().getReferencesToMethod(source), is(empty())); + assertThat(this.index.getIndex(ReferenceIndex.class).getReferencesToMethod(source), is(empty())); } @Test public void subsubInt() { MethodEntry source = TestEntryFactory.newMethod(SUBSUB_CLASS, "", "(I)V"); - assertThat(this.index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( + assertThat(this.index.getIndex(ReferenceIndex.class).getReferencesToMethod(source), containsInAnyOrder( TestEntryFactory.newBehaviorReferenceByMethod(source, CALLER_CLASS.getName(), "f", "()V") )); } @@ -103,7 +105,7 @@ public void subsubInt() { @Test public void defaultConstructable() { MethodEntry source = TestEntryFactory.newMethod(DEFAULT_CLASS, "", "()V"); - assertThat(this.index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( + assertThat(this.index.getIndex(ReferenceIndex.class).getReferencesToMethod(source), containsInAnyOrder( TestEntryFactory.newBehaviorReferenceByMethod(source, CALLER_CLASS.getName(), "g", "()V") )); } diff --git a/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexInheritanceTree.java b/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexInheritanceTree.java index d9ca6d778..08266e6e0 100644 --- a/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexInheritanceTree.java +++ b/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexInheritanceTree.java @@ -2,9 +2,10 @@ import org.quiltmc.enigma.api.ProgressListener; import org.quiltmc.enigma.api.analysis.EntryReference; -import org.quiltmc.enigma.api.analysis.index.EntryIndex; -import org.quiltmc.enigma.api.analysis.index.InheritanceIndex; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.InheritanceIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.ReferenceIndex; import org.quiltmc.enigma.api.class_provider.CachingClassProvider; import org.quiltmc.enigma.api.class_provider.JarClassProvider; import org.quiltmc.enigma.api.translation.mapping.EntryResolver; @@ -44,14 +45,14 @@ public TestJarIndexInheritanceTree() throws Exception { @Test public void obfEntries() { - assertThat(this.index.getEntryIndex().getClasses(), Matchers.containsInAnyOrder( + assertThat(this.index.getIndex(EntryIndex.class).getClasses(), Matchers.containsInAnyOrder( TestEntryFactory.newClass("org/quiltmc/enigma/input/Keep"), BASE_CLASS, SUB_CLASS_A, SUB_CLASS_AA, SUB_CLASS_B )); } @Test public void translationIndex() { - InheritanceIndex index = this.index.getInheritanceIndex(); + InheritanceIndex index = this.index.getIndex(InheritanceIndex.class); // base class assertThat(index.getParents(BASE_CLASS), is(empty())); @@ -77,8 +78,8 @@ public void translationIndex() { @Test public void access() { - assertThat(this.index.getEntryIndex().getFieldAccess(NAME_FIELD), is(new AccessFlags(Opcodes.ACC_PRIVATE))); - assertThat(this.index.getEntryIndex().getFieldAccess(NUM_THINGS_FIELD), is(new AccessFlags(Opcodes.ACC_PRIVATE))); + assertThat(this.index.getIndex(EntryIndex.class).getFieldAccess(NAME_FIELD), is(new AccessFlags(Opcodes.ACC_PRIVATE))); + assertThat(this.index.getIndex(EntryIndex.class).getFieldAccess(NUM_THINGS_FIELD), is(new AccessFlags(Opcodes.ACC_PRIVATE))); } @Test @@ -128,14 +129,14 @@ public void fieldReferences() { Collection> references; // name - references = this.index.getReferenceIndex().getReferencesToField(NAME_FIELD); + references = this.index.getIndex(ReferenceIndex.class).getReferencesToField(NAME_FIELD); assertThat(references, Matchers.containsInAnyOrder( TestEntryFactory.newFieldReferenceByMethod(NAME_FIELD, BASE_CLASS.getName(), "", "(Ljava/lang/String;)V"), TestEntryFactory.newFieldReferenceByMethod(NAME_FIELD, BASE_CLASS.getName(), "a", "()Ljava/lang/String;") )); // numThings - references = this.index.getReferenceIndex().getReferencesToField(NUM_THINGS_FIELD); + references = this.index.getIndex(ReferenceIndex.class).getReferencesToField(NUM_THINGS_FIELD); assertThat(references, Matchers.containsInAnyOrder( TestEntryFactory.newFieldReferenceByMethod(NUM_THINGS_FIELD, SUB_CLASS_B.getName(), "", "()V"), TestEntryFactory.newFieldReferenceByMethod(NUM_THINGS_FIELD, SUB_CLASS_B.getName(), "b", "()V") @@ -149,7 +150,7 @@ public void behaviorReferences() { // baseClass constructor source = TestEntryFactory.newMethod(BASE_CLASS, "", "(Ljava/lang/String;)V"); - references = this.index.getReferenceIndex().getReferencesToMethod(source); + references = this.index.getIndex(ReferenceIndex.class).getReferencesToMethod(source); assertThat(references, Matchers.containsInAnyOrder( TestEntryFactory.newBehaviorReferenceByMethod(source, SUB_CLASS_A.getName(), "", "(Ljava/lang/String;)V"), TestEntryFactory.newBehaviorReferenceByMethod(source, SUB_CLASS_B.getName(), "", "()V") @@ -157,14 +158,14 @@ public void behaviorReferences() { // subClassA constructor source = TestEntryFactory.newMethod(SUB_CLASS_A, "", "(Ljava/lang/String;)V"); - references = this.index.getReferenceIndex().getReferencesToMethod(source); + references = this.index.getIndex(ReferenceIndex.class).getReferencesToMethod(source); assertThat(references, containsInAnyOrder( TestEntryFactory.newBehaviorReferenceByMethod(source, SUB_CLASS_AA.getName(), "", "()V") )); // baseClass.getName() source = TestEntryFactory.newMethod(BASE_CLASS, "a", "()Ljava/lang/String;"); - references = this.index.getReferenceIndex().getReferencesToMethod(source); + references = this.index.getIndex(ReferenceIndex.class).getReferencesToMethod(source); assertThat(references, Matchers.containsInAnyOrder( TestEntryFactory.newBehaviorReferenceByMethod(source, SUB_CLASS_AA.getName(), "a", "()Ljava/lang/String;"), TestEntryFactory.newBehaviorReferenceByMethod(source, SUB_CLASS_B.getName(), "a", "()V") @@ -172,7 +173,7 @@ public void behaviorReferences() { // subclassAA.getName() source = TestEntryFactory.newMethod(SUB_CLASS_AA, "a", "()Ljava/lang/String;"); - references = this.index.getReferenceIndex().getReferencesToMethod(source); + references = this.index.getIndex(ReferenceIndex.class).getReferencesToMethod(source); assertThat(references, containsInAnyOrder( TestEntryFactory.newBehaviorReferenceByMethod(source, SUB_CLASS_AA.getName(), "a", "()V") )); @@ -180,7 +181,7 @@ public void behaviorReferences() { @Test public void containsEntries() { - EntryIndex entryIndex = this.index.getEntryIndex(); + EntryIndex entryIndex = this.index.getIndex(EntryIndex.class); // classes assertThat(entryIndex.hasClass(BASE_CLASS), is(true)); assertThat(entryIndex.hasClass(SUB_CLASS_A), is(true)); diff --git a/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexLoneClass.java b/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexLoneClass.java index 148539c45..843132671 100644 --- a/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexLoneClass.java +++ b/enigma/src/test/java/org/quiltmc/enigma/TestJarIndexLoneClass.java @@ -1,5 +1,6 @@ package org.quiltmc.enigma; +import org.quiltmc.enigma.api.analysis.index.jar.ReferenceIndex; import org.quiltmc.enigma.api.analysis.tree.ClassImplementationsTreeNode; import org.quiltmc.enigma.api.analysis.tree.ClassInheritanceTreeNode; import org.quiltmc.enigma.api.ProgressListener; @@ -7,9 +8,9 @@ import org.quiltmc.enigma.impl.analysis.IndexTreeBuilder; import org.quiltmc.enigma.api.analysis.tree.MethodImplementationsTreeNode; import org.quiltmc.enigma.api.analysis.tree.MethodInheritanceTreeNode; -import org.quiltmc.enigma.api.analysis.index.EntryIndex; -import org.quiltmc.enigma.api.analysis.index.InheritanceIndex; -import org.quiltmc.enigma.api.analysis.index.JarIndex; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; +import org.quiltmc.enigma.api.analysis.index.jar.InheritanceIndex; +import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; import org.quiltmc.enigma.api.class_provider.CachingClassProvider; import org.quiltmc.enigma.api.class_provider.JarClassProvider; import org.quiltmc.enigma.api.translation.VoidTranslator; @@ -40,7 +41,7 @@ public TestJarIndexLoneClass() throws Exception { @Test public void obfEntries() { - assertThat(this.index.getEntryIndex().getClasses(), Matchers.containsInAnyOrder( + assertThat(this.index.getIndex(EntryIndex.class).getClasses(), Matchers.containsInAnyOrder( TestEntryFactory.newClass("org/quiltmc/enigma/input/Keep"), TestEntryFactory.newClass("a") )); @@ -48,7 +49,7 @@ public void obfEntries() { @Test public void translationIndex() { - InheritanceIndex inheritanceIndex = this.index.getInheritanceIndex(); + InheritanceIndex inheritanceIndex = this.index.getIndex(InheritanceIndex.class); assertThat(inheritanceIndex.getParents(new ClassEntry("a")), is(empty())); assertThat(inheritanceIndex.getParents(new ClassEntry("org/quiltmc/enigma/input/Keep")), is(empty())); assertThat(inheritanceIndex.getAncestors(new ClassEntry("a")), is(empty())); @@ -59,7 +60,7 @@ public void translationIndex() { @Test public void access() { - EntryIndex entryIndex = this.index.getEntryIndex(); + EntryIndex entryIndex = this.index.getIndex(EntryIndex.class); assertThat(entryIndex.getFieldAccess(TestEntryFactory.newField("a", "a", "Ljava/lang/String;")), is(AccessFlags.PRIVATE)); assertThat(entryIndex.getMethodAccess(TestEntryFactory.newMethod("a", "a", "()Ljava/lang/String;")), is(AccessFlags.PUBLIC)); assertThat(entryIndex.getFieldAccess(TestEntryFactory.newField("a", "b", "Ljava/lang/String;")), is(nullValue())); @@ -113,7 +114,7 @@ public void relatedMethodImplementations() { @Test public void fieldReferences() { FieldEntry source = TestEntryFactory.newField("a", "a", "Ljava/lang/String;"); - Collection> references = this.index.getReferenceIndex().getReferencesToField(source); + Collection> references = this.index.getIndex(ReferenceIndex.class).getReferencesToField(source); assertThat(references, Matchers.containsInAnyOrder( TestEntryFactory.newFieldReferenceByMethod(source, "a", "", "(Ljava/lang/String;)V"), TestEntryFactory.newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;") @@ -122,27 +123,27 @@ public void fieldReferences() { @Test public void behaviorReferences() { - assertThat(this.index.getReferenceIndex().getReferencesToMethod(TestEntryFactory.newMethod("a", "a", "()Ljava/lang/String;")), is(empty())); + assertThat(this.index.getIndex(ReferenceIndex.class).getReferencesToMethod(TestEntryFactory.newMethod("a", "a", "()Ljava/lang/String;")), is(empty())); } @Test public void interfaces() { - assertThat(this.index.getInheritanceIndex().getParents(new ClassEntry("a")), is(empty())); + assertThat(this.index.getIndex(InheritanceIndex.class).getParents(new ClassEntry("a")), is(empty())); } @Test public void implementingClasses() { - assertThat(this.index.getInheritanceIndex().getChildren(new ClassEntry("a")), is(empty())); + assertThat(this.index.getIndex(InheritanceIndex.class).getChildren(new ClassEntry("a")), is(empty())); } @Test public void isInterface() { - assertThat(this.index.getInheritanceIndex().isParent(new ClassEntry("a")), is(false)); + assertThat(this.index.getIndex(InheritanceIndex.class).isParent(new ClassEntry("a")), is(false)); } @Test public void testContains() { - EntryIndex entryIndex = this.index.getEntryIndex(); + EntryIndex entryIndex = this.index.getIndex(EntryIndex.class); assertThat(entryIndex.hasClass(TestEntryFactory.newClass("a")), is(true)); assertThat(entryIndex.hasClass(TestEntryFactory.newClass("b")), is(false)); assertThat(entryIndex.hasField(TestEntryFactory.newField("a", "a", "Ljava/lang/String;")), is(true)); diff --git a/enigma/src/test/java/org/quiltmc/enigma/TestStatsGeneration.java b/enigma/src/test/java/org/quiltmc/enigma/TestStatsGeneration.java index 6e1401096..71e9f7725 100644 --- a/enigma/src/test/java/org/quiltmc/enigma/TestStatsGeneration.java +++ b/enigma/src/test/java/org/quiltmc/enigma/TestStatsGeneration.java @@ -3,6 +3,7 @@ import org.quiltmc.enigma.api.Enigma; import org.quiltmc.enigma.api.EnigmaProject; import org.quiltmc.enigma.api.ProgressListener; +import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; import org.quiltmc.enigma.api.class_provider.JarClassProvider; import org.quiltmc.enigma.api.stats.ProjectStatsResult; import org.quiltmc.enigma.api.stats.StatType; @@ -36,21 +37,21 @@ void checkNoMappedEntriesByDefault() { @Test void checkClassMapping() { EnigmaProject project = openProject(); - renameAll(project, project.getJarIndex().getEntryIndex().getClasses()); + renameAll(project, project.getJarIndex().getIndex(EntryIndex.class).getClasses()); checkFullyMapped(project, StatType.CLASSES); } @Test void checkMethodMapping() { EnigmaProject project = openProject(); - renameAll(project, project.getJarIndex().getEntryIndex().getMethods()); + renameAll(project, project.getJarIndex().getIndex(EntryIndex.class).getMethods()); checkFullyMapped(project, StatType.METHODS); } @Test void checkFieldMapping() { EnigmaProject project = openProject(); - renameAll(project, project.getJarIndex().getEntryIndex().getFields()); + renameAll(project, project.getJarIndex().getIndex(EntryIndex.class).getFields()); checkFullyMapped(project, StatType.FIELDS); } @@ -58,9 +59,9 @@ void checkFieldMapping() { void checkOverallMapping() { // note: does not check parameters. as this is the most fragile part of stats generation, it should be added to this test as soon as possible! EnigmaProject project = openProject(); - renameAll(project, project.getJarIndex().getEntryIndex().getClasses()); - renameAll(project, project.getJarIndex().getEntryIndex().getFields()); - renameAll(project, project.getJarIndex().getEntryIndex().getMethods()); + renameAll(project, project.getJarIndex().getIndex(EntryIndex.class).getClasses()); + renameAll(project, project.getJarIndex().getIndex(EntryIndex.class).getFields()); + renameAll(project, project.getJarIndex().getIndex(EntryIndex.class).getMethods()); checkFullyMapped(project, StatType.METHODS, StatType.CLASSES, StatType.FIELDS); } diff --git a/enigma/src/test/java/org/quiltmc/enigma/TestTranslator.java b/enigma/src/test/java/org/quiltmc/enigma/TestTranslator.java index 6ad9022ed..5e459e212 100644 --- a/enigma/src/test/java/org/quiltmc/enigma/TestTranslator.java +++ b/enigma/src/test/java/org/quiltmc/enigma/TestTranslator.java @@ -33,7 +33,7 @@ public static void beforeClass() throws Exception { mappings = MappingFormat.ENIGMA_FILE.read( TestUtil.getResource("/translation.mappings"), ProgressListener.none()); - project.setMappings(mappings); + project.setMappings(mappings, ProgressListener.none()); deobfuscator = project.getMapper().getDeobfuscator(); } diff --git a/enigma/src/test/java/org/quiltmc/enigma/translation/mapping/TestMappingValidator.java b/enigma/src/test/java/org/quiltmc/enigma/translation/mapping/TestMappingValidator.java index 39e8ed39b..034ad0739 100644 --- a/enigma/src/test/java/org/quiltmc/enigma/translation/mapping/TestMappingValidator.java +++ b/enigma/src/test/java/org/quiltmc/enigma/translation/mapping/TestMappingValidator.java @@ -40,7 +40,7 @@ public static void beforeAll() throws Exception { @BeforeEach public void beforeEach(RepetitionInfo repetitionInfo) { EntryTree mappings = new HashEntryTree<>(); - project.setMappings(mappings); + project.setMappings(mappings, ProgressListener.none()); remapper = project.getMapper(); // repeat with mapped classes diff --git a/enigma/src/test/java/org/quiltmc/enigma/translation/mapping/TestTinyV2InnerClasses.java b/enigma/src/test/java/org/quiltmc/enigma/translation/mapping/TestTinyV2InnerClasses.java index f00eaea85..cd6df176b 100644 --- a/enigma/src/test/java/org/quiltmc/enigma/translation/mapping/TestTinyV2InnerClasses.java +++ b/enigma/src/test/java/org/quiltmc/enigma/translation/mapping/TestTinyV2InnerClasses.java @@ -17,6 +17,6 @@ public final class TestTinyV2InnerClasses { @Test public void testMappings() throws Exception { EnigmaProject project = Enigma.create().openJar(JAR, new ClasspathClassProvider(), ProgressListener.none()); - project.setMappings(EnigmaMappingsReader.DIRECTORY.read(MAPPINGS, ProgressListener.none())); + project.setMappings(EnigmaMappingsReader.DIRECTORY.read(MAPPINGS, ProgressListener.none()), ProgressListener.none()); } }