private static boolean containsGroovyResources(Module module, VirtualFile root, boolean isSmartMode) {
    if (isSmartMode) {
      Collection<?> files = FileTypeIndex.getFiles(GroovyFileType.GROOVY_FILE_TYPE, GlobalSearchScopes.directoryScope(module.getProject(), root, true));
      return !files.isEmpty();
    } else {
      return !ModuleRootManager.getInstance(module).getFileIndex().iterateContentUnderDirectory(root, file -> {
        if (!file.isDirectory() && FileTypeRegistry.getInstance().isFileOfType(file, GroovyFileType.GROOVY_FILE_TYPE)) {
          return false; // found
        }
        return true;
      });
    }
  }
private static boolean containsGroovyResources(Module module, VirtualFile root, boolean isSmartMode)