@@ -148,7 +148,7 @@ export abstract class WatchedFiles<T> implements vscode.Disposable {
148
148
this . disposables . push (
149
149
vscode . workspace . onDidChangeTextDocument ( ( event : vscode . TextDocumentChangeEvent ) => {
150
150
if ( isUntitledScheme ( event . document . uri ) ) {
151
- this . addItemToRegistry ( event . document . uri , true , event . document . getText ( ) )
151
+ this . addItem ( event . document . uri , true , event . document . getText ( ) )
152
152
}
153
153
} ) ,
154
154
vscode . workspace . onDidCloseTextDocument ( ( event : vscode . TextDocument ) => {
@@ -175,7 +175,7 @@ export abstract class WatchedFiles<T> implements vscode.Disposable {
175
175
* Adds an item to registry. Wipes any existing item in its place with new copy of the data
176
176
* @param uri vscode.Uri containing the item to load in
177
177
*/
178
- public async addItemToRegistry ( uri : vscode . Uri , quiet ?: boolean , contents ?: string ) : Promise < void > {
178
+ public async addItem ( uri : vscode . Uri , quiet ?: boolean , contents ?: string ) : Promise < void > {
179
179
const excluded = this . excludedFilePatterns . find ( pattern => uri . fsPath . match ( pattern ) )
180
180
if ( excluded ) {
181
181
getLogger ( ) . verbose ( `${ this . name } : excluding path (matches "${ excluded } "): ${ uri . fsPath } ` )
@@ -200,12 +200,13 @@ export abstract class WatchedFiles<T> implements vscode.Disposable {
200
200
}
201
201
202
202
/**
203
- * Get a specific item's data
204
- * Untitled files must be referred to by their URI
203
+ * Gets an item by filepath or URI.
204
+ *
205
+ * Untitled files must be referred to by URI.
206
+ *
205
207
* @param path Absolute path to item of interest or a vscode.Uri to the item
206
208
*/
207
- public getRegisteredItem ( path : string | vscode . Uri ) : WatchedItem < T > | undefined {
208
- // fsPath is needed for Windows, it's equivalent to path on mac/linux
209
+ public getItem ( path : string | vscode . Uri ) : WatchedItem < T > | undefined {
209
210
const normalizedPath = typeof path === 'string' ? pathutils . normalize ( path ) : normalizeVSCodeUri ( path )
210
211
this . assertAbsolute ( normalizedPath )
211
212
const item = this . registryData . get ( normalizedPath )
@@ -219,13 +220,13 @@ export abstract class WatchedFiles<T> implements vscode.Disposable {
219
220
}
220
221
221
222
/**
222
- * Returns the registry's data as an array of paths to type T objects
223
+ * Gets all registry items as an array of paths to type `T` objects.
223
224
*/
224
- public get registeredItems ( ) : WatchedItem < T > [ ] {
225
+ public get items ( ) : WatchedItem < T > [ ] {
225
226
const arr : WatchedItem < T > [ ] = [ ]
226
227
227
228
for ( const itemPath of this . registryData . keys ( ) ) {
228
- const item = this . getRegisteredItem ( itemPath )
229
+ const item = this . getItem ( itemPath )
229
230
if ( item ) {
230
231
arr . push ( item )
231
232
}
@@ -272,7 +273,7 @@ export abstract class WatchedFiles<T> implements vscode.Disposable {
272
273
try {
273
274
const found = await vscode . workspace . findFiles ( glob , exclude )
274
275
for ( const item of found ) {
275
- await this . addItemToRegistry ( item , true )
276
+ await this . addItem ( item , true )
276
277
}
277
278
} catch ( e ) {
278
279
const err = e as Error
@@ -299,11 +300,11 @@ export abstract class WatchedFiles<T> implements vscode.Disposable {
299
300
watcher ,
300
301
watcher . onDidChange ( async uri => {
301
302
getLogger ( ) . verbose ( `${ this . name } : detected change: ${ uri . fsPath } ` )
302
- await this . addItemToRegistry ( uri )
303
+ await this . addItem ( uri )
303
304
} ) ,
304
305
watcher . onDidCreate ( async uri => {
305
306
getLogger ( ) . verbose ( `${ this . name } : detected new file: ${ uri . fsPath } ` )
306
- await this . addItemToRegistry ( uri )
307
+ await this . addItem ( uri )
307
308
} ) ,
308
309
watcher . onDidDelete ( async uri => {
309
310
getLogger ( ) . verbose ( `${ this . name } : detected delete: ${ uri . fsPath } ` )
0 commit comments