From ba97287ced0b109a8dfca913d4971ab24f8d52aa Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 8 Nov 2018 18:30:10 -0800 Subject: [PATCH] Strict null check launch service --- src/tsconfig.strictNullChecks.json | 7 ++++-- .../launch/electron-main/launchService.ts | 25 +++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 15b914f4272..0d8ee5abda6 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -118,6 +118,7 @@ "./vs/code/electron-browser/sharedProcess/contrib/nodeCachedDataCleaner.ts", "./vs/code/electron-main/auth.ts", "./vs/code/electron-main/keyboard.ts", + "./vs/code/electron-main/logUploader.ts", "./vs/code/electron-main/sharedProcess.ts", "./vs/code/electron-main/theme.ts", "./vs/code/node/cli.ts", @@ -400,6 +401,7 @@ "./vs/platform/actions/common/menu.ts", "./vs/platform/actions/common/menuService.ts", "./vs/platform/backup/common/backup.ts", + "./vs/platform/backup/electron-main/backupMainService.ts", "./vs/platform/broadcast/electron-browser/broadcastService.ts", "./vs/platform/clipboard/common/clipboardService.ts", "./vs/platform/clipboard/electron-browser/clipboardService.ts", @@ -409,6 +411,7 @@ "./vs/platform/configuration/common/configurationRegistry.ts", "./vs/platform/contextkey/browser/contextKeyService.ts", "./vs/platform/contextkey/common/contextkey.ts", + "./vs/platform/diagnostics/electron-main/diagnosticsService.ts", "./vs/platform/dialogs/common/dialogs.ts", "./vs/platform/dialogs/node/dialogIpc.ts", "./vs/platform/dialogs/node/dialogService.ts", @@ -454,6 +457,7 @@ "./vs/platform/keybinding/test/common/mockKeybindingService.ts", "./vs/platform/label/common/label.ts", "./vs/platform/label/electron-browser/label.contribution.ts", + "./vs/platform/launch/electron-main/launchService.ts", "./vs/platform/lifecycle/common/lifecycle.ts", "./vs/platform/lifecycle/electron-browser/lifecycleService.ts", "./vs/platform/lifecycle/electron-main/lifecycleMain.ts", @@ -707,8 +711,7 @@ "./vs/workbench/services/themes/common/workbenchThemeService.ts", "./vs/workbench/services/title/common/titleService.ts", "./vs/workbench/services/workspace/common/workspaceEditing.ts", - "./vs/workbench/test/electron-browser/api/mock.ts", - "./vs/platform/backup/electron-main/backupMainService.ts" + "./vs/workbench/test/electron-browser/api/mock.ts" ], "exclude": [ "./typings/require-monaco.d.ts" diff --git a/src/vs/platform/launch/electron-main/launchService.ts b/src/vs/platform/launch/electron-main/launchService.ts index e7981250608..ae7227a277b 100644 --- a/src/vs/platform/launch/electron-main/launchService.ts +++ b/src/vs/platform/launch/electron-main/launchService.ts @@ -19,6 +19,7 @@ import { URI, UriComponents } from 'vs/base/common/uri'; import { BrowserWindow } from 'electron'; import { Event } from 'vs/base/common/event'; import { hasArgs } from 'vs/platform/environment/node/argv'; +import { coalesce } from 'vs/base/common/arrays'; export const ID = 'launchService'; export const ILaunchService = createDecorator(ID); @@ -45,15 +46,14 @@ function parseOpenUrl(args: ParsedArgs): URI[] { if (args['open-url'] && args._urls && args._urls.length > 0) { // --open-url must contain -- followed by the url(s) // process.argv is used over args._ as args._ are resolved to file paths at this point - return args._urls + return coalesce(args._urls .map(url => { try { return URI.parse(url); } catch (err) { return null; } - }) - .filter(uri => !!uri); + })); } return []; @@ -99,7 +99,7 @@ export class LaunchChannel implements ILaunchChannel { return this.service.getLogsPath(); } - return undefined; + throw new Error(`Call not found: ${command}`); } } @@ -161,7 +161,7 @@ export class LaunchService implements ILaunchService { } }); - return TPromise.as(null); + return TPromise.as(void 0); } // Otherwise handle in windows service @@ -170,7 +170,7 @@ export class LaunchService implements ILaunchService { private startOpenWindow(args: ParsedArgs, userEnv: IProcessEnvironment): TPromise { const context = !!userEnv['VSCODE_CLI'] ? OpenContext.CLI : OpenContext.DESKTOP; - let usedWindows: ICodeWindow[]; + let usedWindows: ICodeWindow[] = []; // Special case extension development if (!!args.extensionDevelopmentPath) { @@ -238,7 +238,7 @@ export class LaunchService implements ILaunchService { ]).then(() => void 0, () => void 0); } - return TPromise.as(null); + return TPromise.as(void 0); } getMainProcessId(): TPromise { @@ -279,10 +279,13 @@ export class LaunchService implements ILaunchService { if (window.openedFolderUri) { folderURIs.push(window.openedFolderUri); } else if (window.openedWorkspace) { - const rootFolders = this.workspacesMainService.resolveWorkspaceSync(window.openedWorkspace.configPath).folders; - rootFolders.forEach(root => { - folderURIs.push(root.uri); - }); + const resolvedWorkspace = this.workspacesMainService.resolveWorkspaceSync(window.openedWorkspace.configPath); + if (resolvedWorkspace) { + const rootFolders = resolvedWorkspace.folders; + rootFolders.forEach(root => { + folderURIs.push(root.uri); + }); + } } return this.browserWindowToInfo(window.win, folderURIs);