提交 66319f4a 编写于 作者: M Matt Bierner

Strict null check environmentService

上级 04067138
...@@ -427,6 +427,7 @@ ...@@ -427,6 +427,7 @@
"./vs/platform/editor/common/editor.ts", "./vs/platform/editor/common/editor.ts",
"./vs/platform/environment/common/environment.ts", "./vs/platform/environment/common/environment.ts",
"./vs/platform/environment/node/argv.ts", "./vs/platform/environment/node/argv.ts",
"./vs/platform/environment/node/environmentService.ts",
"./vs/platform/extensionManagement/common/extensionEnablementService.ts", "./vs/platform/extensionManagement/common/extensionEnablementService.ts",
"./vs/platform/extensionManagement/common/extensionManagement.ts", "./vs/platform/extensionManagement/common/extensionManagement.ts",
"./vs/platform/extensionManagement/common/extensionManagementUtil.ts", "./vs/platform/extensionManagement/common/extensionManagementUtil.ts",
......
...@@ -74,12 +74,12 @@ export interface ParsedArgs { ...@@ -74,12 +74,12 @@ export interface ParsedArgs {
export const IEnvironmentService = createDecorator<IEnvironmentService>('environmentService'); export const IEnvironmentService = createDecorator<IEnvironmentService>('environmentService');
export interface IDebugParams { export interface IDebugParams {
port: number; port: number | null;
break: boolean; break: boolean;
} }
export interface IExtensionHostDebugParams extends IDebugParams { export interface IExtensionHostDebugParams extends IDebugParams {
debugId: string; debugId?: string;
} }
export interface IEnvironmentService { export interface IEnvironmentService {
...@@ -95,13 +95,13 @@ export interface IEnvironmentService { ...@@ -95,13 +95,13 @@ export interface IEnvironmentService {
userDataPath: string; userDataPath: string;
appNameLong: string; appNameLong: string;
appQuality: string; appQuality?: string;
appSettingsHome: string; appSettingsHome: string;
appSettingsPath: string; appSettingsPath: string;
appKeybindingsPath: string; appKeybindingsPath: string;
settingsSearchBuildId: number; settingsSearchBuildId?: number;
settingsSearchUrl: string; settingsSearchUrl?: string;
workspaceStorageHome: string; workspaceStorageHome: string;
...@@ -114,8 +114,8 @@ export interface IEnvironmentService { ...@@ -114,8 +114,8 @@ export interface IEnvironmentService {
disableExtensions: boolean | string[]; disableExtensions: boolean | string[];
builtinExtensionsPath: string; builtinExtensionsPath: string;
extensionsPath: string; extensionsPath: string;
extensionDevelopmentLocationURI: URI; extensionDevelopmentLocationURI?: URI;
extensionTestsPath: string; extensionTestsPath?: string;
debugExtensionHost: IExtensionHostDebugParams; debugExtensionHost: IExtensionHostDebugParams;
debugSearch: IDebugParams; debugSearch: IDebugParams;
...@@ -128,7 +128,7 @@ export interface IEnvironmentService { ...@@ -128,7 +128,7 @@ export interface IEnvironmentService {
performance: boolean; performance: boolean;
// logging // logging
log: string; log?: string;
logsPath: string; logsPath: string;
verbose: boolean; verbose: boolean;
...@@ -140,12 +140,12 @@ export interface IEnvironmentService { ...@@ -140,12 +140,12 @@ export interface IEnvironmentService {
mainIPCHandle: string; mainIPCHandle: string;
sharedIPCHandle: string; sharedIPCHandle: string;
nodeCachedDataDir: string; nodeCachedDataDir?: string;
installSourcePath: string; installSourcePath: string;
disableUpdates: boolean; disableUpdates: boolean;
disableCrashReporter: boolean; disableCrashReporter: boolean;
driverHandle: string; driverHandle?: string;
driverVerbose: boolean; driverVerbose: boolean;
} }
...@@ -92,8 +92,9 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -92,8 +92,9 @@ export class EnvironmentService implements IEnvironmentService {
@memoize @memoize
get userDataPath(): string { get userDataPath(): string {
if (process.env['VSCODE_PORTABLE']) { const vscodePortable = process.env['VSCODE_PORTABLE'];
return path.join(process.env['VSCODE_PORTABLE'], 'user-data'); if (vscodePortable) {
return path.join(vscodePortable, 'user-data');
} }
return parseUserDataDir(this._args, process); return parseUserDataDir(this._args, process);
...@@ -101,7 +102,7 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -101,7 +102,7 @@ export class EnvironmentService implements IEnvironmentService {
get appNameLong(): string { return product.nameLong; } get appNameLong(): string { return product.nameLong; }
get appQuality(): string { return product.quality; } get appQuality(): string | undefined { return product.quality; }
@memoize @memoize
get appSettingsHome(): string { return path.join(this.userDataPath, 'User'); } get appSettingsHome(): string { return path.join(this.userDataPath, 'User'); }
...@@ -113,10 +114,10 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -113,10 +114,10 @@ export class EnvironmentService implements IEnvironmentService {
get workspaceStorageHome(): string { return path.join(this.appSettingsHome, 'workspaceStorage'); } get workspaceStorageHome(): string { return path.join(this.appSettingsHome, 'workspaceStorage'); }
@memoize @memoize
get settingsSearchBuildId(): number { return product.settingsSearchBuildId; } get settingsSearchBuildId(): number | undefined { return product.settingsSearchBuildId; }
@memoize @memoize
get settingsSearchUrl(): string { return product.settingsSearchUrl; } get settingsSearchUrl(): string | undefined { return product.settingsSearchUrl; }
@memoize @memoize
get appKeybindingsPath(): string { return path.join(this.appSettingsHome, 'keybindings.json'); } get appKeybindingsPath(): string { return path.join(this.appSettingsHome, 'keybindings.json'); }
...@@ -152,17 +153,23 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -152,17 +153,23 @@ export class EnvironmentService implements IEnvironmentService {
if (fromArgs) { if (fromArgs) {
return fromArgs; return fromArgs;
} else if (process.env['VSCODE_EXTENSIONS']) {
return process.env['VSCODE_EXTENSIONS'];
} else if (process.env['VSCODE_PORTABLE']) {
return path.join(process.env['VSCODE_PORTABLE'], 'extensions');
} else {
return path.join(this.userHome, product.dataFolderName, 'extensions');
} }
const vscodeExtensions = process.env['VSCODE_EXTENSIONS'];
if (vscodeExtensions) {
return vscodeExtensions;
}
const vscodePortable = process.env['VSCODE_PORTABLE'];
if (vscodePortable) {
return path.join(vscodePortable, 'extensions');
}
return path.join(this.userHome, product.dataFolderName, 'extensions');
} }
@memoize @memoize
get extensionDevelopmentLocationURI(): URI { get extensionDevelopmentLocationURI(): URI | undefined {
const s = this._args.extensionDevelopmentPath; const s = this._args.extensionDevelopmentPath;
if (s) { if (s) {
if (/^[^:/?#]+?:\/\//.test(s)) { if (/^[^:/?#]+?:\/\//.test(s)) {
...@@ -174,13 +181,13 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -174,13 +181,13 @@ export class EnvironmentService implements IEnvironmentService {
} }
@memoize @memoize
get extensionTestsPath(): string { return this._args.extensionTestsPath ? path.normalize(this._args.extensionTestsPath) : this._args.extensionTestsPath; } get extensionTestsPath(): string | undefined { return this._args.extensionTestsPath ? path.normalize(this._args.extensionTestsPath) : this._args.extensionTestsPath; }
get disableExtensions(): boolean | string[] { get disableExtensions(): boolean | string[] {
if (this._args['disable-extensions']) { if (this._args['disable-extensions']) {
return true; return true;
} }
const disableExtensions: string | string[] = this._args['disable-extension']; const disableExtensions = this._args['disable-extension'];
if (disableExtensions) { if (disableExtensions) {
if (typeof disableExtensions === 'string') { if (typeof disableExtensions === 'string') {
return [disableExtensions]; return [disableExtensions];
...@@ -192,11 +199,11 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -192,11 +199,11 @@ export class EnvironmentService implements IEnvironmentService {
return false; return false;
} }
get skipGettingStarted(): boolean { return this._args['skip-getting-started']; } get skipGettingStarted(): boolean { return !!this._args['skip-getting-started']; }
get skipReleaseNotes(): boolean { return this._args['skip-release-notes']; } get skipReleaseNotes(): boolean { return !!this._args['skip-release-notes']; }
get skipAddToRecentlyOpened(): boolean { return this._args['skip-add-to-recently-opened']; } get skipAddToRecentlyOpened(): boolean { return !!this._args['skip-add-to-recently-opened']; }
@memoize @memoize
get debugExtensionHost(): IExtensionHostDebugParams { return parseExtensionHostPort(this._args, this.isBuilt); } get debugExtensionHost(): IExtensionHostDebugParams { return parseExtensionHostPort(this._args, this.isBuilt); }
...@@ -205,15 +212,15 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -205,15 +212,15 @@ export class EnvironmentService implements IEnvironmentService {
get debugSearch(): IDebugParams { return parseSearchPort(this._args, this.isBuilt); } get debugSearch(): IDebugParams { return parseSearchPort(this._args, this.isBuilt); }
get isBuilt(): boolean { return !process.env['VSCODE_DEV']; } get isBuilt(): boolean { return !process.env['VSCODE_DEV']; }
get verbose(): boolean { return this._args.verbose; } get verbose(): boolean { return !!this._args.verbose; }
get log(): string { return this._args.log; } get log(): string | undefined { return this._args.log; }
get wait(): boolean { return this._args.wait; } get wait(): boolean { return !!this._args.wait; }
get logExtensionHostCommunication(): boolean { return this._args.logExtensionHostCommunication; } get logExtensionHostCommunication(): boolean { return !!this._args.logExtensionHostCommunication; }
get performance(): boolean { return this._args.performance; } get performance(): boolean { return !!this._args.performance; }
get status(): boolean { return this._args.status; } get status(): boolean { return !!this._args.status; }
@memoize @memoize
get mainIPCHandle(): string { return getIPCHandle(this.userDataPath, 'main'); } get mainIPCHandle(): string { return getIPCHandle(this.userDataPath, 'main'); }
...@@ -222,13 +229,13 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -222,13 +229,13 @@ export class EnvironmentService implements IEnvironmentService {
get sharedIPCHandle(): string { return getIPCHandle(this.userDataPath, 'shared'); } get sharedIPCHandle(): string { return getIPCHandle(this.userDataPath, 'shared'); }
@memoize @memoize
get nodeCachedDataDir(): string { return process.env['VSCODE_NODE_CACHED_DATA_DIR'] || undefined; } get nodeCachedDataDir(): string | undefined { return process.env['VSCODE_NODE_CACHED_DATA_DIR'] || undefined; }
get disableUpdates(): boolean { return !!this._args['disable-updates']; } get disableUpdates(): boolean { return !!this._args['disable-updates']; }
get disableCrashReporter(): boolean { return !!this._args['disable-crash-reporter']; } get disableCrashReporter(): boolean { return !!this._args['disable-crash-reporter']; }
get driverHandle(): string { return this._args['driver']; } get driverHandle(): string | undefined { return this._args['driver']; }
get driverVerbose(): boolean { return this._args['driver-verbose']; } get driverVerbose(): boolean { return !!this._args['driver-verbose']; }
constructor(private _args: ParsedArgs, private _execPath: string) { constructor(private _args: ParsedArgs, private _execPath: string) {
if (!process.env['VSCODE_LOGS']) { if (!process.env['VSCODE_LOGS']) {
...@@ -236,7 +243,7 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -236,7 +243,7 @@ export class EnvironmentService implements IEnvironmentService {
process.env['VSCODE_LOGS'] = path.join(this.userDataPath, 'logs', key); process.env['VSCODE_LOGS'] = path.join(this.userDataPath, 'logs', key);
} }
this.logsPath = process.env['VSCODE_LOGS']; this.logsPath = process.env['VSCODE_LOGS']!;
} }
} }
...@@ -248,14 +255,14 @@ export function parseSearchPort(args: ParsedArgs, isBuild: boolean): IDebugParam ...@@ -248,14 +255,14 @@ export function parseSearchPort(args: ParsedArgs, isBuild: boolean): IDebugParam
return parseDebugPort(args.debugSearch, args.debugBrkSearch, 5876, isBuild); return parseDebugPort(args.debugSearch, args.debugBrkSearch, 5876, isBuild);
} }
export function parseDebugPort(debugArg: string, debugBrkArg: string, defaultBuildPort: number, isBuild: boolean, debugId?: string): IExtensionHostDebugParams { export function parseDebugPort(debugArg: string | undefined, debugBrkArg: string | undefined, defaultBuildPort: number, isBuild: boolean, debugId?: string): IExtensionHostDebugParams {
const portStr = debugBrkArg || debugArg; const portStr = debugBrkArg || debugArg;
const port = Number(portStr) || (!isBuild ? defaultBuildPort : null); const port = Number(portStr) || (!isBuild ? defaultBuildPort : null);
const brk = port ? Boolean(!!debugBrkArg) : false; const brk = port ? Boolean(!!debugBrkArg) : false;
return { port, break: brk, debugId }; return { port, break: brk, debugId };
} }
function parsePathArg(arg: string, process: NodeJS.Process): string { function parsePathArg(arg: string | undefined, process: NodeJS.Process): string | undefined {
if (!arg) { if (!arg) {
return undefined; return undefined;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册