getCompletions method

Future<List<LspCompletion>> getCompletions(
  1. int line,
  2. int character
)

This method is used to get completions at a specific position in the document.

This method is used internally by the CodeCrafter, calling this with appropriate parameters will returns a List of LspCompletion.

Implementation

Future<List<LspCompletion>> getCompletions(int line, int character) async {
  List<LspCompletion> completion = [];
  final response = await _sendRequest(
    method: 'textDocument/completion',
    params: _commonParams(line, character),
  );
  for (var item in response['result']['items']) {
    completion.add(
      LspCompletion(
        label: item['label'],
        itemType: CompletionItemType.values.firstWhere(
          (type) => type.value == item['kind'],
          orElse: () => CompletionItemType.text,
        ),
      ),
    );
  }
  return completion;
}