How to use the @theia/languages/lib/browser.TextDocument.create function in @theia/languages

To help you get started, we’ve selected a few @theia/languages examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse-theia / theia / packages / debug / src / browser / console / debug-console-session.ts View on Github external
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 [];
    }