From 0307a95d4e7e20e4d89ca1f0a9d964fe47dd17c8 Mon Sep 17 00:00:00 2001 From: tsantalis Date: Mon, 25 Nov 2024 19:59:54 -0500 Subject: [PATCH] Fix for issue #198 --- .../java/org/codetracker/AbstractTracker.java | 8 ++++---- .../AttributeTrackerChangeHistory.java | 4 ++-- .../codetracker/MethodTrackerChangeHistory.java | 15 ++++++++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/codetracker/AbstractTracker.java b/src/main/java/org/codetracker/AbstractTracker.java index e5f09951790..e30cc646929 100644 --- a/src/main/java/org/codetracker/AbstractTracker.java +++ b/src/main/java/org/codetracker/AbstractTracker.java @@ -642,8 +642,8 @@ protected static boolean isAttributeAdded(UMLModelDiff modelDiff, String classNa return true; } - UMLClass addedClass = modelDiff.getAddedClass(className); - if (addedClass != null) { + Set addedClasses = modelDiff.getAllAddedClasses(className); + for (UMLClass addedClass : addedClasses) { for (UMLAttribute attribute : addedClass.getAttributes()) { if (isAttributeAdded(attribute, equalOperator, currentVersion)) return true; @@ -714,8 +714,8 @@ protected static boolean isMethodAdded(UMLModelDiff modelDiff, String className, return true; } - UMLClass addedClass = modelDiff.getAddedClass(className); - if (addedClass != null) { + Set addedClasses = modelDiff.getAllAddedClasses(className); + for (UMLClass addedClass : addedClasses) { for (UMLOperation operation : addedClass.getOperations()) { if (isMethodAdded(operation, equalOperator, addedMethodHandler, currentVersion)) return true; diff --git a/src/main/java/org/codetracker/AttributeTrackerChangeHistory.java b/src/main/java/org/codetracker/AttributeTrackerChangeHistory.java index 9e8a4b0ffec..8c06afb1358 100644 --- a/src/main/java/org/codetracker/AttributeTrackerChangeHistory.java +++ b/src/main/java/org/codetracker/AttributeTrackerChangeHistory.java @@ -261,8 +261,8 @@ public boolean isAttributeAdded(UMLModelDiff modelDiff, String className, Versio return true; } - UMLClass addedClass = modelDiff.getAddedClass(className); - if (addedClass != null) { + Set addedClasses = modelDiff.getAllAddedClasses(className); + for (UMLClass addedClass : addedClasses) { for (UMLAttribute umlAttribute : addedClass.getAttributes()) { if (handleAddAttribute(currentVersion, parentVersion, equalOperator, umlAttribute, "added with new class")) return true; diff --git a/src/main/java/org/codetracker/MethodTrackerChangeHistory.java b/src/main/java/org/codetracker/MethodTrackerChangeHistory.java index 8d0cf391d2a..4439331e49b 100644 --- a/src/main/java/org/codetracker/MethodTrackerChangeHistory.java +++ b/src/main/java/org/codetracker/MethodTrackerChangeHistory.java @@ -850,23 +850,24 @@ public boolean isMethodAdded(UMLModelDiff modelDiff, String className, Version c } } - UMLClass addedClass = modelDiff.getAddedClass(className); - if (addedClass != null) { + Set addedClasses = modelDiff.getAllAddedClasses(className); + for (UMLClass addedClass : addedClasses) { for (UMLOperation operation : addedClass.getOperations()) { if (handleAddOperation(currentVersion, parentVersion, equalOperator, operation, "added with new class")) return true; } } - else { + if (addedClasses.isEmpty()) { String prefix = new String(className); + Set outerAddedClasses = null; while (prefix.contains(".")) { prefix = prefix.substring(0, prefix.lastIndexOf(".")); - addedClass = modelDiff.getAddedClass(prefix); - if (addedClass != null) { + outerAddedClasses = modelDiff.getAllAddedClasses(prefix); + if (!outerAddedClasses.isEmpty()) { break; } } - if (addedClass != null) { + for (UMLClass addedClass : outerAddedClasses) { for (UMLAnonymousClass anonymousClass : addedClass.getAnonymousClassList()) { for (UMLOperation operation : anonymousClass.getOperations()) { if (handleAddOperation(currentVersion, parentVersion, equalOperator, operation, "added with new anonymous class")) @@ -930,7 +931,7 @@ public boolean isMethodAdded(UMLModelDiff modelDiff, String className, Version c if (handleAddOperation(currentVersion, parentVersion, equalOperator, operation, "new initializer")) return true; } - if (addedClass != null) { + for (UMLClass addedClass : addedClasses) { for (UMLInitializer operation : addedClass.getInitializers()) { if (handleAddOperation(currentVersion, parentVersion, equalOperator, operation, "added with new class")) return true;