Skip to content

Commit

Permalink
Don't forget to export member and arg/var comments
Browse files Browse the repository at this point in the history
  • Loading branch information
NebelNidas committed Jun 17, 2023
1 parent e0b7bd4 commit 3296634
Showing 1 changed file with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,40 +127,40 @@ private static void writeMethod(EntryTreeNode<EntryMapping> methodNode, MemoryMa
}
}

private static void writeMethodArg(EntryTreeNode<EntryMapping> methodArgNode, MemoryMappingTree mappingTree) {
if (methodArgNode.getValue() == null || methodArgNode.getValue().equals(EntryMapping.DEFAULT)) {
private static void writeMethodArg(EntryTreeNode<EntryMapping> argNode, MemoryMappingTree mappingTree) {
if (argNode.getValue() == null || argNode.getValue().equals(EntryMapping.DEFAULT)) {
return; // Shortcut
}

LocalVariableEntry methodArgEntry = ((LocalVariableEntry) methodArgNode.getEntry());
mappingTree.visitMethodArg(-1, methodArgEntry.getIndex(), methodArgEntry.getName());
LocalVariableEntry argEntry = ((LocalVariableEntry) argNode.getEntry());
mappingTree.visitMethodArg(-1, argEntry.getIndex(), argEntry.getName());

EntryMapping methodArgMapping = methodArgNode.getValue();
EntryMapping argMapping = argNode.getValue();

if (methodArgMapping == null) {
methodArgMapping = EntryMapping.DEFAULT;
if (argMapping == null) {
argMapping = EntryMapping.DEFAULT;
}

mappingTree.visitDstName(MappedElementKind.METHOD_ARG, 0, methodArgMapping.targetName());
mappingTree.visitComment(MappedElementKind.METHOD_ARG, methodArgMapping.javadoc());
mappingTree.visitDstName(MappedElementKind.METHOD_ARG, 0, argMapping.targetName());
mappingTree.visitComment(MappedElementKind.METHOD_ARG, argMapping.javadoc());
}

private static void writeMethodVar(EntryTreeNode<EntryMapping> methodVarNode, MemoryMappingTree mappingTree) {
if (methodVarNode.getValue() == null || methodVarNode.getValue().equals(EntryMapping.DEFAULT)) {
private static void writeMethodVar(EntryTreeNode<EntryMapping> varNode, MemoryMappingTree mappingTree) {
if (varNode.getValue() == null || varNode.getValue().equals(EntryMapping.DEFAULT)) {
return; // Shortcut
}

LocalVariableEntry methodVarEntry = ((LocalVariableEntry) methodVarNode.getEntry());
mappingTree.visitMethodVar(-1, methodVarEntry.getIndex(), -1, -1, methodVarEntry.getName());
LocalVariableEntry varEntry = ((LocalVariableEntry) varNode.getEntry());
mappingTree.visitMethodVar(-1, varEntry.getIndex(), -1, -1, varEntry.getName());

EntryMapping methodVarMapping = methodVarNode.getValue();
EntryMapping varMapping = varNode.getValue();

if (methodVarMapping == null) {
methodVarMapping = EntryMapping.DEFAULT;
if (varMapping == null) {
varMapping = EntryMapping.DEFAULT;
}

mappingTree.visitDstName(MappedElementKind.METHOD_VAR, 0, methodVarMapping.targetName());
mappingTree.visitComment(MappedElementKind.METHOD_VAR, methodVarMapping.javadoc());
mappingTree.visitDstName(MappedElementKind.METHOD_VAR, 0, varMapping.targetName());
mappingTree.visitComment(MappedElementKind.METHOD_VAR, varMapping.javadoc());
}

public static EntryTree<EntryMapping> fromMappingIo(MemoryMappingTree mappingTree, ProgressListener progress) {
Expand All @@ -184,7 +184,7 @@ private static void readClass(ClassMapping classMapping, EntryTree<EntryMapping>
dstName = dstName.substring(dstName.lastIndexOf('$') + 1);
}

mappingTree.insert(currentClass, new EntryMapping(dstName));
mappingTree.insert(currentClass, new EntryMapping(dstName, classMapping.getComment()));

for (FieldMapping fieldMapping : classMapping.getFields()) {
readField(fieldMapping, currentClass, mappingTree);
Expand All @@ -197,36 +197,36 @@ private static void readClass(ClassMapping classMapping, EntryTree<EntryMapping>

private static void readField(FieldMapping fieldMapping, ClassEntry parent, EntryTree<EntryMapping> mappingTree) {
mappingTree.insert(new FieldEntry(parent, fieldMapping.getSrcName(), new TypeDescriptor(fieldMapping.getSrcDesc())),
new EntryMapping(fieldMapping.getDstName(0)));
new EntryMapping(fieldMapping.getDstName(0), fieldMapping.getComment()));
}

private static void readMethod(MethodMapping methodMapping, ClassEntry parent, EntryTree<EntryMapping> mappingTree) {
MethodEntry currentMethod;
mappingTree.insert(currentMethod = new MethodEntry(parent, methodMapping.getSrcName(), new MethodDescriptor(methodMapping.getSrcDesc())),
new EntryMapping(methodMapping.getDstName(0)));
new EntryMapping(methodMapping.getDstName(0), methodMapping.getComment()));

for (MethodArgMapping methodArgMapping : methodMapping.getArgs()) {
readMethodArg(methodArgMapping, currentMethod, mappingTree);
for (MethodArgMapping argMapping : methodMapping.getArgs()) {
readMethodArg(argMapping, currentMethod, mappingTree);
}

for (MethodVarMapping methodVarMapping : methodMapping.getVars()) {
readMethodVar(methodVarMapping, currentMethod, mappingTree);
for (MethodVarMapping varMapping : methodMapping.getVars()) {
readMethodVar(varMapping, currentMethod, mappingTree);
}
}

private static void readMethodArg(MethodArgMapping methodArgMapping, MethodEntry parent, EntryTree<EntryMapping> mappingTree) {
String methodArgSrcName = methodArgMapping.getSrcName() != null ? methodArgMapping.getSrcName() : "";
private static void readMethodArg(MethodArgMapping argMapping, MethodEntry parent, EntryTree<EntryMapping> mappingTree) {
String srcName = argMapping.getSrcName() != null ? argMapping.getSrcName() : "";

mappingTree.insert(
new LocalVariableEntry(parent, methodArgMapping.getLvIndex(), methodArgSrcName, true, null),
new EntryMapping(methodArgMapping.getDstName(0)));
new LocalVariableEntry(parent, argMapping.getLvIndex(), srcName, true, null),
new EntryMapping(argMapping.getDstName(0), argMapping.getComment()));
}

private static void readMethodVar(MethodVarMapping methodVarMapping, MethodEntry parent, EntryTree<EntryMapping> mappingTree) {
String methodVarSrcName = methodVarMapping.getSrcName() != null ? methodVarMapping.getSrcName() : "";
private static void readMethodVar(MethodVarMapping varMapping, MethodEntry parent, EntryTree<EntryMapping> mappingTree) {
String srcName = varMapping.getSrcName() != null ? varMapping.getSrcName() : "";

mappingTree.insert(
new LocalVariableEntry(parent, methodVarMapping.getLvIndex(), methodVarSrcName, false, null),
new EntryMapping(methodVarMapping.getDstName(0)));
new LocalVariableEntry(parent, varMapping.getLvIndex(), srcName, false, null),
new EntryMapping(varMapping.getDstName(0), varMapping.getComment()));
}
}

0 comments on commit 3296634

Please sign in to comment.