void () { final PsiElementFactory factory = getFactory(); final PsiMethod method = factory.createMethodFromText( """ /** * Javadoc * @param p1 */ void m();""", null); final PsiDocComment docComment = method.getDocComment(); assertNotNull(docComment); final PsiDocTag[] tags = docComment.getTags(); final PsiDocTag tag2 = factory.createParamTag("p2", ""); docComment.addBefore(tag2, tags[0]); assertEquals( """ /** * Javadoc * @param p2 * @param p1 */""", docComment.getText()); }