diff options
author | Linnea Gräf <nea@nea.moe> | 2024-03-06 02:38:29 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-03-06 02:38:29 +0100 |
commit | 0a48c5a768a084cfe623302e865de1e367e6d09e (patch) | |
tree | 9a0d5dd4d8ecd7950f9aadf51a7d975ddc3de310 /src/main/java/moe/nea/zwirn/TinyDiffer.java | |
parent | 3c5d9d3c161c1516e2a695e21b9c69e816e88036 (diff) | |
download | zwirn-0a48c5a768a084cfe623302e865de1e367e6d09e.tar.gz zwirn-0a48c5a768a084cfe623302e865de1e367e6d09e.tar.bz2 zwirn-0a48c5a768a084cfe623302e865de1e367e6d09e.zip |
Fix occassional diffing problems
Diffstat (limited to 'src/main/java/moe/nea/zwirn/TinyDiffer.java')
-rw-r--r-- | src/main/java/moe/nea/zwirn/TinyDiffer.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/moe/nea/zwirn/TinyDiffer.java b/src/main/java/moe/nea/zwirn/TinyDiffer.java index 2c274f7..5a3c20d 100644 --- a/src/main/java/moe/nea/zwirn/TinyDiffer.java +++ b/src/main/java/moe/nea/zwirn/TinyDiffer.java @@ -9,6 +9,8 @@ import java.util.function.BiFunction; import java.util.function.Function; import java.util.stream.Collectors; +import static moe.nea.zwirn.ZwirnUtil.TODO; + public class TinyDiffer { private final TinyFile base; private final TinyFile overlay; @@ -27,6 +29,8 @@ public class TinyDiffer { retainedToNormalLookup = retainedNamespaces.stream() .mapToInt(it -> base.getHeader().getNamespaces().indexOf(it)) .toArray(); + if (baseSharedIndex != 0 || overlaySharedIndex != 0) + TODO("add support for remapping descriptors"); } @@ -158,7 +162,10 @@ public class TinyDiffer { @Nullable TinyClass overlayClass) { var names = diffNamesWithMappings(baseClass, overlayClass); var fields = diffChildrenByMapping(baseClass, overlayClass, TinyClass::getFields, this::diffField); - var methods = diffChildrenByMapping(baseClass, overlayClass, TinyClass::getMethods, this::diffMethod); + var methods = diffChildren(baseClass, overlayClass, + it -> it.getMethodNames().get(baseSharedIndex) + it.getMethodDescriptorInFirstNamespace(), + it -> it.getMethodNames().get(overlaySharedIndex) + it.getMethodDescriptorInFirstNamespace(), + TinyClass::getMethods, this::diffMethod); var comments = diffComments(baseClass, overlayClass, TinyClass::getComments); return Retained.keep( new TinyClass( @@ -181,6 +188,7 @@ public class TinyDiffer { return Retained.empty(new ArrayList<>(commentExtractor.apply(baseObject))); var comments = new ArrayList<>(commentExtractor.apply(overlayObject)); comments.removeAll(commentExtractor.apply(baseObject)); + comments.removeIf(String::isEmpty); if (comments.isEmpty()) return Retained.empty(comments); return Retained.strong(comments); @@ -193,7 +201,7 @@ public class TinyDiffer { var comments = diffComments(baseMethod, overlayMethod, TinyMethod::getComments); return Retained.keep( new TinyMethod( - names.diff.get(0), + baseMethod.getMethodDescriptorInFirstNamespace(), names.diff, params.diff, variables.diff, @@ -253,7 +261,7 @@ public class TinyDiffer { var comments = diffComments(baseField, overlayField, TinyField::getComments); return Retained.keep( new TinyField( - names.diff.get(0), + baseField.getFieldDescriptorInFirstNamespace(), names.diff, comments.diff ), |