Moved extension comparing to beginning
authorKiryl Chetyrbak <kirylchetyrbak@gmail.com>
Tue, 4 Apr 2017 17:10:04 +0000 (13:10 -0400)
committerKiryl Chetyrbak <kirylchetyrbak@gmail.com>
Tue, 4 Apr 2017 17:10:04 +0000 (13:10 -0400)
python/src/com/jetbrains/python/sdk/PreferredSdkComparator.java

index 85a68932962b3eddc491501d48903ba78d9374cc..6de0c34e5d515c7422fae998ca22eb1ada17d8e5 100644 (file)
@@ -32,6 +32,14 @@ public class PreferredSdkComparator implements Comparator<Sdk> {
 
   @Override
   public int compare(Sdk o1, Sdk o2) {
+    for (PySdkWeightProvider provider : Extensions.getExtensions(PySdkWeightProvider.EP_NAME)) {
+      int weight1 = provider.getWeight(o1);
+      int weight2 = provider.getWeight(o2);
+      if(weight1 != weight2) {
+        return weight2 - weight1;
+      }
+    }
+
     final PythonSdkFlavor flavor1 = PythonSdkFlavor.getFlavor(o1);
     final PythonSdkFlavor flavor2 = PythonSdkFlavor.getFlavor(o2);
     int remote1Weight = PySdkUtil.isRemote(o1) ? 0 : 1;
@@ -50,20 +58,13 @@ public class PreferredSdkComparator implements Comparator<Sdk> {
     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;
     }
 
-    for (PySdkWeightProvider provider : Extensions.getExtensions(PySdkWeightProvider.EP_NAME)) {
-      int weight1 = provider.getWeight(o1);
-      int weight2 = provider.getWeight(o2);
-      if(weight1 != weight2) {
-        return weight2 - weight1;
-      }
-    }
-
     return -Comparing.compare(o1.getVersionString(), o2.getVersionString());
   }
 }
\ No newline at end of file