Skip to content

Commit

Permalink
Fix MappingSourceNsSwitch not dropping entries with missing destin…
Browse files Browse the repository at this point in the history
…ation names (#133)
  • Loading branch information
NebelNidas authored Oct 15, 2024
1 parent 3c390d8 commit d65d8bc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/net/fabricmc/tinyremapper/TinyUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ private static MappingVisitor createAdapter(String fromNs, String toNs, MappingA
new MappingDstNsReorder(
new FlatAsRegularMappingVisitor(new MappingAdapter(out)),
toNs),
fromNs);
fromNs,
true);
}

private static final class MappingAdapter implements FlatMappingVisitor {
Expand All @@ -108,23 +109,23 @@ private static final class MappingAdapter implements FlatMappingVisitor {
@Override
public boolean visitClass(String srcName, String[] dstNames) throws IOException {
String dstName = dstNames[0];
if (!bothNullOrEqual(srcName, dstName)) next.acceptClass(srcName, dstName);
if (!anyNullOrEqual(srcName, dstName)) next.acceptClass(srcName, dstName);
return true;
}

@Override
public boolean visitField(String srcClsName, String srcName, String srcDesc,
String[] dstClsNames, String[] dstNames, String[] dstDescs) throws IOException {
String dstName = dstNames[0];
if (!bothNullOrEqual(srcName, dstName)) next.acceptField(new Member(srcClsName, srcName, srcDesc), dstName);
if (!anyNullOrEqual(srcName, dstName)) next.acceptField(new Member(srcClsName, srcName, srcDesc), dstName);
return false;
}

@Override
public boolean visitMethod(String srcClsName, String srcName, String srcDesc,
String[] dstClsNames, String[] dstNames, String[] dstDescs) throws IOException {
String dstName = dstNames[0];
if (!bothNullOrEqual(srcName, dstName)) next.acceptMethod(new Member(srcClsName, srcName, srcDesc), dstName);
if (!anyNullOrEqual(srcName, dstName)) next.acceptMethod(new Member(srcClsName, srcName, srcDesc), dstName);
return true;
}

Expand Down Expand Up @@ -164,7 +165,7 @@ private static boolean firstNullOrEqual(Object o1, Object o2) {
return o1 == null || o1.equals(o2);
}

private static boolean bothNullOrEqual(Object o1, Object o2) {
private static boolean anyNullOrEqual(Object o1, Object o2) {
return o2 == null || firstNullOrEqual(o1, o2);
}
}

0 comments on commit d65d8bc

Please sign in to comment.