Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 5714dba

Browse files
committed
chore: cede default type ownership and mark deprecated
For microsoft/vscode-js-debug#1065
1 parent 31336f7 commit 5714dba

File tree

7 files changed

+26
-244
lines changed

7 files changed

+26
-244
lines changed

package.json

Lines changed: 8 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-debug",
3-
"displayName": "Node Debug (legacy)",
3+
"displayName": "[Deprecated] Node Debug (legacy)",
44
"version": "1.44.32",
55
"publisher": "ms-vscode",
66
"description": "%extension.description%",
@@ -28,9 +28,10 @@
2828
"keywords": [
2929
"multi-root ready"
3030
],
31-
"engines": {
32-
"vscode": "^1.49.0"
33-
},
31+
"engines": {
32+
"vscode": "^1.60.0-insider",
33+
"node": ">=10"
34+
},
3435
"extensionDependencies": [
3536
"ms-vscode.node-debug2"
3637
],
@@ -81,8 +82,7 @@
8182
},
8283
"main": "./dist/extension.js",
8384
"activationEvents": [
84-
"onDebugInitialConfigurations",
85-
"onDebugResolve:node",
85+
"onDebugResolve:legacy-node",
8686
"onCommand:extension.pickNodeProcess",
8787
"onCommand:extension.node-debug.toggleSkippingFile",
8888
"onCommand:extension.node-debug.attachNodeProcess",
@@ -111,7 +111,7 @@
111111
{
112112
"command": "extension.node-debug.toggleSkippingFile",
113113
"group": "navigation",
114-
"when": "inDebugMode && debugType == 'node' && callStackItemType == 'stackFrame'"
114+
"when": "inDebugMode && debugType == 'legacy-node' && callStackItemType == 'stackFrame'"
115115
}
116116
]
117117
},
@@ -137,7 +137,7 @@
137137
],
138138
"debuggers": [
139139
{
140-
"type": "node",
140+
"type": "legacy-node",
141141
"label": "%node.label%",
142142
"program": "./dist/nodeDebug.js",
143143
"runtime": "node",
@@ -151,168 +151,6 @@
151151
"javascriptreact",
152152
"typescriptreact"
153153
],
154-
"configurationSnippets": [
155-
{
156-
"label": "%node.snippet.launch.label%",
157-
"description": "%node.snippet.launch.description%",
158-
"body": {
159-
"type": "node",
160-
"request": "launch",
161-
"name": "${2:Launch Program}",
162-
"program": "^\"\\${workspaceFolder}/${1:app.js}\"",
163-
"skipFiles": [
164-
"<node_internals>/**"
165-
]
166-
}
167-
},
168-
{
169-
"label": "%node.snippet.npm.label%",
170-
"markdownDescription": "%node.snippet.npm.description%",
171-
"body": {
172-
"type": "node",
173-
"request": "launch",
174-
"name": "${1:Launch via NPM}",
175-
"runtimeExecutable": "npm",
176-
"runtimeArgs": [
177-
"run-script",
178-
"debug"
179-
],
180-
"port": 9229,
181-
"skipFiles": [
182-
"<node_internals>/**"
183-
]
184-
}
185-
},
186-
{
187-
"label": "%node.snippet.attach.label%",
188-
"description": "%node.snippet.attach.description%",
189-
"body": {
190-
"type": "node",
191-
"request": "attach",
192-
"name": "${1:Attach}",
193-
"port": 9229,
194-
"skipFiles": [
195-
"<node_internals>/**"
196-
]
197-
}
198-
},
199-
{
200-
"label": "%node.snippet.remoteattach.label%",
201-
"description": "%node.snippet.remoteattach.description%",
202-
"body": {
203-
"type": "node",
204-
"request": "attach",
205-
"name": "${1:Attach to Remote}",
206-
"address": "${2:TCP/IP address of process to be debugged}",
207-
"port": 9229,
208-
"localRoot": "^\"\\${workspaceFolder}\"",
209-
"remoteRoot": "${3:Absolute path to the remote directory containing the program}",
210-
"skipFiles": [
211-
"<node_internals>/**"
212-
]
213-
}
214-
},
215-
{
216-
"label": "%node.snippet.attachProcess.label%",
217-
"description": "%node.snippet.attachProcess.description%",
218-
"body": {
219-
"type": "node",
220-
"request": "attach",
221-
"name": "${1:Attach by Process ID}",
222-
"processId": "^\"\\${command:PickProcess}\"",
223-
"skipFiles": [
224-
"<node_internals>/**"
225-
]
226-
}
227-
},
228-
{
229-
"label": "%node.snippet.nodemon.label%",
230-
"description": "%node.snippet.nodemon.description%",
231-
"body": {
232-
"type": "node",
233-
"request": "launch",
234-
"name": "nodemon",
235-
"runtimeExecutable": "nodemon",
236-
"program": "^\"\\${workspaceFolder}/${1:app.js}\"",
237-
"restart": true,
238-
"console": "integratedTerminal",
239-
"internalConsoleOptions": "neverOpen",
240-
"skipFiles": [
241-
"<node_internals>/**"
242-
]
243-
}
244-
},
245-
{
246-
"label": "%node.snippet.mocha.label%",
247-
"description": "%node.snippet.mocha.description%",
248-
"body": {
249-
"type": "node",
250-
"request": "launch",
251-
"name": "Mocha Tests",
252-
"program": "^\"\\${workspaceFolder}/node_modules/mocha/bin/_mocha\"",
253-
"args": [
254-
"-u",
255-
"tdd",
256-
"--timeout",
257-
"999999",
258-
"--colors",
259-
"^\"\\${workspaceFolder}/${1:test}\""
260-
],
261-
"internalConsoleOptions": "openOnSessionStart",
262-
"skipFiles": [
263-
"<node_internals>/**"
264-
]
265-
}
266-
},
267-
{
268-
"label": "%node.snippet.yo.label%",
269-
"markdownDescription": "%node.snippet.yo.description%",
270-
"body": {
271-
"type": "node",
272-
"request": "launch",
273-
"name": "Yeoman ${1:generator}",
274-
"program": "^\"\\${workspaceFolder}/node_modules/yo/lib/cli.js\"",
275-
"args": [
276-
"${1:generator}"
277-
],
278-
"console": "integratedTerminal",
279-
"internalConsoleOptions": "neverOpen",
280-
"skipFiles": [
281-
"<node_internals>/**"
282-
]
283-
}
284-
},
285-
{
286-
"label": "%node.snippet.gulp.label%",
287-
"description": "%node.snippet.gulp.description%",
288-
"body": {
289-
"type": "node",
290-
"request": "launch",
291-
"name": "Gulp ${1:task}",
292-
"program": "^\"\\${workspaceFolder}/node_modules/gulp/bin/gulp.js\"",
293-
"args": [
294-
"${1:task}"
295-
],
296-
"skipFiles": [
297-
"<node_internals>/**"
298-
]
299-
}
300-
},
301-
{
302-
"label": "%node.snippet.electron.label%",
303-
"description": "%node.snippet.electron.description%",
304-
"body": {
305-
"type": "node",
306-
"request": "launch",
307-
"name": "Electron Main",
308-
"runtimeExecutable": "^\"\\${workspaceFolder}/node_modules/.bin/electron\"",
309-
"program": "^\"\\${workspaceFolder}/main.js\"",
310-
"skipFiles": [
311-
"<node_internals>/**"
312-
]
313-
}
314-
}
315-
],
316154
"configurationAttributes": {
317155
"launch": {
318156
"properties": {

src/node/extension/autoAttach.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ export function getPidFromSession(session: vscode.DebugSession): Promise<number>
4141
clearTimeout(timer);
4242
resolve(NaN);
4343
}
44-
}, session.type === 'node2' ? 500 : 100);
44+
}, session.type === 'legacy-node2' ? 500 : 100);
4545
});
4646
}
4747

4848
export function initializeAutoAttach(context: vscode.ExtensionContext) {
4949

5050
context.subscriptions.push(vscode.debug.onDidStartDebugSession(session => {
51-
if (session.type === 'node' || session.type === 'node2') {
51+
if (session.type === 'legacy-node' || session.type === 'legacy-node2') {
5252
// try to get pid from newly started node.js debug session
5353
pids.push(getPidFromSession(session));
5454
}

src/node/extension/configurationProvider.ts

Lines changed: 5 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ export class NodeConfigurationProvider implements vscode.DebugConfigurationProvi
3030
this._logger = new Logger();
3131
}
3232

33-
/**
34-
* Returns an initial debug configuration based on contextual information, e.g. package.json or folder.
35-
*/
36-
provideDebugConfigurations(folder: vscode.WorkspaceFolder | undefined, token?: vscode.CancellationToken): vscode.ProviderResult<vscode.DebugConfiguration[]> {
37-
38-
return [createLaunchConfigFromContext(folder, false)];
39-
}
40-
4133
/**
4234
* Try to add all missing attributes to the debug configuration being launched.
4335
*/
@@ -128,7 +120,7 @@ export class NodeConfigurationProvider implements vscode.DebugConfigurationProvi
128120

129121
// fixup log parameters
130122
if (config.trace && !config.logFilePath) {
131-
const fileName = config.type === 'node' ? 'debugadapter-legacy.txt' : 'debugadapter.txt';
123+
const fileName = config.type === 'legacy-node' ? 'debugadapter-legacy.txt' : 'debugadapter.txt';
132124

133125
if (this._extensionContext.logPath) {
134126
try {
@@ -144,13 +136,6 @@ export class NodeConfigurationProvider implements vscode.DebugConfigurationProvi
144136
// tell the extension what file patterns can be debugged
145137
config.__debuggablePatterns = this.getJavaScriptPatterns();
146138

147-
// add the workspace folder for js-debug, if useV3 is set
148-
if (useV3()) {
149-
config.__workspaceFolder = folder ? '${workspaceFolder}' : config.cwd /* attempt fallback */;
150-
} else {
151-
annoyingDeprecationNotification();
152-
}
153-
154139
// everything ok: let VS Code start the debug session
155140
return config;
156141
}
@@ -306,7 +291,7 @@ export class NodeConfigurationProvider implements vscode.DebugConfigurationProvi
306291
function createLaunchConfigFromContext(folder: vscode.WorkspaceFolder | undefined, resolve: boolean, existingConfig?: vscode.DebugConfiguration): vscode.DebugConfiguration {
307292

308293
const config = {
309-
type: 'node',
294+
type: 'legacy-node',
310295
request: 'launch',
311296
name: localize('node.launch.config.name', "Launch Program"),
312297
skipFiles: ['<node_internals>/**'],
@@ -459,28 +444,16 @@ function guessProgramFromPackage(folder: vscode.WorkspaceFolder | undefined, pac
459444
//---- debug type -------------------------------------------------------------------------------------------------------------
460445

461446
async function determineDebugType(config: any, logger: Logger): Promise<string | null> {
462-
if (useV3()) {
463-
return 'pwa-node';
464-
} else if (config.protocol === 'legacy') {
465-
return 'node';
447+
if (config.protocol === 'legacy') {
448+
return 'legacy-node';
466449
} else if (config.protocol === 'inspector') {
467-
return 'node2';
450+
return 'legacy-node2';
468451
} else {
469452
// 'auto', or unspecified
470453
return detectDebugType(config, logger);
471454
}
472455
}
473456

474-
const v3Setting ='debug.javascript.usePreview';
475-
476-
function useV3() {
477-
return getWithoutDefault(v3Setting) ?? true;
478-
}
479-
480-
function getWithoutDefault<T>(setting: string): T | undefined {
481-
const info = vscode.workspace.getConfiguration().inspect<T>(setting);
482-
return info?.workspaceValue ?? info?.globalValue;
483-
}
484457

485458
function nvsStandardArchName(arch) {
486459
switch (arch) {
@@ -519,32 +492,3 @@ function parseVersionString(versionString) {
519492

520493
return { nvsFormat, remoteName, semanticVersion, arch };
521494
}
522-
523-
let hasShownDeprecation = false;
524-
525-
async function annoyingDeprecationNotification() {
526-
if (hasShownDeprecation) {
527-
return;
528-
}
529-
530-
const useNewDebugger = 'Upgrade';
531-
hasShownDeprecation = true;
532-
const inspect = vscode.workspace.getConfiguration().inspect(v3Setting);
533-
const isWorkspace = inspect?.workspaceValue === false;
534-
const result = await vscode.window.showWarningMessage(
535-
`You're using a ${isWorkspace ? 'workspace' : 'user'} setting to use VS Code's legacy Node.js debugger, which will be removed soon. Please update your settings using the "Upgrade" button to use our modern debugger.`,
536-
useNewDebugger,
537-
);
538-
539-
if (result !== useNewDebugger) {
540-
return;
541-
}
542-
543-
const config = vscode.workspace.getConfiguration();
544-
if (inspect?.globalValue === false) {
545-
config.update(v3Setting, true, vscode.ConfigurationTarget.Global);
546-
}
547-
if (inspect?.workspaceValue === false) {
548-
config.update(v3Setting, true, vscode.ConfigurationTarget.Workspace);
549-
}
550-
}

src/node/extension/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { initializeAutoAttach } from './autoAttach';
1414
export function activate(context: vscode.ExtensionContext) {
1515

1616
// register a configuration provider
17-
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('node', new NodeConfigurationProvider(context)));
17+
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('legacy-node', new NodeConfigurationProvider(context)));
1818

1919
// auto attach
2020
initializeAutoAttach(context);

src/node/extension/processPicker.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function attachProcess() {
3030
if (result) {
3131

3232
const config = {
33-
type: 'node',
33+
type: 'legacy-node',
3434
request: 'attach',
3535
name: 'process',
3636
processId: result
@@ -85,8 +85,8 @@ export async function resolveProcessId(config: vscode.DebugConfiguration) : Prom
8585
if (debugType) {
8686
// processID is handled, so turn this config into a normal port attach configuration
8787
delete config.processId;
88-
config.port = debugType === 'node2' ? INSPECTOR_PORT_DEFAULT : LEGACY_PORT_DEFAULT;
89-
config.protocol = debugType === 'node2' ? 'inspector' : 'legacy';
88+
config.port = debugType === 'legacy-node2' ? INSPECTOR_PORT_DEFAULT : LEGACY_PORT_DEFAULT;
89+
config.protocol = debugType === 'legacy-node2' ? 'inspector' : 'legacy';
9090
} else {
9191
throw new Error(localize('pid.error', "Attach to process: cannot put process '{0}' in debug mode.", processId));
9292
}
@@ -220,8 +220,8 @@ function determineDebugTypeForPidInDebugMode(config: any, pid: number): Promise<
220220
}
221221

222222
return debugProtocolP.then(debugProtocol => {
223-
return debugProtocol === 'inspector' ? 'node2' :
224-
debugProtocol === 'legacy' ? 'node' :
223+
return debugProtocol === 'inspector' ? 'legacy-node2' :
224+
debugProtocol === 'legacy' ? 'legacy-node' :
225225
null;
226226
});
227227
}

0 commit comments

Comments
 (0)