提交 cbff3636 编写于 作者: R Rob Lourens

Strict null check extHostSearch.ts

上级 621163d3
...@@ -430,6 +430,7 @@ ...@@ -430,6 +430,7 @@
"./vs/workbench/api/node/extHostMessageService.ts", "./vs/workbench/api/node/extHostMessageService.ts",
"./vs/workbench/api/node/extHostOutputService.ts", "./vs/workbench/api/node/extHostOutputService.ts",
"./vs/workbench/api/node/extHostSearch.fileIndex.ts", "./vs/workbench/api/node/extHostSearch.fileIndex.ts",
"./vs/workbench/api/node/extHostSearch.ts",
"./vs/workbench/api/node/extHostStorage.ts", "./vs/workbench/api/node/extHostStorage.ts",
"./vs/workbench/api/node/extHostTypes.ts", "./vs/workbench/api/node/extHostTypes.ts",
"./vs/workbench/api/node/extHostUrls.ts", "./vs/workbench/api/node/extHostUrls.ts",
......
...@@ -124,6 +124,10 @@ export class ExtHostSearch implements ExtHostSearchShape { ...@@ -124,6 +124,10 @@ export class ExtHostSearch implements ExtHostSearchShape {
}, token); }, token);
} else { } else {
const indexProvider = this._fileIndexProvider.get(handle); const indexProvider = this._fileIndexProvider.get(handle);
if (!indexProvider) {
throw new Error('unknown provider: ' + handle);
}
return this._fileIndexSearchManager.fileSearch(query, indexProvider, batch => { return this._fileIndexSearchManager.fileSearch(query, indexProvider, batch => {
this._proxy.$handleFileMatch(handle, session, batch.map(p => p.resource)); this._proxy.$handleFileMatch(handle, session, batch.map(p => p.resource));
}, token); }, token);
...@@ -147,7 +151,11 @@ export class ExtHostSearch implements ExtHostSearchShape { ...@@ -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> { $clearCache(cacheKey: string): Promise<void> {
...@@ -163,8 +171,8 @@ export class ExtHostSearch implements ExtHostSearchShape { ...@@ -163,8 +171,8 @@ export class ExtHostSearch implements ExtHostSearchShape {
$provideTextSearchResults(handle: number, session: number, rawQuery: IRawTextQuery, token: CancellationToken): Promise<ISearchCompleteStats> { $provideTextSearchResults(handle: number, session: number, rawQuery: IRawTextQuery, token: CancellationToken): Promise<ISearchCompleteStats> {
const provider = this._textSearchProvider.get(handle); const provider = this._textSearchProvider.get(handle);
if (!provider.provideTextSearchResults) { if (!provider || !provider.provideTextSearchResults) {
return Promise.resolve(undefined); throw new Error(`Unknown provider ${handle}`);
} }
const query = reviveQuery(rawQuery); const query = reviveQuery(rawQuery);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册