Strict null check launch service

This commit is contained in:
Matt Bierner 2018-11-08 18:30:10 -08:00
parent 026df2745e
commit ba97287ced
2 changed files with 19 additions and 13 deletions

View file

@ -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"

View file

@ -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<ILaunchService>(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<void> {
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<number> {
@ -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);