"use strict"; /** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ Object.defineProperty(exports, "__esModule", { value: true }); exports.SymbolRemovalMigration = void 0; const ts = require("typescript"); const migration_1 = require("../../update-tool/migration"); const upgrade_data_1 = require("../upgrade-data"); /** Migration that flags imports for symbols that have been removed. */ class SymbolRemovalMigration extends migration_1.Migration { /** Change data that upgrades to the specified target version. */ data = (0, upgrade_data_1.getVersionUpgradeData)(this, 'symbolRemoval'); // Only enable the migration rule if there is upgrade data. enabled = this.data.length !== 0; visitNode(node) { if (!ts.isImportDeclaration(node) || !ts.isStringLiteral(node.moduleSpecifier)) { return; } const namedBindings = node.importClause && node.importClause.namedBindings; if (!namedBindings || !ts.isNamedImports(namedBindings)) { return; } const moduleNameMatches = this.data.filter(entry => node.moduleSpecifier.text === entry.module); if (!moduleNameMatches.length) { return; } namedBindings.elements.forEach(element => { const elementName = element.propertyName?.text || element.name.text; moduleNameMatches.forEach(match => { if (match.name === elementName) { this.createFailureAtNode(element, match.message); } }); }); } } exports.SymbolRemovalMigration = SymbolRemovalMigration; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3ltYm9sLXJlbW92YWwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL3NjaGVtYXRpY3MvbmctdXBkYXRlL21pZ3JhdGlvbnMvc3ltYm9sLXJlbW92YWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7R0FNRzs7O0FBRUgsaUNBQWlDO0FBQ2pDLDJEQUFzRDtBQUV0RCxrREFBbUU7QUFFbkUsdUVBQXVFO0FBQ3ZFLE1BQWEsc0JBQXVCLFNBQVEscUJBQXNCO0lBQ2hFLGlFQUFpRTtJQUNqRSxJQUFJLEdBQStCLElBQUEsb0NBQXFCLEVBQUMsS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