Skip to content

Commit 5a575d3

Browse files
committed
Support tarantool_builtin_module internal function
1 parent d51ee29 commit 5a575d3

File tree

9 files changed

+4640
-4586
lines changed

9 files changed

+4640
-4586
lines changed

.vscode/launch.json

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
{
2-
"version": "0.2.0",
3-
"configurations": [
4-
{
5-
"name": "Extension",
6-
"type": "extensionHost",
7-
"request": "launch",
8-
"runtimeExecutable": "${execPath}",
9-
"args": [
10-
"--extensionDevelopmentPath=${workspaceFolder}"
11-
],
12-
"outFiles": [
13-
"${workspaceFolder}/**/*.js"
14-
],
15-
// "preLaunchTask": "npm: watch"
16-
},
17-
{
18-
"name": "Extension Installed",
19-
"type": "extensionHost",
20-
"request": "launch",
21-
"runtimeExecutable": "${execPath}",
22-
"args": [
23-
"--extensionDevelopmentPath=${workspaceFolder}/../../.vscode/extensions/tomblind.local-lua-debugger-vscode-0.1.0"
24-
],
25-
"outFiles": [
26-
"${workspaceFolder}/../../.vscode/extensions/tomblind.local-lua-debugger-vscode-0.1.0/**/*.js"
27-
],
28-
// "preLaunchTask": "npm: watch"
29-
},
30-
{
31-
"name": "Server",
32-
"type": "node",
33-
"request": "launch",
34-
"cwd": "${workspaceFolder}",
35-
"program": "${workspaceFolder}/extension/debugAdapter.ts",
36-
"args": [
37-
"--server=4711"
38-
],
39-
"outFiles": [
40-
"${workspaceFolder}/**/*.js"
41-
]
42-
}
43-
]
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Extension",
6+
"type": "extensionHost",
7+
"request": "launch",
8+
"runtimeExecutable": "${execPath}",
9+
"args": [
10+
"--extensionDevelopmentPath=${workspaceFolder}"
11+
],
12+
"outFiles": [
13+
"${workspaceFolder}/**/*.js"
14+
],
15+
// "preLaunchTask": "npm: watch"
16+
},
17+
{
18+
"name": "Extension Installed",
19+
"type": "extensionHost",
20+
"request": "launch",
21+
"runtimeExecutable": "${execPath}",
22+
"args": [
23+
"--extensionDevelopmentPath=${workspaceFolder}/../../.vscode/extensions/usenko-timur.tarantool-local-lua-debugger-vscode-0.3.3"
24+
],
25+
"outFiles": [
26+
"${workspaceFolder}/../../.vscode/extensions/usenko-timur.tarantool-local-lua-debugger-vscode-0.3.3/**/*.js"
27+
],
28+
// "preLaunchTask": "npm: watch"
29+
},
30+
{
31+
"name": "Server",
32+
"type": "node",
33+
"request": "launch",
34+
"cwd": "${workspaceFolder}",
35+
"program": "${workspaceFolder}/extension/debugAdapter.ts",
36+
"args": [
37+
"--server=4711"
38+
],
39+
"outFiles": [
40+
"${workspaceFolder}/**/*.js"
41+
]
42+
}
43+
]
4444
}

debugger/debugger.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,19 @@ export namespace Debugger {
504504

505505
} else if (inp === "cont" || inp === "continue") {
506506
break;
507-
507+
} else if (inp.sub(1, 23) === "tarantool-builtin-data ") {
508+
const path = inp.sub(24);
509+
if (!path) {
510+
Send.error(`Bad expression: ${inp}`);
511+
} else {
512+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
513+
const content: string | null = tarantool_builtin_module(`@${path}`);
514+
if (typeof content === "string") {
515+
Send.result(content);
516+
} else {
517+
Send.error(`Nullable tarantool_builtin_module response: @${path}`);
518+
}
519+
}
508520
} else if (inp === "autocont" || inp === "autocontinue") {
509521
updateHook();
510522
inDebugBreak = false;

debugger/tarantool.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare function tarantool_builtin_module(filePath: string): string | null;

extension/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const configurationProvider: vscode.DebugConfigurationProvider = {
9797
return abortLaunch("No path for debugger");
9898
}
9999

100-
const extension = vscode.extensions.getExtension("tomblind.local-lua-debugger-vscode");
100+
const extension = vscode.extensions.getExtension("usenko-timur.tarantool-local-lua-debugger-vscode");
101101
if (typeof extension === "undefined") {
102102
return abortLaunch("Failed to find extension path");
103103
}

extension/luaDebugSession.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,28 @@ export class LuaDebugSession extends LoggingDebugSession {
378378
this.sendResponse(response);
379379
}
380380

381+
protected async sourceRequest(
382+
response: DebugProtocol.SourceResponse,
383+
args: DebugProtocol.SourceArguments,
384+
): Promise<void> {
385+
if (args.source?.adapterData === "tarantool-builtin-data") {
386+
const msg = await this.waitForCommandResponse(`tarantool-builtin-data ${args.source.path ?? ""}`);
387+
if (msg.type === "result") {
388+
const result = msg.results[0];
389+
if (result.type === "string") {
390+
let content = result.value ?? "";
391+
392+
content = content.replace(/^"/, "");
393+
content = content.replace(/"$/, "");
394+
395+
response.body = {content};
396+
}
397+
}
398+
}
399+
400+
this.sendResponse(response);
401+
}
402+
381403
protected async stackTraceRequest(
382404
response: DebugProtocol.StackTraceResponse,
383405
args: DebugProtocol.StackTraceArguments
@@ -414,7 +436,17 @@ export class LuaDebugSession extends LoggingDebugSession {
414436
//Un-mapped source
415437
const sourcePath = this.resolvePath(frame.source);
416438
if (typeof source === "undefined" && typeof sourcePath !== "undefined") {
417-
source = new Source(path.basename(frame.source), sourcePath);
439+
if (sourcePath.indexOf("builtin/") === 0) {
440+
source = new Source(
441+
path.basename(frame.source),
442+
this.convertDebuggerPathToClient(sourcePath),
443+
1,
444+
"internal module",
445+
"tarantool-builtin-data"
446+
);
447+
} else {
448+
source = new Source(path.basename(frame.source), sourcePath);
449+
}
418450
}
419451

420452
//Function name
@@ -763,6 +795,10 @@ export class LuaDebugSession extends LoggingDebugSession {
763795
return;
764796
}
765797

798+
if (filePath.indexOf("builtin/") === 0) {
799+
return filePath;
800+
}
801+
766802
const config = this.assert(this.config);
767803
let fullPath = path.isAbsolute(filePath) ? filePath : path.join(config.cwd, filePath);
768804

0 commit comments

Comments
 (0)