mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't duplicate symlink in suggested interpreter path
This commit is contained in:
@@ -19,10 +19,10 @@ import com.intellij.openapi.util.io.FileSystemUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -36,14 +36,14 @@ public class MacPythonSdkFlavor extends CPythonSdkFlavor {
|
||||
|
||||
@Override
|
||||
public Collection<String> suggestHomePaths() {
|
||||
List<String> candidates = new ArrayList<String>();
|
||||
Set<String> candidates = new HashSet<String>();
|
||||
collectPythonInstallations("/Library/Frameworks/Python.framework/Versions", candidates);
|
||||
collectPythonInstallations("/System/Library/Frameworks/Python.framework/Versions", candidates);
|
||||
UnixPythonSdkFlavor.collectUnixPythons("/usr/local/bin", candidates);
|
||||
return candidates;
|
||||
}
|
||||
|
||||
private static void collectPythonInstallations(String pythonPath, List<String> candidates) {
|
||||
private static void collectPythonInstallations(String pythonPath, Set<String> candidates) {
|
||||
VirtualFile rootVDir = LocalFileSystem.getInstance().findFileByPath(pythonPath);
|
||||
if (rootVDir != null) {
|
||||
if (rootVDir instanceof NewVirtualFile) {
|
||||
@@ -63,7 +63,7 @@ public class MacPythonSdkFlavor extends CPythonSdkFlavor {
|
||||
if (FileSystemUtil.isSymLink(path)) {
|
||||
path = FileSystemUtil.resolveSymLink(path);
|
||||
}
|
||||
if (path != null) {
|
||||
if (path != null && !candidates.contains(path)) {
|
||||
candidates.add(path);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ import com.intellij.openapi.util.io.FileSystemUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -37,12 +37,12 @@ public class UnixPythonSdkFlavor extends CPythonSdkFlavor {
|
||||
|
||||
@Override
|
||||
public Collection<String> suggestHomePaths() {
|
||||
List<String> candidates = new ArrayList<String>();
|
||||
Set<String> candidates = new HashSet<String>();
|
||||
collectUnixPythons("/usr/bin", candidates);
|
||||
return candidates;
|
||||
}
|
||||
|
||||
public static void collectUnixPythons(String path, List<String> candidates) {
|
||||
public static void collectUnixPythons(String path, Set<String> candidates) {
|
||||
VirtualFile rootDir = LocalFileSystem.getInstance().findFileByPath(path);
|
||||
if (rootDir != null) {
|
||||
if (rootDir instanceof NewVirtualFile) {
|
||||
@@ -59,7 +59,8 @@ public class UnixPythonSdkFlavor extends CPythonSdkFlavor {
|
||||
if (FileSystemUtil.isSymLink(childPath)) {
|
||||
childPath = FileSystemUtil.resolveSymLink(childPath);
|
||||
}
|
||||
if (childPath != null && !childName.endsWith("-config") && !childName.startsWith("pythonw") && !childName.endsWith("m")) {
|
||||
if (childPath != null && !childName.endsWith("-config") && !childName.startsWith("pythonw") && !childName.endsWith("m") &&
|
||||
!candidates.contains(childPath)) {
|
||||
candidates.add(childPath);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user