Select python facet for a module
Answered
Hi,
I would like to automatically add a python facet to a module from my plugin. I can do this through the UI but I am unable to do so through the plugin. I am aware of FacetManager class and its addFacet but how do I get the facet to add in the first place? Essentially, I am looking for a way to get all the facets available in the project (the facets shown in the image below).
Please sign in to leave a comment.
Hi,
Please try using
FacetTypeRegistry.getInstance().getFacetTypes()
.Thanks Karol, this is what I was looking for! Just to confirm, is this the correct way of using this API:
Also,
Thanks,
Aman
Hi,
You can use
PythonFacetType.getInstance()
, so you don’t need to hardcode the “Python” ID.To set SDK, try
pythonFacet.setSdk(<required SDK>)
, see:https://github.com/JetBrains/intellij-community/blob/master/python/pluginJava/com/jetbrains/python/facet/PythonFacetType.java#L44-L47
Perfect! Thanks for your help.