Is there any difference in use the RunLineMarkerContributor between IDEA 2021 and IDEA 2020?

Answered
I published a plugin Cap-Elasticsearch-Client - IntelliJ IDEs | JetBrains, but it has some problem for IDEA 2021.
I implementation some extensions in plugin.xml like this
<extensions defaultExtensionNs="com.intellij">
    <!-- Add your extensions here -->
    <fileType name="Elasticsearch KQL" language="ElasticsearchKql" extensions="eskql"
              fieldName="INSTANCE"
              implementationClass="com.cap.plugins.elasticsearch.language.kql.ElasticsearchKqlFileType"/>
    <lang.parserDefinition language="ElasticsearchKql"
                           implementationClass="com.cap.plugins.elasticsearch.language.kql.lexer.ElasticsearchKqlParserDefinition"/>
    <lang.syntaxHighlighterFactory language="ElasticsearchKql"
                                   implementationClass="com.cap.plugins.elasticsearch.language.kql.highlighter.ElasticsearchKqlSyntaxHighlighterFactory"/>
    <lang.commenter language="ElasticsearchKql"
                    implementationClass="com.cap.plugins.elasticsearch.language.kql.commenter.ElasticsearchKqlCommenter"/>
    <braceMatcher filetype="Elasticsearch KQL"
                  implementationClass="com.cap.plugins.elasticsearch.language.kql.structure.ElasticsearchKqlPairedBraceMatcherAdapter"/>
    <fileIndentOptionsProvider
            implementation="com.cap.plugins.elasticsearch.language.kql.formatter.ElasticsearchKqlFileIndentOptionsProvider"/>
    <multiHostInjector
            implementation="com.cap.plugins.elasticsearch.language.kql.formatter.injection.ElasticsearchKqlBodyInjector"/>
    <lang.formatter language="ElasticsearchKql"
                    implementationClass="com.cap.plugins.elasticsearch.language.kql.formatter.ElasticsearchKqlFormattingModelBuilder"/>
    <runLineMarkerContributor language="ElasticsearchKql"
                              implementationClass="com.cap.plugins.elasticsearch.language.kql.lineMarker.ElasticsearchKqlRunLineMarkerContributor"/>
    <completion.contributor language="ElasticsearchKql"
                            implementationClass="com.cap.plugins.elasticsearch.language.kql.completion.ElasticsearchKqlCompletionContributor"/>
    <fileEditorProvider
            implementation="com.cap.plugins.elasticsearch.ui.editor.kql.devtools.console.ElasticsearchKqlConsoleFileEditorProvider"/>
</extensions>

Then i debug or run this plugin use gradle command: Task/intellij/runIde,
When i use IDEA 2020 with build.gradle like this
intellij {
    version = '2020.1'
    sandboxDirectory = "${getBuildDir().parent}/idea-sandbox-${version}"
    type = 'IC'
    updateSinceUntilBuild = false
}
this plugin will work ok, and it can show the marker like this
but, when i use IDEA 2021 with build.gradle like this
intellij {
    version = '2021.1'
    sandboxDirectory = "${getBuildDir().parent}/idea-sandbox-${version}"
    type = 'IC'
    updateSinceUntilBuild = false
}
the marker is not ok, it is not show.
 
I add some code to print information when the class init, for every extensions.
class ElasticsearchKqlRunLineMarkerContributor : RunLineMarkerContributor() {
    init {
        println("======> ${this.javaClass.name} init <=====")
    }

    override fun getInfo(element: PsiElement): Info? {
        // My code here
    }
}
And i run again.
When i run with IDEA 2021, it print
======> com.cap.plugins.elasticsearch.language.kql.ElasticsearchKqlFileType init <=====
======> com.cap.plugins.elasticsearch.language.kql.lexer.ElasticsearchKqlParserDefinition init <=====
======> com.cap.plugins.elasticsearch.ui.editor.kql.devtools.console.ElasticsearchKqlConsoleFileEditorProvider init <=====
======> com.cap.plugins.elasticsearch.language.kql.formatter.ElasticsearchKqlFileIndentOptionsProvider init <=====
======> com.cap.plugins.elasticsearch.language.kql.highlighter.ElasticsearchKqlSyntaxHighlighterFactory init <=====
======> com.cap.plugins.elasticsearch.language.kql.formatter.injection.ElasticsearchKqlBodyInjector init <=====
 
======> com.cap.plugins.elasticsearch.language.kql.structure.ElasticsearchKqlPairedBraceMatcherAdapter init <=====
======> com.cap.plugins.elasticsearch.language.kql.completion.ElasticsearchKqlCompletionContributor init <=====
======> com.cap.plugins.elasticsearch.language.kql.commenter.ElasticsearchKqlCommenter init <=====
======> com.cap.plugins.elasticsearch.language.kql.formatter.ElasticsearchKqlFormattingModelBuilder init <=====
When i run with IDEA 2020, it print
======> com.cap.plugins.elasticsearch.language.kql.ElasticsearchKqlFileType init <=====
======> com.cap.plugins.elasticsearch.language.kql.lexer.ElasticsearchKqlParserDefinition init <=====
======> com.cap.plugins.elasticsearch.ui.editor.kql.devtools.console.ElasticsearchKqlConsoleFileEditorProvider init <=====
======> com.cap.plugins.elasticsearch.language.kql.formatter.ElasticsearchKqlFileIndentOptionsProvider init <=====
======> com.cap.plugins.elasticsearch.language.kql.highlighter.ElasticsearchKqlSyntaxHighlighterFactory init <=====
======> com.cap.plugins.elasticsearch.language.kql.formatter.injection.ElasticsearchKqlBodyInjector init <=====
======> com.cap.plugins.elasticsearch.language.kql.lineMarker.ElasticsearchKqlRunLineMarkerContributor init <=====
======> com.cap.plugins.elasticsearch.language.kql.structure.ElasticsearchKqlPairedBraceMatcherAdapter init <=====
======> com.cap.plugins.elasticsearch.language.kql.completion.ElasticsearchKqlCompletionContributor init <=====
======> com.cap.plugins.elasticsearch.language.kql.commenter.ElasticsearchKqlCommenter init <=====
======> com.cap.plugins.elasticsearch.language.kql.formatter.ElasticsearchKqlFormattingModelBuilder init <=====
It looks like when use IDEA 2021,  the RunLineMarkerContributor does not init. 
But the code is same.
Is there any difference in use the RunLineMarkerContributor between IDEA 2021 and IDEA 2020? What should we pay attention to when i use the RunLineMarkerContributor?
 
And the
class ElasticsearchKqlBodyInjector : MultiHostInjector
It initialized and printed the message both IDEA 2020 and IDEA 2021, but the json string's format is diffrence, such as json key's color, and the brack matcher. Look at above two pictures. Is there any difference between the IDEA 2020 and IDEA 2021?
3 comments
Comment actions Permalink

It seems this might be related to ElasticsearchKqlConsoleFileEditorProvider and highlighting passes. Please share this code.

 

0
Comment actions Permalink

The code is hosted in GitHub GitHub - Cap-Cloud/Cap-Elasticsearch-Client, community branch. Thanks!

0
Comment actions Permalink

https://github.com/Cap-Cloud/Cap-Elasticsearch-Client/blob/community/Plugins/Cap-Elasticsearch/src/main/kotlin/com/cap/plugins/elasticsearch/ui/editor/ElasticsearchFileEditor.kt should

- implement com.intellij.openapi.fileEditor.TextEditor

- override com.intellij.openapi.fileEditor.FileEditor#getBackgroundHighlighter

 

See com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl#getBackgroundHighlighter as reference

0

Please sign in to leave a comment.