PY-21590 PY-21002 Cache installed packages for a remote SDK created in New Project dialog

I removed the old check (now obsolete) that prevented caching of the
list of installed packages in SDKs with unset interpreter paths. It
turned out to be the case with new remote interpreters created right in
"New Project" dialog where detecting interpreters paths is delayed
until the moment of actual project initialization when PythonSdkUpdater
is run.

It led to repetitive requesting the list of installed packages that,
first, badly affected the responsiveness of the dialog (PY-21590) and
also caused network operations on EDT when installed packages were
requested once again under modal progress indicators inside the write
action in the Django project generator (PY-21002) (platform executes
such tasks directly of EDT to prevent possible deadlocks).
This commit is contained in:
Mikhail Golubev
2017-04-12 18:36:34 +03:00
parent 58f6c40cca
commit d83f1a84fd
@@ -17,8 +17,6 @@ package com.jetbrains.python.packaging;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.vfs.VirtualFile;
import com.jetbrains.python.packaging.ui.PyCondaManagementService;
import com.jetbrains.python.packaging.ui.PyPackageManagementService;
import com.jetbrains.python.sdk.PythonSdkType;
@@ -47,17 +45,11 @@ public class PyPackageManagersImpl extends PyPackageManagers {
else {
manager = new PyPackageManagerImpl(sdk);
}
if (sdkIsSetUp(sdk))
myInstances.put(key, manager);
myInstances.put(key, manager);
}
return manager;
}
private static boolean sdkIsSetUp(@NotNull final Sdk sdk) {
final VirtualFile[] roots = sdk.getRootProvider().getFiles(OrderRootType.CLASSES);
return roots.length != 0;
}
public PyPackageManagementService getManagementService(Project project, Sdk sdk) {
if (PyCondaPackageManagerImpl.isCondaVEnv(sdk)) {
return new PyCondaManagementService(project, sdk);