Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions src/main/java/net/fabricmc/lorenztiny/TinyMappingsReader.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of lorenz-tiny, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 FabricMC
* Copyright (c) 2020, 2022 FabricMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -72,22 +72,35 @@ public TinyMappingsReader(final MappingTree tree, final String from, final Strin
@Override
public MappingSet read(final MappingSet mappings) {
for (final MappingTree.ClassMapping klass : this.tree.getClasses()) {
final ClassMapping<?, ?> mapping = mappings.getOrCreateClassMapping(klass.getName(this.from))
.setDeobfuscatedName(klass.getName(this.to));
final String classNameTo = klass.getName(this.to);
final String classNameFrom = klass.getName(this.from);
if (classNameTo == null || classNameFrom == null) {
continue;
}
final ClassMapping<?, ?> mapping = mappings.getOrCreateClassMapping(classNameFrom)
.setDeobfuscatedName(classNameTo);

for (final MappingTree.FieldMapping field : klass.getFields()) {
mapping.getOrCreateFieldMapping(field.getName(this.from), field.getDesc(this.from))
.setDeobfuscatedName(field.getName(this.to));
final String fieldNameTo = field.getName(this.to);
final String fieldNameFrom = field.getName(this.from);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these "from" names can be null too? With custom namespaces they are not necessarily in the mandatory populated NS column.

if (fieldNameTo != null) {
mapping.getOrCreateFieldMapping(fieldNameFrom, field.getDesc(this.from))
.setDeobfuscatedName(fieldNameTo);
}
}

for (final MappingTree.MethodMapping method : klass.getMethods()) {
final MethodMapping methodmapping = mapping
.getOrCreateMethodMapping(method.getName(this.from), method.getDesc(this.from))
.setDeobfuscatedName(method.getName(this.to));
final String methodNameTo = method.getName(this.to);
final String methodNameFrom = method.getName(this.from);
if (methodNameTo != null) {
final MethodMapping methodmapping = mapping
.getOrCreateMethodMapping(methodNameFrom, method.getDesc(this.from))
.setDeobfuscatedName(methodNameTo);

for (final MappingTree.MethodArgMapping param : method.getArgs()) {
methodmapping.getOrCreateParameterMapping(param.getArgPosition())
.setDeobfuscatedName(param.getName(this.to));
for (final MappingTree.MethodArgMapping param : method.getArgs()) {
methodmapping.getOrCreateParameterMapping(param.getArgPosition())
.setDeobfuscatedName(param.getName(this.to));
}
}
}
}
Expand Down