1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | import { ForkOptions, Options } from '../core/analyzer';
|
15 | import { Result } from '../model/analysis';
|
16 | import { Document, ScannedDocument, Warning } from '../model/model';
|
17 | import { PackageRelativeUrl, ResolvedUrl } from '../model/url';
|
18 | import { ParsedDocument } from '../parser/document';
|
19 | import { Parser } from '../parser/parser';
|
20 | import { Scanner } from '../scanning/scanner';
|
21 | import { UrlLoader } from '../url-loader/url-loader';
|
22 | import { UrlResolver } from '../url-loader/url-resolver';
|
23 | import { AnalysisCache } from './analysis-cache';
|
24 | import { MinimalCancelToken } from './cancel-token';
|
25 | export declare const analyzerVersion: string;
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | export declare class AnalysisContext {
|
40 | readonly parsers: Map<string, Parser<ParsedDocument<{} | null | undefined, {}>>>;
|
41 | private readonly _languageAnalyzers;
|
42 |
|
43 | private readonly _lazyEdges;
|
44 | private readonly _scanners;
|
45 | readonly loader: UrlLoader;
|
46 | readonly resolver: UrlResolver;
|
47 | private readonly _cache;
|
48 |
|
49 | private readonly _generation;
|
50 | |
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | private _analysisComplete;
|
57 | static getDefaultScanners(options: Options): Map<string, Scanner<ParsedDocument<{} | null | undefined, {}>, {} | null | undefined, {}>[]>;
|
58 | constructor(options: Options, cache?: AnalysisCache, generation?: number);
|
59 | /**
|
60 | * Returns a copy of this cache context with proper cache invalidation.
|
61 | */
|
62 | filesChanged(urls: PackageRelativeUrl[]): AnalysisContext;
|
63 | /**
|
64 | * Implements Analyzer#analyze, see its docs.
|
65 | */
|
66 | analyze(urls: PackageRelativeUrl[], cancelToken: MinimalCancelToken): Promise<AnalysisContext>;
|
67 | /**
|
68 | * Internal analysis method called when we know we need to fork.
|
69 | */
|
70 | private _analyze;
|
71 | /**
|
72 | * Gets an analyzed Document from the document cache. This is only useful for
|
73 | * Analyzer plugins. You almost certainly want to use `analyze()` instead.
|
74 | *
|
75 | * If a document has been analyzed, it returns the analyzed Document. If not
|
76 | * the scanned document cache is used and a new analyzed Document is returned.
|
77 | * If a file is in neither cache, it returns `undefined`.
|
78 | */
|
79 | getDocument(resolvedUrl: ResolvedUrl): Document | Warning;
|
80 | /**
|
81 | * This is only useful for Analyzer plugins.
|
82 | *
|
83 | * If a url has been scanned, returns the ScannedDocument.
|
84 | */
|
85 | _getScannedDocument(resolvedUrl: ResolvedUrl): ScannedDocument | undefined;
|
86 | /**
|
87 | * Clear all cached information from this analyzer instance.
|
88 | *
|
89 | * Note: if at all possible, instead tell the analyzer about the specific
|
90 | * files that changed rather than clearing caches like this. Caching provides
|
91 | * large performance gains.
|
92 | */
|
93 | clearCaches(): AnalysisContext;
|
94 | /**
|
95 | * Returns a copy of the context but with optional replacements of cache or
|
96 | * constructor options.
|
97 | *
|
98 | * Note: this feature is experimental.
|
99 | */
|
100 | _fork(cache?: AnalysisCache, options?: ForkOptions): AnalysisContext;
|
101 | /**
|
102 | * Scans a file locally, that is for features that do not depend
|
103 | * on this files imports. Local features can be cached even when
|
104 | * imports are invalidated. This method does not trigger transitive
|
105 | * scanning, _scan() does that.
|
106 | *
|
107 | * TODO(justinfagnani): consider renaming this to something like
|
108 | * _preScan, since about the only useful things it can find are
|
109 | * imports, exports and other syntactic structures.
|
110 | */
|
111 | private _scanLocal;
|
112 | /**
|
113 | * Scan a toplevel document and all of its transitive dependencies.
|
114 | */
|
115 | scan(resolvedUrl: ResolvedUrl, cancelToken: MinimalCancelToken): Promise<Result<ScannedDocument, Warning>>;
|
116 | /**
|
117 | * Scans a ParsedDocument.
|
118 | */
|
119 | private _scanDocument;
|
120 | private _getScannedFeatures;
|
121 | private _scanInlineDocuments;
|
122 | /**
|
123 | * Returns `true` if the provided resolved URL can be loaded. Obeys the
|
124 | * semantics defined by `UrlLoader` and should only be used to check
|
125 | * resolved URLs.
|
126 | */
|
127 | canLoad(resolvedUrl: ResolvedUrl): boolean;
|
128 | /**
|
129 | * Loads the content at the provided resolved URL. Obeys the semantics
|
130 | * defined by `UrlLoader` and should only be used to attempt to load resolved
|
131 | * URLs.
|
132 | *
|
133 | * Currently does no caching. If the provided contents are given then they
|
134 | * are used instead of hitting the UrlLoader (e.g. when you have in-memory
|
135 | * contents that should override disk).
|
136 | */
|
137 | load(resolvedUrl: ResolvedUrl): Promise<Result<string, string>>;
|
138 | /**
|
139 | * Caching + loading wrapper around _parseContents.
|
140 | */
|
141 | private _parse;
|
142 | /**
|
143 | * Parse the given string into the Abstract Syntax Tree (AST) corresponding
|
144 | * to its type.
|
145 | */
|
146 | private _parseContents;
|
147 | /**
|
148 | * Resolves all resolvable URLs in the list, removes unresolvable ones.
|
149 | */
|
150 | resolveUserInputUrls(urls: PackageRelativeUrl[]): ResolvedUrl[];
|
151 | }
|