Strict null check extHostSearch.ts

This commit is contained in:
Rob Lourens
2019-02-09 16:18:02 -08:00
parent 621163d300
commit cbff363641
2 changed files with 12 additions and 3 deletions

View File

@@ -124,6 +124,10 @@ export class ExtHostSearch implements ExtHostSearchShape {
}, token);
} else {
const indexProvider = this._fileIndexProvider.get(handle);
if (!indexProvider) {
throw new Error('unknown provider: ' + handle);
}
return this._fileIndexSearchManager.fileSearch(query, indexProvider, batch => {
this._proxy.$handleFileMatch(handle, session, batch.map(p => p.resource));
}, token);
@@ -147,7 +151,11 @@ export class ExtHostSearch implements ExtHostSearchShape {
}
};
return this._internalFileSearchProvider.doFileSearch(rawQuery, onResult, token);
if (!this._internalFileSearchProvider) {
throw new Error('No internal file search handler');
}
return <Promise<ISearchCompleteStats>>this._internalFileSearchProvider.doFileSearch(rawQuery, onResult, token);
}
$clearCache(cacheKey: string): Promise<void> {
@@ -163,8 +171,8 @@ export class ExtHostSearch implements ExtHostSearchShape {
$provideTextSearchResults(handle: number, session: number, rawQuery: IRawTextQuery, token: CancellationToken): Promise<ISearchCompleteStats> {
const provider = this._textSearchProvider.get(handle);
if (!provider.provideTextSearchResults) {
return Promise.resolve(undefined);
if (!provider || !provider.provideTextSearchResults) {
throw new Error(`Unknown provider ${handle}`);
}
const query = reviveQuery(rawQuery);