Fix unobfuscated names not having params or docs. (#532)

dev/0.11
modmuss50 2021-11-09 22:07:43 +00:00 committed by GitHub
parent cb5c009e1a
commit b2228e3175
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 36 deletions

View File

@ -73,8 +73,6 @@ import net.fabricmc.mappingio.tree.MappingTree;
import net.fabricmc.mappingio.tree.MemoryMappingTree;
import net.fabricmc.stitch.Command;
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 MinecraftMappedProvider mappedProvider;
@ -312,18 +310,22 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
Stopwatch stopwatch = Stopwatch.createStarted();
project.getLogger().info(":merging mappings");
MemoryMappingTree tree = new MemoryMappingTree();
MappingSourceNsSwitch sourceNsSwitch = new MappingSourceNsSwitch(tree, MappingsNamespace.OFFICIAL.toString());
readIntermediaryTree().accept(sourceNsSwitch);
MemoryMappingTree intermediaryTree = new MemoryMappingTree();
readIntermediaryTree().accept(new MappingSourceNsSwitch(intermediaryTree, MappingsNamespace.INTERMEDIARY.toString()));
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)) {
tree.accept(writer);
officialTree.accept(writer);
}
project.getLogger().info(":merged mappings in " + stopwatch.stop());
@ -374,28 +376,6 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
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) {
Command command = new CommandProposeFieldNames();
runCommand(command, minecraftProvider.getMergedJar().getAbsolutePath(),

View File

@ -24,6 +24,8 @@
package net.fabricmc.loom.util;
import java.util.Objects;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.RecordComponentVisitor;
@ -60,7 +62,7 @@ public class RecordComponentFixVisitor extends ClassVisitor {
@Override
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_")) {
super.visitRecordComponent(name, descriptor, signature);

View File

@ -28,7 +28,7 @@ import org.gradle.util.GradleVersion
class LoomTestConstants {
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]
}

View File

@ -1,9 +1,9 @@
org.gradle.jvmargs=-Xmx1G
minecraft_version=21w39a
yarn_mappings=21w39a+build.1
loader_version=0.11.7
fabric_version=0.40.4+1.18
minecraft_version=21w44a
yarn_mappings=21w44a+build.8
loader_version=0.12.5
fabric_version=0.42.1+1.18
mod_version = 1.0.0
maven_group = com.example