[python] Rename and move python facets

Facets should be in appropriate packages according to v2

GitOrigin-RevId: cacc729a038f40bfaf9ebb2d89d1e1a744fd71f1
This commit is contained in:
Ilya.Kazakevich
2024-01-16 14:02:45 +01:00
committed by intellij-monorepo-bot
parent f207c9f575
commit 8a334cf9d2
15 changed files with 109 additions and 120 deletions

View File

@@ -7,8 +7,8 @@
<extensions defaultExtensionNs="com.intellij">
<newProjectWizard.languageGenerator implementation="com.jetbrains.python.newProject.PythonNewProjectWizard"/>
<moduleType id="PYTHON_MODULE" implementationClass="com.jetbrains.python.module.PythonModuleType"/>
<facetType implementation="com.jetbrains.python.facet.PythonFacetType"/>
<frameworkSupport implementation="com.jetbrains.python.facet.PythonFrameworkSupportProvider"/>
<facetType implementation="com.intellij.python.community.plugin.java.facet.JavaPythonFacetType"/>
<frameworkSupport implementation="com.intellij.python.community.plugin.java.facet.PythonFrameworkSupportProvider"/>
<projectStructureDetector implementation="com.jetbrains.python.module.PyProjectStructureDetector"/>
<moduleConfigurationEditorProvider implementation="com.jetbrains.python.module.PythonModuleConfigurationEditorProvider"/>
<completion.contributor language="Python" implementationClass="com.jetbrains.python.psi.impl.PyConstructorArgumentCompletionContributor"/>

View File

@@ -1,22 +1,23 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.facet;
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.python.community.plugin.java.facet;
import com.intellij.facet.Facet;
import com.intellij.facet.FacetType;
import com.intellij.facet.FacetTypeId;
import com.intellij.openapi.module.Module;
import com.intellij.python.community.plugin.impl.facet.PythonFacetUtil;
import com.jetbrains.python.facet.LibraryContributingFacet;
import org.jetbrains.annotations.NotNull;
public class PythonFacet extends LibraryContributingFacet<PythonFacetConfiguration> {
public static final FacetTypeId<PythonFacet> ID = new FacetTypeId<>("python");
public class JavaPythonFacet extends LibraryContributingFacet<JavaPythonFacetConfiguration> {
public static final FacetTypeId<JavaPythonFacet> ID = new FacetTypeId<>("python");
public PythonFacet(@NotNull final FacetType facetType,
@NotNull final Module module,
@NotNull final String name,
@NotNull final PythonFacetConfiguration configuration,
Facet underlyingFacet) {
public JavaPythonFacet(@NotNull final FacetType facetType,
@NotNull final Module module,
@NotNull final String name,
@NotNull final JavaPythonFacetConfiguration configuration,
Facet underlyingFacet) {
super(facetType, module, name, configuration, underlyingFacet);
}

View File

@@ -1,5 +1,5 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.facet;
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.python.community.plugin.java.facet;
import com.intellij.facet.FacetConfiguration;
import com.intellij.facet.ui.FacetEditorContext;
@@ -9,11 +9,12 @@ import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.text.StringUtil;
import com.jetbrains.python.facet.PythonFacetSettings;
import com.jetbrains.python.sdk.PythonSdkType;
import org.jdom.Element;
public class PythonFacetConfiguration extends PythonFacetSettings implements FacetConfiguration {
class JavaPythonFacetConfiguration extends PythonFacetSettings implements FacetConfiguration {
private static final String SDK_NAME = "sdkName";
@Override

View File

@@ -1,5 +1,5 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.jetbrains.python.facet;
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.python.community.plugin.java.facet;
import com.intellij.facet.Facet;
import com.intellij.facet.FacetType;
@@ -19,22 +19,22 @@ import javax.swing.*;
import java.util.List;
public final class PythonFacetType extends FacetType<PythonFacet, PythonFacetConfiguration> {
public final class JavaPythonFacetType extends FacetType<JavaPythonFacet, JavaPythonFacetConfiguration> {
@NonNls
private static final String ID = "Python";
public static PythonFacetType getInstance() {
return findInstance(PythonFacetType.class);
public static JavaPythonFacetType getInstance() {
return findInstance(JavaPythonFacetType.class);
}
public PythonFacetType() {
super(PythonFacet.ID, ID, PyBundle.message("python.facet.name"));
public JavaPythonFacetType() {
super(JavaPythonFacet.ID, ID, PyBundle.message("python.facet.name"));
}
@Override
public PythonFacetConfiguration createDefaultConfiguration() {
PythonFacetConfiguration result = new PythonFacetConfiguration();
public JavaPythonFacetConfiguration createDefaultConfiguration() {
JavaPythonFacetConfiguration result = new JavaPythonFacetConfiguration();
List<Sdk> sdks = ProjectJdkTable.getInstance().getSdksOfType(PythonSdkType.getInstance());
if (sdks.size() > 0) {
result.setSdk(sdks.get(0));
@@ -43,8 +43,8 @@ public final class PythonFacetType extends FacetType<PythonFacet, PythonFacetCon
}
@Override
public PythonFacet createFacet(@NotNull Module module, String name, @NotNull PythonFacetConfiguration configuration, @Nullable Facet underlyingFacet) {
return new PythonFacet(this, module, name, configuration, underlyingFacet);
public JavaPythonFacet createFacet(@NotNull Module module, String name, @NotNull JavaPythonFacetConfiguration configuration, @Nullable Facet underlyingFacet) {
return new JavaPythonFacet(this, module, name, configuration, underlyingFacet);
}
@Override

View File

@@ -1,5 +1,5 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.facet;
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.python.community.plugin.java.facet;
import com.intellij.facet.FacetManager;
import com.intellij.facet.ModifiableFacetModel;
@@ -37,7 +37,7 @@ public class PythonFrameworkSupportConfigurable extends FrameworkSupportConfigur
public void addSupport(@NotNull Module module, @NotNull ModifiableRootModel model, @Nullable Library library) {
final FacetManager facetManager = FacetManager.getInstance(module);
ModifiableFacetModel facetModel = facetManager.createModifiableModel();
PythonFacet facet = facetManager.createFacet(PythonFacetType.getInstance(), "Python", null);
JavaPythonFacet facet = facetManager.createFacet(JavaPythonFacetType.getInstance(), "Python", null);
facet.getConfiguration().setSdk(mySdkComboBox.getSelectedSdk());
facetModel.addFacet(facet);
facetModel.commit();

View File

@@ -1,5 +1,5 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.facet;
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.python.community.plugin.java.facet;
import com.intellij.facet.FacetManager;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable;
@@ -16,7 +16,7 @@ import javax.swing.*;
public final class PythonFrameworkSupportProvider extends FrameworkSupportProvider {
public PythonFrameworkSupportProvider() {
super("Python", PythonFacetType.getInstance().getPresentableName());
super("Python", JavaPythonFacetType.getInstance().getPresentableName());
}
@Override
@@ -37,6 +37,6 @@ public final class PythonFrameworkSupportProvider extends FrameworkSupportProvid
@Override
public boolean isSupportAlreadyAdded(@NotNull Module module) {
return FacetManager.getInstance(module).getFacetsByType(PythonFacetType.getInstance().getId()).size() > 0;
return FacetManager.getInstance(module).getFacetsByType(JavaPythonFacetType.getInstance().getId()).size() > 0;
}
}

View File

@@ -1,5 +1,5 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.facet;
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.python.community.plugin.java.facet;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.jetbrains.python.facet.PythonSdkEditorTab">
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.python.community.plugin.java.facet.PythonSdkEditorTab">
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
@@ -10,7 +10,7 @@
<size top="5" left="10" bottom="10" right="10"/>
</border>
<children>
<component id="5b600" class="com.jetbrains.python.facet.PythonSdkComboBox" binding="mySdkComboBox">
<component id="5b600" class="com.intellij.python.community.plugin.java.facet.PythonSdkComboBox" binding="mySdkComboBox">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>

View File

@@ -1,5 +1,5 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.facet;
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.python.community.plugin.java.facet;
import com.intellij.facet.ui.FacetEditorContext;
import com.intellij.facet.ui.FacetEditorTab;
@@ -61,8 +61,8 @@ public class PythonSdkEditorTab extends FacetEditorTab {
return mySdkComboBox.getSelectedSdk() != getFacetConfiguration().getSdk();
}
private PythonFacetConfiguration getFacetConfiguration() {
return ((PythonFacetConfiguration) myEditorContext.getFacet().getConfiguration());
private JavaPythonFacetConfiguration getFacetConfiguration() {
return ((JavaPythonFacetConfiguration) myEditorContext.getFacet().getConfiguration());
}
@Override

View File

@@ -15,8 +15,8 @@ import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.psi.search.FileTypeIndex;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PythonFileType;
import com.jetbrains.python.facet.PythonFacet;
import com.jetbrains.python.facet.PythonFacetType;
import com.intellij.python.community.plugin.java.facet.JavaPythonFacet;
import com.intellij.python.community.plugin.java.facet.JavaPythonFacetType;
import com.jetbrains.python.sdk.PyDetectedSdk;
import com.jetbrains.python.sdk.PySdkExtKt;
import com.jetbrains.python.sdk.PythonSdkUtil;
@@ -117,7 +117,7 @@ public final class PythonPluginCommandLineInspectionProjectConfigurator implemen
return;
}
final PythonFacetType facetType = PythonFacetType.getInstance();
final JavaPythonFacetType facetType = JavaPythonFacetType.getInstance();
int skippedModules = 0;
for (Module m : ModuleManager.getInstance(project).getModules()) {
if (ReadAction.compute(() -> !FileTypeIndex.containsFileOfType(PythonFileType.INSTANCE, m.getModuleContentScope()))) {
@@ -133,7 +133,7 @@ public final class PythonPluginCommandLineInspectionProjectConfigurator implemen
invokeLaterOnWriteThreadUnderLock(
() -> {
final PythonFacet addedFacet = facetManager.addFacet(facetType, facetType.getPresentableName(), null);
final JavaPythonFacet addedFacet = facetManager.addFacet(facetType, facetType.getPresentableName(), null);
PySdkExtKt.excludeInnerVirtualEnv(m, addedFacet.getConfiguration().getSdk());
}
);