Skip to content

Commit

Permalink
Pull up annotationDiffList to superclass
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Jul 28, 2024
1 parent 0dab24b commit 30f8035
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
23 changes: 23 additions & 0 deletions src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.refactoringminer.util.PrefixSuffixUtils;

import gr.uom.java.xmi.UMLAbstractClass;
import gr.uom.java.xmi.UMLAnnotation;
import gr.uom.java.xmi.UMLAnonymousClass;
import gr.uom.java.xmi.UMLAttribute;
import gr.uom.java.xmi.UMLEnumConstant;
Expand Down Expand Up @@ -64,6 +65,7 @@ public abstract class UMLAbstractClassDiff {
private Map<SplitVariableReplacement, Set<CandidateSplitVariableRefactoring>> splitMap = new LinkedHashMap<SplitVariableReplacement, Set<CandidateSplitVariableRefactoring>>();
protected List<Refactoring> refactorings;
protected UMLModelDiff modelDiff;
protected UMLAnnotationListDiff annotationListDiff;
private UMLImplementedInterfaceListDiff interfaceListDiff;
private UMLCommentListDiff commentListDiff;
private static final List<String> collectionAPINames = List.of("get", "add", "contains", "put", "putAll", "addAll", "equals");
Expand All @@ -87,6 +89,7 @@ public UMLAbstractClassDiff(UMLAbstractClass originalClass, UMLAbstractClass nex
this.nextClass = nextClass;
this.modelDiff = modelDiff;
this.interfaceListDiff = new UMLImplementedInterfaceListDiff(originalClass.getImplementedInterfaces(), nextClass.getImplementedInterfaces());
processAnnotations();
}

public List<UMLOperation> getAddedOperations() {
Expand Down Expand Up @@ -149,6 +152,26 @@ public UMLModelDiff getModelDiff() {
return modelDiff;
}

protected void processAnnotations() {
this.annotationListDiff = new UMLAnnotationListDiff(originalClass.getAnnotations(), nextClass.getAnnotations());
for(UMLAnnotation annotation : annotationListDiff.getAddedAnnotations()) {
AddClassAnnotationRefactoring refactoring = new AddClassAnnotationRefactoring(annotation, originalClass, nextClass);
refactorings.add(refactoring);
}
for(UMLAnnotation annotation : annotationListDiff.getRemovedAnnotations()) {
RemoveClassAnnotationRefactoring refactoring = new RemoveClassAnnotationRefactoring(annotation, originalClass, nextClass);
refactorings.add(refactoring);
}
for(UMLAnnotationDiff annotationDiff : annotationListDiff.getAnnotationDiffs()) {
ModifyClassAnnotationRefactoring refactoring = new ModifyClassAnnotationRefactoring(annotationDiff.getRemovedAnnotation(), annotationDiff.getAddedAnnotation(), originalClass, nextClass);
refactorings.add(refactoring);
}
}

public UMLAnnotationListDiff getAnnotationListDiff() {
return annotationListDiff;
}

public UMLCommentListDiff getCommentListDiff() {
if(commentListDiff == null)
commentListDiff = new UMLCommentListDiff(originalClass.getComments(), nextClass.getComments());
Expand Down
22 changes: 0 additions & 22 deletions src/main/java/gr/uom/java/xmi/diff/UMLClassBaseDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public abstract class UMLClassBaseDiff extends UMLAbstractClassDiff implements C
private UMLType newSuperclass;
private List<UMLType> addedImplementedInterfaces;
private List<UMLType> removedImplementedInterfaces;
private UMLAnnotationListDiff annotationListDiff;
private UMLImportListDiff importDiffList;
private UMLTypeParameterListDiff typeParameterDiffList;
private Map<MethodInvocationReplacement, UMLOperationBodyMapper> consistentMethodInvocationRenamesInModel;
Expand Down Expand Up @@ -157,7 +156,6 @@ public void process() throws RefactoringMinerTimedOutException {
processInitializers();
processModifiers();
processTypeParameters();
processAnnotations();
processEnumConstants();
processInheritance();
processOperations();
Expand Down Expand Up @@ -412,10 +410,6 @@ public UMLImportListDiff getImportDiffList() {
return importDiffList;
}

public UMLAnnotationListDiff getAnnotationListDiff() {
return annotationListDiff;
}

public UMLTypeParameterListDiff getTypeParameterDiffList() {
return typeParameterDiffList;
}
Expand Down Expand Up @@ -524,22 +518,6 @@ else if(originalClass.isStatic()) {
}
}

private void processAnnotations() {
this.annotationListDiff = new UMLAnnotationListDiff(originalClass.getAnnotations(), nextClass.getAnnotations());
for(UMLAnnotation annotation : annotationListDiff.getAddedAnnotations()) {
AddClassAnnotationRefactoring refactoring = new AddClassAnnotationRefactoring(annotation, originalClass, nextClass);
refactorings.add(refactoring);
}
for(UMLAnnotation annotation : annotationListDiff.getRemovedAnnotations()) {
RemoveClassAnnotationRefactoring refactoring = new RemoveClassAnnotationRefactoring(annotation, originalClass, nextClass);
refactorings.add(refactoring);
}
for(UMLAnnotationDiff annotationDiff : annotationListDiff.getAnnotationDiffs()) {
ModifyClassAnnotationRefactoring refactoring = new ModifyClassAnnotationRefactoring(annotationDiff.getRemovedAnnotation(), annotationDiff.getAddedAnnotation(), originalClass, nextClass);
refactorings.add(refactoring);
}
}

public UMLOperationBodyMapper findMapperWithMatchingSignatures(UMLOperation operation1, UMLOperation operation2) {
for(UMLOperationBodyMapper mapper : operationBodyMapperList) {
if(mapper.getOperation1() != null && mapper.getOperation1().equalSignature(operation1) && mapper.getOperation2() != null && mapper.getOperation2().equalSignature(operation2)) {
Expand Down

0 comments on commit 30f8035

Please sign in to comment.