Struggling to figure out implementation

Answered

I created a NodeJS linter for the Gherkin syntax and want to create an IntelliJ plugin for this. The idea is that I'll use ProcessBuilder in order to invoke the NodeJS program.

I first tried with LocalInspectionTool, however, the linter requires the content of the file, which won't be updated if the file isn't saved (the linter accepts a file path and loads the content).

A way around this could be to send the file content to the NodeJS program as a command line argument. However, files could be hundreds of lines long, so I'm not sure if that's feasible. 

I also tried DocumentListener to see if this would be a way to do this, however, I get no log outputs when I change the file running in the sandbox environment. Here's an example of what I'm using for this:

import com.intellij.openapi.editor.event.DocumentListener;

final class Gherklin implements DocumentListener {
    @Override
    public void documentChanged(@NotNull DocumentEvent event) {
        System.out.println("Document Changed - " + event.toString());
    }
}

And my plugin.xml entry

<projectListeners>
    <listener class="org.gherklin.Gherklin"
              topic="com.intellij.openapi.editor.event.DocumentListener"/>
</projectListeners>

I'm trying to follow the same principles as the ESLint plugin does, but I can't find the source for that anywhere so I'm flying blind right now.

0
2 comments

I also changed the underlying linter to parse STDIN so that I could use that for LocalInspectionTool. The problem is that the whole operation (visiting document, sending to Node program, reading output JSON) takes about 0.7 seconds, which is far too slow for real time updates. 

0

Please sign in to leave a comment.