Skip to content

Commit a0978d0

Browse files
chore. enhance dba (#204)
1 parent 13c1a9f commit a0978d0

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,14 @@
298298
{
299299
"type": "powerquery",
300300
"request": "launch",
301-
"name": "%extension.pqtest.initialConfigurations.name%",
301+
"name": "Evaluate power query file.",
302302
"program": "${workspaceFolder}/${command:AskForPowerQueryFileName}"
303303
}
304304
],
305305
"configurationSnippets": [
306306
{
307307
"label": "powerquery Debug: Launch",
308-
"description": "%extension.pqtest.configurationSnippets.description%",
308+
"description": "A new configuration for testing power query file a user selected.",
309309
"body": {
310310
"type": "powerquery",
311311
"request": "launch",

package.nls.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,5 @@
2828
"extension.pqtest.debugger.properties.operation.description": "PQTest operation string",
2929
"extension.pqtest.debugger.properties.operation.info.description": "info: Returns all module information",
3030
"extension.pqtest.debugger.properties.operation.runTest.description": "run-test: test connection",
31-
"extension.pqtest.debugger.properties.operation.testConnection.description": "test-connection: test current connection",
32-
"extension.pqtest.initialConfigurations.name": "Evaluate power query file.",
33-
"extension.pqtest.configurationSnippets.description": "A new configuration for testing power query file a user selected."
31+
"extension.pqtest.debugger.properties.operation.testConnection.description": "test-connection: test current connection"
3432
}

src/debugAdaptor/activateMQueryDebug.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
import * as Net from "net";
99
import * as vscode from "vscode";
10+
import { join } from "path";
11+
import { platform } from "process";
12+
import { randomBytes } from "crypto";
1013
import { Socket } from "net";
14+
import { tmpdir } from "os";
1115

1216
import { CancellationToken, DebugConfiguration, ProviderResult, TextEditor, WorkspaceFolder } from "vscode";
1317

@@ -54,24 +58,27 @@ class InlineDebugAdapterFactory implements vscode.DebugAdapterDescriptorFactory
5458
}
5559
}
5660

57-
class MQueryNodeDebugAdapterServerDescriptorFactory implements vscode.DebugAdapterDescriptorFactory {
61+
class MQueryNodeDebugAdapterNamedPipeServerDescriptorFactory implements vscode.DebugAdapterDescriptorFactory {
5862
private server?: Net.Server;
5963

6064
createDebugAdapterDescriptor(
6165
_session: vscode.DebugSession,
6266
_executable: vscode.DebugAdapterExecutable | undefined,
6367
): vscode.ProviderResult<vscode.DebugAdapterDescriptor> {
6468
if (!this.server) {
65-
// start listening on a random port
69+
// start listening on a random named pipe path
70+
const pipeName: string = randomBytes(10).toString("utf8");
71+
const pipePath: string = platform === "win32" ? join("\\\\.\\pipe\\", pipeName) : join(tmpdir(), pipeName);
72+
6673
this.server = Net.createServer((socket: Socket) => {
6774
const session: MQueryDebugSession = new MQueryDebugSession();
6875
session.setRunAsServer(true);
6976
session.start(socket as NodeJS.ReadableStream, socket);
70-
}).listen(0);
77+
}).listen(pipePath);
7178
}
7279

7380
// make VS Code connect to debug server
74-
return new vscode.DebugAdapterServer((this.server.address() as Net.AddressInfo).port);
81+
return new vscode.DebugAdapterNamedPipeServer(this.server.address() as string);
7582
}
7683

7784
dispose(): void {
@@ -106,7 +113,9 @@ export function activateMQueryDebug(vscExtCtx: vscode.ExtensionContext, mode: "i
106113
);
107114

108115
const factory: vscode.DebugAdapterDescriptorFactory =
109-
mode === "server" ? new MQueryNodeDebugAdapterServerDescriptorFactory() : new InlineDebugAdapterFactory();
116+
mode === "server"
117+
? new MQueryNodeDebugAdapterNamedPipeServerDescriptorFactory()
118+
: new InlineDebugAdapterFactory();
110119

111120
vscExtCtx.subscriptions.push(
112121
vscode.debug.registerDebugAdapterDescriptorFactory(ExtensionConstants.PQDebugType, factory),

0 commit comments

Comments
 (0)