From e870ea71ece0bfae6f542324bbc4ac51b0158d22 Mon Sep 17 00:00:00 2001 From: ix0rai Date: Wed, 18 Sep 2024 18:22:53 -0500 Subject: [PATCH] decrease API breakage by using Set over Collection --- .../api/class_provider/ProjectClassProvider.java | 10 ++++++---- .../quiltmc/enigma/api/service/JarIndexerService.java | 6 +++--- .../enigma/impl/analysis/index/AbstractJarIndex.java | 3 +-- 3 files changed, 10 insertions(+), 9 deletions(-) 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 cf5b352e..0d0b7521 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,6 +7,8 @@ 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 @@ -78,11 +80,11 @@ public Collection getClassNames() { return this.classNames; } - public Collection getMainClassNames() { - return this.main != null ? this.main.getClassNames() : Collections.emptySet(); + public Set getMainClassNames() { + return this.main != null ? new HashSet<>(this.main.getClassNames()) : Collections.emptySet(); } - public Collection getLibraryClassNames() { - return this.libraries != null ? this.libraries.getClassNames() : Collections.emptySet(); + public Set getLibraryClassNames() { + return this.libraries != null ? new HashSet<>(this.libraries.getClassNames()) : Collections.emptySet(); } } 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 c717f682..24954387 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 @@ -6,7 +6,7 @@ import org.quiltmc.enigma.api.class_provider.ProjectClassProvider; import javax.annotation.Nullable; -import java.util.Collection; +import java.util.Set; /** * Jar indexer services analyse jar files as they're opened to collect information about their contents. @@ -35,7 +35,7 @@ static boolean shouldIndexLibraries(@Nullable EnigmaServiceContext scope, ProjectClassProvider classProvider, JarIndex jarIndex); + void acceptJar(Set scope, ProjectClassProvider classProvider, JarIndex jarIndex); /** * Whether this indexer should be run on libraries in addition to the main project being indexed. @@ -69,7 +69,7 @@ static JarIndexerService fromVisitor(@Nullable EnigmaServiceContext scope, ProjectClassProvider classProvider, JarIndex jarIndex) { + public void acceptJar(Set scope, ProjectClassProvider classProvider, JarIndex jarIndex) { for (String className : scope) { ClassNode node = classProvider.get(className); if (node != null) { 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 630577db..9d549ab0 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,7 +25,6 @@ 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; @@ -76,7 +75,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(Collection classNames, ClassProvider classProvider, ProgressListener progress) { + public void indexJar(Set classNames, ClassProvider classProvider, ProgressListener progress) { // for use in processIndex this.progress = progress;