Skip to content

Commit

Permalink
Fix for issue #198
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Nov 26, 2024
1 parent f3bb82f commit 0307a95
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/codetracker/AbstractTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,8 @@ protected static boolean isAttributeAdded(UMLModelDiff modelDiff, String classNa
return true;
}

UMLClass addedClass = modelDiff.getAddedClass(className);
if (addedClass != null) {
Set<UMLClass> addedClasses = modelDiff.getAllAddedClasses(className);
for (UMLClass addedClass : addedClasses) {
for (UMLAttribute attribute : addedClass.getAttributes()) {
if (isAttributeAdded(attribute, equalOperator, currentVersion))
return true;
Expand Down Expand Up @@ -714,8 +714,8 @@ protected static boolean isMethodAdded(UMLModelDiff modelDiff, String className,
return true;
}

UMLClass addedClass = modelDiff.getAddedClass(className);
if (addedClass != null) {
Set<UMLClass> addedClasses = modelDiff.getAllAddedClasses(className);
for (UMLClass addedClass : addedClasses) {
for (UMLOperation operation : addedClass.getOperations()) {
if (isMethodAdded(operation, equalOperator, addedMethodHandler, currentVersion))
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ public boolean isAttributeAdded(UMLModelDiff modelDiff, String className, Versio
return true;
}

UMLClass addedClass = modelDiff.getAddedClass(className);
if (addedClass != null) {
Set<UMLClass> 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;
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/org/codetracker/MethodTrackerChangeHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -850,23 +850,24 @@ public boolean isMethodAdded(UMLModelDiff modelDiff, String className, Version c
}
}

UMLClass addedClass = modelDiff.getAddedClass(className);
if (addedClass != null) {
Set<UMLClass> 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<UMLClass> 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"))
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0307a95

Please sign in to comment.