My language plugin never got run by CLion

This plugin worked in early clion eaps, but stopped working after several updates of clion.

Here's plugin.xml:

<idea-plugin version="2">

  <id>com.example.test</id>

  <name>Test</name>

  <version>1.0</version>

  <vendor email="test@example.com" url="http://www.example.com">test@example.com</vendor>

  <description><![CDATA[

    ]]></description>

  <change-notes><![CDATA[

    ]]>

  </change-notes>

  <!-- please see http://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->

  <idea-version since-build="131"/>

  <!-- please see http://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products

       on how to target different products -->

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

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

  <extensions defaultExtensionNs="com.intellij">

    <!-- Add your extensions here -->

      <documentationProvider  implementation="com.example.MyDocumentationProvider" />

  </extensions>

  <application-components>

    <!-- Add your application components here -->

  </application-components>

  <project-components>

    <!-- Add your project components here -->

  </project-components>

  <actions>

    <!-- Add your actions here -->

  </actions>

</idea-plugin>

Here's MyDocumentationProvider:

public class MyDocumentationProvider implements CidrDocumentationProvider {

    @Nullable

    @Override

    public String getQuickNavigateInfo(PsiElement psiElement, PsiElement psiElement2) {

        String test = "test";

        return test;

    }

}

public List<String> getUrlFor(PsiElement psiElement, PsiElement psiElement1) {
    return super.getUrlFor(psiElement, psiElement1);
}


I tried to set a breakpoint inside "getQuickNavigateInfo" and press "Ctrl + Q" in clion, but it never paused. If I put another breakpoint inside getUrlFor(), it would break there.

I tried to extend "lang.documentationProvider" instead of "documentationProvider", but failed.

I tried to add order="first" to <documentationProvider></documentationProvider>, but failed either.

0
5 comments

The code you have provided here will not compile, because CidrDocumentationProvider is a class, not an interface. You need to implement the base interface (com.intellij.lang.documentation.DocumentationProvider).

Also, the method called when you press Ctrl-Q is generateDoc(). getQuickNavigateInfo() is called when you press Ctrl and hover over a reference to an element. getUrlFor() is called when you use the View |  External Documentation action.

0

It seems not like this.
When I pressed Ctrl + Q, only getUrlFor() was called, twice. generateDoc() was not called.
Also, when I moved the cursor to an element with Ctrl pressed, getQuickNavigateInfo() was not called either. The hint pane jumped out directly.
There wasn't any item called "External Documentation action" under "View" menu.

Sorry for the error in my code. My local copy is complete and compiled successfully.

0

getUrlFor() will indeed be called; the external documenation takes precedence over generated documentation, so if it was possible to find a URL with external documentation, it will be used and generateDoc() will not be called.

Ctrl-hover will call getQuickNavigateInfo() when hovering over a reference. When hovering over a declaration, it will indeed show the "Show usages of ..." hint directly.

The "External documentation" action is not show in the menu when it is not available.

0

Sorry, but I still can't figure out why clion wouldn't pause at breakpoints inside getQuickNavigateInfo() and other member functions except getUrlFor().

0

If you just want to understand how the API works, you can run IntelliJ IDEA Community Edition under a debugger (with your plugin if you like) and see in detail which methods are called in which situations. If you want to accomplish something specific, please let us know what exactly you're trying to do.

0

Please sign in to leave a comment.