source: trip-planner-front/node_modules/@angular/cdk/schematics/ng-update/migrations/class-inheritance.js@ 84d0fbb

Last change on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 6.9 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.ClassInheritanceMigration = void 0;
11const ts = require("typescript");
12const migration_1 = require("../../update-tool/migration");
13const base_types_1 = require("../typescript/base-types");
14const upgrade_data_1 = require("../upgrade-data");
15/**
16 * Migration that identifies class declarations that extend CDK or Material classes
17 * which had a public property change.
18 */
19class ClassInheritanceMigration extends migration_1.Migration {
20 constructor() {
21 super(...arguments);
22 /**
23 * Map of classes that have been updated. Each class name maps to the according property
24 * change data.
25 */
26 this.propertyNames = new Map();
27 // Only enable the migration rule if there is upgrade data.
28 this.enabled = this.propertyNames.size !== 0;
29 }
30 init() {
31 upgrade_data_1.getVersionUpgradeData(this, 'propertyNames')
32 .filter(data => data.limitedTo && data.limitedTo.classes)
33 .forEach(data => data.limitedTo.classes.forEach(name => this.propertyNames.set(name, data)));
34 }
35 visitNode(node) {
36 if (ts.isClassDeclaration(node)) {
37 this._visitClassDeclaration(node);
38 }
39 }
40 _visitClassDeclaration(node) {
41 const baseTypes = base_types_1.determineBaseTypes(node);
42 const className = node.name ? node.name.text : '{unknown-name}';
43 if (!baseTypes) {
44 return;
45 }
46 baseTypes.forEach(typeName => {
47 const data = this.propertyNames.get(typeName);
48 if (data) {
49 this.createFailureAtNode(node, `Found class "${className}" which extends class ` +
50 `"${typeName}". Please note that the base class property ` +
51 `"${data.replace}" has changed to "${data.replaceWith}". ` +
52 `You may need to update your class as well.`);
53 }
54 });
55 }
56}
57exports.ClassInheritanceMigration = ClassInheritanceMigration;
58//# sourceMappingURL=data:application/json;base64,eyJ2ZXJ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kYXRhKSB7XG4gICAgICAgIHRoaXMuY3JlYXRlRmFpbHVyZUF0Tm9kZShcbiAgICAgICAgICAgIG5vZGUsXG4gICAgICAgICAgICBgRm91bmQgY2xhc3MgXCIke2NsYXNzTmFtZX1cIiB3aGljaCBleHRlbmRzIGNsYXNzIGAgK1xuICAgICAgICAgICAgICAgIGBcIiR7dHlwZU5hbWV9XCIuIFBsZWFzZSBub3RlIHRoYXQgdGhlIGJhc2UgY2xhc3MgcHJvcGVydHkgYCArXG4gICAgICAgICAgICAgICAgYFwiJHtkYXRhLnJlcGxhY2V9XCIgaGFzIGNoYW5nZWQgdG8gXCIke2RhdGEucmVwbGFjZVdpdGh9XCIuIGAgK1xuICAgICAgICAgICAgICAgIGBZb3UgbWF5IG5lZWQgdG8gdXBkYXRlIHlvdXIgY2xhc3MgYXMgd2VsbC5gKTtcbiAgICAgIH1cbiAgICB9KTtcbiAgfVxufVxuIl19
Note: See TracBrowser for help on using the repository browser.