"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.Migration = void 0; const ts = require("typescript"); class Migration { program; typeChecker; targetVersion; context; upgradeData; fileSystem; logger; /** List of migration failures that need to be reported. */ failures = []; constructor( /** TypeScript program for the migration. */ program, /** TypeChecker instance for the analysis program. */ typeChecker, /** * Version for which the migration rule should run. Null if the migration * is invoked manually. */ targetVersion, /** Context data for the migration. */ context, /** Upgrade data passed to the migration. */ upgradeData, /** File system that can be used for modifying files. */ fileSystem, /** Logger that can be used to print messages as part of the migration. */ logger) { this.program = program; this.typeChecker = typeChecker; this.targetVersion = targetVersion; this.context = context; this.upgradeData = upgradeData; this.fileSystem = fileSystem; this.logger = logger; } /** Method can be used to perform global analysis of the program. */ init() { } /** * Method that will be called once all nodes, templates and stylesheets * have been visited. */ postAnalysis() { } /** * Method that will be called for each node in a given source file. Unlike tslint, this * function will only retrieve TypeScript nodes that need to be casted manually. This * allows us to only walk the program source files once per program and not per * migration rule (significant performance boost). */ visitNode(node) { } /** Method that will be called for each Angular template in the program. */ visitTemplate(template) { } /** Method that will be called for each stylesheet in the program. */ visitStylesheet(stylesheet) { } /** Creates a failure with a specified message at the given node location. */ createFailureAtNode(node, message) { const sourceFile = node.getSourceFile(); this.failures.push({ filePath: this.fileSystem.resolve(sourceFile.fileName), position: ts.getLineAndCharacterOfPosition(sourceFile, node.getStart()), message: message, }); } } exports.Migration = Migration; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlncmF0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2Nkay9zY2hlbWF0aWNzL3VwZGF0ZS10b29sL21pZ3JhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7OztHQU1HO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