0

I try to write some custom lint rules. To achieve this, I used the analyzer_plugin package and I set up my project as it should be. Here is a simplified excerpt of the main class :

class LintAnalyzerPlugin extends ServerPlugin {

  @override
  Future<void> analyzeFile({required AnalysisContext analysisContext, required String path}) async {

    channel.sendNotification(
      AnalysisErrorsParams(path, [getAnalysisError(path)]).toNotification(),
    );
  }
}

channel.sendNotification is called but no message is displayed into VS Code Problems panel.

After some investigation, I found out that the JSON generated for the sent notification use Dart server Legacy protocol. But the Dart analyzer server run by Dart Code extension wait for LSP (Microsoft Language Server Protocol).

Fortunately the extension offers a setting to start the server with the Legacy protocol:

"dart.useLegacyAnalyzerProtocol": true

And now the VS Code Problems panel populates sent notifications.

Unfortunately Dart Code extension advises to use LSP because the Legacy protocol will eventually be removed some day.

Is it possible to generate LSP? Or did I miss something?

If anyone has any suggestions, I'm all ears.

Alexis BG
  • 1
  • 1
  • Have you tried reviewing the issues on the package, or filing one yourself? That's probably better than asking on SO. – Randal Schwartz Oct 15 '22 at 17:20
  • You can also ask on the discord server for DartCode. There's a link to it on the project source. – Randal Schwartz Oct 15 '22 at 17:21
  • @alexis-bg, have you found a solution to this issue ? I currently try to achieve a working demo of analyzer_plugin : https://github.com/evaisse/dart_demo_analyzer_plugin I struggle with this error using android studio in the analyzer status webpage: "Unrecorded error while starting the plugin." – evaisse Aug 02 '23 at 12:58

0 Answers0