void () { CommandProcessor.getInstance().executeCommand(getProject(), () -> ApplicationManager.getApplication().runWriteAction(() -> { final PsiElementFactory factory = getFactory(); final PsiJavaFile psiFile; try { psiFile = (PsiJavaFile)createFile("aaa.java", """ class A {/** * Javadoc * @param p1 * @param p3 */ void m();}"""); final PsiClass psiClass = psiFile.getClasses()[0]; final PsiMethod method = psiClass.getMethods()[0]; PsiDocComment docComment = method.getDocComment(); assertNotNull(docComment); final PsiDocTag[] tags = docComment.getTags(); final PsiDocTag tag2 = factory.createParamTag("p2", ""); docComment.addAfter(tag2, tags[0]); docComment = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(docComment); assertEquals( """ /** * Javadoc * @param p1 * @param p2 * @param p3 */""", docComment.getText()); } catch (IncorrectOperationException e) {} }), "", null); }