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>

36 lines (30 loc) 1.08 kB
import { LiquidHtmlNode, LiquidRawTag } from '@shopify/liquid-html-parser'; import { isError, JSONNode, SourceCodeType } from '@shopify/theme-check-common'; import { AugmentedJsonSourceCode, AugmentedLiquidSourceCode, AugmentedSourceCode, } from '../documents'; export type RequestContext = { doc: AugmentedSourceCode; schema?: LiquidRawTag; parsed?: any | Error; }; export type LiquidRequestContext = { doc: Omit<AugmentedLiquidSourceCode, 'ast'> & { ast: LiquidHtmlNode }; schema: LiquidRawTag; parsed: any; }; export type JSONRequestContext = { doc: Omit<AugmentedJsonSourceCode, 'ast'> & { ast: JSONNode }; }; export function isLiquidRequestContext(context: RequestContext): context is LiquidRequestContext { const { doc, schema, parsed } = context; return ( doc.type === SourceCodeType.LiquidHtml && !!schema && !isError(doc.ast) && !isError(parsed) ); } export function isJSONRequestContext(context: RequestContext): context is JSONRequestContext { const { doc } = context; return doc.type === SourceCodeType.JSON && !isError(doc.ast); }