void (@NotNull PsiElement anchor) { checkState(); if (!comments.isEmpty()) { PsiElement parent = anchor.getParent(); PsiElementFactory factory = JavaPsiFacade.getElementFactory(anchor.getProject()); for (PsiComment comment : comments) { if (shouldIgnore(comment)) continue; PsiElement added = parent.addBefore(factory.createCommentFromText(comment.getText(), anchor), anchor); PsiElement prevSibling = added.getPrevSibling(); if (prevSibling instanceof PsiWhiteSpace) { PsiElement prev = anchor.getPrevSibling(); ASTNode whiteSpaceBefore = normalizeWhiteSpace((PsiWhiteSpace)prevSibling, prev); parent.getNode().addChild(whiteSpaceBefore, anchor.getNode()); if (prev instanceof PsiWhiteSpace) { prev.delete(); } } } } comments = null; }