mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 05:21:29 +07:00
Python, DS: Use the new interpreter configuration UI to unify it between DS and PyCharm.
GitOrigin-RevId: 9faec46e4265e4a085c8f6acabee78551360c6a4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
48290d78a4
commit
d74ffab3ba
@@ -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<PyNewProjectSettings> {
|
||||
public PyCharmNewProjectStep() {
|
||||
super(new Customization());
|
||||
@@ -50,16 +47,14 @@ public final class PyCharmNewProjectStep extends AbstractNewProjectStep<PyNewPro
|
||||
//noinspection unchecked
|
||||
return new NewProjectWizardProjectSettingsStep<PyNewProjectSettings>(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<? extends DirectoryProjectGenerator<?>> generators, @NotNull AbstractCallback<PyNewProjectSettings> callback) {
|
||||
public AnAction[] getActions(@NotNull List<? extends DirectoryProjectGenerator<?>> generators,
|
||||
@NotNull AbstractCallback<PyNewProjectSettings> 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<PyNewPro
|
||||
return 0;
|
||||
}));
|
||||
|
||||
if (useNewInterpreterCreationUi()) {
|
||||
//noinspection unchecked
|
||||
var map = StreamEx.of(generators)
|
||||
.map(generator -> new Pair<>(generator, getActions((DirectoryProjectGenerator<PyNewProjectSettings>)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<PyNewProjectSettings>)generator, callback)))
|
||||
.toArray(EMPTY_ARRAY);
|
||||
var map = StreamEx.of(generators)
|
||||
.map(generator -> new Pair<>(generator, getActions((DirectoryProjectGenerator<PyNewProjectSettings>)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};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -625,9 +625,6 @@ The Python plug-in provides smart editing for Python scripts. The feature set of
|
||||
<lookup.usageDetails implementation="com.jetbrains.python.statistics.PyCompletionStatisticLogger"/>
|
||||
<statistics.collectorExtension implementation="com.jetbrains.python.statistics.PyCompletionUsageExtension"/>
|
||||
|
||||
<registryKey key="python.new.interpreter.creation.ui" defaultValue="true"
|
||||
description="Enable new UI for adding Python interpreter in New Project dialog."/>
|
||||
|
||||
<!-- Parameter Info -->
|
||||
<registryKey key="python.parameter.info.show.all.hints" defaultValue="false"
|
||||
description="Show type hints for all parameters in parameter info window"/>
|
||||
|
||||
@@ -188,9 +188,6 @@ public abstract class PythonProjectGenerator<T extends PyNewProjectSettings> 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<T extends PyNewProjectSettings> ext
|
||||
}
|
||||
|
||||
public static boolean useNewInterpreterCreationUi() {
|
||||
return Registry.is("python.new.interpreter.creation.ui") && !PlatformUtils.isDataSpell();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user