diff --git a/src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java b/src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java index d325f073f..a6c4e7bb2 100644 --- a/src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java +++ b/src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java @@ -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; @@ -64,6 +65,7 @@ public abstract class UMLAbstractClassDiff { private Map> splitMap = new LinkedHashMap>(); protected List refactorings; protected UMLModelDiff modelDiff; + protected UMLAnnotationListDiff annotationListDiff; private UMLImplementedInterfaceListDiff interfaceListDiff; private UMLCommentListDiff commentListDiff; private static final List collectionAPINames = List.of("get", "add", "contains", "put", "putAll", "addAll", "equals"); @@ -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 getAddedOperations() { @@ -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()); diff --git a/src/main/java/gr/uom/java/xmi/diff/UMLClassBaseDiff.java b/src/main/java/gr/uom/java/xmi/diff/UMLClassBaseDiff.java index a13c198bc..5c1203914 100644 --- a/src/main/java/gr/uom/java/xmi/diff/UMLClassBaseDiff.java +++ b/src/main/java/gr/uom/java/xmi/diff/UMLClassBaseDiff.java @@ -75,7 +75,6 @@ public abstract class UMLClassBaseDiff extends UMLAbstractClassDiff implements C private UMLType newSuperclass; private List addedImplementedInterfaces; private List removedImplementedInterfaces; - private UMLAnnotationListDiff annotationListDiff; private UMLImportListDiff importDiffList; private UMLTypeParameterListDiff typeParameterDiffList; private Map consistentMethodInvocationRenamesInModel; @@ -157,7 +156,6 @@ public void process() throws RefactoringMinerTimedOutException { processInitializers(); processModifiers(); processTypeParameters(); - processAnnotations(); processEnumConstants(); processInheritance(); processOperations(); @@ -412,10 +410,6 @@ public UMLImportListDiff getImportDiffList() { return importDiffList; } - public UMLAnnotationListDiff getAnnotationListDiff() { - return annotationListDiff; - } - public UMLTypeParameterListDiff getTypeParameterDiffList() { return typeParameterDiffList; } @@ -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)) {