From d74ffab3bafd50d054576423274bc70128fe2506 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Wed, 14 Aug 2024 17:54:49 +0200 Subject: [PATCH] Python, DS: Use the new interpreter configuration UI to unify it between DS and PyCharm. GitOrigin-RevId: 9faec46e4265e4a085c8f6acabee78551360c6a4 --- .../steps/PyCharmNewProjectStep.java | 38 +++++++------------ .../pluginCore/resources/META-INF/plugin.xml | 3 -- .../newProject/PythonProjectGenerator.java | 5 +-- 3 files changed, 14 insertions(+), 32 deletions(-) diff --git a/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/newProject/steps/PyCharmNewProjectStep.java b/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/newProject/steps/PyCharmNewProjectStep.java index 7c8303fb6f64..d6466ccc7bb1 100644 --- a/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/newProject/steps/PyCharmNewProjectStep.java +++ b/python/ide/impl/src/com/intellij/pycharm/community/ide/impl/newProject/steps/PyCharmNewProjectStep.java @@ -8,10 +8,9 @@ import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.util.Pair; import com.intellij.openapi.wm.impl.welcomeScreen.collapsedActionGroup.CollapsedActionGroup; import com.intellij.platform.DirectoryProjectGenerator; -import com.intellij.util.ObjectUtils; import com.intellij.pycharm.community.ide.impl.PyCharmCommunityCustomizationBundle; +import com.intellij.util.ObjectUtils; import com.jetbrains.python.newProject.*; -import com.jetbrains.python.newProject.steps.ProjectSpecificSettingsStep; import com.jetbrains.python.newProject.steps.PythonProjectSpecificSettingsStep; import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; @@ -21,8 +20,6 @@ import java.util.Arrays; import java.util.Comparator; import java.util.List; -import static com.jetbrains.python.newProject.PythonProjectGenerator.useNewInterpreterCreationUi; - public final class PyCharmNewProjectStep extends AbstractNewProjectStep { public PyCharmNewProjectStep() { super(new Customization()); @@ -50,16 +47,14 @@ public final class PyCharmNewProjectStep extends AbstractNewProjectStep(npwGenerator); } - else if (useNewInterpreterCreationUi()) { - return new PythonProjectSpecificSettingsStep<>(projectGenerator, callback); - } else { - return new ProjectSpecificSettingsStep<>(projectGenerator, callback); + return new PythonProjectSpecificSettingsStep<>(projectGenerator, callback); } } @Override - public AnAction[] getActions(@NotNull List> generators, @NotNull AbstractCallback callback) { + public AnAction[] getActions(@NotNull List> generators, + @NotNull AbstractCallback callback) { generators = new ArrayList<>(generators); generators.sort(Comparator.comparing(DirectoryProjectGenerator::getName)); generators.sort(Comparator.comparingInt(value -> { @@ -72,23 +67,16 @@ public final class PyCharmNewProjectStep extends AbstractNewProjectStep new Pair<>(generator, getActions((DirectoryProjectGenerator)generator, callback))) - .partitioningBy((pair) -> pair.first instanceof PythonProjectGenerator); - - var python = new DefaultActionGroup(PyCharmCommunityCustomizationBundle.message("new.project.python.group.name"), - map.get(true).stream().flatMap(pair -> Arrays.stream(pair.second)).toList()); - var other = new CollapsedActionGroup(PyCharmCommunityCustomizationBundle.message("new.project.other.group.name"), - map.get(false).stream().flatMap(pair -> Arrays.stream(pair.second)).toList()); - return new AnAction[] { python, other }; - } - //noinspection unchecked - return StreamEx.of(generators) - .flatMap(generator -> StreamEx.of(getActions((DirectoryProjectGenerator)generator, callback))) - .toArray(EMPTY_ARRAY); + var map = StreamEx.of(generators) + .map(generator -> new Pair<>(generator, getActions((DirectoryProjectGenerator)generator, callback))) + .partitioningBy((pair) -> pair.first instanceof PythonProjectGenerator); + + var python = new DefaultActionGroup(PyCharmCommunityCustomizationBundle.message("new.project.python.group.name"), + map.get(true).stream().flatMap(pair -> Arrays.stream(pair.second)).toList()); + var other = new CollapsedActionGroup(PyCharmCommunityCustomizationBundle.message("new.project.other.group.name"), + map.get(false).stream().flatMap(pair -> Arrays.stream(pair.second)).toList()); + return new AnAction[]{python, other}; } } } diff --git a/python/pluginCore/resources/META-INF/plugin.xml b/python/pluginCore/resources/META-INF/plugin.xml index c860a4d3ac45..057439ed70de 100644 --- a/python/pluginCore/resources/META-INF/plugin.xml +++ b/python/pluginCore/resources/META-INF/plugin.xml @@ -625,9 +625,6 @@ The Python plug-in provides smart editing for Python scripts. The feature set of - - diff --git a/python/src/com/jetbrains/python/newProject/PythonProjectGenerator.java b/python/src/com/jetbrains/python/newProject/PythonProjectGenerator.java index b8b4ba2bfd35..73f405de2fa6 100644 --- a/python/src/com/jetbrains/python/newProject/PythonProjectGenerator.java +++ b/python/src/com/jetbrains/python/newProject/PythonProjectGenerator.java @@ -188,9 +188,6 @@ public abstract class PythonProjectGenerator ext final Sdk createdSdk = ((PyLazySdk)sdk).create(); LOGGER.info(String.format("Lazy PythonSDK generated sdk: %s", createdSdk)); settings.setSdk(createdSdk); - if (createdSdk != null && !useNewInterpreterCreationUi()) { - SdkConfigurationUtil.addSdk(createdSdk); - } } final PyProjectSynchronizer synchronizer = sdk != null ? PyProjectSynchronizerProvider.getSynchronizer(sdk) : null; @@ -516,6 +513,6 @@ public abstract class PythonProjectGenerator ext } public static boolean useNewInterpreterCreationUi() { - return Registry.is("python.new.interpreter.creation.ui") && !PlatformUtils.isDataSpell(); + return true; } }