Skip to content

Commit

Permalink
Fix for issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Aug 30, 2024
1 parent 67589bc commit 8e982de
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ public Set<CandidateSplitVariableRefactoring> getCandidateAttributeSplits() {
}

public List<Refactoring> getRefactorings() throws RefactoringMinerTimedOutException {
List<Refactoring> originalRefactorings = new ArrayList<Refactoring>(this.refactorings);
List<Refactoring> refactorings = new ArrayList<Refactoring>(this.refactorings);
if(!originalClass.getTypeDeclarationKind().equals(nextClass.getTypeDeclarationKind())) {
boolean anonymousToClass = originalClass.getTypeDeclarationKind().endsWith("class") && nextClass.getTypeDeclarationKind().endsWith("class");
Expand Down Expand Up @@ -815,7 +816,7 @@ public List<Refactoring> getRefactorings() throws RefactoringMinerTimedOutExcept
if((!originalClass.containsAttributeWithName(pattern.getAfter()) || cyclicRename(renameMap, pattern)) &&
(!nextClass.containsAttributeWithName(pattern.getBefore()) || cyclicRename(renameMap, pattern)) &&
!inconsistentAttributeRename(pattern, aliasedAttributesInOriginalClass, aliasedAttributesInNextClass) &&
!attributeMerged(a1, a2, refactorings) && !attributeSplit(a1, a2, refactorings)) {
!attributeMerged(a1, a2, refactorings) && !attributeSplit(a1, a2, refactorings) && !attributeWithConflictingRename(a1, a2, originalRefactorings)) {
if(a1 instanceof UMLEnumConstant && a2 instanceof UMLEnumConstant) {
UMLEnumConstantDiff enumConstantDiff = new UMLEnumConstantDiff((UMLEnumConstant)a1, (UMLEnumConstant)a2, this, modelDiff);
if(!enumConstantDiffList.contains(enumConstantDiff)) {
Expand Down Expand Up @@ -1237,6 +1238,21 @@ else if(refactoring instanceof SplitVariableRefactoring) {
return newRefactorings;
}

private boolean attributeWithConflictingRename(UMLAttribute a1, UMLAttribute a2, List<Refactoring> refactorings) {
for(Refactoring refactoring : refactorings) {
if(refactoring instanceof RenameAttributeRefactoring) {
RenameAttributeRefactoring rename = (RenameAttributeRefactoring)refactoring;
if(rename.getOriginalAttribute().equals(a1) && !rename.getRenamedAttribute().equals(a2)) {
return true;
}
else if(!rename.getOriginalAttribute().equals(a1) && rename.getRenamedAttribute().equals(a2)) {
return true;
}
}
}
return false;
}

private boolean attributeMerged(UMLAttribute a1, UMLAttribute a2, List<Refactoring> refactorings) {
for(Refactoring refactoring : refactorings) {
if(refactoring instanceof MergeAttributeRefactoring) {
Expand Down

0 comments on commit 8e982de

Please sign in to comment.