openDocument method
Opens the document in the LSP server.
This method is used internally by the CodeForge widget and calling it directly is not recommended.
If initialContent is provided, it will be used as the document content.
Otherwise, the content will be read from filePath.
Implementation
Future<void> openDocument(String filePath) async {
final version = (_openDocuments[filePath] ?? 0) + 1;
_openDocuments[filePath] = version;
final String text = await File(filePath).readAsString();
await _sendNotification(
method: 'textDocument/didOpen',
params: {
'textDocument': {
'uri': Uri.file(filePath).toString(),
'languageId': languageId,
'version': version,
'text': text,
},
},
);
await Future.delayed(Duration(milliseconds: 300));
}