diff --git a/src/main/java/org/refactoringminer/astDiff/matchers/wrappers/JavaDocMatcher.java b/src/main/java/org/refactoringminer/astDiff/matchers/wrappers/JavaDocMatcher.java index 7df22f989f..3084faf54a 100644 --- a/src/main/java/org/refactoringminer/astDiff/matchers/wrappers/JavaDocMatcher.java +++ b/src/main/java/org/refactoringminer/astDiff/matchers/wrappers/JavaDocMatcher.java @@ -18,8 +18,7 @@ import java.util.Optional; -import static org.refactoringminer.astDiff.utils.TreeUtilFunctions.areBothFromThisType; -import static org.refactoringminer.astDiff.utils.TreeUtilFunctions.isFromType; +import static org.refactoringminer.astDiff.utils.TreeUtilFunctions.*; /* Created by pourya on 2024-05-22*/ public class JavaDocMatcher extends OptimizationAwareMatcher implements TreeMatcher { @@ -93,8 +92,14 @@ private void processJavaDocs(Tree srcTree, Tree dstTree, UMLJavadoc srcUMLJavaDo { if (srcTag.isIsoStructuralTo(dstTag)) optimizationData.getSubtreeMappings().addMappingRecursively(srcTag,dstTag); - else - optimizationData.getSubtreeMappings().addMapping(srcTag,dstTag); + else { + optimizationData.getSubtreeMappings().addMapping(srcTag, dstTag); + Tree srcTagName = findFirstByType(srcTag, Constants.TAG_NAME); + Tree dstTagName = findFirstByType(dstTag, Constants.TAG_NAME); + if (srcTagName != null && dstTagName != null) + if (srcTagName.isIsoStructuralTo(dstTagName)) + optimizationData.getSubtreeMappings().addMapping(srcTagName, dstTagName); + } } } } diff --git a/src/main/java/org/refactoringminer/astDiff/utils/Constants.java b/src/main/java/org/refactoringminer/astDiff/utils/Constants.java index 2b01416502..7e474b84c2 100644 --- a/src/main/java/org/refactoringminer/astDiff/utils/Constants.java +++ b/src/main/java/org/refactoringminer/astDiff/utils/Constants.java @@ -82,6 +82,7 @@ public class Constants { public static final String JAVA_DOC = "Javadoc"; public static final String TEXT_ELEMENT = "TextElement"; public static final String TAG_ELEMENT = "TagElement"; + public static final String TAG_NAME = "TAG_NAME"; public static final String SIMPLE_TYPE = "SimpleType"; public static final String EXPRESSION_METHOD_REFERENCE = "ExpressionMethodReference"; @@ -92,4 +93,5 @@ public class Constants { public static final String LINE_COMMENT = "LineComment"; public static final String BLOCK_COMMENT = "BlockComment"; + }