1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { SummaryResolver } from '../summary_resolver';
|
---|
9 | import { StaticSymbol, StaticSymbolCache } from './static_symbol';
|
---|
10 | export declare class ResolvedStaticSymbol {
|
---|
11 | symbol: StaticSymbol;
|
---|
12 | metadata: any;
|
---|
13 | constructor(symbol: StaticSymbol, metadata: any);
|
---|
14 | }
|
---|
15 | /**
|
---|
16 | * The host of the SymbolResolverHost disconnects the implementation from TypeScript / other
|
---|
17 | * language
|
---|
18 | * services and from underlying file systems.
|
---|
19 | */
|
---|
20 | export interface StaticSymbolResolverHost {
|
---|
21 | /**
|
---|
22 | * Return a ModuleMetadata for the given module.
|
---|
23 | * Angular CLI will produce this metadata for a module whenever a .d.ts files is
|
---|
24 | * produced and the module has exported variables or classes with decorators. Module metadata can
|
---|
25 | * also be produced directly from TypeScript sources by using MetadataCollector in tools/metadata.
|
---|
26 | *
|
---|
27 | * @param modulePath is a string identifier for a module as an absolute path.
|
---|
28 | * @returns the metadata for the given module.
|
---|
29 | */
|
---|
30 | getMetadataFor(modulePath: string): {
|
---|
31 | [key: string]: any;
|
---|
32 | }[] | undefined;
|
---|
33 | /**
|
---|
34 | * Converts a module name that is used in an `import` to a file path.
|
---|
35 | * I.e.
|
---|
36 | * `path/to/containingFile.ts` containing `import {...} from 'module-name'`.
|
---|
37 | */
|
---|
38 | moduleNameToFileName(moduleName: string, containingFile?: string): string | null;
|
---|
39 | /**
|
---|
40 | * Get a file suitable for display to the user that should be relative to the project directory
|
---|
41 | * or the current directory.
|
---|
42 | */
|
---|
43 | getOutputName(filePath: string): string;
|
---|
44 | }
|
---|
45 | /**
|
---|
46 | * This class is responsible for loading metadata per symbol,
|
---|
47 | * and normalizing references between symbols.
|
---|
48 | *
|
---|
49 | * Internally, it only uses symbols without members,
|
---|
50 | * and deduces the values for symbols with members based
|
---|
51 | * on these symbols.
|
---|
52 | */
|
---|
53 | export declare class StaticSymbolResolver {
|
---|
54 | private host;
|
---|
55 | private staticSymbolCache;
|
---|
56 | private summaryResolver;
|
---|
57 | private errorRecorder?;
|
---|
58 | private metadataCache;
|
---|
59 | private resolvedSymbols;
|
---|
60 | private importAs;
|
---|
61 | private symbolResourcePaths;
|
---|
62 | private symbolFromFile;
|
---|
63 | private knownFileNameToModuleNames;
|
---|
64 | constructor(host: StaticSymbolResolverHost, staticSymbolCache: StaticSymbolCache, summaryResolver: SummaryResolver<StaticSymbol>, errorRecorder?: ((error: any, fileName?: string | undefined) => void) | undefined);
|
---|
65 | resolveSymbol(staticSymbol: StaticSymbol): ResolvedStaticSymbol;
|
---|
66 | /**
|
---|
67 | * getImportAs produces a symbol that can be used to import the given symbol.
|
---|
68 | * The import might be different than the symbol if the symbol is exported from
|
---|
69 | * a library with a summary; in which case we want to import the symbol from the
|
---|
70 | * ngfactory re-export instead of directly to avoid introducing a direct dependency
|
---|
71 | * on an otherwise indirect dependency.
|
---|
72 | *
|
---|
73 | * @param staticSymbol the symbol for which to generate a import symbol
|
---|
74 | */
|
---|
75 | getImportAs(staticSymbol: StaticSymbol, useSummaries?: boolean): StaticSymbol | null;
|
---|
76 | /**
|
---|
77 | * getResourcePath produces the path to the original location of the symbol and should
|
---|
78 | * be used to determine the relative location of resource references recorded in
|
---|
79 | * symbol metadata.
|
---|
80 | */
|
---|
81 | getResourcePath(staticSymbol: StaticSymbol): string;
|
---|
82 | /**
|
---|
83 | * getTypeArity returns the number of generic type parameters the given symbol
|
---|
84 | * has. If the symbol is not a type the result is null.
|
---|
85 | */
|
---|
86 | getTypeArity(staticSymbol: StaticSymbol): number | null;
|
---|
87 | getKnownModuleName(filePath: string): string | null;
|
---|
88 | recordImportAs(sourceSymbol: StaticSymbol, targetSymbol: StaticSymbol): void;
|
---|
89 | recordModuleNameForFileName(fileName: string, moduleName: string): void;
|
---|
90 | /**
|
---|
91 | * Invalidate all information derived from the given file and return the
|
---|
92 | * static symbols contained in the file.
|
---|
93 | *
|
---|
94 | * @param fileName the file to invalidate
|
---|
95 | */
|
---|
96 | invalidateFile(fileName: string): StaticSymbol[];
|
---|
97 | private _resolveSymbolMembers;
|
---|
98 | private _resolveSymbolFromSummary;
|
---|
99 | /**
|
---|
100 | * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
|
---|
101 | * All types passed to the StaticResolver should be pseudo-types returned by this method.
|
---|
102 | *
|
---|
103 | * @param declarationFile the absolute path of the file where the symbol is declared
|
---|
104 | * @param name the name of the type.
|
---|
105 | * @param members a symbol for a static member of the named type
|
---|
106 | */
|
---|
107 | getStaticSymbol(declarationFile: string, name: string, members?: string[]): StaticSymbol;
|
---|
108 | /**
|
---|
109 | * hasDecorators checks a file's metadata for the presence of decorators without evaluating the
|
---|
110 | * metadata.
|
---|
111 | *
|
---|
112 | * @param filePath the absolute path to examine for decorators.
|
---|
113 | * @returns true if any class in the file has a decorator.
|
---|
114 | */
|
---|
115 | hasDecorators(filePath: string): boolean;
|
---|
116 | getSymbolsOf(filePath: string): StaticSymbol[];
|
---|
117 | private _createSymbolsOf;
|
---|
118 | private createResolvedSymbol;
|
---|
119 | private createExport;
|
---|
120 | private reportError;
|
---|
121 | /**
|
---|
122 | * @param module an absolute path to a module file.
|
---|
123 | */
|
---|
124 | private getModuleMetadata;
|
---|
125 | getSymbolByModule(module: string, symbolName: string, containingFile?: string): StaticSymbol;
|
---|
126 | private resolveModule;
|
---|
127 | }
|
---|
128 | export declare function unescapeIdentifier(identifier: string): string;
|
---|
129 | export declare function unwrapResolvedMetadata(metadata: any): any;
|
---|