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 | */
|
---|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
10 | exports.getImportOfIdentifier = void 0;
|
---|
11 | const ts = require("typescript");
|
---|
12 | /** Resolves the import of the specified identifier. */
|
---|
13 | function getImportOfIdentifier(node, typeChecker) {
|
---|
14 | // Free standing identifiers which resolve to an import will be handled
|
---|
15 | // as direct imports. e.g. "@Component()" where "Component" is an identifier
|
---|
16 | // referring to an import specifier.
|
---|
17 | const directImport = getSpecificImportOfIdentifier(node, typeChecker);
|
---|
18 | if (directImport !== null) {
|
---|
19 | return directImport;
|
---|
20 | }
|
---|
21 | else if (ts.isQualifiedName(node.parent) && node.parent.right === node) {
|
---|
22 | // Determines the import of a qualified name. e.g. "let t: core.Component". In that
|
---|
23 | // case, the import of the most left identifier will be determined ("core").
|
---|
24 | const qualifierRoot = getQualifiedNameRoot(node.parent);
|
---|
25 | if (qualifierRoot) {
|
---|
26 | const moduleName = getImportOfNamespacedIdentifier(qualifierRoot, typeChecker);
|
---|
27 | if (moduleName) {
|
---|
28 | return { moduleName, symbolName: node.text };
|
---|
29 | }
|
---|
30 | }
|
---|
31 | }
|
---|
32 | else if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) {
|
---|
33 | // Determines the import of a property expression. e.g. "@core.Component". In that
|
---|
34 | // case, the import of the most left identifier will be determined ("core").
|
---|
35 | const rootIdentifier = getPropertyAccessRoot(node.parent);
|
---|
36 | if (rootIdentifier) {
|
---|
37 | const moduleName = getImportOfNamespacedIdentifier(rootIdentifier, typeChecker);
|
---|
38 | if (moduleName) {
|
---|
39 | return { moduleName, symbolName: node.text };
|
---|
40 | }
|
---|
41 | }
|
---|
42 | }
|
---|
43 | return null;
|
---|
44 | }
|
---|
45 | exports.getImportOfIdentifier = getImportOfIdentifier;
|
---|
46 | /**
|
---|
47 | * Resolves the import of the specified identifier. Expects the identifier to resolve
|
---|
48 | * to a fine-grained import declaration with import specifiers.
|
---|
49 | */
|
---|
50 | function getSpecificImportOfIdentifier(node, typeChecker) {
|
---|
51 | const symbol = typeChecker.getSymbolAtLocation(node);
|
---|
52 | if (!symbol || !symbol.declarations || !symbol.declarations.length) {
|
---|
53 | return null;
|
---|
54 | }
|
---|
55 | const declaration = symbol.declarations[0];
|
---|
56 | if (!ts.isImportSpecifier(declaration)) {
|
---|
57 | return null;
|
---|
58 | }
|
---|
59 | // Since the declaration is an import specifier, we can walk up three times to get a reference
|
---|
60 | // to the import declaration node (NamedImports -> ImportClause -> ImportDeclaration).
|
---|
61 | const importDecl = declaration.parent.parent.parent;
|
---|
62 | if (!ts.isStringLiteral(importDecl.moduleSpecifier)) {
|
---|
63 | return null;
|
---|
64 | }
|
---|
65 | return {
|
---|
66 | moduleName: importDecl.moduleSpecifier.text,
|
---|
67 | symbolName: declaration.propertyName ? declaration.propertyName.text : declaration.name.text
|
---|
68 | };
|
---|
69 | }
|
---|
70 | /**
|
---|
71 | * Resolves the import of the specified identifier. Expects the identifier to
|
---|
72 | * resolve to a namespaced import declaration. e.g. "import * as core from ...".
|
---|
73 | */
|
---|
74 | function getImportOfNamespacedIdentifier(node, typeChecker) {
|
---|
75 | const symbol = typeChecker.getSymbolAtLocation(node);
|
---|
76 | if (!symbol || !symbol.declarations || !symbol.declarations.length) {
|
---|
77 | return null;
|
---|
78 | }
|
---|
79 | const declaration = symbol.declarations[0];
|
---|
80 | if (!ts.isNamespaceImport(declaration)) {
|
---|
81 | return null;
|
---|
82 | }
|
---|
83 | // Since the declaration is a namespace import, we can walk up three times to get a reference
|
---|
84 | // to the import declaration node (NamespaceImport -> ImportClause -> ImportDeclaration).
|
---|
85 | const importDecl = declaration.parent.parent;
|
---|
86 | if (!ts.isStringLiteral(importDecl.moduleSpecifier)) {
|
---|
87 | return null;
|
---|
88 | }
|
---|
89 | return importDecl.moduleSpecifier.text;
|
---|
90 | }
|
---|
91 | /**
|
---|
92 | * Gets the root identifier of a qualified type chain. For example: "core.GestureConfig"
|
---|
93 | * will return the "core" identifier. Allowing us to find the import of "core".
|
---|
94 | */
|
---|
95 | function getQualifiedNameRoot(name) {
|
---|
96 | while (ts.isQualifiedName(name.left)) {
|
---|
97 | name = name.left;
|
---|
98 | }
|
---|
99 | return ts.isIdentifier(name.left) ? name.left : null;
|
---|
100 | }
|
---|
101 | /**
|
---|
102 | * Gets the root identifier of a property access chain. For example: "core.GestureConfig"
|
---|
103 | * will return the "core" identifier. Allowing us to find the import of "core".
|
---|
104 | */
|
---|
105 | function getPropertyAccessRoot(node) {
|
---|
106 | while (ts.isPropertyAccessExpression(node.expression)) {
|
---|
107 | node = node.expression;
|
---|
108 | }
|
---|
109 | return ts.isIdentifier(node.expression) ? node.expression : null;
|
---|
110 | }
|
---|
111 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1wb3J0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9jZGsvc2NoZW1hdGljcy91cGRhdGUtdG9vbC91dGlscy9pbXBvcnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7O0dBTUc7OztBQUVILGlDQUFpQztBQVdqQyx1REFBdUQ7QUFDdkQsU0FBZ0IscUJBQXFCLENBQUMsSUFBbUIsRUFBRSxXQUEyQjtJQUVwRix1RUFBdUU7SUFDdkUsNEVBQTRFO0lBQzVFLG9DQUFvQztJQUNwQyxNQUFNLFlBQVksR0FBRyw2QkFBNkIsQ0FBQyxJQUFJLEVBQUUsV0FBVyxDQUFDLENBQUM7SUFDdEUsSUFBSSxZQUFZLEtBQUssSUFBSSxFQUFFO1FBQ3pCLE9BQU8sWUFBWSxDQUFDO0tBQ3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