PsiDocComment (PsiMethod method, String resourceName) { PsiClass containingClass = method.getContainingClass(); assert containingClass != null : method; String containingClassName = containingClass.getName(); assert containingClassName != null : containingClass; try { String text; try (InputStream commentStream = JavaDocInfoGenerator.class.getResourceAsStream(resourceName)) { if (commentStream == null) return null; byte[] bytes = FileUtil.loadBytes(commentStream); text = new String(bytes, StandardCharsets.UTF_8); } text = StringUtil.replace(text, "<ClassName>", containingClassName); return JavaPsiFacade.getElementFactory(myProject).createDocCommentFromText(text); } catch (IOException | IncorrectOperationException e) { LOG.info(e); return null; } }