From 18b7aab93c0394338d6578ea09962443bf92ef1b Mon Sep 17 00:00:00 2001 From: Alexander Koshevoy Date: Tue, 9 Feb 2016 18:11:16 +0300 Subject: [PATCH] PY-18453 Python package management facilities disablement fixed Enabled by default for non-remote SDKs plus Vagrant, Ssh and WebDeployment credential-based SDKs. --- .../python/packaging/PyPackageUtil.java | 6 ++- .../python/sdk/CredentialsTypeExChecker.java | 41 ++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/python/src/com/jetbrains/python/packaging/PyPackageUtil.java b/python/src/com/jetbrains/python/packaging/PyPackageUtil.java index 56172f3b19e1..178ede13f93c 100644 --- a/python/src/com/jetbrains/python/packaging/PyPackageUtil.java +++ b/python/src/com/jetbrains/python/packaging/PyPackageUtil.java @@ -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); } } diff --git a/python/src/com/jetbrains/python/sdk/CredentialsTypeExChecker.java b/python/src/com/jetbrains/python/sdk/CredentialsTypeExChecker.java index 92b52a903e45..2a3ae5f4179f 100644 --- a/python/src/com/jetbrains/python/sdk/CredentialsTypeExChecker.java +++ b/python/src/com/jetbrains/python/sdk/CredentialsTypeExChecker.java @@ -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 result = Ref.create(false); + final Ref result = Ref.create(mySshContribution); data.switchOnConnectionType(new LanguageCaseCollector() { @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(); }