private static @Nullable FileTemplate findTemplateByElement(PsiJavaDocumentedElement commentOwner) {
    String templateName = findTemplateNameByElement(commentOwner);
    if (templateName == null) return null;
    try {
      return FileTemplateManager.getInstance(commentOwner.getProject()).getCodeTemplate(templateName);
    }
    catch (IllegalStateException e) {
      return null;
    }
  }
private static @Nullable FileTemplate findTemplateByElement(PsiJavaDocumentedElement commentOwner)