From ae3f1ec15511ca2e1cf697b06d0117e37c386d92 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Fri, 2 Mar 2018 17:15:32 +0700 Subject: [PATCH] CommentTracker#deleteAndRestoreComments: stop at file level --- .../src/com/siyeh/ig/psiutils/CommentTracker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/CommentTracker.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/CommentTracker.java index 901d917f73d1..fe8024f51627 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/CommentTracker.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/CommentTracker.java @@ -111,7 +111,7 @@ public class CommentTracker { public void deleteAndRestoreComments(@NotNull PsiElement element) { grabCommentsOnDelete(element); PsiElement anchor = element; - while (anchor.getParent() != null && anchor.getParent().getFirstChild() == anchor) { + while (anchor.getParent() != null && !(anchor.getParent() instanceof PsiFile) && anchor.getParent().getFirstChild() == anchor) { anchor = anchor.getParent(); } insertCommentsBefore(anchor);