Defining extension point and extension in the same plugin

I'm defining an extension point in my plugin and I want to include a couple of implementation of this in the same plugin. Plugin.xml looks like this:

 

<extensionPoints>
<extensionPoint interface="com.appurate.intellij.plugin.atf.typestructure.ATFPropertyFactory"
name="PropertyFactory" area="IDEA_PROJECT"/>
</extensionPoints>
<extensions defaultExtensionNs="com.appurate.intellij.plugin.atf">
<PropertyFactory
implementation="com.appurate.intellij.plugin.atf.typestructure.impl.psi.ATFPsiPropertyFactory"/>
<PropertyFactory
implementation="com.appurate.intellij.plugin.atf.typestructure.impl.xsd.ATFXsdPropertyFactory"/>
</extensions>

however, when I try to get these extensions in my code I get an exception 

Missing extension point: com.appurate.intellij.plugin.atf.PropertyFactory in area null

And this is the code to get the extensions:

propertyFactories = Extensions.getExtensions(new ExtensionPointName<ATFPropertyFactory>("com.appurate.intellij.plugin.atf.PropertyFactory"));



Can I do this? i.e. defining extension point and extension in the same plugin? and also, is this the correct way of getting those extensions? 

 

4 comments

 

Arbitrary sample: org.jetbrains.plugins.gradle.frameworkSupport.GradleFrameworkSupportProvider

See also http://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_extensions_and_extension_points.html for a detailed reference.

 

If it still doesn't work, please provide a complete project to reproduce.

0

Thanks Yann for the reply. I found the problem. I had to pass a reference to the project to Extensions.getExtensions method.

propertyFactories = Extensions.getExtensions(ExtensionPointName.create("com.appurate.intellij.plugin.atf.PropertyFactory"),project);

Thanks,

Vahid

0

You're welcome. Usually you should define a static field EP_NAME for ExtensionPointName (usually in the Extension class/bean itself), then you can use easier EP_NAME.getExtensions(...) directly.

0

That was a great tip Yann. Simplified a few things in my code.

 

Thanks,

Vahid

0

Please sign in to leave a comment.