Search in sources :

Example 1 with CPythonSdkFlavor

use of com.jetbrains.python.sdk.flavors.CPythonSdkFlavor in project intellij-community by JetBrains.

the class PreferredSdkComparator method compare.

@Override
public int compare(Sdk o1, Sdk o2) {
    final PythonSdkFlavor flavor1 = PythonSdkFlavor.getFlavor(o1);
    final PythonSdkFlavor flavor2 = PythonSdkFlavor.getFlavor(o2);
    int remote1Weight = PySdkUtil.isRemote(o1) ? 0 : 1;
    int remote2Weight = PySdkUtil.isRemote(o2) ? 0 : 1;
    if (remote1Weight != remote2Weight) {
        return remote2Weight - remote1Weight;
    }
    int detectedWeight1 = o1 instanceof PyDetectedSdk ? 0 : 1;
    int detectedWeight2 = o2 instanceof PyDetectedSdk ? 0 : 1;
    if (detectedWeight1 != detectedWeight2) {
        return detectedWeight2 - detectedWeight1;
    }
    int venv1weight = PythonSdkType.isVirtualEnv(o1) ? 0 : 1;
    int venv2weight = PythonSdkType.isVirtualEnv(o2) ? 0 : 1;
    if (venv1weight != venv2weight) {
        return venv2weight - venv1weight;
    }
    int flavor1weight = flavor1 instanceof CPythonSdkFlavor ? 1 : 0;
    int flavor2weight = flavor2 instanceof CPythonSdkFlavor ? 1 : 0;
    if (flavor1weight != flavor2weight) {
        return flavor2weight - flavor1weight;
    }
    return -Comparing.compare(o1.getVersionString(), o2.getVersionString());
}
Also used : CPythonSdkFlavor(com.jetbrains.python.sdk.flavors.CPythonSdkFlavor) PythonSdkFlavor(com.jetbrains.python.sdk.flavors.PythonSdkFlavor) CPythonSdkFlavor(com.jetbrains.python.sdk.flavors.CPythonSdkFlavor)

Aggregations

CPythonSdkFlavor (com.jetbrains.python.sdk.flavors.CPythonSdkFlavor)1 PythonSdkFlavor (com.jetbrains.python.sdk.flavors.PythonSdkFlavor)1