Skip to content

Commit

Permalink
Support field initializer moved from constructor to field declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Feb 18, 2024
1 parent 6729dae commit c3cbce4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 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 @@ -130,6 +130,22 @@ else if(!removedAttribute.getType().equalsQualified(addedAttribute.getType()))
}
else if(initializer1 == null && initializer2 != null) {
initializerChanged = true;
for(UMLOperationBodyMapper operationBodyMapper : operationBodyMapperList) {
if(operationBodyMapper.getContainer1().isConstructor() && operationBodyMapper.getContainer2().isConstructor()) {
for(AbstractCodeFragment fragment1 : operationBodyMapper.getNonMappedLeavesT1()) {
String fragment = fragment1.getString();
if((fragment.startsWith(addedAttribute.getName() + "=") ||
fragment.startsWith("this." + addedAttribute.getName() + "=")) &&
fragment.endsWith(";\n")) {
String variableInitializer = fragment.substring(fragment.indexOf("=")+1, fragment.lastIndexOf(";\n"));
List<LeafExpression> leafExpressions1 = fragment1.findExpression(variableInitializer);
if(leafExpressions1.size() == 1) {
this.mapper = new UMLOperationBodyMapper(fragment1, initializer2, operationBodyMapper.getContainer1(), operationBodyMapper.getContainer2(), classDiff, modelDiff);
}
}
}
}
}
}
else if(initializer1 != null && initializer2 == null) {
initializerChanged = true;
Expand Down

0 comments on commit c3cbce4

Please sign in to comment.