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>

60 lines 2.78 kB
"use strict"; var _a, _b, _c; Object.defineProperty(exports, "__esModule", { value: true }); exports.Configuration = exports.ConfigurationKeys = exports.CHECK_ON_CHANGE = exports.CHECK_ON_SAVE = exports.CHECK_ON_OPEN = void 0; const theme_check_common_1 = require("@shopify/theme-check-common"); const vscode_languageserver_1 = require("vscode-languageserver"); exports.CHECK_ON_OPEN = 'themeCheck.checkOnOpen'; exports.CHECK_ON_SAVE = 'themeCheck.checkOnSave'; exports.CHECK_ON_CHANGE = 'themeCheck.checkOnChange'; exports.ConfigurationKeys = [exports.CHECK_ON_OPEN, exports.CHECK_ON_SAVE, exports.CHECK_ON_CHANGE]; class Configuration { constructor(connection, capabilities) { this.connection = connection; this.capabilities = capabilities; this[_a] = true; this[_b] = true; this[_c] = true; this.fetchConfiguration = (0, theme_check_common_1.memo)(async () => { if (!this.capabilities.hasWorkspaceConfigurationSupport) return; const configs = await this.connection.workspace.getConfiguration(exports.ConfigurationKeys.map((key) => ({ section: key }))); for (let i = 0; i < exports.ConfigurationKeys.length; i++) { const key = exports.ConfigurationKeys[i]; if (configs[i] !== null) { this[key] = configs[i]; } } }); this.registerDidChangeCapability = (0, theme_check_common_1.memo)(async () => { if (!this.capabilities.hasDidChangeConfigurationDynamicRegistrationSupport) return; return this.connection.client.register(vscode_languageserver_1.DidChangeConfigurationNotification.type); }); this.connection = connection; this.capabilities = capabilities; } setup() { this[exports.CHECK_ON_OPEN] = this.capabilities.initializationOption(exports.CHECK_ON_OPEN, true); this[exports.CHECK_ON_SAVE] = this.capabilities.initializationOption(exports.CHECK_ON_SAVE, true); this[exports.CHECK_ON_CHANGE] = this.capabilities.initializationOption(exports.CHECK_ON_CHANGE, true); } async shouldCheckOnOpen() { await this.fetchConfiguration(); return this[exports.CHECK_ON_OPEN]; } async shouldCheckOnSave() { await this.fetchConfiguration(); return this[exports.CHECK_ON_SAVE]; } async shouldCheckOnChange() { await this.fetchConfiguration(); return this[exports.CHECK_ON_CHANGE]; } clearCache() { this.fetchConfiguration.clearCache(); } } exports.Configuration = Configuration; _a = exports.CHECK_ON_OPEN, _b = exports.CHECK_ON_SAVE, _c = exports.CHECK_ON_CHANGE; //# sourceMappingURL=Configuration.js.map