-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix tiny remapper not properly writing comments on parameters
- Loading branch information
Showing
4 changed files
with
108 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
enigma/src/test/java/org/quiltmc/enigma/input/interfaces/Inheritor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.quiltmc.enigma.input.interfaces; | ||
|
||
public class Inheritor implements Root { | ||
@Override | ||
public int a() { | ||
return 23; | ||
} | ||
|
||
@Override | ||
public double b(double c) { | ||
return c + 100d; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
enigma/src/test/java/org/quiltmc/enigma/input/interfaces/Root.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.quiltmc.enigma.input.interfaces; | ||
|
||
public interface Root { | ||
public int a(); | ||
|
||
public double b(double c); | ||
} |
83 changes: 83 additions & 0 deletions
83
.../src/test/java/org/quiltmc/enigma/translation/mapping/TestMethodOverrideParamJavadoc.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package org.quiltmc.enigma.translation.mapping; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.quiltmc.enigma.TestEntryFactory; | ||
import org.quiltmc.enigma.TestUtil; | ||
import org.quiltmc.enigma.api.Enigma; | ||
import org.quiltmc.enigma.api.EnigmaProject; | ||
import org.quiltmc.enigma.api.ProgressListener; | ||
import org.quiltmc.enigma.api.class_provider.ClasspathClassProvider; | ||
import org.quiltmc.enigma.api.service.ReadWriteService; | ||
import org.quiltmc.enigma.api.translation.mapping.EntryMapping; | ||
import org.quiltmc.enigma.api.translation.mapping.serde.FileType; | ||
import org.quiltmc.enigma.api.translation.mapping.serde.MappingFileNameFormat; | ||
import org.quiltmc.enigma.api.translation.mapping.serde.MappingParseException; | ||
import org.quiltmc.enigma.api.translation.mapping.serde.MappingSaveParameters; | ||
import org.quiltmc.enigma.api.translation.mapping.tree.EntryTree; | ||
import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry; | ||
import org.quiltmc.enigma.api.translation.representation.entry.LocalVariableEntry; | ||
import org.quiltmc.enigma.api.translation.representation.entry.MethodEntry; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.function.Predicate; | ||
|
||
public class TestMethodOverrideParamJavadoc { | ||
private static final MappingSaveParameters PARAMETERS = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF, false, null, null); | ||
private static final Path JAR = TestUtil.obfJar("interfaces"); | ||
private static Enigma enigma; | ||
private static EnigmaProject project; | ||
|
||
@BeforeAll | ||
static void setupEnigma() throws IOException { | ||
enigma = Enigma.create(); | ||
project = enigma.openJar(JAR, new ClasspathClassProvider(), ProgressListener.createEmpty()); | ||
} | ||
|
||
void test(ReadWriteService readWriteService, String tmpNameSuffix) throws IOException, MappingParseException { | ||
var remapper = project.getRemapper(); | ||
|
||
ClassEntry inheritor = TestEntryFactory.newClass("a"); | ||
MethodEntry method = TestEntryFactory.newMethod(inheritor, "a", "(D)D"); | ||
LocalVariableEntry param = TestEntryFactory.newParameter(method, 1); | ||
|
||
EntryMapping mapping = remapper.getMapping(param); | ||
Assertions.assertNull(mapping.javadoc()); | ||
|
||
remapper.putMapping(TestUtil.newVC(), param, mapping.withJavadoc("gaming")); | ||
|
||
EntryMapping withJavadoc = remapper.getMapping(param); | ||
Assertions.assertEquals("gaming", withJavadoc.javadoc()); | ||
|
||
File tempFile = File.createTempFile("testMethodOverrideParamJavadoc", tmpNameSuffix); | ||
tempFile.delete(); //remove the auto created file | ||
|
||
readWriteService.write(remapper.getMappings(), tempFile.toPath(), ProgressListener.createEmpty(), PARAMETERS); | ||
Assertions.assertTrue(tempFile.exists(), "Written file not created"); | ||
EntryTree<EntryMapping> loadedMappings = readWriteService.read(tempFile.toPath(), ProgressListener.createEmpty()); | ||
|
||
project.setMappings(loadedMappings, ProgressListener.createEmpty()); | ||
remapper = project.getRemapper(); | ||
|
||
EntryMapping newMapping = remapper.getMapping(param); | ||
Assertions.assertEquals("gaming", newMapping.javadoc()); | ||
} | ||
|
||
@Test | ||
public void testEnigmaFile() throws IOException, MappingParseException { | ||
this.test(this.getService(file -> file.getExtensions().contains("mapping") && !file.isDirectory()), ".mapping"); | ||
} | ||
|
||
@Test | ||
public void testTinyFile() throws IOException, MappingParseException { | ||
this.test(this.getService(file -> file.getExtensions().contains("tiny") && !file.isDirectory()), ".tiny"); | ||
} | ||
|
||
@SuppressWarnings("all") | ||
private ReadWriteService getService(Predicate<FileType> predicate) { | ||
return this.enigma.getReadWriteService(this.enigma.getSupportedFileTypes().stream().filter(predicate).findFirst().get()).get(); | ||
} | ||
} |