mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'feature/ext-point-for-sdk-comparator' of https://github.com/da1z/intellij-community
This commit is contained in:
@@ -658,6 +658,7 @@
|
||||
<extensionPoint qualifiedName="Pythonid.pythonFlavorProvider" interface="com.jetbrains.python.sdk.flavors.PythonFlavorProvider"/>
|
||||
<extensionPoint qualifiedName="Pythonid.debugSessionFactory" interface="com.jetbrains.python.debugger.PyDebugSessionFactory"/>
|
||||
<extensionPoint qualifiedName="Pythonid.customPackageIdentifier" interface="com.jetbrains.python.psi.PyCustomPackageIdentifier"/>
|
||||
<extensionPoint qualifiedName="Pythonid.pythonSdkComparator" interface="com.jetbrains.python.sdk.PySdkComparator" />
|
||||
</extensionPoints>
|
||||
|
||||
<extensions defaultExtensionNs="Pythonid">
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.jetbrains.python.sdk;
|
||||
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.jetbrains.python.sdk.flavors.CPythonSdkFlavor;
|
||||
@@ -30,6 +31,13 @@ public class PreferredSdkComparator implements Comparator<Sdk> {
|
||||
|
||||
@Override
|
||||
public int compare(Sdk o1, Sdk o2) {
|
||||
for (PySdkComparator comparator : Extensions.getExtensions(PySdkComparator.EP_NAME)) {
|
||||
int result = comparator.compare(o1, o2);
|
||||
if(result != 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
final PythonSdkFlavor flavor1 = PythonSdkFlavor.getFlavor(o1);
|
||||
final PythonSdkFlavor flavor2 = PythonSdkFlavor.getFlavor(o2);
|
||||
int remote1Weight = PySdkUtil.isRemote(o1) ? 0 : 1;
|
||||
@@ -48,6 +56,7 @@ 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) {
|
||||
@@ -56,4 +65,4 @@ public class PreferredSdkComparator implements Comparator<Sdk> {
|
||||
|
||||
return -Comparing.compare(o1.getVersionString(), o2.getVersionString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jetbrains.python.sdk;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
|
||||
/**
|
||||
* Created by kirylch on 3/29/2017.
|
||||
*/
|
||||
public interface PySdkComparator {
|
||||
ExtensionPointName<PySdkComparator> EP_NAME = ExtensionPointName.create("Pythonid.pythonSdkComparator");
|
||||
|
||||
int compare(Sdk sdk1, Sdk sdk2);
|
||||
}
|
||||
Reference in New Issue
Block a user