don't duplicate symlink in suggested interpreter path

This commit is contained in:
Ekaterina Tuzova
2014-03-04 18:50:41 +04:00
parent f95d39dd51
commit 49a5a3f836
2 changed files with 11 additions and 10 deletions
@@ -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;