Optionally depending on other plugins in 2024.1+

已回答

Hi. I'm a developer of TeaVM, tool that converts Java bytecode to JavaScript. As a part of project there's an IDEA plugin that allows to run TeaVM compiler right from the IDEA and to debug Java/Kotlin/Scala code converted into JavaScript right in IDEA. However, this is not an option after IDEA 2024, since plugin does not pass validation anymore. The reason is a sudden deprecation of ExtensionsArea API without any instructions how to replace it. ExtensionArea is used to implement debugging of Kotlin and Scala code. Both plugins are optional dependencies for TeaVM IDEA plugin, so it only handles Kotlin and Scala breakpoints when corresponding plugins are installed. To achieve this, TeaVM does following.

1. Specifies optional dependencies in plugin.xml as follows:

<depends optional="true" config-file="kotlin.xml">org.jetbrains.kotlin</depends>
<depends optional="true" config-file="scala.xml">org.intellij.scala</depends>

2. In kotlin.xml and scala.xml extensions are declared as follows

<extensions defaultExtensionNs="org.teavm.extensions">
  <breakpointProvider implementation="org.teavm.idea.debug.TeaVMScalaBreakpointProvider"/>
</extensions>

3. In the code TeaVM plugin utilizes these extensions in the following way:

var breakpointProvider = session.getProject().getExtensionArea()
        .<TeaVMBreakpointProvider<?>>getExtensionPoint(
                "org.teavm.extensions.breakpointProvider");
if (breakpointProvider != null) {
    for (TeaVMBreakpointProvider<?> provider : breakpointProvider.getExtensions()) {
        breakpointHandlers.add(new TeaVMLineBreakpointHandler<>(
                provider.getBreakpointType(),
                session.getProject(), innerDebugger, this));
    }
}

Now I need to use some alternative approach to achieve this. What can you suggest? I can only imagine using Class.forName to test the presence of corresponding breakpoint types. Is it a correct replacement, or IDEA provides another recommended mechanism?

1

Hi,

Try using ExtensionPointName:

public static final ExtensionPointName<TeaVMBreakpointProvider<?>> EP_NAME = new ExtensionPointName<>("org.teavm.extensions.breakpointProvider");

Then, to get extensions:

EP_NAME.getExtensionList()
1

请先登录再写评论。