Skip to content

Commit

Permalink
ASTDiff: Extract Duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
pouryafard75 committed May 9, 2024
1 parent bfc4c3f commit 9bb49aa
Showing 1 changed file with 14 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -719,13 +719,8 @@ private static void additionallyMatchedStatements(Tree srcTree, Tree dstTree, Tr
}

private void processClassAnnotations(Tree srcTree, Tree dstTree, UMLAnnotationListDiff annotationListDiff, ExtendedMultiMappingStore mappingStore) {
for (org.apache.commons.lang3.tuple.Pair<UMLAnnotation, UMLAnnotation> umlAnnotationUMLAnnotationPair : annotationListDiff.getCommonAnnotations()) {
Tree srcClassAnnotationTree = TreeUtilFunctions.findByLocationInfo(srcTree , umlAnnotationUMLAnnotationPair.getLeft().getLocationInfo());
Tree dstClassAnnotationTree = TreeUtilFunctions.findByLocationInfo(dstTree, umlAnnotationUMLAnnotationPair.getRight().getLocationInfo());
if (srcClassAnnotationTree == null || dstClassAnnotationTree == null) return;
if (srcClassAnnotationTree.isIsoStructuralTo(dstClassAnnotationTree))
mappingStore.addMappingRecursively(srcClassAnnotationTree,dstClassAnnotationTree);
}
for (org.apache.commons.lang3.tuple.Pair<UMLAnnotation, UMLAnnotation> umlAnnotationUMLAnnotationPair : annotationListDiff.getCommonAnnotations())
processLocationInfoProviders(srcTree, dstTree, mappingStore, umlAnnotationUMLAnnotationPair.getLeft(), umlAnnotationUMLAnnotationPair.getRight());
}

private void matchBlocks(Tree srcStatementNode, Tree dstStatementNode, ExtendedMultiMappingStore mappingStore) {
Expand Down Expand Up @@ -1135,20 +1130,18 @@ private void findVariablesAndMatch(Tree srcTree, Tree dstTree, AbstractCodeMappi
}

private void processClassImplementedInterfaces(Tree srcTree, Tree dstTree, UMLClassBaseDiff classDiff, ExtendedMultiMappingStore mappingStore) {
for (org.apache.commons.lang3.tuple.Pair<UMLType, UMLType> commonInterface : classDiff.getInterfaceListDiff().getCommonInterfaces()) {
Tree srcInterfaceTree = TreeUtilFunctions.findByLocationInfo(srcTree, commonInterface.getLeft().getLocationInfo());
Tree dstInterfaceTree = TreeUtilFunctions.findByLocationInfo(dstTree, commonInterface.getRight().getLocationInfo());
if (srcInterfaceTree == null || dstInterfaceTree == null) return;
if (srcInterfaceTree.isIsoStructuralTo(dstInterfaceTree))
mappingStore.addMappingRecursively(srcInterfaceTree,dstInterfaceTree);
}
for (org.apache.commons.lang3.tuple.Pair<UMLType, UMLType> commonInterface : classDiff.getInterfaceListDiff().getChangedInterfaces()) {
Tree srcInterfaceTree = TreeUtilFunctions.findByLocationInfo(srcTree, commonInterface.getLeft().getLocationInfo());
Tree dstInterfaceTree = TreeUtilFunctions.findByLocationInfo(dstTree, commonInterface.getRight().getLocationInfo());
if (srcInterfaceTree == null || dstInterfaceTree == null) return;
if (srcInterfaceTree.isIsoStructuralTo(dstInterfaceTree))
mappingStore.addMappingRecursively(srcInterfaceTree,dstInterfaceTree);
}
for (org.apache.commons.lang3.tuple.Pair<UMLType, UMLType> commonInterface : classDiff.getInterfaceListDiff().getCommonInterfaces())
processLocationInfoProviders(srcTree, dstTree, mappingStore, commonInterface.getLeft(), commonInterface.getRight());
for (org.apache.commons.lang3.tuple.Pair<UMLType, UMLType> changedInterface : classDiff.getInterfaceListDiff().getChangedInterfaces())
processLocationInfoProviders(srcTree, dstTree, mappingStore, changedInterface.getLeft(), changedInterface.getRight());
}

private static void processLocationInfoProviders(Tree srcTree, Tree dstTree, ExtendedMultiMappingStore mappingStore, LocationInfoProvider left, LocationInfoProvider right) {
Tree srcInterfaceTree = TreeUtilFunctions.findByLocationInfo(srcTree, left.getLocationInfo());
Tree dstInterfaceTree = TreeUtilFunctions.findByLocationInfo(dstTree, right.getLocationInfo());
if (srcInterfaceTree == null || dstInterfaceTree == null) return;
if (srcInterfaceTree.isIsoStructuralTo(dstInterfaceTree))
mappingStore.addMappingRecursively(srcInterfaceTree,dstInterfaceTree);
}

private void processClassAttributes(Tree srcTree, Tree dstTree, UMLAbstractClassDiff classDiff, ExtendedMultiMappingStore mappingStore) {
Expand Down

0 comments on commit 9bb49aa

Please sign in to comment.