From f8d59005b18d81507cd5d3c5ba7e060bfaa0a601 Mon Sep 17 00:00:00 2001 From: Pouryafard75 Date: Wed, 2 Oct 2024 13:53:54 -0400 Subject: [PATCH] ASTDiff: Add a null check for common comments --- .../astDiff/matchers/wrappers/CommentMatcher.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/refactoringminer/astDiff/matchers/wrappers/CommentMatcher.java b/src/main/java/org/refactoringminer/astDiff/matchers/wrappers/CommentMatcher.java index bea12cf79..b3ab85ee7 100644 --- a/src/main/java/org/refactoringminer/astDiff/matchers/wrappers/CommentMatcher.java +++ b/src/main/java/org/refactoringminer/astDiff/matchers/wrappers/CommentMatcher.java @@ -20,11 +20,13 @@ public CommentMatcher(UMLCommentListDiff commonComment) { @Override public void match(Tree srcTree, Tree dstTree, ExtendedMultiMappingStore mappingStore) { - for (Pair commonComment : commentListDiff.getCommonComments()) { - Tree srcComment = TreeUtilFunctions.findByLocationInfo(srcTree, commonComment.getLeft().getLocationInfo()); - Tree dstComment = TreeUtilFunctions.findByLocationInfo(dstTree, commonComment.getRight().getLocationInfo()); - if (srcComment != null && dstComment != null) { - mappingStore.addMapping(srcComment, dstComment); + if (commentListDiff.getCommonComments() != null) { + for (Pair commonComment : commentListDiff.getCommonComments()) { + Tree srcComment = TreeUtilFunctions.findByLocationInfo(srcTree, commonComment.getLeft().getLocationInfo()); + Tree dstComment = TreeUtilFunctions.findByLocationInfo(dstTree, commonComment.getRight().getLocationInfo()); + if (srcComment != null && dstComment != null) { + mappingStore.addMapping(srcComment, dstComment); + } } } }