From 7e7315fb37e96bf81d2b063f9225f0b8f5ad69dc Mon Sep 17 00:00:00 2001 From: tsantalis Date: Sat, 11 Jan 2025 08:18:13 -0500 Subject: [PATCH] More accurate instanceAttributeMovedAlongWithMethod() rule --- src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java b/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java index 1f7e688ac..63391219d 100644 --- a/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java +++ b/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java @@ -1793,7 +1793,7 @@ private boolean instanceAttributeMovedAlongWithMethod(UMLAttribute addedAttribut UMLClassBaseDiff targetClassDiff = getUMLClassDiff(addedAttribute.getClassName()); if(sourceClassDiff != null) { for(UMLAttribute attribute : sourceClassDiff.getNextClass().getAttributes()) { - if(attribute.getType() != null && addedAttribute.getClassName().endsWith(attribute.getType().getClassType())) { + if(attribute.getType() != null && addedAttribute.getClassName().endsWith("." + attribute.getType().getClassType())) { return true; } if(targetClassDiff != null) { @@ -1802,12 +1802,18 @@ private boolean instanceAttributeMovedAlongWithMethod(UMLAttribute addedAttribut return true; } } + UMLType superclassType = targetClassDiff.getNextClass().getSuperclass(); + if(superclassType != null) { + if(attribute.getType().equals(superclassType)) { + return true; + } + } } } } if(targetClassDiff != null) { for(UMLAttribute attribute : targetClassDiff.getRemovedAttributes()) { - if(attribute.getType() != null && removedAttribute.getClassName().endsWith(attribute.getType().getClassType())) { + if(attribute.getType() != null && removedAttribute.getClassName().endsWith("." + attribute.getType().getClassType())) { return true; } }