Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)

* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973

* disable strict null check
This commit is contained in:
Anthony Dresser
2019-07-15 22:35:46 -07:00
committed by GitHub
parent f720ec642f
commit 0b7e7ddbf9
2406 changed files with 59140 additions and 35464 deletions

View File

@@ -8,28 +8,28 @@ import * as os from 'os';
import { localize } from 'vs/nls';
import { ParsedArgs } from 'vs/platform/environment/common/environment';
import { join } from 'vs/base/common/path';
import { writeFileSync } from 'fs';
import { writeFileSync } from 'vs/base/node/pfs';
/**
* This code is also used by standalone cli's. Avoid adding any other dependencies.
*/
class HelpCategories {
o = localize('optionsUpperCase', "Options");
e = localize('extensionsManagement', "Extensions Management");
t = localize('troubleshooting', "Troubleshooting");
}
const helpCategories = {
o: localize('optionsUpperCase', "Options"),
e: localize('extensionsManagement', "Extensions Management"),
t: localize('troubleshooting', "Troubleshooting")
};
export interface Option {
id: string;
id: keyof ParsedArgs;
type: 'boolean' | 'string';
alias?: string;
deprecates?: string; // old deprecated id
args?: string | string[];
description?: string;
cat?: keyof HelpCategories;
cat?: keyof typeof helpCategories;
}
//_urls
export const options: Option[] = [
{ id: 'diff', type: 'boolean', cat: 'o', alias: 'd', args: ['file', 'file'], description: localize('diff', "Compare two files with each other.") },
{ id: 'add', type: 'boolean', cat: 'o', alias: 'a', args: 'folder', description: localize('add', "Add folder(s) to the last active window.") },
@@ -41,6 +41,7 @@ export const options: Option[] = [
{ id: 'user-data-dir', type: 'string', cat: 'o', args: 'dir', description: localize('userDataDir', "Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.") },
{ id: 'version', type: 'boolean', cat: 'o', alias: 'v', description: localize('version', "Print version.") },
{ id: 'help', type: 'boolean', cat: 'o', alias: 'h', description: localize('help', "Print usage.") },
{ id: 'telemetry', type: 'boolean', cat: 'o', description: localize('telemetry', "Shows all telemetry events which VS code collects.") },
{ id: 'folder-uri', type: 'string', cat: 'o', args: 'uri', description: localize('folderUri', "Opens a window with given folder uri(s)") },
{ id: 'file-uri', type: 'string', cat: 'o', args: 'uri', description: localize('fileUri', "Opens a window with given file uri(s)") },
@@ -54,7 +55,6 @@ export const options: Option[] = [
{ id: 'verbose', type: 'boolean', cat: 't', description: localize('verbose', "Print verbose output (implies --wait).") },
{ id: 'log', type: 'string', cat: 't', args: 'level', description: localize('log', "Log level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'.") },
{ id: 'status', type: 'boolean', alias: 's', cat: 't', description: localize('status', "Print process usage and diagnostics information.") },
{ id: 'prof-modules', type: 'boolean', alias: 'p', cat: 't', description: localize('prof-modules', "Capture performance markers while loading JS modules and print them with 'F1 > Developer: Startup Performance") },
{ id: 'prof-startup', type: 'boolean', cat: 't', description: localize('prof-startup', "Run CPU profiler during startup") },
{ id: 'disable-extensions', type: 'boolean', deprecates: 'disableExtensions', cat: 't', description: localize('disableExtensions', "Disable all installed extensions.") },
{ id: 'disable-extension', type: 'string', cat: 't', args: 'extension-id', description: localize('disableExtension', "Disable an extension.") },
@@ -62,7 +62,6 @@ export const options: Option[] = [
{ id: 'inspect-extensions', type: 'string', deprecates: 'debugPluginHost', args: 'port', cat: 't', description: localize('inspect-extensions', "Allow debugging and profiling of extensions. Check the developer tools for the connection URI.") },
{ id: 'inspect-brk-extensions', type: 'string', deprecates: 'debugBrkPluginHost', args: 'port', cat: 't', description: localize('inspect-brk-extensions', "Allow debugging and profiling of extensions with the extension host being paused after start. Check the developer tools for the connection URI.") },
{ id: 'disable-gpu', type: 'boolean', cat: 't', description: localize('disableGPU', "Disable GPU hardware acceleration.") },
{ id: 'upload-logs', type: 'string', cat: 't', description: localize('uploadLogs', "Uploads logs from current session to a secure endpoint.") },
{ id: 'max-memory', type: 'string', cat: 't', description: localize('maxMemory', "Max memory size for a window (in Mbytes).") },
{ id: 'remote', type: 'string' },
@@ -86,15 +85,14 @@ export const options: Option[] = [
{ id: 'skip-add-to-recently-opened', type: 'boolean' },
{ id: 'unity-launch', type: 'boolean' },
{ id: 'open-url', type: 'boolean' },
{ id: 'nolazy', type: 'boolean' },
{ id: 'issue', type: 'boolean' },
{ id: 'file-write', type: 'boolean' },
{ id: 'file-chmod', type: 'boolean' },
{ id: 'driver-verbose', type: 'boolean' },
{ id: 'force', type: 'boolean' },
{ id: 'trace-category-filter', type: 'string' },
{ id: 'trace-options', type: 'string' },
{ id: 'prof-code-loading', type: 'boolean' },
{ id: '_', type: 'string' },
// {{SQL CARBON EDIT}}
{ id: 'command', type: 'string', alias: 'c', cat: 'o', args: 'command-name', description: localize('commandParameter', 'Name of command to run') },
{ id: 'database', type: 'string', alias: 'D', cat: 'o', args: 'database', description: localize('databaseParameter', 'Database name') },
@@ -103,7 +101,9 @@ export const options: Option[] = [
{ id: 'aad', type: 'boolean', cat: 'o', description: localize('aadParameter', 'Use Azure Active Directory authentication for server connection') },
{ id: 'integrated', type: 'boolean', alias: 'E', cat: 'o', description: localize('integratedAuthParameter', 'Use Integrated authentication for server connection') },
// {{SQL CARBON EDIT}} - End
{ id: '_', type: 'string' }
{ id: 'js-flags', type: 'string' }, // chrome js flags
{ id: 'nolazy', type: 'boolean' }, // node inspect
];
export function parseArgs(args: string[], isOptionSupported = (_: Option) => true): ParsedArgs {
@@ -130,8 +130,8 @@ export function parseArgs(args: string[], isOptionSupported = (_: Option) => tru
}
}
// remote aliases to avoid confusion
const parsedArgs = minimist(args, { string, boolean, alias }) as ParsedArgs;
for (let o of options) {
const parsedArgs = minimist(args, { string, boolean, alias });
for (const o of options) {
if (o.alias) {
delete parsedArgs[o.alias];
}
@@ -198,8 +198,6 @@ function wrapText(text: string, columns: number): string[] {
export function buildHelpMessage(productName: string, executableName: string, version: string, isOptionSupported = (_: Option) => true, isPipeSupported = true): string {
const columns = (process.stdout).isTTY && (process.stdout).columns || 80;
let categories = new HelpCategories();
let help = [`${productName} ${version}`];
help.push('');
help.push(`${localize('usage', "Usage")}: ${executableName} [${localize('options', "options")}][${localize('paths', 'paths')}...]`);
@@ -212,10 +210,12 @@ export function buildHelpMessage(productName: string, executableName: string, ve
}
help.push('');
}
for (let key in categories) {
for (let helpCategoryKey in helpCategories) {
const key = <keyof typeof helpCategories>helpCategoryKey;
let categoryOptions = options.filter(o => !!o.description && o.cat === key && isOptionSupported(o));
if (categoryOptions.length) {
help.push(categories[key]);
help.push(helpCategories[key]);
help.push(...formatOptions(categoryOptions, columns));
help.push('');
}

View File

@@ -3,11 +3,12 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IEnvironmentService, ParsedArgs, IDebugParams, IExtensionHostDebugParams } from 'vs/platform/environment/common/environment';
import { IEnvironmentService, ParsedArgs, IDebugParams, IExtensionHostDebugParams, BACKUPS } from 'vs/platform/environment/common/environment';
import * as crypto from 'crypto';
import * as paths from 'vs/base/node/paths';
import * as os from 'os';
import * as path from 'vs/base/common/path';
import * as resources from 'vs/base/common/resources';
import { memoize } from 'vs/base/common/decorators';
import pkg from 'vs/platform/product/node/package';
import product from 'vs/platform/product/node/product';
@@ -21,7 +22,9 @@ import { URI } from 'vs/base/common/uri';
const xdgRuntimeDir = process.env['XDG_RUNTIME_DIR'];
function getNixIPCHandle(userDataPath: string, type: string): string {
if (xdgRuntimeDir) {
const vscodePortable = process.env['VSCODE_PORTABLE'];
if (xdgRuntimeDir && !vscodePortable) {
const scope = crypto.createHash('md5').update(userDataPath).digest('hex').substr(0, 8);
return path.join(xdgRuntimeDir, `vscode-${scope}-${pkg.version}-${type}.sock`);
}
@@ -93,6 +96,7 @@ export class EnvironmentService implements IEnvironmentService {
@memoize
get userDataPath(): string {
const vscodePortable = process.env['VSCODE_PORTABLE'];
if (vscodePortable) {
return path.join(vscodePortable, 'user-data');
}
@@ -100,45 +104,51 @@ export class EnvironmentService implements IEnvironmentService {
return parseUserDataDir(this._args, process);
}
@memoize
get webUserDataHome(): URI { return URI.file(parsePathArg(this._args['web-user-data-dir'], process) || this.userDataPath); }
get appNameLong(): string { return product.nameLong; }
get appQuality(): string | undefined { return product.quality; }
@memoize
get appSettingsHome(): string { return path.join(this.userDataPath, 'User'); }
get appSettingsHome(): URI { return URI.file(path.join(this.userDataPath, 'User')); }
@memoize
get appSettingsPath(): string { return path.join(this.appSettingsHome, 'settings.json'); }
get userRoamingDataHome(): URI { return this.appSettingsHome; }
@memoize
get machineSettingsHome(): string { return path.join(this.userDataPath, 'Machine'); }
get settingsResource(): URI { return resources.joinPath(this.userRoamingDataHome, 'settings.json'); }
@memoize
get machineSettingsPath(): string { return path.join(this.machineSettingsHome, 'settings.json'); }
get machineSettingsHome(): URI { return URI.file(path.join(this.userDataPath, 'Machine')); }
@memoize
get globalStorageHome(): string { return path.join(this.appSettingsHome, 'globalStorage'); }
get machineSettingsResource(): URI { return resources.joinPath(this.machineSettingsHome, 'settings.json'); }
@memoize
get workspaceStorageHome(): string { return path.join(this.appSettingsHome, 'workspaceStorage'); }
get globalStorageHome(): string { return path.join(this.appSettingsHome.fsPath, 'globalStorage'); }
@memoize
get settingsSearchBuildId(): number | undefined { return product.settingsSearchBuildId; }
get workspaceStorageHome(): string { return path.join(this.appSettingsHome.fsPath, 'workspaceStorage'); }
@memoize
get settingsSearchUrl(): string | undefined { return product.settingsSearchUrl; }
get keybindingsResource(): URI { return resources.joinPath(this.userRoamingDataHome, 'keybindings.json'); }
@memoize
get appKeybindingsPath(): string { return path.join(this.appSettingsHome, 'keybindings.json'); }
get keyboardLayoutResource(): URI { return resources.joinPath(this.userRoamingDataHome, 'keyboardLayout.json'); }
@memoize
get localeResource(): URI { return resources.joinPath(this.userRoamingDataHome, 'locale.json'); }
@memoize
get isExtensionDevelopment(): boolean { return !!this._args.extensionDevelopmentPath; }
@memoize
get backupHome(): string { return path.join(this.userDataPath, 'Backups'); }
get backupHome(): URI { return URI.file(path.join(this.userDataPath, BACKUPS)); }
@memoize
get backupWorkspacesPath(): string { return path.join(this.backupHome, 'workspaces.json'); }
get backupWorkspacesPath(): string { return path.join(this.backupHome.fsPath, 'workspaces.json'); }
@memoize
get untitledWorkspacesHome(): URI { return URI.file(path.join(this.userDataPath, 'Workspaces')); }
@@ -170,6 +180,7 @@ export class EnvironmentService implements IEnvironmentService {
}
const vscodePortable = process.env['VSCODE_PORTABLE'];
if (vscodePortable) {
return path.join(vscodePortable, 'extensions');
}
@@ -261,6 +272,9 @@ export class EnvironmentService implements IEnvironmentService {
get driverHandle(): string | undefined { return this._args['driver']; }
get driverVerbose(): boolean { return !!this._args['driver-verbose']; }
readonly webviewResourceRoot = 'vscode-resource:{{resource}}';
readonly webviewCspSource = 'vscode-resource:';
constructor(private _args: ParsedArgs, private _execPath: string) {
if (!process.env['VSCODE_LOGS']) {
const key = toLocalISOString(new Date()).replace(/-|:|\.\d+Z$/g, '');
@@ -285,10 +299,11 @@ export function parseSearchPort(args: ParsedArgs, isBuild: boolean): IDebugParam
return parseDebugPort(args['inspect-search'], args['inspect-brk-search'], 5876, isBuild);
}
export function parseDebugPort(debugArg: string | undefined, debugBrkArg: string | undefined, defaultBuildPort: number, isBuild: boolean, debugId?: string): IExtensionHostDebugParams {
function parseDebugPort(debugArg: string | undefined, debugBrkArg: string | undefined, defaultBuildPort: number, isBuild: boolean, debugId?: string): IExtensionHostDebugParams {
const portStr = debugBrkArg || debugArg;
const port = Number(portStr) || (!isBuild ? defaultBuildPort : null);
const brk = port ? Boolean(!!debugBrkArg) : false;
return { port, break: brk, debugId };
}
@@ -303,9 +318,9 @@ function parsePathArg(arg: string | undefined, process: NodeJS.Process): string
if (path.normalize(arg) === resolved) {
return resolved;
} else {
return path.resolve(process.env['VSCODE_CWD'] || process.cwd(), arg);
}
return path.resolve(process.env['VSCODE_CWD'] || process.cwd(), arg);
}
export function parseUserDataDir(args: ParsedArgs, process: NodeJS.Process): string {