@Override
 protected boolean isValidForFile(
     @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
   if (file instanceof PsiCompiledElement) return false;
   if (!GroovyFileType.GROOVY_FILE_TYPE.equals(file.getFileType())) return false;
   return !GradleConstants.SETTINGS_FILE_NAME.equals(file.getName())
       && file.getName().endsWith(GradleConstants.EXTENSION);
 }
  @Nullable
  @Override
  public VirtualFile adjust(@NotNull VirtualFile configPath) {
    if (!configPath.isDirectory()) {
      return configPath;
    }

    VirtualFile result = configPath.findChild(GradleConstants.DEFAULT_SCRIPT_NAME);
    if (result != null) {
      return result;
    }

    for (VirtualFile child : configPath.getChildren()) {
      String name = child.getName();
      if (!name.endsWith(GradleConstants.EXTENSION)) {
        continue;
      }
      if (!GradleConstants.SETTINGS_FILE_NAME.equals(name) && !child.isDirectory()) {
        return child;
      }
    }
    return null;
  }