Fix unobfuscated names not having params or docs. (#532)
parent
cb5c009e1a
commit
b2228e3175
|
@ -73,8 +73,6 @@ import net.fabricmc.mappingio.tree.MappingTree;
|
||||||
import net.fabricmc.mappingio.tree.MemoryMappingTree;
|
import net.fabricmc.mappingio.tree.MemoryMappingTree;
|
||||||
import net.fabricmc.stitch.Command;
|
import net.fabricmc.stitch.Command;
|
||||||
import net.fabricmc.stitch.commands.CommandProposeFieldNames;
|
import net.fabricmc.stitch.commands.CommandProposeFieldNames;
|
||||||
import net.fabricmc.stitch.commands.tinyv2.CommandMergeTinyV2;
|
|
||||||
import net.fabricmc.stitch.commands.tinyv2.CommandReorderTinyV2;
|
|
||||||
|
|
||||||
public class MappingsProviderImpl extends DependencyProvider implements MappingsProvider {
|
public class MappingsProviderImpl extends DependencyProvider implements MappingsProvider {
|
||||||
public MinecraftMappedProvider mappedProvider;
|
public MinecraftMappedProvider mappedProvider;
|
||||||
|
@ -312,18 +310,22 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||||
project.getLogger().info(":merging mappings");
|
project.getLogger().info(":merging mappings");
|
||||||
|
|
||||||
MemoryMappingTree tree = new MemoryMappingTree();
|
MemoryMappingTree intermediaryTree = new MemoryMappingTree();
|
||||||
MappingSourceNsSwitch sourceNsSwitch = new MappingSourceNsSwitch(tree, MappingsNamespace.OFFICIAL.toString());
|
readIntermediaryTree().accept(new MappingSourceNsSwitch(intermediaryTree, MappingsNamespace.INTERMEDIARY.toString()));
|
||||||
readIntermediaryTree().accept(sourceNsSwitch);
|
|
||||||
|
|
||||||
try (BufferedReader reader = Files.newBufferedReader(from, StandardCharsets.UTF_8)) {
|
try (BufferedReader reader = Files.newBufferedReader(from, StandardCharsets.UTF_8)) {
|
||||||
Tiny2Reader.read(reader, tree);
|
Tiny2Reader.read(reader, intermediaryTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
inheritMappedNamesOfEnclosingClasses(tree);
|
MemoryMappingTree officialTree = new MemoryMappingTree();
|
||||||
|
MappingNsCompleter nsCompleter = new MappingNsCompleter(officialTree, Map.of(MappingsNamespace.OFFICIAL.toString(), MappingsNamespace.INTERMEDIARY.toString()));
|
||||||
|
MappingSourceNsSwitch nsSwitch = new MappingSourceNsSwitch(nsCompleter, MappingsNamespace.OFFICIAL.toString());
|
||||||
|
intermediaryTree.accept(nsSwitch);
|
||||||
|
|
||||||
|
inheritMappedNamesOfEnclosingClasses(officialTree);
|
||||||
|
|
||||||
try (Tiny2Writer writer = new Tiny2Writer(Files.newBufferedWriter(out, StandardCharsets.UTF_8), false)) {
|
try (Tiny2Writer writer = new Tiny2Writer(Files.newBufferedWriter(out, StandardCharsets.UTF_8), false)) {
|
||||||
tree.accept(writer);
|
officialTree.accept(writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
project.getLogger().info(":merged mappings in " + stopwatch.stop());
|
project.getLogger().info(":merged mappings in " + stopwatch.stop());
|
||||||
|
@ -374,28 +376,6 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reorderMappings(Path oldMappings, Path newMappings, String... newOrder) {
|
|
||||||
Command command = new CommandReorderTinyV2();
|
|
||||||
String[] args = new String[2 + newOrder.length];
|
|
||||||
args[0] = oldMappings.toAbsolutePath().toString();
|
|
||||||
args[1] = newMappings.toAbsolutePath().toString();
|
|
||||||
System.arraycopy(newOrder, 0, args, 2, newOrder.length);
|
|
||||||
runCommand(command, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void mergeMappings(Path intermediaryMappings, Path yarnMappings, Path newMergedMappings) {
|
|
||||||
try {
|
|
||||||
Command command = new CommandMergeTinyV2();
|
|
||||||
runCommand(command, intermediaryMappings.toAbsolutePath().toString(),
|
|
||||||
yarnMappings.toAbsolutePath().toString(),
|
|
||||||
newMergedMappings.toAbsolutePath().toString(),
|
|
||||||
MappingsNamespace.INTERMEDIARY.toString(), MappingsNamespace.OFFICIAL.toString());
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Could not merge mappings from " + intermediaryMappings.toString()
|
|
||||||
+ " with mappings from " + yarnMappings, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void suggestFieldNames(MinecraftProviderImpl minecraftProvider, Path oldMappings, Path newMappings) {
|
private void suggestFieldNames(MinecraftProviderImpl minecraftProvider, Path oldMappings, Path newMappings) {
|
||||||
Command command = new CommandProposeFieldNames();
|
Command command = new CommandProposeFieldNames();
|
||||||
runCommand(command, minecraftProvider.getMergedJar().getAbsolutePath(),
|
runCommand(command, minecraftProvider.getMergedJar().getAbsolutePath(),
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
package net.fabricmc.loom.util;
|
package net.fabricmc.loom.util;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.objectweb.asm.ClassVisitor;
|
import org.objectweb.asm.ClassVisitor;
|
||||||
import org.objectweb.asm.FieldVisitor;
|
import org.objectweb.asm.FieldVisitor;
|
||||||
import org.objectweb.asm.RecordComponentVisitor;
|
import org.objectweb.asm.RecordComponentVisitor;
|
||||||
|
@ -60,7 +62,7 @@ public class RecordComponentFixVisitor extends ClassVisitor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
|
public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
|
||||||
String intermediaryName = mappings.getField(owner, name, descriptor).getName(intermediaryNsId);
|
String intermediaryName = Objects.requireNonNull(mappings.getField(owner, name, descriptor), "Could not get field for %s:%s%s".formatted(owner, name, descriptor)).getName(intermediaryNsId);
|
||||||
|
|
||||||
if (!hasExistingComponents && intermediaryName != null && intermediaryName.startsWith("comp_")) {
|
if (!hasExistingComponents && intermediaryName != null && intermediaryName.startsWith("comp_")) {
|
||||||
super.visitRecordComponent(name, descriptor, signature);
|
super.visitRecordComponent(name, descriptor, signature);
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.gradle.util.GradleVersion
|
||||||
|
|
||||||
class LoomTestConstants {
|
class LoomTestConstants {
|
||||||
public final static String DEFAULT_GRADLE = GradleVersion.current().getVersion()
|
public final static String DEFAULT_GRADLE = GradleVersion.current().getVersion()
|
||||||
public final static String PRE_RELEASE_GRADLE = "7.4-20211023222429+0000"
|
public final static String PRE_RELEASE_GRADLE = "7.4-20211108233000+0000"
|
||||||
|
|
||||||
public final static String[] STANDARD_TEST_VERSIONS = [DEFAULT_GRADLE, PRE_RELEASE_GRADLE]
|
public final static String[] STANDARD_TEST_VERSIONS = [DEFAULT_GRADLE, PRE_RELEASE_GRADLE]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
|
|
||||||
minecraft_version=21w39a
|
minecraft_version=21w44a
|
||||||
yarn_mappings=21w39a+build.1
|
yarn_mappings=21w44a+build.8
|
||||||
loader_version=0.11.7
|
loader_version=0.12.5
|
||||||
fabric_version=0.40.4+1.18
|
fabric_version=0.42.1+1.18
|
||||||
|
|
||||||
mod_version = 1.0.0
|
mod_version = 1.0.0
|
||||||
maven_group = com.example
|
maven_group = com.example
|
||||||
|
|
Loading…
Reference in New Issue