source: trip-planner-front/node_modules/@angular/compiler-cli/ngcc/src/analysis/private_declarations_analyzer.js

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

initial commit

  • Property mode set to 100644
File size: 10.0 KB
Line 
1(function (factory) {
2 if (typeof module === "object" && typeof module.exports === "object") {
3 var v = factory(require, exports);
4 if (v !== undefined) module.exports = v;
5 }
6 else if (typeof define === "function" && define.amd) {
7 define("@angular/compiler-cli/ngcc/src/analysis/private_declarations_analyzer", ["require", "exports", "@angular/compiler-cli/src/ngtsc/file_system", "@angular/compiler-cli/ngcc/src/utils"], factory);
8 }
9})(function (require, exports) {
10 "use strict";
11 Object.defineProperty(exports, "__esModule", { value: true });
12 exports.PrivateDeclarationsAnalyzer = void 0;
13 var file_system_1 = require("@angular/compiler-cli/src/ngtsc/file_system");
14 var utils_1 = require("@angular/compiler-cli/ngcc/src/utils");
15 /**
16 * This class will analyze a program to find all the declared classes
17 * (i.e. on an NgModule) that are not publicly exported via an entry-point.
18 */
19 var PrivateDeclarationsAnalyzer = /** @class */ (function () {
20 function PrivateDeclarationsAnalyzer(host, referencesRegistry) {
21 this.host = host;
22 this.referencesRegistry = referencesRegistry;
23 }
24 PrivateDeclarationsAnalyzer.prototype.analyzeProgram = function (program) {
25 var rootFiles = this.getRootFiles(program);
26 return this.getPrivateDeclarations(rootFiles, this.referencesRegistry.getDeclarationMap());
27 };
28 PrivateDeclarationsAnalyzer.prototype.getRootFiles = function (program) {
29 return program.getRootFileNames().map(function (f) { return program.getSourceFile(f); }).filter(utils_1.isDefined);
30 };
31 PrivateDeclarationsAnalyzer.prototype.getPrivateDeclarations = function (rootFiles, declarations) {
32 var _this = this;
33 var privateDeclarations = new Map(declarations);
34 rootFiles.forEach(function (f) {
35 var exports = _this.host.getExportsOfModule(f);
36 if (exports) {
37 exports.forEach(function (declaration, exportedName) {
38 if (declaration.node !== null && utils_1.hasNameIdentifier(declaration.node)) {
39 if (privateDeclarations.has(declaration.node.name)) {
40 var privateDeclaration = privateDeclarations.get(declaration.node.name);
41 if (privateDeclaration.node !== declaration.node) {
42 throw new Error(declaration.node.name.text + " is declared multiple times.");
43 }
44 // This declaration is public so we can remove it from the list
45 privateDeclarations.delete(declaration.node.name);
46 }
47 }
48 });
49 }
50 });
51 return Array.from(privateDeclarations.keys()).map(function (id) {
52 var from = file_system_1.absoluteFromSourceFile(id.getSourceFile());
53 var declaration = privateDeclarations.get(id);
54 var dtsDeclaration = _this.host.getDtsDeclaration(declaration.node);
55 var dtsFrom = dtsDeclaration && file_system_1.absoluteFromSourceFile(dtsDeclaration.getSourceFile());
56 return { identifier: id.text, from: from, dtsFrom: dtsFrom };
57 });
58 };
59 return PrivateDeclarationsAnalyzer;
60 }());
61 exports.PrivateDeclarationsAnalyzer = PrivateDeclarationsAnalyzer;
62});
63//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9kZWNsYXJhdGlvbnNfYW5hbHl6ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb21waWxlci1jbGkvbmdjYy9zcmMvYW5hbHlzaXMvcHJpdmF0ZV9kZWNsYXJhdGlvbnNfYW5hbHl6ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7O0lBU0EsMkVBQXNGO0lBR3RGLDhEQUFzRDtJQVd0RDs7O09BR0c7SUFDSDtRQUNFLHFDQUNZLElBQXdCLEVBQVUsa0JBQTBDO1lBQTVFLFNBQUksR0FBSixJQUFJLENBQW9CO1lBQVUsdUJBQWtCLEdBQWxCLGtCQUFrQixDQUF3QjtRQUFHLENBQUM7UUFFNUYsb0RBQWMsR0FBZCxVQUFlLE9BQW1CO1lBQ2hDLElBQU0sU0FBUyxHQUFHLElBQUksQ0FBQyxZQUFZLENBQUMsT0FBTyxDQUFDLENBQUM7WUFDN0MsT0FBT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Y2xhcmF0aW9ucy5kZWxldGUoZGVjbGFyYXRpb24ubm9kZS5uYW1lKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgfVxuICAgIH0pO1xuXG4gICAgcmV0dXJuIEFycmF5LmZyb20ocHJpdmF0ZURlY2xhcmF0aW9ucy5rZXlzKCkpLm1hcChpZCA9PiB7XG4gICAgICBjb25zdCBmcm9tID0gYWJzb2x1dGVGcm9tU291cmNlRmlsZShpZC5nZXRTb3VyY2VGaWxlKCkpO1xuICAgICAgY29uc3QgZGVjbGFyYXRpb24gPSBwcml2YXRlRGVjbGFyYXRpb25zLmdldChpZCkhO1xuICAgICAgY29uc3QgZHRzRGVjbGFyYXRpb24gPSB0aGlzLmhvc3QuZ2V0RHRzRGVjbGFyYXRpb24oZGVjbGFyYXRpb24ubm9kZSk7XG4gICAgICBjb25zdCBkdHNGcm9tID0gZHRzRGVjbGFyYXRpb24gJiYgYWJzb2x1dGVGcm9tU291cmNlRmlsZShkdHNEZWNsYXJhdGlvbi5nZXRTb3VyY2VGaWxlKCkpO1xuXG4gICAgICByZXR1cm4ge2lkZW50aWZpZXI6IGlkLnRleHQsIGZyb20sIGR0c0Zyb219O1xuICAgIH0pO1xuICB9XG59XG4iXX0=
Note: See TracBrowser for help on using the repository browser.