Skip to content

Commit

Permalink
Consistently use Util suffix for classes with static helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
NebelNidas committed Jan 1, 2025
1 parent 6f0904b commit 275f223
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.junit.jupiter.api.Test;
import org.objectweb.asm.Type;

import net.fabricmc.mappingio.TestHelper;
import net.fabricmc.mappingio.TestUtil;
import net.fabricmc.mappingio.tree.MappingTree;
import net.fabricmc.mappingio.tree.MappingTree.ClassMapping;
import net.fabricmc.mappingio.tree.MappingTree.FieldMapping;
Expand All @@ -50,7 +50,7 @@ public class MappingTreeRemapperTest {

@BeforeAll
public static void setup() throws IOException {
mappingTree = TestHelper.acceptTestMappings(new MemoryMappingTree());
mappingTree = TestUtil.acceptTestMappings(new MemoryMappingTree());
srcNs = mappingTree.getSrcNamespace();
dstNs = mappingTree.getDstNamespaces().get(0);

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/fabricmc/mappingio/format/FeatureSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ default boolean supportsClasses() {
}

default boolean supportsFields() {
return FeatureSetHelper.isSupported(fields());
return FeatureSetUtil.isSupported(fields());
}

default boolean supportsMethods() {
return FeatureSetHelper.isSupported(methods());
return FeatureSetUtil.isSupported(methods());
}

default boolean supportsArgs() {
return FeatureSetHelper.isSupported(args());
return FeatureSetUtil.isSupported(args());
}

default boolean supportsVars() {
return FeatureSetHelper.isSupported(vars());
return FeatureSetUtil.isSupported(vars());
}

enum MetadataSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import net.fabricmc.mappingio.format.FeatureSet.MemberSupport;

// Only exists since Java 8 doesn't support private interface methods
final class FeatureSetHelper {
private FeatureSetHelper() {
final class FeatureSetUtil {
private FeatureSetUtil() {
}

static boolean isSupported(MemberSupport members) {
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/net/fabricmc/mappingio/TestFileUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public static void main(String[] args) throws IOException {
continue;
}

Path defaultPath = TestHelper.MappingDirs.VALID.resolve(TestHelper.getFileName(format));
Path holesPath = TestHelper.MappingDirs.VALID_WITH_HOLES.resolve(TestHelper.getFileName(format));
Path repeatPath = TestHelper.MappingDirs.REPEATED_ELEMENTS.resolve(TestHelper.getFileName(format));
Path defaultPath = TestUtil.MappingDirs.VALID.resolve(TestUtil.getFileName(format));
Path holesPath = TestUtil.MappingDirs.VALID_WITH_HOLES.resolve(TestUtil.getFileName(format));
Path repeatPath = TestUtil.MappingDirs.REPEATED_ELEMENTS.resolve(TestUtil.getFileName(format));

TestHelper.acceptTestMappings(MappingWriter.create(defaultPath, format));
TestHelper.acceptTestMappingsWithHoles(MappingWriter.create(holesPath, format));
TestUtil.acceptTestMappings(MappingWriter.create(defaultPath, format));
TestUtil.acceptTestMappingsWithHoles(MappingWriter.create(holesPath, format));

if (format != MappingFormat.ENIGMA_DIR) {
TestHelper.acceptTestMappingsWithRepeats(
TestUtil.acceptTestMappingsWithRepeats(
MappingWriter.create(repeatPath, format),
format != MappingFormat.ENIGMA_FILE,
format != MappingFormat.ENIGMA_FILE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
import net.fabricmc.mappingio.tree.MappingTreeView;
import net.fabricmc.mappingio.tree.MemoryMappingTree;

public final class TestHelper {
public final class TestUtil {
public static Path getResource(String slashPrefixedResourcePath) {
try {
return Paths.get(TestHelper.class.getResource(slashPrefixedResourcePath).toURI());
return Paths.get(TestUtil.class.getResource(slashPrefixedResourcePath).toURI());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/net/fabricmc/mappingio/read/DetectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@

import net.fabricmc.mappingio.MappingReader;
import net.fabricmc.mappingio.NopMappingVisitor;
import net.fabricmc.mappingio.TestHelper;
import net.fabricmc.mappingio.TestUtil;
import net.fabricmc.mappingio.format.MappingFormat;

public class DetectionTest {
private static final Path dir = TestHelper.MappingDirs.DETECTION;
private static final Path dir = TestUtil.MappingDirs.DETECTION;

@Test
public void enigmaFile() throws Exception {
Expand Down Expand Up @@ -121,7 +121,7 @@ public void jobfFile() throws Exception {
}

private void check(MappingFormat format) throws Exception {
Path path = dir.resolve(TestHelper.getFileName(format));
Path path = dir.resolve(TestUtil.getFileName(format));
assertEquals(format, MappingReader.detectFormat(path));

if (!format.hasSingleFile()) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import net.fabricmc.mappingio.MappingReader;
import net.fabricmc.mappingio.SubsetAssertingVisitor;
import net.fabricmc.mappingio.TestHelper;
import net.fabricmc.mappingio.TestUtil;
import net.fabricmc.mappingio.VisitOrderVerifyingVisitor;
import net.fabricmc.mappingio.adapter.FlatAsRegularMappingVisitor;
import net.fabricmc.mappingio.adapter.MappingSourceNsSwitch;
Expand Down Expand Up @@ -145,9 +145,9 @@ public void jobfFile() throws Exception {
}

private void checkDefault(MappingFormat format) throws Exception {
Path path = TestHelper.MappingDirs.VALID.resolve(TestHelper.getFileName(format));
Path path = TestUtil.MappingDirs.VALID.resolve(TestUtil.getFileName(format));

VisitableMappingTree referenceTree = TestHelper.acceptTestMappings(new MemoryMappingTree());
VisitableMappingTree referenceTree = TestUtil.acceptTestMappings(new MemoryMappingTree());
VisitableMappingTree tree = new MemoryMappingTree();
boolean allowConsecutiveDuplicateElementVisits = false;

Expand All @@ -167,9 +167,9 @@ private void checkDefault(MappingFormat format) throws Exception {
}

private void checkRepeated(MappingFormat format, boolean allowConsecutiveDuplicateElementVisits) throws Exception {
Path path = TestHelper.MappingDirs.REPEATED_ELEMENTS.resolve(TestHelper.getFileName(format));
Path path = TestUtil.MappingDirs.REPEATED_ELEMENTS.resolve(TestUtil.getFileName(format));

VisitableMappingTree referenceTree = TestHelper.acceptTestMappingsWithRepeats(new MemoryMappingTree(), true, true);
VisitableMappingTree referenceTree = TestUtil.acceptTestMappingsWithRepeats(new MemoryMappingTree(), true, true);
VisitableMappingTree tree = new MemoryMappingTree();

MappingReader.read(path, format, new VisitOrderVerifyingVisitor(tree, allowConsecutiveDuplicateElementVisits));
Expand All @@ -188,9 +188,9 @@ private void checkRepeated(MappingFormat format, boolean allowConsecutiveDuplica
}

private void checkHoles(MappingFormat format) throws Exception {
Path path = TestHelper.MappingDirs.VALID_WITH_HOLES.resolve(TestHelper.getFileName(format));
Path path = TestUtil.MappingDirs.VALID_WITH_HOLES.resolve(TestUtil.getFileName(format));

VisitableMappingTree referenceTree = TestHelper.acceptTestMappingsWithHoles(new MemoryMappingTree());
VisitableMappingTree referenceTree = TestUtil.acceptTestMappingsWithHoles(new MemoryMappingTree());
VisitableMappingTree tree = new MemoryMappingTree();
boolean allowConsecutiveDuplicateElementVisits = false;

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/net/fabricmc/mappingio/tree/MergeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import net.fabricmc.mappingio.MappingReader;
import net.fabricmc.mappingio.MappingVisitor;
import net.fabricmc.mappingio.SubsetAssertingVisitor;
import net.fabricmc.mappingio.TestHelper;
import net.fabricmc.mappingio.TestUtil;
import net.fabricmc.mappingio.VisitOrderVerifyingVisitor;
import net.fabricmc.mappingio.adapter.FlatAsRegularMappingVisitor;
import net.fabricmc.mappingio.tree.MappingTree.ClassMapping;
Expand All @@ -41,7 +41,7 @@
import net.fabricmc.mappingio.tree.MemoryMappingTree.FieldEntry;

public class MergeTest {
private static final Path dir = TestHelper.MappingDirs.MERGING;
private static final Path dir = TestUtil.MappingDirs.MERGING;
private static final String ns1 = "ns1";
private static final String ns2 = "ns2";
private static final String ns3 = "ns3";
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/net/fabricmc/mappingio/tree/MetadataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import net.fabricmc.mappingio.MappingFlag;
import net.fabricmc.mappingio.NopMappingVisitor;
import net.fabricmc.mappingio.TestHelper;
import net.fabricmc.mappingio.TestUtil;

public class MetadataTest {
private static final Random random = new Random();
Expand All @@ -42,7 +42,7 @@ public class MetadataTest {

@BeforeAll
public static void setup() throws Exception {
tree = TestHelper.acceptTestMappings(new MemoryMappingTree());
tree = TestUtil.acceptTestMappings(new MemoryMappingTree());
tree.getMetadata().clear();

for (int i = 0; i < 40; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import net.fabricmc.mappingio.TestHelper;
import net.fabricmc.mappingio.TestUtil;

public class SetNamespacesTest {
private MemoryMappingTree tree;
Expand All @@ -36,7 +36,7 @@ public class SetNamespacesTest {
@BeforeEach
public void setup() throws IOException {
tree = new MemoryMappingTree();
TestHelper.acceptTestMappings(tree);
TestUtil.acceptTestMappings(tree);

srcNs = tree.getSrcNamespace();
dstNs0 = tree.getDstNamespaces().get(0);
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/net/fabricmc/mappingio/visiting/VisitEndTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import net.fabricmc.mappingio.MappingReader;
import net.fabricmc.mappingio.MappingVisitor;
import net.fabricmc.mappingio.SubsetAssertingVisitor;
import net.fabricmc.mappingio.TestHelper;
import net.fabricmc.mappingio.TestUtil;
import net.fabricmc.mappingio.VisitOrderVerifyingVisitor;
import net.fabricmc.mappingio.adapter.FlatAsRegularMappingVisitor;
import net.fabricmc.mappingio.format.MappingFormat;
Expand Down Expand Up @@ -127,17 +127,17 @@ public void jobfFile() throws Exception {
}

private void check(MappingFormat format) throws Exception {
checkDir(TestHelper.MappingDirs.DETECTION, format);
checkDir(TestHelper.MappingDirs.VALID, format);
checkDir(TestHelper.MappingDirs.REPEATED_ELEMENTS, format);
checkDir(TestHelper.MappingDirs.VALID_WITH_HOLES, format);
checkDir(TestUtil.MappingDirs.DETECTION, format);
checkDir(TestUtil.MappingDirs.VALID, format);
checkDir(TestUtil.MappingDirs.REPEATED_ELEMENTS, format);
checkDir(TestUtil.MappingDirs.VALID_WITH_HOLES, format);
}

private void checkDir(Path dir, MappingFormat format) throws Exception {
Path path = dir.resolve(TestHelper.getFileName(format));
Path path = dir.resolve(TestUtil.getFileName(format));
if (!Files.exists(path)) return;

MappingTreeView supTree = TestHelper.MappingDirs.getCorrespondingTree(dir);
MappingTreeView supTree = TestUtil.MappingDirs.getCorrespondingTree(dir);

checkCompliance(format, path, 1, true, supTree);
checkCompliance(format, path, 1, false, supTree);
Expand Down
22 changes: 11 additions & 11 deletions src/test/java/net/fabricmc/mappingio/write/WriteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import net.fabricmc.mappingio.MappingReader;
import net.fabricmc.mappingio.MappingWriter;
import net.fabricmc.mappingio.SubsetAssertingVisitor;
import net.fabricmc.mappingio.TestHelper;
import net.fabricmc.mappingio.TestUtil;
import net.fabricmc.mappingio.adapter.FlatAsRegularMappingVisitor;
import net.fabricmc.mappingio.adapter.ForwardingMappingVisitor;
import net.fabricmc.mappingio.adapter.MappingNsCompleter;
Expand All @@ -52,15 +52,15 @@ public class WriteTest {

@BeforeAll
public static void setup() throws Exception {
validTree = TestHelper.acceptTestMappings(new MemoryMappingTree());
validTree = TestUtil.acceptTestMappings(new MemoryMappingTree());
treeNsAltMap.put(validTree.getDstNamespaces().get(0), validTree.getSrcNamespace());
treeNsAltMap.put(validTree.getDstNamespaces().get(1), validTree.getSrcNamespace());

validWithRepeatsTree = TestHelper.acceptTestMappingsWithRepeats(new MemoryMappingTree(), true, true);
validWithRepeatsTree = TestUtil.acceptTestMappingsWithRepeats(new MemoryMappingTree(), true, true);
treeWithRepeatsNsAltMap.put(validWithRepeatsTree.getDstNamespaces().get(0), validWithRepeatsTree.getSrcNamespace());
treeWithRepeatsNsAltMap.put(validWithRepeatsTree.getDstNamespaces().get(1), validWithRepeatsTree.getSrcNamespace());

validWithHolesTree = TestHelper.acceptTestMappingsWithHoles(new MemoryMappingTree());
validWithHolesTree = TestUtil.acceptTestMappingsWithHoles(new MemoryMappingTree());
treeWithHolesNsAltMap.put(validWithHolesTree.getDstNamespaces().get(0), validWithHolesTree.getSrcNamespace());
treeWithHolesNsAltMap.put(validWithHolesTree.getDstNamespaces().get(1), validWithHolesTree.getSrcNamespace());
}
Expand Down Expand Up @@ -136,19 +136,19 @@ public void jobfFile() throws Exception {
}

private void check(MappingFormat format) throws Exception {
Path path = dir.resolve(TestHelper.getFileName(format));
TestHelper.acceptTestMappings(MappingWriter.create(path, format));
Path path = dir.resolve(TestUtil.getFileName(format));
TestUtil.acceptTestMappings(MappingWriter.create(path, format));
readWithMio(validTree, path, format);
readWithLorenz(path, format);
readWithSrgUtils(validTree, format, treeNsAltMap);

boolean isEnigma = format == MappingFormat.ENIGMA_FILE || format == MappingFormat.ENIGMA_DIR;
TestHelper.acceptTestMappingsWithRepeats(MappingWriter.create(path, format), !isEnigma, !isEnigma);
TestUtil.acceptTestMappingsWithRepeats(MappingWriter.create(path, format), !isEnigma, !isEnigma);
readWithMio(validWithRepeatsTree, path, format);
readWithLorenz(path, format);
readWithSrgUtils(validWithRepeatsTree, format, treeWithRepeatsNsAltMap);

TestHelper.acceptTestMappingsWithHoles(MappingWriter.create(path, format));
TestUtil.acceptTestMappingsWithHoles(MappingWriter.create(path, format));
readWithMio(validWithHolesTree, path, format);
readWithLorenz(path, format);
readWithSrgUtils(validWithHolesTree, format, treeWithHolesNsAltMap);
Expand All @@ -163,13 +163,13 @@ private void readWithMio(MappingTreeView origTree, Path outputPath, MappingForma
}

private void readWithLorenz(Path path, MappingFormat format) throws Exception {
org.cadixdev.lorenz.io.MappingFormat lorenzFormat = TestHelper.toLorenzFormat(format);
org.cadixdev.lorenz.io.MappingFormat lorenzFormat = TestUtil.toLorenzFormat(format);
if (lorenzFormat == null) return;
lorenzFormat.read(path);
}

private void readWithSrgUtils(MappingTreeView tree, MappingFormat format, Map<String, String> nsAltMap) throws Exception {
IMappingFile.Format srgUtilsFormat = TestHelper.toSrgUtilsFormat(format);
IMappingFile.Format srgUtilsFormat = TestUtil.toSrgUtilsFormat(format);
if (srgUtilsFormat == null) return;

// TODO: Remove once https://github.com/neoforged/SRGUtils/issues/7 is fixed
Expand All @@ -189,7 +189,7 @@ public boolean visitElementContent(MappedElementKind targetKind) throws IOExcept
},
nsAltMap));

Path path = TestHelper.writeToDir(dstNsCompTree, dir, format);
Path path = TestUtil.writeToDir(dstNsCompTree, dir, format);
INamedMappingFile.load(path.toFile());
}
}

0 comments on commit 275f223

Please sign in to comment.