@angular/cdk
Version:
Angular Material Component Development Kit
103 lines • 3.97 kB
JavaScript
;
/**
* @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.dev/license
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Migration = void 0;
const ts = __importStar(require("typescript"));
class Migration {
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;
/** List of migration failures that need to be reported. */
this.failures = [];
}
/** 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=migration.js.map