analyze method

Future<List<Diagnostic>> analyze(
  1. String uri,
  2. String text, {
  3. String? languageId,
})

Sets the buffer for uri to text (opening it if new, otherwise changing it) and returns the diagnostics from the resulting analysis.

The convenient one-call entry point for "check this code":

final errors = await lsp.analyze('file:///Foo.dart', source);

Implementation

Future<List<Diagnostic>> analyze(
  String uri,
  String text, {
  String? languageId,
}) async {
  await _ready;
  // Subscribe before mutating so the resulting publish is never missed.
  final next = _client.diagnostics.firstWhere((d) => d.uri == uri);
  if (isOpen(uri)) {
    change(uri, text);
  } else {
    open(uri, text, languageId: languageId);
  }
  return (await next).diagnostics;
}