forked from buehler/node-typescript-parser
-
Notifications
You must be signed in to change notification settings - Fork 2
/
DeclarationIndex.d.ts
217 lines (217 loc) · 6.36 KB
/
DeclarationIndex.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
import { DeclarationInfo } from './declarations/DeclarationInfo';
import { TypescriptParser } from './TypescriptParser';
/**
* IndexDelta type, is calculated by the declaration index to give an overview, what has changed in the index.
* Returns a list of deleted declarations, newly added declarations (with the corresponding infos) and
* which declarations have been updated (with all declarations under that name).
*/
export declare type IndexDelta = {
added: {
[declaration: string]: DeclarationInfo[];
};
updated: {
[declaration: string]: DeclarationInfo[];
};
deleted: string[];
};
/**
* Interface for file changes. Contains lists of file uri's to the specific action.
*
* @export
* @interface FileChanges
*/
export interface FileChanges {
created: string[];
updated: string[];
deleted: string[];
}
/**
* Global index of declarations. Contains declarations and origins.
* Provides reverse index for search and declaration info for imports.
*
* @export
* @class DeclarationIndex
*/
export declare class DeclarationIndex {
private parser;
private rootPath;
private building;
/**
* Hash of parsed resources. Contains all parsed files / namespaces / declarations
* of the current workspace.
*
* @private
* @type {Resources}
* @memberof DeclarationIndex
*/
private parsedResources;
/**
* Declaration index. Reverse index from a name to many declarations assotiated to the name.
*
* @private
* @type {({ [declaration: string]: DeclarationInfo[] } | undefined)}
* @memberof DeclarationIndex
*/
private _index;
/**
* Indicator if the first index was loaded and calculated or not.
*
* @readonly
* @type {boolean}
* @memberof DeclarationIndex
*/
get indexReady(): boolean;
/**
* Reverse index of the declarations.
*
* @readonly
* @type {({ [declaration: string]: DeclarationInfo[] } | undefined)}
* @memberof DeclarationIndex
*/
get index(): {
[declaration: string]: DeclarationInfo[];
} | undefined;
/**
* List of all declaration information. Contains the typescript declaration and the
* "from" information (from where the symbol is imported).
*
* @readonly
* @type {DeclarationInfo[]}
* @memberof DeclarationIndex
*/
get declarationInfos(): DeclarationInfo[];
constructor(parser: TypescriptParser, rootPath: string);
/**
* Calculates the differences between two indices. Calculates removed, added and updated declarations.
* The updated declarations are calculated and all declarations that the new index contains are inserted in the list.
*
* @static
* @param {{ [declaration: string]: DeclarationInfo[] }} oldIndex
* @param {{ [declaration: string]: DeclarationInfo[] }} newIndex
* @returns {IndexDelta}
* @memberof DeclarationIndex
*/
static calculateIndexDelta(oldIndex: {
[declaration: string]: DeclarationInfo[];
}, newIndex: {
[declaration: string]: DeclarationInfo[];
}): IndexDelta;
/**
* Resets the whole index. Does delete everything. Period.
* Is useful for unit testing or similar things.
*
* @memberof DeclarationIndex
*/
reset(): void;
/**
* Tells the index to build a new index.
* Can be canceled with a cancellationToken.
*
* @param {string[]} filePathes
* @returns {Promise<void>}
*
* @memberof DeclarationIndex
*/
buildIndex(filePathes: string[]): Promise<void>;
/**
* Is called when file events happen. Does reindex for the changed files and creates a new index.
* Returns the differences for the new index.
*
* @param {FileEvent[]} changes
* @returns {Promise<IndexDelta>}
*
* @memberof DeclarationIndex
*/
reindexForChanges(changes: FileChanges): Promise<IndexDelta>;
/**
* Returns a list of files that export a certain resource (declaration).
*
* @private
* @param {string} resourceToCheck
* @returns {string[]}
*
* @memberof DeclarationIndex
*/
private getExportedResources;
/**
* Checks if a file does export another resource.
* (i.e. export ... from ...)
*
* @private
* @param {File} resource The file that is checked
* @param {string} resourcePath The resource that is searched for
* @returns {boolean}
*
* @memberof DeclarationIndex
*/
private doesExportResource;
/**
* Does parse the resources (symbols and declarations) of a given file.
* Can be cancelled with the token.
*
* @private
* @param {File[]} [files=[]]
* @returns {Promise<Resources>}
*
* @memberof DeclarationIndex
*/
private parseResources;
/**
* Creates a reverse index out of the give resources.
* Can be cancelled with the token.
*
* @private
* @param {Resources} resources
* @returns {Promise<ResourceIndex>}
*
* @memberof DeclarationIndex
*/
private createIndex;
/**
* Process all exports of a the parsed resources. Does move the declarations accordingly to their
* export nature.
*
* @private
* @param {Resources} parsedResources
* @param {Resource} resource
* @param {Resource[]} [processedResources=[]]
* @returns {void}
*
* @memberof DeclarationIndex
*/
private processResourceExports;
/**
* Processes an all export, does move the declarations accordingly.
* (i.e. export * from './myFile')
*
* @private
* @param {Resource} exportingLib
* @param {Resource} exportedLib
*
* @memberof DeclarationIndex
*/
private processAllFromExport;
/**
* Processes a named export, does move the declarations accordingly.
* (i.e. export {MyClass} from './myFile')
*
* @private
* @param {NamedExport} tsExport
* @param {Resource} exportingLib
* @param {Resource} exportedLib
*
* @memberof DeclarationIndex
*/
private processNamedFromExport;
/**
* Processes an assigned export, does move the declarations accordingly.
* (i.e. export = namespaceName)
*
* @private
* @param {AssignedExport} tsExport
* @param {Resource} exportingLib
*
* @memberof DeclarationIndex
*/
private processAssignedExport;
}