Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5f5cd84

Browse files
committedAug 5, 2022
Support tarantool_builtin_module internal function
1 parent d51ee29 commit 5f5cd84

File tree

10 files changed

+4629
-4586
lines changed

10 files changed

+4629
-4586
lines changed
 

‎.vscode/launch.json

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,31 @@
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": "Server",
19+
"type": "node",
20+
"request": "launch",
21+
"cwd": "${workspaceFolder}",
22+
"program": "${workspaceFolder}/extension/debugAdapter.ts",
23+
"args": [
24+
"--server=4711"
25+
],
26+
"outFiles": [
27+
"${workspaceFolder}/**/*.js"
28+
]
29+
}
30+
]
4431
}

‎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/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const EXTENSION_ID = "usenko-timur.tarantool-local-lua-debugger-vscode";

‎extension/extension.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import * as vscode from "vscode";
2424
import * as Net from "net";
2525
import * as path from "path";
26+
import {EXTENSION_ID} from "./constants";
2627
import {LuaDebugSession} from "./luaDebugSession";
2728
import {LaunchConfig, isCustomProgramConfig, LuaProgramConfig} from "./launchConfig";
2829

@@ -97,7 +98,7 @@ const configurationProvider: vscode.DebugConfigurationProvider = {
9798
return abortLaunch("No path for debugger");
9899
}
99100

100-
const extension = vscode.extensions.getExtension("tomblind.local-lua-debugger-vscode");
101+
const extension = vscode.extensions.getExtension(EXTENSION_ID);
101102
if (typeof extension === "undefined") {
102103
return abortLaunch("Failed to find extension path");
103104
}

‎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

‎package-lock.json

Lines changed: 4332 additions & 4332 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 210 additions & 209 deletions
Large diffs are not rendered by default.

‎resources/tarantool-logo-small.svg

Lines changed: 4 additions & 0 deletions
Loading
3.65 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.