-
-
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 a bunch of parameter javadoc issues (#227)
* fix tiny remapper not properly writing comments on parameters * who up inverting they check * fix in interface * fix checkstyle * fix test
- Loading branch information
Showing
6 changed files
with
127 additions
and
6 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
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
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 { | ||
int a(); | ||
|
||
double b(double c); | ||
} |
80 changes: 80 additions & 0 deletions
80
.../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,80 @@ | ||
package org.quiltmc.enigma.translation.mapping; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
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; | ||
|
||
@BeforeEach | ||
void setupEnigma() throws IOException { | ||
enigma = Enigma.create(); | ||
project = enigma.openJar(JAR, new ClasspathClassProvider(), ProgressListener.createEmpty()); | ||
} | ||
|
||
void test(ReadWriteService readWriteService, String tmpNameSuffix) throws IOException, MappingParseException { | ||
ClassEntry inheritor = TestEntryFactory.newClass("a"); | ||
MethodEntry method = TestEntryFactory.newMethod(inheritor, "a", "(D)D"); | ||
LocalVariableEntry param = TestEntryFactory.newParameter(method, 1); | ||
|
||
EntryMapping mapping = project.getRemapper().getMapping(param); | ||
Assertions.assertNull(mapping.javadoc()); | ||
|
||
project.getRemapper().putMapping(TestUtil.newVC(), param, mapping.withJavadoc("gaming")); | ||
|
||
EntryMapping withJavadoc = project.getRemapper().getMapping(param); | ||
Assertions.assertEquals("gaming", withJavadoc.javadoc()); | ||
|
||
File tempFile = File.createTempFile("testMethodOverrideParamJavadoc", tmpNameSuffix); | ||
tempFile.delete(); //remove the auto created file | ||
|
||
readWriteService.write(project.getRemapper().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()); | ||
|
||
EntryMapping newMapping = project.getRemapper().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(); | ||
} | ||
} |