Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected async completions({ textDocument: { uri }, position }: CompletionParams): Promise {
const session = this.manager.currentSession;
if (session && session.capabilities.supportsCompletionsRequest) {
const model = monaco.editor.getModel(monaco.Uri.parse(uri));
if (model) {
const column = position.character + 1;
const lineNumber = position.line + 1;
const word = model.getWordAtPosition({ column, lineNumber });
const prefixLength = word ? word.word.length : 0;
const text = model.getValue();
const document = TextDocument.create(uri, model.getModeId(), model.getVersionId(), text);
const items = await session.completions(text, column, lineNumber);
return items.map(item => this.asCompletionItem(document, position, prefixLength, item));
}
}
return [];
}