From ee0feb05e3bf90cb37f868bd98a190c9753072c3 Mon Sep 17 00:00:00 2001 From: ix0rai Date: Wed, 18 Sep 2024 18:28:01 -0500 Subject: [PATCH] fix ProjectClassProvider returns types and AbstractJarIndex access --- .../src/main/java/org/quiltmc/enigma/api/Enigma.java | 6 +++++- .../api/class_provider/ProjectClassProvider.java | 10 ++++------ .../enigma/impl/analysis/index/AbstractJarIndex.java | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) 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 945042e7..32ea23ba 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/Enigma.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/Enigma.java @@ -44,11 +44,13 @@ import java.sql.DriverManager; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Properties; import java.util.ServiceLoader; +import java.util.Set; import java.util.concurrent.atomic.AtomicReference; public class Enigma { @@ -134,7 +136,9 @@ private void index(JarIndex index, ProjectClassProvider classProvider, ProgressL for (var service : indexers) { if (!(libraries && !service.shouldIndexLibraries())) { progress.step(i++, I18n.translateFormatted("progress." + progressKey + ".custom_indexing.indexer", service.getId())); - service.acceptJar(libraries ? classProvider.getLibraryClassNames() : classProvider.getMainClassNames(), classProvider, index); + var names = libraries ? classProvider.getLibraryClassNames() : classProvider.getMainClassNames(); + Set scope = new HashSet<>(names); + service.acceptJar(scope, classProvider, index); } } diff --git a/enigma/src/main/java/org/quiltmc/enigma/api/class_provider/ProjectClassProvider.java b/enigma/src/main/java/org/quiltmc/enigma/api/class_provider/ProjectClassProvider.java index 0d0b7521..cf5b352e 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/api/class_provider/ProjectClassProvider.java +++ b/enigma/src/main/java/org/quiltmc/enigma/api/class_provider/ProjectClassProvider.java @@ -7,8 +7,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; -import java.util.Set; public class ProjectClassProvider implements ClassProvider { @Nullable @@ -80,11 +78,11 @@ public Collection getClassNames() { return this.classNames; } - public Set getMainClassNames() { - return this.main != null ? new HashSet<>(this.main.getClassNames()) : Collections.emptySet(); + public Collection getMainClassNames() { + return this.main != null ? this.main.getClassNames() : Collections.emptySet(); } - public Set getLibraryClassNames() { - return this.libraries != null ? new HashSet<>(this.libraries.getClassNames()) : Collections.emptySet(); + public Collection getLibraryClassNames() { + return this.libraries != null ? this.libraries.getClassNames() : Collections.emptySet(); } } diff --git a/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/index/AbstractJarIndex.java b/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/index/AbstractJarIndex.java index 9d549ab0..a248b529 100644 --- a/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/index/AbstractJarIndex.java +++ b/enigma/src/main/java/org/quiltmc/enigma/impl/analysis/index/AbstractJarIndex.java @@ -25,6 +25,7 @@ import org.quiltmc.enigma.api.translation.representation.entry.ParentedEntry; import org.quiltmc.enigma.util.I18n; +import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map; @@ -75,7 +76,7 @@ public T getIndex(Class clazz) { * @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) { + protected void indexJar(Collection classNames, ClassProvider classProvider, ProgressListener progress) { // for use in processIndex this.progress = progress;