Skip to content

Commit

Permalink
feat: experiment enlistment code
Browse files Browse the repository at this point in the history
  • Loading branch information
connor4312 committed Mar 3, 2020
1 parent b20d54d commit 909e54c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"onDebugResolve:chrome",
"onDebugResolve:NAMESPACE(node)",
"onDebugResolve:NAMESPACE(node-terminal)",
"onCommand:extension.js-debug.experimentEnlist",
"onCommand:extension.NAMESPACE(node-debug).pickNodeProcess",
"onCommand:extension.NAMESPACE(node-debug).prettyPrint",
"onCommand:extension.NAMESPACE(node-debug).toggleSkippingFile",
Expand Down
13 changes: 11 additions & 2 deletions src/common/contributionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import { Command, WorkspaceConfiguration, WorkspaceFolder, commands } from 'vscode';
import {
Command,
WorkspaceConfiguration,
WorkspaceFolder,
commands,
ConfigurationTarget,
} from 'vscode';
import { ITerminalLaunchConfiguration } from '../configuration';

export const enum Contributions {
Expand All @@ -13,6 +19,7 @@ export const enum Contributions {
DebugNpmScript = 'extension.NAMESPACE(node-debug).npmScript',
CreateDebuggerTerminal = 'extension.NAMESPACE(node-debug).createDebuggerTerminal',

EnlistExperimentCommand = 'extension.js-debug.experimentEnlist',
AddCustomBreakpointsCommand = 'extension.NAMESPACE(chrome-debug).addCustomBreakpoints',
RemoveCustomBreakpointCommand = 'extension.NAMESPACE(chrome-debug).removeCustomBreakpoint',
RemoveAllCustomBreakpointsCommand = 'extension.NAMESPACE(chrome-debug).removeAllCustomBreakpoints',
Expand Down Expand Up @@ -68,6 +75,7 @@ export interface ICommandTypes {
[Contributions.CreateDebuggerTerminal]: { args: [string?, WorkspaceFolder?]; out: void };
[Contributions.ToggleSkippingCommand]: { args: [string | number]; out: void };
[Contributions.PrettyPrintCommand]: { args: []; out: void };
[Contributions.EnlistExperimentCommand]: { args: []; out: void };
}

/**
Expand Down Expand Up @@ -113,4 +121,5 @@ export const writeConfig = <K extends keyof IConfigurationTypes>(
config: WorkspaceConfiguration,
key: K,
value: IConfigurationTypes[K],
) => config.update(key, value);
target?: ConfigurationTarget,
) => config.update(key, value, target);
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { IDebugConfigurationProvider } from './ui/configuration';
import { registerCompanionBrowserLaunch } from './ui/companionBrowserLaunch';
import { tmpdir } from 'os';
import { PrettyPrintTrackerFactory } from './ui/prettyPrint';
import { toggleOnExperiment } from './ui/experimentEnlist';

// eslint-disable-next-line
const packageJson = require('../package.json');
Expand All @@ -42,6 +43,7 @@ export function activate(context: vscode.ExtensionContext) {
registerCommand(vscode.commands, Contributions.PickProcessCommand, pickProcess),
registerCommand(vscode.commands, Contributions.AttachProcessCommand, attachProcess),
registerCommand(vscode.commands, Contributions.ToggleSkippingCommand, toggleSkippingFile),
registerCommand(vscode.commands, Contributions.EnlistExperimentCommand, toggleOnExperiment),
);

context.subscriptions.push(
Expand Down
25 changes: 25 additions & 0 deletions src/ui/experimentEnlist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { writeConfig, Configuration } from '../common/contributionUtils';

const localize = nls.loadMessageBundle();

export const toggleOnExperiment = async () => {
await writeConfig(
vscode.workspace.getConfiguration(),
Configuration.UsePreviewDebugger,
true,
vscode.ConfigurationTarget.Global,
);

await vscode.window.showInformationMessage(
localize(
'experimentEnlist',
'You can turn the new debugger off using the "debug.javascript.usePreview" setting. Please report any problems you run into, thanks for trying it out!',
),
);
};

0 comments on commit 909e54c

Please sign in to comment.