UNPKG

@abaplint/core

Version:
47 lines 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RenameGlobalInterface = void 0; const Statements = require("../../abap/2_statements/statements"); const Expressions = require("../../abap/2_statements/expressions"); const vscode_languageserver_types_1 = require("vscode-languageserver-types"); const _lsp_utils_1 = require("../../lsp/_lsp_utils"); const renamer_helper_1 = require("./renamer_helper"); const interface_1 = require("../interface"); class RenameGlobalInterface { constructor(reg) { this.reg = reg; } buildEdits(obj, oldName, newName) { if (!(obj instanceof interface_1.Interface)) { throw new Error("not an interface"); } const main = obj.getMainABAPFile(); if (main === undefined) { throw new Error("Main file not found"); } let changes = []; // todo, this is actually the same as "id" ? { const edits = []; for (const s of main.getStatements()) { if (s.get() instanceof Statements.Interface) { const exp = s.findFirstExpression(Expressions.InterfaceName); if (exp === undefined) { continue; } edits.push(vscode_languageserver_types_1.TextEdit.replace(_lsp_utils_1.LSPUtils.tokenToRange(exp.getFirstToken()), newName.toLowerCase())); } } changes.push(vscode_languageserver_types_1.TextDocumentEdit.create({ uri: main.getFilename(), version: 1 }, edits)); } const helper = new renamer_helper_1.RenamerHelper(this.reg); changes = changes.concat(helper.buildXMLFileEdits(obj, "CLSNAME", oldName, newName)); changes = changes.concat(helper.renameFiles(obj, oldName, newName)); changes = changes.concat(helper.renameReferences(obj.getIdentifier(), oldName, newName)); return { documentChanges: changes, }; } } exports.RenameGlobalInterface = RenameGlobalInterface; //# sourceMappingURL=rename_global_interface.js.map