changeFile method

Future<void> changeFile(
  1. String filePath,
  2. String content
)

Notify content change (sends textDocument/didChange).

Implementation

Future<void> changeFile(String filePath, String content) async {
  final serverName = _openFiles[filePath];
  if (serverName == null) return;

  final server = _servers[serverName];
  if (server == null) return;

  final version = (_fileVersions[filePath] ?? 0) + 1;
  _fileVersions[filePath] = version;

  server.sendNotification('textDocument/didChange', {
    'textDocument': {'uri': _fileUri(filePath), 'version': version},
    'contentChanges': [
      {'text': content},
    ],
  });
}