UNPKG

@shopify/theme-language-server-common

Version:

<h1 align="center" style="position: relative;" > <br> <img src="https://github.com/Shopify/theme-check-vscode/blob/main/images/shopify_glyph.png?raw=true" alt="logo" width="141" height="160"> <br> Theme Language Server </h1>

31 lines (27 loc) 855 B
import { CompletionItem, CompletionList, CompletionParams, HoverParams, } from 'vscode-languageserver-protocol'; import { DocumentManager } from '../../documents'; export function getRequestParams( documentManager: DocumentManager, relativePath: string, source: string, ): HoverParams & CompletionParams { const uri = `file:///root/${relativePath}`; const sourceWithoutCursor = source.replace('█', ''); documentManager.open(uri, sourceWithoutCursor, 1); const doc = documentManager.get(uri)!.textDocument; const position = doc.positionAt(source.indexOf('█')); return { textDocument: { uri: uri }, position: position, }; } export function isCompletionList( completions: null | CompletionList | CompletionItem[], ): completions is CompletionList { return completions !== null && !Array.isArray(completions); }