Plugin extension point problem

已回答

I had an error getting the extension implementation of MyInterface. such as


private static final ExtensionPointName<MyInterface> EP_NAME = ExtensionPointName.create("my.plugin.myExtensionPoint2");
Error message: java.lang.ClassNotFoundException: another.MyInterfaceImpl

I looked in the documentation but I didn't find an example of how to get an instance of all extensions for myExtensionPoint2 。

https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html
0

Hi,

Please clarify the case. I don't understand where the code you pasted is located. Where is it called? Where is the usage of MyInterfaceImpl? What is the full stacktrace?

Ideally, provide a working reproducible example with the steps to reproduce.

0

Hi,

This is my plugin code


package com.aiwan.rust.tool.extend;

import com.aiwan.jb.Extend;
import com.intellij.openapi.extensions.ExtensionPointName;
import java.util.ArrayList;
import java.util.List;

public class MethodExtensionPoint implements ExtensionPoint {
    public static final ExtensionPointName<ExtensionPoint> EP_NAME = ExtensionPointName.create("com.aiwan.RustTool.methodExtensionPoint");

    public MethodExtensionPoint() {
    }

    public static List<ExtensionPoint> getExtensionList() {
        return EP_NAME.getExtensionList();
    }

    public List<Extend> getExtendList() {
        return new ArrayList();
    }
}

Exposed extension points

  <extensionPoints>

    <extensionPoint name="methodExtensionPoint" interface="com.aiwan.rust.tool.extend.MethodExtensionPoint" dynamic="true" />

  </extensionPoints>

 

anotherPlugin

package com.example.extendplugin;

import com.aiwan.jb.Extend;
import com.aiwan.rust.tool.extend.MethodExtensionPoint;
import com.example.extendplugin.extend.ApiImpl;

import java.util.List;



public class MyMethodExtend extends MethodExtensionPoint {
    @Override
    public List<Extend> getExtendList() {
        return List.of(new ApiImpl());
    }
}

plugin.xml

    <extensions defaultExtensionNs="com.aiwan.RustTool">

        <methodExtensionPoint implementation="com.example.extendplugin.MyMethodExtend"/>

    </extensions>

I get an error when using EP_NAME in my plugin to get all extension instances.

om.intellij.diagnostic.PluginException: Cannot create extension (class=com.example.extendplugin.MyMethodExtend) [Plugin: com.example.extend-plugin]
	at com.intellij.serviceContainer.ComponentManagerImpl.createError(ComponentManagerImpl.kt:1067)
	at com.intellij.openapi.extensions.impl.XmlExtensionAdapter.doCreateInstance(XmlExtensionAdapter.kt:69)
	at com.intellij.openapi.extensions.impl.XmlExtensionAdapter.createInstance(XmlExtensionAdapter.kt:30)
	at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processAdapter(ExtensionPointImpl.java:474)
	at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processAdapters(ExtensionPointImpl.java:422)
	at com.intellij.openapi.extensions.impl.ExtensionPointImpl.getExtensionList(ExtensionPointImpl.java:248)
	at com.intellij.openapi.extensions.ExtensionPointName.getExtensionList(ExtensionPointName.kt:43)
	at com.aiwan.rust.tool.extend.MethodExtensionPoint.getExtensionList(MethodExtensionPoint.java:20)
	at com.aiwan.rust.tool.navigation.handler.ApiHandler.getExtendList(ApiHandler.java:27)
	at com.aiwan.rust.tool.navigation.handler.Handler.getPanel(Handler.java:24)
	at com.aiwan.rust.tool.navigation.handler.Handler.navigate(Handler.java:46)
	at com.intellij.codeInsight.daemon.NavigateAction.actionPerformed(NavigateAction.java:61)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.java:339)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:313)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:362)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:313)
	at com.intellij.openapi.editor.impl.EditorGutterComponentImpl.performAction(EditorGutterComponentImpl.java:2304)
	at com.intellij.openapi.editor.impl.EditorGutterComponentImpl.invokeGutterAction(EditorGutterComponentImpl.java:2246)
	at com.intellij.openapi.editor.impl.EditorGutterComponentImpl.mouseReleased(EditorGutterComponentImpl.java:2224)
	at com.intellij.openapi.editor.impl.EditorImpl.processMouseReleased(EditorImpl.java:2391)
	at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.lambda$runMouseReleasedCommand$1(EditorImpl.java:4029)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:219)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:174)
	at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.runMouseReleasedCommand(EditorImpl.java:4031)
	at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.mouseReleased(EditorImpl.java:3916)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:298)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6657)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3385)
	at java.desktop/java.awt.Component.processEvent(Component.java:6422)
	at java.desktop/java.awt.Container.processEvent(Container.java:2266)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5027)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4954)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4581)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4522)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2808)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:791)
	at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:740)
	at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:734)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:764)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:762)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:761)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:685)
	at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.kt:633)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:588)
	at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:67)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:369)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:368)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:368)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:363)
	at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:992)
	at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113)
	at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:992)
	at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:363)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:405)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
Caused by: java.lang.ClassNotFoundException: com.example.extendplugin.MyMethodExtend PluginClassLoader(plugin=PluginDescriptor(name=rust-tool-extend, id=com.example.extend-plugin, descriptorPath=plugin.xml, path=D:\my-study\rust-tool-example\extend-plugin\build\idea-sandbox\plugins\extend-plugin, version=1.0-SNAPSHOT, package=null, isBundled=false), packagePrefix=null, state=active)
	at com.intellij.serviceContainer.ComponentManagerImplKt.doLoadClass(ComponentManagerImpl.kt:1607)
Caused by: java.lang.ClassNotFoundException: com.example.extendplugin.MyMethodExtend PluginClassLoader(plugin=PluginDescriptor(name=rust-tool-extend, id=com.example.extend-plugin, descriptorPath=plugin.xml, path=D:\my-study\rust-tool-example\extend-plugin\build\idea-sandbox\plugins\extend-plugin, version=1.0-SNAPSHOT, package=null, isBundled=false), packagePrefix=null, state=active)

	at com.intellij.serviceContainer.ComponentManagerImplKt.access$doLoadClass(ComponentManagerImpl.kt:1)
	at com.intellij.serviceContainer.ComponentManagerImpl.loadClass(ComponentManagerImpl.kt:947)
	at com.intellij.openapi.extensions.impl.InterfaceExtensionImplementationClassResolver.resolveImplementationClass(InterfaceExtensionImplementationClassResolver.kt:24)
	at com.intellij.openapi.extensions.impl.XmlExtensionAdapter.doCreateInstance(XmlExtensionAdapter.kt:48)
	... 69 more
0

Hi,

I assume that both plugins are installed when you test it.

I'm sorry, but I don't see the issue. In this case, please provide a minimal project to reproduce the problem, a test project I can run it on, and describe steps to reproduce.

0

请先登录再写评论。