String (PsiComment _comment) { final PsiJavaDocumentedElement commentOwner = ((PsiDocComment)_comment).getOwner(); if (Registry.is("java.javadoc.use.templates")) { String javaDocStub = generateStubFromTemplate(commentOwner); if (javaDocStub != null) return javaDocStub; } final StringBuilder builder = new StringBuilder(); final CodeDocumentationAwareCommenter commenter = (CodeDocumentationAwareCommenter)LanguageCommenters.INSTANCE.forLanguage(_comment.getLanguage()); if (commentOwner instanceof PsiMethod psiMethod) { generateParametersTakingDocFromSuperMethods(builder, commenter, psiMethod); final PsiTypeParameterList typeParameterList = psiMethod.getTypeParameterList(); if (typeParameterList != null) { createTypeParamsListComment(builder, commenter, typeParameterList); } if (psiMethod.getReturnType() != null && !PsiTypes.voidType().equals(psiMethod.getReturnType())) { builder.append(CodeDocumentationUtil.createDocCommentLine(RETURN_TAG, _comment.getContainingFile(), commenter)); builder.append(LINE_SEPARATOR); } final PsiJavaCodeReferenceElement[] references = psiMethod.getThrowsList().getReferenceElements(); for (PsiJavaCodeReferenceElement reference : references) { builder.append(CodeDocumentationUtil.createDocCommentLine(THROWS_TAG, _comment.getContainingFile(), commenter)); builder.append(reference.getText()); builder.append(LINE_SEPARATOR); } } else if (commentOwner instanceof PsiClass) { if (((PsiClass)commentOwner).isRecord()) { for (PsiRecordComponent component : ((PsiClass)commentOwner).getRecordComponents()) { builder.append(CodeDocumentationUtil.createDocCommentLine(PARAM_TAG, commentOwner.getContainingFile(), commenter)); builder.append(component.getName()); builder.append(LINE_SEPARATOR); } } final PsiTypeParameterList typeParameterList = ((PsiClass)commentOwner).getTypeParameterList(); if (typeParameterList != null) { createTypeParamsListComment(builder, commenter, typeParameterList); } } return builder.length() > 0 ? builder.toString() : null; }