use of com.intellij.facet.Facet 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;
}
use of com.intellij.facet.Facet in project intellij-community by JetBrains.
the class PythonCommandLineState method addRootsFromModule.
private static void addRootsFromModule(Module module, Collection<String> pythonPathList) {
// for Jython
final CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module);
if (extension != null) {
final VirtualFile path = extension.getCompilerOutputPath();
if (path != null) {
pythonPathList.add(path.getPath());
}
final VirtualFile pathForTests = extension.getCompilerOutputPathForTests();
if (pathForTests != null) {
pythonPathList.add(pathForTests.getPath());
}
}
//additional paths from facets (f.e. buildout)
final Facet[] facets = FacetManager.getInstance(module).getAllFacets();
for (Facet facet : facets) {
if (facet instanceof PythonPathContributingFacet) {
List<String> more_paths = ((PythonPathContributingFacet) facet).getAdditionalPythonPath();
if (more_paths != null)
pythonPathList.addAll(more_paths);
}
}
}
use of com.intellij.facet.Facet 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;
}
use of com.intellij.facet.Facet in project intellij-community by JetBrains.
the class FacetModelBase method getFacetsByType.
@Override
@NotNull
public <F extends Facet> Collection<F> getFacetsByType(FacetTypeId<F> typeId) {
if (myType2Facets == null) {
MultiValuesMap<FacetTypeId, Facet> typeToFacets = new MultiValuesMap<>();
for (Facet facet : getAllFacets()) {
typeToFacets.put(facet.getTypeId(), facet);
}
Map<FacetTypeId, Collection<Facet>> typeToFacetsCollection = new HashMap<>();
for (FacetTypeId id : typeToFacets.keySet()) {
final Collection<Facet> facets = typeToFacets.get(id);
typeToFacetsCollection.put(id, Collections.unmodifiableCollection(facets));
}
myType2Facets = typeToFacetsCollection;
}
final Collection<F> facets = (Collection<F>) myType2Facets.get(typeId);
return facets != null ? facets : Collections.<F>emptyList();
}
use of com.intellij.facet.Facet in project intellij-community by JetBrains.
the class FacetModelBase method getSortedFacets.
@Override
@NotNull
public Facet[] getSortedFacets() {
if (mySortedFacets == null) {
final Facet[] allFacets = getAllFacets();
if (allFacets.length == 0) {
mySortedFacets = Facet.EMPTY_ARRAY;
} else {
LinkedHashSet<Facet> facets = new LinkedHashSet<>();
for (Facet facet : allFacets) {
addUnderlyingFacets(facets, facet);
}
mySortedFacets = facets.toArray(new Facet[facets.size()]);
}
}
return mySortedFacets;
}
Aggregations