mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-18453 Python package management facilities disablement fixed
Enabled by default for non-remote SDKs plus Vagrant, Ssh and WebDeployment credential-based SDKs.
This commit is contained in:
@@ -39,6 +39,7 @@ import com.jetbrains.python.psi.resolve.QualifiedResolveResult;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import com.jetbrains.python.remote.PyCredentialsContribution;
|
||||
import com.jetbrains.python.sdk.CredentialsTypeExChecker;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -195,11 +196,14 @@ public class PyPackageUtil {
|
||||
}
|
||||
|
||||
public static boolean packageManagementEnabled(@Nullable Sdk sdk) {
|
||||
if (!PythonSdkType.isRemote(sdk)) {
|
||||
return true;
|
||||
}
|
||||
return new CredentialsTypeExChecker() {
|
||||
@Override
|
||||
protected boolean checkLanguageContribution(PyCredentialsContribution languageContribution) {
|
||||
return languageContribution.isPackageManagementEnabled();
|
||||
}
|
||||
}.check(sdk);
|
||||
}.withSshContribution(true).withVagrantContribution(true).withWebDeploymentContribution(true).check(sdk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,35 @@ package com.jetbrains.python.sdk;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.remote.RemoteCredentialsHolder;
|
||||
import com.intellij.remote.RemoteSdkAdditionalData;
|
||||
import com.intellij.remote.VagrantBasedCredentialsHolder;
|
||||
import com.intellij.remote.WebDeploymentCredentialsHolder;
|
||||
import com.intellij.remote.ext.CredentialsCase;
|
||||
import com.intellij.remote.ext.LanguageCaseCollector;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.jetbrains.python.remote.PyCredentialsContribution;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class CredentialsTypeExChecker {
|
||||
private boolean mySshContribution;
|
||||
private boolean myVagrantContribution;
|
||||
private boolean myWebDeploymentContribution;
|
||||
|
||||
public CredentialsTypeExChecker withSshContribution(boolean sshContribution) {
|
||||
mySshContribution = sshContribution;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialsTypeExChecker withVagrantContribution(boolean vagrantContribution) {
|
||||
myVagrantContribution = vagrantContribution;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialsTypeExChecker withWebDeploymentContribution(boolean webDeploymentContribution) {
|
||||
myWebDeploymentContribution = webDeploymentContribution;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean check(@Nullable final Sdk sdk) {
|
||||
if (sdk == null) {
|
||||
@@ -37,14 +59,29 @@ public abstract class CredentialsTypeExChecker {
|
||||
}
|
||||
|
||||
public boolean check(RemoteSdkAdditionalData data) {
|
||||
final Ref<Boolean> result = Ref.create(false);
|
||||
final Ref<Boolean> result = Ref.create(mySshContribution);
|
||||
data.switchOnConnectionType(new LanguageCaseCollector<PyCredentialsContribution>() {
|
||||
|
||||
@Override
|
||||
protected void processLanguageContribution(PyCredentialsContribution languageContribution, Object credentials) {
|
||||
result.set(checkLanguageContribution(languageContribution));
|
||||
}
|
||||
}.collectCases(PyCredentialsContribution.class));
|
||||
}.collectCases(PyCredentialsContribution.class, new CredentialsCase.Ssh() {
|
||||
@Override
|
||||
public void process(RemoteCredentialsHolder credentials) {
|
||||
result.set(mySshContribution);
|
||||
}
|
||||
}, new CredentialsCase.Vagrant() {
|
||||
@Override
|
||||
public void process(VagrantBasedCredentialsHolder credentials) {
|
||||
result.set(myVagrantContribution);
|
||||
}
|
||||
}, new CredentialsCase.WebDeployment() {
|
||||
@Override
|
||||
public void process(WebDeploymentCredentialsHolder credentials) {
|
||||
result.set(myWebDeploymentContribution);
|
||||
}
|
||||
}));
|
||||
return result.get();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user