Plugin development, use localization pre-installed plugin.

Hi,

I'm working on a plugin for me and others at work to simplify some tasks we do every day.

The PHP side of my plugin is done, but I want to add completion in gettext files (.po and .pot). If I add the localization plugin to my project and set the scope to either compile or provided PhpStorm throws an error.

  • Compile scope: Language with ID Locale is already defined.
  • Provided scope: NoClassDefFoundException.

Is there an other way to to do this?

 

Code so far:

https://pastebin.com/F6ameNQP

0
4 comments

Hey. Could you please clarify what do you mean by "the localization plugin"?

0

I want to add completion for the Locale language which is defined in this plugin that's pre-installed in PhpStorm:

 

I added it as a library:

0

The proper scope is "Provided". Could you please post the whole stack trace?

Also, please don't forget to add the localization plugin as a dependency as it can be disabled despite bundled.

<depends>org.jetbrains.plugins.localization</depends>

If you don't want to depend on the plugin you can make completion optional, see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html

0

Stack trace:

com/jetbrains/localization/LocaleElementTypes
java.lang.NoClassDefFoundError: com/jetbrains/localization/LocaleElementTypes
at com.basmilius.bastools.framework.all.completion.GetTextCompletionProvider.getPlace(GetTextCompletionProvider.kt:29)
at com.basmilius.bastools.framework.base.completion.BaseCompletionContributor.extend(BaseCompletionContributor.kt:30)
at com.basmilius.bastools.framework.all.completion.GetTextCompletionContributor.<init>(GetTextCompletionContributor.kt:22)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.picocontainer.defaults.InstantiatingComponentAdapter.newInstance(InstantiatingComponentAdapter.java:193)
at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.doGetComponentInstance(CachingConstructorInjectionComponentAdapter.java:103)
at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.instantiateGuarded(CachingConstructorInjectionComponentAdapter.java:80)
at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.getComponentInstance(CachingConstructorInjectionComponentAdapter.java:63)
at com.intellij.openapi.extensions.AbstractExtensionPointBean.instantiate(AbstractExtensionPointBean.java:75)
at com.intellij.openapi.extensions.CustomLoadingExtensionPointBean.instantiateExtension(CustomLoadingExtensionPointBean.java:47)
at com.intellij.lang.LanguageExtensionPoint.access$000(LanguageExtensionPoint.java:28)
at com.intellij.lang.LanguageExtensionPoint$1.compute(LanguageExtensionPoint.java:42)
at com.intellij.openapi.util.NotNullLazyValue.getValue(NotNullLazyValue.java:39)
at com.intellij.lang.LanguageExtensionPoint.getInstance(LanguageExtensionPoint.java:53)
at com.intellij.codeInsight.completion.CompletionPreloader.preload(CompletionPreloader.java:32)
at com.intellij.openapi.application.Preloader.a(Preloader.java:74)
at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:171)
at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:548)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:493)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:158)
at com.intellij.openapi.application.Preloader.a(Preloader.java:72)
at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:212)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.jetbrains.localization.LocaleElementTypes PluginClassLoader[com.basmilius.bastools, 1.2.0] com.intellij.ide.plugins.cl.PluginClassLoader@615dcc96
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 29 more

 

I think I found the problem. My plugin targets multiple IDE's and my plugin xml files look like this:

plugin.xml

<depends>com.intellij.modules.platform</depends>
<depends>com.intellij.modules.lang</depends>

<depends optional="true" config-file="./php-plugin.xml">com.jetbrains.php</depends>

 

php-plugin.xml

<depends optional="true" config-file="./localization-plugin.xml">org.jetbrains.plugins.localization</depends>

 

And it works when i move the depends from php-plugin.xml to plugin.xml

0

Please sign in to leave a comment.