Search in sources :

Example 1 with PythonFacetSettings

use of com.jetbrains.python.facet.PythonFacetSettings in project intellij-community by JetBrains.

the class PythonSdkType method findPythonSdk.

@Nullable
public static Sdk findPythonSdk(@Nullable Module module) {
    if (module == null)
        return null;
    final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
    if (sdk != null && sdk.getSdkType() instanceof PythonSdkType)
        return sdk;
    final Facet[] facets = FacetManager.getInstance(module).getAllFacets();
    for (Facet facet : facets) {
        final FacetConfiguration configuration = facet.getConfiguration();
        if (configuration instanceof PythonFacetSettings) {
            return ((PythonFacetSettings) configuration).getSdk();
        }
    }
    return null;
}
Also used : FacetConfiguration(com.intellij.facet.FacetConfiguration) PythonFacetSettings(com.jetbrains.python.facet.PythonFacetSettings) Facet(com.intellij.facet.Facet) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with PythonFacetSettings

use of com.jetbrains.python.facet.PythonFacetSettings in project intellij-community by JetBrains.

the class PythonLanguageLevelPusher method isPythonModule.

private static boolean isPythonModule(@NotNull final Module module) {
    final ModuleType moduleType = ModuleType.get(module);
    if (moduleType instanceof PythonModuleTypeBase)
        return true;
    final Facet[] allFacets = FacetManager.getInstance(module).getAllFacets();
    for (Facet facet : allFacets) {
        if (facet.getConfiguration() instanceof PythonFacetSettings) {
            return true;
        }
    }
    return false;
}
Also used : ModuleType(com.intellij.openapi.module.ModuleType) PythonFacetSettings(com.jetbrains.python.facet.PythonFacetSettings) PythonModuleTypeBase(com.jetbrains.python.PythonModuleTypeBase) Facet(com.intellij.facet.Facet)

Aggregations

Facet (com.intellij.facet.Facet)2 PythonFacetSettings (com.jetbrains.python.facet.PythonFacetSettings)2 FacetConfiguration (com.intellij.facet.FacetConfiguration)1 ModuleType (com.intellij.openapi.module.ModuleType)1 PythonModuleTypeBase (com.jetbrains.python.PythonModuleTypeBase)1 Nullable (org.jetbrains.annotations.Nullable)1