LAB-31 Use StandardFileSystems.local() in getExecutablePath to avoid unnecessary casting

GitOrigin-RevId: e2747e6fca1c7a527f3ee26861720260abac1cc0
This commit is contained in:
Stanislav Utikeev
2020-01-15 13:21:30 +03:00
committed by intellij-monorepo-bot
parent 3607636422
commit 1b72efbf1c

View File

@@ -315,16 +315,17 @@ public class PythonSdkUtil {
File binPath = new File(homeDirectory);
File binDir = binPath.getParentFile();
if (binDir == null) return null;
VirtualFileSystem localVfs = StandardFileSystems.local();
File runner = new File(binDir, name);
if (runner.exists()) return LocalFileSystem.getInstance().extractPresentableUrl(runner.getPath());
if (runner.exists()) return localVfs.extractPresentableUrl(runner.getPath());
runner = new File(new File(binDir, "Scripts"), name);
if (runner.exists()) return LocalFileSystem.getInstance().extractPresentableUrl(runner.getPath());
if (runner.exists()) return localVfs.extractPresentableUrl(runner.getPath());
runner = new File(new File(binDir.getParentFile(), "Scripts"), name);
if (runner.exists()) return LocalFileSystem.getInstance().extractPresentableUrl(runner.getPath());
if (runner.exists()) return localVfs.extractPresentableUrl(runner.getPath());
runner = new File(new File(binDir.getParentFile(), "local"), name);
if (runner.exists()) return LocalFileSystem.getInstance().extractPresentableUrl(runner.getPath());
if (runner.exists()) return localVfs.extractPresentableUrl(runner.getPath());
runner = new File(new File(new File(binDir.getParentFile(), "local"), "bin"), name);
if (runner.exists()) return LocalFileSystem.getInstance().extractPresentableUrl(runner.getPath());
if (runner.exists()) return localVfs.extractPresentableUrl(runner.getPath());
// if interpreter is a symlink
if (FileSystemUtil.isSymLink(homeDirectory)) {
@@ -335,9 +336,9 @@ public class PythonSdkUtil {
}
// Search in standard unix path
runner = new File(new File("/usr", "bin"), name);
if (runner.exists()) return LocalFileSystem.getInstance().extractPresentableUrl(runner.getPath());
if (runner.exists()) return localVfs.extractPresentableUrl(runner.getPath());
runner = new File(new File(new File("/usr", "local"), "bin"), name);
if (runner.exists()) return LocalFileSystem.getInstance().extractPresentableUrl(runner.getPath());
if (runner.exists()) return localVfs.extractPresentableUrl(runner.getPath());
return null;
}