1 | import * as ts from 'typescript';
|
2 | import { PackageJsonLookup } from '@rushstack/node-core-library';
|
3 | import { AstDeclaration } from './AstDeclaration';
|
4 | import { AstModule, AstModuleExportInfo } from './AstModule';
|
5 | import { AstEntity } from './AstEntity';
|
6 | import { MessageRouter } from '../collector/MessageRouter';
|
7 |
|
8 |
|
9 |
|
10 | export interface IFetchAstSymbolOptions {
|
11 | |
12 |
|
13 |
|
14 | followedSymbol: ts.Symbol;
|
15 | |
16 |
|
17 |
|
18 | isExternal: boolean;
|
19 | |
20 |
|
21 |
|
22 |
|
23 | includeNominalAnalysis: boolean;
|
24 | |
25 |
|
26 |
|
27 |
|
28 | addIfMissing: boolean;
|
29 | |
30 |
|
31 |
|
32 | localName?: string;
|
33 | }
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | export declare class AstSymbolTable {
|
45 | private readonly _program;
|
46 | private readonly _typeChecker;
|
47 | private readonly _messageRouter;
|
48 | private readonly _globalVariableAnalyzer;
|
49 | private readonly _packageMetadataManager;
|
50 | private readonly _exportAnalyzer;
|
51 | private readonly _alreadyWarnedGlobalNames;
|
52 | |
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | private readonly _astSymbolsBySymbol;
|
60 | |
61 |
|
62 |
|
63 | private readonly _astDeclarationsByDeclaration;
|
64 | private readonly _entitiesByNode;
|
65 | constructor(program: ts.Program, typeChecker: ts.TypeChecker, packageJsonLookup: PackageJsonLookup, bundledPackageNames: ReadonlySet<string>, messageRouter: MessageRouter);
|
66 | /**
|
67 | * Used to analyze an entry point that belongs to the working package.
|
68 | */
|
69 | fetchAstModuleFromWorkingPackage(sourceFile: ts.SourceFile): AstModule;
|
70 | /**
|
71 | * This crawls the specified entry point and collects the full set of exported AstSymbols.
|
72 | */
|
73 | fetchAstModuleExportInfo(astModule: AstModule): AstModuleExportInfo;
|
74 | /**
|
75 | * Attempts to retrieve an export by name from the specified `AstModule`.
|
76 | * Returns undefined if no match was found.
|
77 | */
|
78 | tryGetExportOfAstModule(exportName: string, astModule: AstModule): AstEntity | undefined;
|
79 | /**
|
80 | * Ensures that AstSymbol.analyzed is true for the provided symbol. The operation
|
81 | * starts from the root symbol and then fills out all children of all declarations, and
|
82 | * also calculates AstDeclaration.referencedAstSymbols for all declarations.
|
83 | * If the symbol is not imported, any non-imported references are also analyzed.
|
84 | *
|
85 | * @remarks
|
86 | * This is an expensive operation, so we only perform it for top-level exports of an
|
87 | * the AstModule. For example, if some code references a nested class inside
|
88 | * a namespace from another library, we do not analyze any of that class's siblings
|
89 | * or members. (We do always construct its parents however, since AstDefinition.parent
|
90 | * is immutable, and needed e.g. to calculate release tag inheritance.)
|
91 | */
|
92 | analyze(astEntity: AstEntity): void;
|
93 | /**
|
94 | * For a given astDeclaration, this efficiently finds the child corresponding to the
|
95 | * specified ts.Node. It is assumed that AstDeclaration.isSupportedSyntaxKind() would return true for
|
96 | * that node type, and that the node is an immediate child of the provided AstDeclaration.
|
97 | */
|
98 | getChildAstDeclarationByNode(node: ts.Node, parentAstDeclaration: AstDeclaration): AstDeclaration;
|
99 | /**
|
100 | * For a given ts.Identifier that is part of an AstSymbol that we analyzed, return the AstEntity that
|
101 | * it refers to. Returns undefined if it doesn't refer to anything interesting.
|
102 | * @remarks
|
103 | * Throws an Error if the ts.Identifier is not part of node tree that was analyzed.
|
104 | */
|
105 | tryGetEntityForNode(identifier: ts.Identifier | ts.ImportTypeNode): AstEntity | undefined;
|
106 | /**
|
107 | * Builds an AstSymbol.localName for a given ts.Symbol. In the current implementation, the localName is
|
108 | * a TypeScript-like expression that may be a string literal or ECMAScript symbol expression.
|
109 | *
|
110 | * ```ts
|
111 | * class X {
|
112 | *
|
113 | * public identifier: number = 1;
|
114 | *
|
115 | * public "quoted string!": number = 2;
|
116 | *
|
117 | * public [MyNamespace.MySymbol]: number = 3;
|
118 | * }
|
119 | * ```
|
120 | */
|
121 | static getLocalNameForSymbol(symbol: ts.Symbol): string;
|
122 | private _analyzeAstNamespaceImport;
|
123 | private _analyzeAstSymbol;
|
124 | /**
|
125 | * Used by analyze to recursively analyze the entire child tree.
|
126 | */
|
127 | private _analyzeChildTree;
|
128 | private _fetchEntityForNode;
|
129 | private _fetchAstDeclaration;
|
130 | private _fetchAstSymbol;
|
131 | /**
|
132 | * Returns the first parent satisfying isAstDeclaration(), or undefined if none is found.
|
133 | */
|
134 | private _tryFindFirstAstDeclarationParent;
|
135 | }
|
136 | //# sourceMappingURL=AstSymbolTable.d.ts.map |
\ | No newline at end of file |