1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | import * as babel from '@babel/types';
|
15 | import { AnalysisContext } from '../core/analysis-context';
|
16 | import { ParsedCssDocument } from '../css/css-document';
|
17 | import { ParsedHtmlDocument } from '../html/html-document';
|
18 | import { JavaScriptDocument } from '../javascript/javascript-document';
|
19 | import { ParsedJsonDocument } from '../json/json-document';
|
20 | import { ParsedDocument } from '../parser/document';
|
21 | import { ParsedTypeScriptDocument } from '../typescript/typescript-document';
|
22 | import { Feature, ScannedFeature } from './feature';
|
23 | import { ImmutableSet } from './immutable';
|
24 | import { AstNodeWithLanguage } from './inline-document';
|
25 | import { DocumentQuery as Query, DocumentQueryWithKind as QueryWithKind, FeatureKind, FeatureKindMap, Queryable } from './queryable';
|
26 | import { SourceRange } from './source-range';
|
27 | import { ResolvedUrl } from './url';
|
28 | import { Warning } from './warning';
|
29 |
|
30 |
|
31 |
|
32 | export declare class ScannedDocument {
|
33 | document: ParsedDocument;
|
34 | features: ScannedFeature[];
|
35 | warnings: Warning[];
|
36 | isInline: boolean;
|
37 | readonly sourceRange: SourceRange;
|
38 | readonly astNode: AstNodeWithLanguage | undefined;
|
39 | constructor(document: ParsedDocument, features: ScannedFeature[], warnings?: Warning[]);
|
40 | readonly url: ResolvedUrl;
|
41 | /**
|
42 | * Gets all features in this scanned document and all inline documents it
|
43 | * contains.
|
44 | */
|
45 | getNestedFeatures(): ScannedFeature[];
|
46 | private _getNestedFeatures;
|
47 | }
|
48 | export interface DeclaredWithStatement {
|
49 | |
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | statementAst: babel.Statement | undefined;
|
58 | }
|
59 | declare module './queryable' {
|
60 | interface FeatureKindMap {
|
61 | 'document': Document;
|
62 | 'html-document': Document<ParsedHtmlDocument>;
|
63 | 'js-document': Document<JavaScriptDocument>;
|
64 | 'json-document': Document<ParsedJsonDocument>;
|
65 | 'css-document': Document<ParsedCssDocument>;
|
66 | 'typescript-document': Document<ParsedTypeScriptDocument>;
|
67 | }
|
68 | }
|
69 | export declare class Document<ParsedType extends ParsedDocument = ParsedDocument> implements Feature, Queryable {
|
70 | readonly kinds: ImmutableSet<string>;
|
71 | readonly identifiers: ImmutableSet<string>;
|
72 | |
73 |
|
74 |
|
75 |
|
76 | _analysisContext: AnalysisContext;
|
77 | warnings: Warning[];
|
78 | languageAnalysis?: {};
|
79 | private readonly _localFeatures;
|
80 | private readonly _scannedDocument;
|
81 | private readonly _localFeaturesByStatement;
|
82 | |
83 |
|
84 |
|
85 |
|
86 |
|
87 | private _begunResolving;
|
88 | |
89 |
|
90 |
|
91 | private _doneResolving;
|
92 | constructor(base: ScannedDocument, analyzer: AnalysisContext, languageAnalysis?: {});
|
93 | readonly url: ResolvedUrl;
|
94 | readonly isInline: boolean;
|
95 | readonly sourceRange: SourceRange | undefined;
|
96 | readonly astNode: AstNodeWithLanguage | undefined;
|
97 | readonly parsedDocument: ParsedType;
|
98 | readonly resolved: boolean;
|
99 | readonly type: string;
|
100 | /**
|
101 | * Resolves all features of this document, so that they have references to all
|
102 | * their dependencies.
|
103 | *
|
104 | * This method can only be called once
|
105 | */
|
106 | resolve(): void;
|
107 | /**
|
108 | * Adds and indexes a feature to this document before resolve().
|
109 | */
|
110 | _addFeature(feature: Feature): void;
|
111 | /**
|
112 | * Get features on the document.
|
113 | *
|
114 | * Be default it includes only features on the document, but you can specify
|
115 | * whether to include features that are reachable by imports, features from
|
116 | * outside the current package, etc. See the documentation for Query for more
|
117 | * details.
|
118 | *
|
119 | * You can also narrow by feature kind and identifier.
|
120 | */
|
121 | getFeatures<K extends FeatureKind>(query: QueryWithKind<K>): Set<FeatureKindMap[K]>;
|
122 | getFeatures(query?: Query): Set<Feature>;
|
123 | private _getByKind;
|
124 | private _getById;
|
125 | private _getByStatement;
|
126 | /** Filters out the given features by the given kind. */
|
127 | private _filterByKind;
|
128 | private _isCachable;
|
129 | private _getSlowlyByKind;
|
130 | /**
|
131 | * Walks the graph of documents, starting from `this`, finding features which
|
132 | * match the given query and adding them to the `result` set. Uses `visited`
|
133 | * to deal with cycles.
|
134 | *
|
135 | * This method is O(numFeatures), though it does not walk documents that are
|
136 | * not relevant to the query (e.g. based on whether the query follows imports,
|
137 | * or excludes lazy imports)
|
138 | */
|
139 | private _listFeatures;
|
140 | private _filterOutExternal;
|
141 | /**
|
142 | * Get warnings for the document and all matched features.
|
143 | */
|
144 | getWarnings(query?: Query): Warning[];
|
145 | toString(): string;
|
146 | private _toString;
|
147 | stringify(): string;
|
148 | private _indexFeature;
|
149 | private _featuresByKind;
|
150 | private _featuresByKindAndId;
|
151 | private _buildIndexes;
|
152 | }
|