Skip to content

Commit

Permalink
Comment and Javadoc diff in Attribute and EnumConstant diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Jul 31, 2024
1 parent f55618b commit c00596f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1223,12 +1223,6 @@ public UMLOperationBodyMapper(UMLAttribute removedAttribute, UMLAttribute addedA
leaves2.add(expression2);
processLeaves(leaves1, leaves2, new LinkedHashMap<String, String>(), false);
}
if(removedAttribute.getJavadoc() != null && addedAttribute.getJavadoc() != null) {
UMLJavadocDiff diff = new UMLJavadocDiff(removedAttribute.getJavadoc(), addedAttribute.getJavadoc());
this.javadocDiff = Optional.of(diff);
}
this.commentListDiff = new UMLCommentListDiff(removedAttribute.getComments(), addedAttribute.getComments());
checkUnmatchedStatementsBeingCommented();
}

public UMLOperationBodyMapper(UMLInitializer initializer1, UMLInitializer initializer2, UMLAbstractClassDiff classDiff) throws RefactoringMinerTimedOutException {
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/gr/uom/java/xmi/diff/UMLAttributeDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class UMLAttributeDiff {
private UMLOperationBodyMapper mapper;
private UMLAbstractClassDiff classDiff;
private UMLModelDiff modelDiff;
private Optional<UMLJavadocDiff> javadocDiff = Optional.empty();
private UMLCommentListDiff commentListDiff;

public UMLAttributeDiff(UMLAttribute removedAttribute, UMLAttribute addedAttribute, UMLAbstractClassDiff classDiff, UMLModelDiff modelDiff) throws RefactoringMinerTimedOutException {
this.classDiff = classDiff;
Expand Down Expand Up @@ -125,6 +127,11 @@ else if(!removedAttribute.getType().equalsQualified(addedAttribute.getType()))
this.annotationListDiff = new UMLAnnotationListDiff(removedAttribute.getAnnotations(), addedAttribute.getAnnotations());
AbstractExpression initializer1 = removedAttribute.getVariableDeclaration().getInitializer();
AbstractExpression initializer2 = addedAttribute.getVariableDeclaration().getInitializer();
if(removedAttribute.getJavadoc() != null && addedAttribute.getJavadoc() != null) {
UMLJavadocDiff diff = new UMLJavadocDiff(removedAttribute.getJavadoc(), addedAttribute.getJavadoc());
this.javadocDiff = Optional.of(diff);
}
this.commentListDiff = new UMLCommentListDiff(removedAttribute.getComments(), addedAttribute.getComments());
if(initializer1 != null && initializer2 != null) {
if(!initializer1.getExpression().equals(initializer2.getExpression())) {
initializerChanged = true;
Expand Down Expand Up @@ -195,6 +202,14 @@ public boolean isQualifiedTypeChanged() {
return qualifiedTypeChanged;
}

public Optional<UMLJavadocDiff> getJavadocDiff() {
return javadocDiff;
}

public UMLCommentListDiff getCommentListDiff() {
return commentListDiff;
}

public Optional<UMLOperationBodyMapper> getInitializerMapper() {
return Optional.ofNullable(mapper);
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/gr/uom/java/xmi/diff/UMLEnumConstantDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class UMLEnumConstantDiff {
private boolean argumentsChanged;
private UMLAnnotationListDiff annotationListDiff;
private UMLAnonymousClassDiff anonymousClassDiff;
private Optional<UMLJavadocDiff> javadocDiff = Optional.empty();
private UMLCommentListDiff commentListDiff;
private Set<Refactoring> refactorings = new LinkedHashSet<Refactoring>();

public UMLEnumConstantDiff(UMLEnumConstant removedEnumConstant, UMLEnumConstant addedEnumConstant, UMLAbstractClassDiff classDiff, UMLModelDiff modelDiff) throws RefactoringMinerTimedOutException {
Expand All @@ -46,6 +48,11 @@ public UMLEnumConstantDiff(UMLEnumConstant removedEnumConstant, UMLEnumConstant
}
}
}
if(removedEnumConstant.getJavadoc() != null && addedEnumConstant.getJavadoc() != null) {
UMLJavadocDiff diff = new UMLJavadocDiff(removedEnumConstant.getJavadoc(), addedEnumConstant.getJavadoc());
this.javadocDiff = Optional.of(diff);
}
this.commentListDiff = new UMLCommentListDiff(removedEnumConstant.getComments(), addedEnumConstant.getComments());
}

public UMLEnumConstant getRemovedEnumConstant() {
Expand All @@ -64,6 +71,14 @@ public boolean isArgumentsChanged() {
return argumentsChanged;
}

public Optional<UMLJavadocDiff> getJavadocDiff() {
return javadocDiff;
}

public UMLCommentListDiff getCommentListDiff() {
return commentListDiff;
}

public Optional<UMLAnonymousClassDiff> getAnonymousClassDiff() {
return Optional.ofNullable(anonymousClassDiff);
}
Expand Down

0 comments on commit c00596f

Please sign in to comment.