void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiElement parent = element.getParent(); if (!(parent instanceof PsiJavaDocumentedElement documentedElement)) { return; } PsiDocComment docComment = documentedElement.getDocComment(); if (docComment != null) { PsiDocTag existingTag = docComment.findTagByName(DEPRECATED_TAG_NAME); PsiDocTag deprecatedTag = JavaPsiFacade.getElementFactory(project).createDocTagFromText("@" + DEPRECATED_TAG_NAME + TEXT); PsiDocTag addedTag = existingTag != null ? (PsiDocTag)existingTag.replace(deprecatedTag) : (PsiDocTag)docComment.add(deprecatedTag); moveCaretAfter(addedTag, updater); } else { @NlsSafe PsiDocComment newDocComment = JavaPsiFacade.getElementFactory(project).createDocCommentFromText( StringUtil.join("/**\n", " * ", "@" + DEPRECATED_TAG_NAME + TEXT, "\n */") ); PsiDocComment addedComment = (PsiDocComment)documentedElement.addBefore(newDocComment, documentedElement.getFirstChild()); PsiDocTag addedTag = addedComment.findTagByName(DEPRECATED_TAG_NAME); if (addedTag != null) { moveCaretAfter(addedTag, updater); } } }