diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 55c52fe5b61..3cf149651b9 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -624,6 +624,7 @@ "./vs/workbench/parts/welcome/walkThrough/node/walkThroughUtils.ts", "./vs/workbench/services/activity/common/activity.ts", "./vs/workbench/services/backup/common/backup.ts", + "./vs/workbench/services/backup/node/backupFileService.ts", "./vs/workbench/services/commands/common/commandService.ts", "./vs/workbench/services/configuration/common/configuration.ts", "./vs/workbench/services/configuration/common/configurationExtensionPoint.ts", @@ -665,6 +666,7 @@ "./vs/workbench/services/notification/common/notificationService.ts", "./vs/workbench/services/panel/common/panelService.ts", "./vs/workbench/services/part/common/partService.ts", + "./vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl.ts", "./vs/workbench/services/remote/node/remoteAgentEnvironmentChannel.ts", "./vs/workbench/services/remote/node/remoteAgentService.ts", "./vs/workbench/services/scm/common/scm.ts", @@ -672,12 +674,14 @@ "./vs/workbench/services/search/common/searchHelpers.ts", "./vs/workbench/services/search/node/fileSearchManager.ts", "./vs/workbench/services/search/node/legacy/search.ts", + "./vs/workbench/services/search/node/ripgrepFileSearch.ts", "./vs/workbench/services/search/node/ripgrepSearchProvider.ts", "./vs/workbench/services/search/node/ripgrepSearchUtils.ts", "./vs/workbench/services/search/node/ripgrepTextSearchEngine.ts", "./vs/workbench/services/search/node/search.ts", "./vs/workbench/services/search/node/searchHistoryService.ts", "./vs/workbench/services/search/node/searchIpc.ts", + "./vs/workbench/services/search/node/textSearchAdapter.ts", "./vs/workbench/services/search/node/textSearchManager.ts", "./vs/workbench/services/search/test/node/ripgrepTextSearchEngine.test.ts", "./vs/workbench/services/search/test/node/textSearchManager.test.ts", diff --git a/src/vs/workbench/services/backup/common/backup.ts b/src/vs/workbench/services/backup/common/backup.ts index 7c6d84d01e5..a9ff80f9b9b 100644 --- a/src/vs/workbench/services/backup/common/backup.ts +++ b/src/vs/workbench/services/backup/common/backup.ts @@ -31,7 +31,7 @@ export interface IBackupFileService { * @param resource The resource that is backed up. * @return The backup resource if any. */ - loadBackupResource(resource: Uri): TPromise; + loadBackupResource(resource: Uri): TPromise; /** * Given a resource, returns the associated backup resource. @@ -63,7 +63,7 @@ export interface IBackupFileService { * @param value The contents from a backup resource as stream. * @return The backup file's backed up content as text buffer factory. */ - resolveBackupContent(backup: Uri): TPromise; + resolveBackupContent(backup: Uri): TPromise; /** * Discards the backup associated with a resource if it exists.. diff --git a/src/vs/workbench/services/backup/node/backupFileService.ts b/src/vs/workbench/services/backup/node/backupFileService.ts index 61520c6260d..43fbee57535 100644 --- a/src/vs/workbench/services/backup/node/backupFileService.ts +++ b/src/vs/workbench/services/backup/node/backupFileService.ts @@ -32,7 +32,7 @@ export class BackupSnapshot implements ITextSnapshot { constructor(private snapshot: ITextSnapshot, private preamble: string) { } - read(): string { + read(): string | null { let value = this.snapshot.read(); if (!this.preambleHandled) { this.preambleHandled = true; @@ -145,7 +145,7 @@ export class BackupFileService implements IBackupFileService { }); } - loadBackupResource(resource: Uri): TPromise { + loadBackupResource(resource: Uri): TPromise { return this.ready.then(model => { // Return directly if we have a known backup with that resource @@ -252,7 +252,7 @@ export class InMemoryBackupFileService implements IBackupFileService { return TPromise.as(this.backups.size > 0); } - loadBackupResource(resource: Uri): TPromise { + loadBackupResource(resource: Uri): TPromise { const backupResource = this.toBackupResource(resource); if (this.backups.has(backupResource.toString())) { return TPromise.as(backupResource); @@ -268,7 +268,7 @@ export class InMemoryBackupFileService implements IBackupFileService { return TPromise.as(void 0); } - resolveBackupContent(backupResource: Uri): TPromise { + resolveBackupContent(backupResource: Uri): TPromise { const snapshot = this.backups.get(backupResource.toString()); if (snapshot) { return TPromise.as(createTextBufferFactoryFromSnapshot(snapshot)); diff --git a/src/vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl.ts b/src/vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl.ts index 08cd8b179e2..95d75606ec8 100644 --- a/src/vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl.ts +++ b/src/vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl.ts @@ -42,7 +42,7 @@ class RemoteAgentConnection extends Disposable implements IRemoteAgentConnection readonly remoteAuthority: string; private _connection: TPromise | null; - private _environment: TPromise | null; + private _environment: TPromise | null; constructor( remoteAuthority: string, @@ -56,7 +56,7 @@ class RemoteAgentConnection extends Disposable implements IRemoteAgentConnection this._environment = null; } - getEnvironment(): TPromise { + getEnvironment(): TPromise { if (!this._environment) { const client = new RemoteExtensionEnvironmentChannelClient(this.getChannel('remoteextensionsenvironment')); diff --git a/src/vs/workbench/services/remote/node/remoteAgentService.ts b/src/vs/workbench/services/remote/node/remoteAgentService.ts index 9f74647a1b2..983caa9dc64 100644 --- a/src/vs/workbench/services/remote/node/remoteAgentService.ts +++ b/src/vs/workbench/services/remote/node/remoteAgentService.ts @@ -34,7 +34,7 @@ export interface IRemoteAgentService { export interface IRemoteAgentConnection { readonly remoteAuthority: string; - getEnvironment(): TPromise; + getEnvironment(): TPromise; getChannel(channelName: string): T; registerChannel(channelName: string, channel: T); diff --git a/src/vs/workbench/services/search/node/ripgrepFileSearch.ts b/src/vs/workbench/services/search/node/ripgrepFileSearch.ts index 950b35ccb8a..d722e44ebac 100644 --- a/src/vs/workbench/services/search/node/ripgrepFileSearch.ts +++ b/src/vs/workbench/services/search/node/ripgrepFileSearch.ts @@ -44,7 +44,7 @@ function getRgArgs(config: IFileQuery, folderQuery: IFolderQuery, includePattern } }); - let siblingClauses: glob.IExpression; + let siblingClauses: glob.IExpression | null; const rgGlobs = foldersToRgExcludeGlobs([folderQuery], excludePattern, undefined, false); rgGlobs.globArgs.forEach(globArg => { @@ -85,7 +85,7 @@ function getRgArgs(config: IFileQuery, folderQuery: IFolderQuery, includePattern export interface IRgGlobResult { globArgs: string[]; - siblingClauses: glob.IExpression; + siblingClauses: glob.IExpression | null; } export function foldersToRgExcludeGlobs(folderQueries: IFolderQuery[], globalExclude: glob.IExpression, excludesToSkip?: Set, absoluteGlobs = true): IRgGlobResult { @@ -93,7 +93,7 @@ export function foldersToRgExcludeGlobs(folderQueries: IFolderQuery[], globalExc let siblingClauses: glob.IExpression = {}; folderQueries.forEach(folderQuery => { const totalExcludePattern = objects.assign({}, folderQuery.excludePattern || {}, globalExclude || {}); - const result = globExprsToRgGlobs(totalExcludePattern, absoluteGlobs && folderQuery.folder.fsPath, excludesToSkip); + const result = globExprsToRgGlobs(totalExcludePattern, absoluteGlobs ? folderQuery.folder.fsPath : undefined, excludesToSkip); globArgs.push(...result.globArgs); if (result.siblingClauses) { siblingClauses = objects.assign(siblingClauses, result.siblingClauses); @@ -107,7 +107,7 @@ export function foldersToIncludeGlobs(folderQueries: IFolderQuery[], globalInclu const globArgs: string[] = []; folderQueries.forEach(folderQuery => { const totalIncludePattern = objects.assign({}, globalInclude || {}, folderQuery.includePattern || {}); - const result = globExprsToRgGlobs(totalIncludePattern, absoluteGlobs && folderQuery.folder.fsPath); + const result = globExprsToRgGlobs(totalIncludePattern, absoluteGlobs ? folderQuery.folder.fsPath : undefined); globArgs.push(...result.globArgs); }); @@ -116,7 +116,7 @@ export function foldersToIncludeGlobs(folderQueries: IFolderQuery[], globalInclu function globExprsToRgGlobs(patterns: glob.IExpression, folder?: string, excludesToSkip?: Set): IRgGlobResult { const globArgs: string[] = []; - let siblingClauses: glob.IExpression = null; + let siblingClauses: glob.IExpression | null = null; Object.keys(patterns) .forEach(key => { if (excludesToSkip && excludesToSkip.has(key)) { diff --git a/src/vs/workbench/services/search/node/search.ts b/src/vs/workbench/services/search/node/search.ts index 22cd4800928..965d5c0a6bf 100644 --- a/src/vs/workbench/services/search/node/search.ts +++ b/src/vs/workbench/services/search/node/search.ts @@ -34,7 +34,7 @@ export interface ISearchEngine { export interface ISerializedSearchSuccess { type: 'success'; limitHit: boolean; - stats: IFileSearchStats | ITextSearchStats; + stats: IFileSearchStats | ITextSearchStats | null; } export interface ISearchEngineSuccess { @@ -71,7 +71,7 @@ export function isSerializedFileMatch(arg: ISerializedSearchProgressItem): arg i } export interface ISerializedFileMatch { - path: string; + path?: string; results?: ITextSearchResult[]; numMatches?: number; } diff --git a/src/vs/workbench/services/search/node/textSearchAdapter.ts b/src/vs/workbench/services/search/node/textSearchAdapter.ts index c953c7866e9..02117a2eda4 100644 --- a/src/vs/workbench/services/search/node/textSearchAdapter.ts +++ b/src/vs/workbench/services/search/node/textSearchAdapter.ts @@ -16,7 +16,7 @@ export class TextSearchEngineAdapter { } search(token: CancellationToken, onResult: (matches: ISerializedFileMatch[]) => void, onMessage: (message: IProgress) => void): Promise { - if (!this.query.folderQueries.length && !this.query.extraFileResources.length) { + if ((!this.query.folderQueries || !this.query.folderQueries.length) && (!this.query.extraFileResources || !this.query.extraFileResources.length)) { return Promise.resolve({ type: 'success', limitHit: false, @@ -40,7 +40,7 @@ export class TextSearchEngineAdapter { }, token) .then( - c => resolve({ limitHit: c.limitHit, stats: null, type: 'success' }), + c => resolve({ limitHit: c.limitHit, stats: null, type: 'success' } as ISerializedSearchSuccess), reject); }); } @@ -48,9 +48,9 @@ export class TextSearchEngineAdapter { function fileMatchToSerialized(match: IFileMatch): ISerializedFileMatch { return { - path: match.resource.fsPath, + path: match.resource ? match.resource.fsPath : undefined, results: match.results, - numMatches: match.results.reduce((sum, r) => { + numMatches: (match.results || []).reduce((sum, r) => { if (!!(r).ranges) { const m = r; return sum + (Array.isArray(m.ranges) ? m.ranges.length : 1);