FileChooserDescriptor () { final var descriptor = new FileChooserDescriptor(true, false, false, false, false, false) { @Override public void validateSelectedFiles(VirtualFile @NotNull [] files) throws Exception { if (files.length != 0) { VirtualFile file = files[0]; if (!isLocatedInWsl(file) && !isValidSdkHome(file.getPath())) { throw new Exception(PyBundle.message("python.sdk.error.invalid.interpreter.name", file.getName())); } } } @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { // TODO: add a better, customizable filtering if (!file.isDirectory()) { if (isLocatedInLocalWindowsFS(file)) { String path = file.getPath(); boolean looksExecutable = false; for (String ext : PythonSdkUtil.WINDOWS_EXECUTABLE_SUFFIXES) { if (path.endsWith(ext)) { looksExecutable = true; break; } } return looksExecutable && super.isFileVisible(file, showHiddenFiles); } } return super.isFileVisible(file, showHiddenFiles); } }.withTitle(PyBundle.message("sdk.select.path")).withShowHiddenFiles(SystemInfo.isUnix); // XXX: Workaround for PY-21787 and PY-43507 since the native macOS dialog always follows symlinks if (SystemInfo.isMac) { descriptor.setForcedToUseIdeaFileChooser(true); } return descriptor; }