Simplify checking if sdk is editable (PY-45708)

GitOrigin-RevId: 04e98dd7a85a62ddd0b48ad149f6d16780496ea9
This commit is contained in:
Semyon Proshev
2021-07-30 16:35:29 +00:00
committed by intellij-monorepo-bot
parent 623c5570a3
commit 8fab03be0d
2 changed files with 8 additions and 6 deletions
@@ -34,13 +34,13 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.StandardFileSystems;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ExceptionUtil;
import com.intellij.util.PathMappingSettings;
import com.intellij.util.Processor;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.codeInsight.typing.PyTypeShed;
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
import com.jetbrains.python.configuration.PyConfigurableInterpreterList;
import com.jetbrains.python.packaging.PyPackageManager;
import com.jetbrains.python.psi.PyUtil;
import com.jetbrains.python.remote.PyRemoteSdkAdditionalDataBase;
@@ -417,7 +417,7 @@ public class PythonSdkUpdater implements StartupActivity.Background {
When current method was executed for original sdk,
roots changes were not applied since there were no changes in paths to transfer (they were shared with editable copy).
*/
if (PyConfigurableInterpreterList.getInstance(project).getModel().getProjectSdks().containsKey(sdk) &&
if (ArrayUtil.contains(sdk, ProjectJdkTable.getInstance().getAllJdks()) &&
!pathsToTransfer.equals(PyTransferredSdkRootsKt.getPathsToTransfer(sdk))) {
if (project != null) {
PyTransferredSdkRootsKt.removeTransferredRootsFromModulesWithSdk(project, sdk);
@@ -134,11 +134,10 @@ class PySdkPathsTest {
)
.also { module.pythonSdk = it }
sdk.putUserData(PythonSdkType.MOCK_PY_VERSION_KEY, pythonVersion)
Disposer.register(projectModel.project, sdk)
mockPythonPluginDisposable()
runWriteActionAndWait { sdk.getOrCreateAdditionalData() }
PyConfigurableInterpreterList.getInstance(projectModel.project).model.addSdk(sdk)
runWriteActionAndWait { ProjectJdkTable.getInstance().addJdk(sdk) }
val editableSdk = PyConfigurableInterpreterList.getInstance(projectModel.project).model.findSdk(sdk.name)
editableSdk!!.putUserData(PythonSdkType.MOCK_PY_VERSION_KEY, pythonVersion)
@@ -165,6 +164,8 @@ class PySdkPathsTest {
updateSdkPaths(sdk) // since editableSdk was created after additional data had been created for sdk, they share the same data
checkRoots(sdk, module, listOf(moduleRoot), emptyList())
runWriteActionAndWait { ProjectJdkTable.getInstance().removeJdk(sdk) }
}
@Test
@@ -186,8 +187,7 @@ class PySdkPathsTest {
)
.also { module.pythonSdk = it }
sdk.putUserData(PythonSdkType.MOCK_PY_VERSION_KEY, pythonVersion)
Disposer.register(projectModel.project, sdk)
PyConfigurableInterpreterList.getInstance(projectModel.project).model.addSdk(sdk)
runWriteActionAndWait { ProjectJdkTable.getInstance().addJdk(sdk) }
val editableSdk = PyConfigurableInterpreterList.getInstance(projectModel.project).model.findSdk(sdk.name)
editableSdk!!.putUserData(PythonSdkType.MOCK_PY_VERSION_KEY, pythonVersion)
@@ -220,6 +220,8 @@ class PySdkPathsTest {
updateSdkPaths(sdk) // after updateJdk call editableSdk and sdk share the same data
checkRoots(sdk, module, listOf(moduleRoot), emptyList())
runWriteActionAndWait { ProjectJdkTable.getInstance().removeJdk(sdk) }
}
@Test