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.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RenameHandler = void 0; const theme_check_common_1 = require("@shopify/theme-check-common"); const AssetRenameHandler_1 = require("./handlers/AssetRenameHandler"); const SnippetRenameHandler_1 = require("./handlers/SnippetRenameHandler"); /** * The RenameHandler is responsible for handling workspace/didRenameFiles notifications. * * Stuff we'll handle: * - When a snippet is renamed, then we'll change all the render calls * - When an asset is renamed, then we'll change the asset_url calls * - etc. */ class RenameHandler { constructor(connection, documentManager, fileExists) { this.documentManager = documentManager; this.fileExists = fileExists; this.handlers = [new SnippetRenameHandler_1.SnippetRenameHandler(connection), new AssetRenameHandler_1.AssetRenameHandler(connection)]; } async onDidRenameFiles(params) { const rootUri = await (0, theme_check_common_1.findRoot)(theme_check_common_1.path.dirname(params.files[0].oldUri), this.fileExists); await this.documentManager.preload(rootUri); const theme = this.documentManager.theme(rootUri, true); const promises = this.handlers.map((handler) => handler.onDidRenameFiles(params, theme)); await Promise.all(promises); } } exports.RenameHandler = RenameHandler; //# sourceMappingURL=RenameHandler.js.map