@Override
  public boolean isApplicable(@NotNull PsiElement element, @NotNull Document copyDocument, int newOffset) {
    if (!PsiUtil.isAvailable(JavaFeature.TRY_WITH_RESOURCES, element)) return false;

    PsiExpression initializer = JavaPostfixTemplatesUtils.getTopmostExpression(element);

    if (initializer == null) return false;

    return DumbService.getInstance(initializer.getProject()).computeWithAlternativeResolveEnabled(() -> {
      if (!(initializer.getType() instanceof PsiClassType classType)) return false;
      final PsiClass aClass = classType.resolve();
      Project project = element.getProject();
      final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
      final PsiClass autoCloseable = facade.findClass(CommonClassNames.JAVA_LANG_AUTO_CLOSEABLE, ProjectScope.getLibrariesScope(project));
      return InheritanceUtil.isInheritorOrSelf(aClass, autoCloseable, true);
    });
  }
@Override
  public boolean isApplicable(@NotNull PsiElement element, @NotNull Document copyDocument, int newOffset)