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>

30 lines 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isFixable = exports.isInRange = exports.toCodeAction = void 0; const vscode_languageserver_1 = require("vscode-languageserver"); // They have an awkard API for creating them, so we have this helper here // to make it a bit more straightforward. function toCodeAction(title, command, diagnostics, kind, isPreferred = false) { const codeAction = vscode_languageserver_1.CodeAction.create(title, command, kind); codeAction.diagnostics = diagnostics; codeAction.isPreferred = isPreferred; return codeAction; } exports.toCodeAction = toCodeAction; /** * The range is either the selection or cursor position, an offense is in * range if the selection and offense overlap in any way. */ function isInRange({ offense }, start, end) { const offenseStart = offense.start.index; const offenseEnd = offense.end.index; const isOutOfRange = offenseEnd < start || offenseStart > end; return !isOutOfRange; } exports.isInRange = isInRange; function isFixable(anomaly) { const { offense } = anomaly; return 'fix' in offense && offense.fix !== undefined; } exports.isFixable = isFixable; //# sourceMappingURL=utils.js.map