Skip to content

Commit 8d4f749

Browse files
committed
chore: improve dev debugging experience
1 parent 79c1031 commit 8d4f749

File tree

5 files changed

+64
-21
lines changed

5 files changed

+64
-21
lines changed

Diff for: .vscode/launch.json

+19-11
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,23 @@
33
// Hover to view descriptions of existing attributes.
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
{
6-
"version": "0.2.0",
7-
"configurations": [
8-
{
9-
"name": "Extension",
10-
"type": "extensionHost",
11-
"request": "launch",
12-
"args": [
13-
"--extensionDevelopmentPath=${workspaceFolder}"
14-
]
15-
}
16-
]
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Run extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
13+
"preLaunchTask": "Build"
14+
},
15+
{
16+
"type": "node",
17+
"request": "attach",
18+
"name": "Attach to Server",
19+
"address": "localhost",
20+
"port": 6009,
21+
"sourceMaps": true,
22+
"outFiles": ["${workspaceRoot}/dist/*.js"]
23+
}
24+
]
1725
}

Diff for: .vscode/tasks.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Build",
6+
"type": "shell",
7+
"command": "npm run build",
8+
"options": {
9+
"cwd": "${workspaceFolder}"
10+
},
11+
"group": {
12+
"kind": "build",
13+
"isDefault": true
14+
},
15+
"presentation": {
16+
"reveal": "never",
17+
"panel": "shared"
18+
}
19+
}
20+
]
21+
}

Diff for: README.md

+18-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ If you want to test out the lsp, you can clone the repo and open up VSCode
2020

2121
```console
2222
git clone https://github.com/mug1wara26/source-lsp && cd source-lsp
23-
npm i
23+
npm i
2424
code .
2525
```
2626

@@ -45,4 +45,20 @@ Documentation for diagnostics can be found [here](server/src/rules)
4545
## Autocomplete
4646

4747
Documentation for built in names or modules are generated by the script `server/src/docs/build_docs.mjs`. This script is not automatically run during the build process, as it is rarely updated.
48-
If an update to the autocomplete is required, run `npm run docs`.
48+
If an update to the autocomplete is required, run `npm run docs`.
49+
50+
## Notes to developers
51+
52+
### Debugging in VS Code
53+
Follow these steps to use the VS Code debugger to step through function calls in the server and client:
54+
55+
1. Ensure VS Code is running on the root directory of this project. Open the _Run and Debug_ side panel by clicking or using the Ctrl+Shift+D shortcut.
56+
Observe that there is a dropdown to select launch configurations at the top, and a Call Stack panel at the middle.
57+
58+
2. Run the _Run Extension_ debug launch config. This will automatically build the necessary files.
59+
A new VS Code window in debug mode should appear with expected LSP features working.
60+
You should now be able to set breakpoints in TS files within the client/ folder.
61+
62+
3. Run the _Attach to Server_ debug launch config.
63+
If needed, ensure that a new debug session named `Remote Process [0] << Attach to Server 6009` appears in the Call Stack panel and does not die.
64+
You should now be able to set breakpoints in TS files within the server/ folder.

Diff for: client/src/extension.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/* --------------------------------------------------------------------------------------------
2-
* Copyright (c) Microsoft Corporation. All rights reserved.
3-
* Licensed under the MIT License. See License.txt in the project root for license information.
4-
* ------------------------------------------------------------------------------------------ */
5-
61
import * as path from 'path';
72
import { workspace, ExtensionContext } from 'vscode';
83

@@ -27,13 +22,16 @@ export function activate(context: ExtensionContext) {
2722
path.join("dist", 'source-lsp.js')
2823
);
2924

25+
let debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };
26+
3027
// If the extension is launched in debug mode then the debug server options are used
3128
// Otherwise the run options are used
3229
const serverOptions: ServerOptions = {
3330
run: { module: serverModule, transport: TransportKind.ipc },
3431
debug: {
3532
module: serverModule,
3633
transport: TransportKind.ipc,
34+
options: debugOptions
3735
}
3836
};
3937

@@ -65,7 +63,7 @@ export function activate(context: ExtensionContext) {
6563
const selectedVersion = await window.showQuickPick(versions, {
6664
placeHolder: "Select the language version",
6765
});
68-
66+
6967
if (selectedVersion) {
7068
await setLanguageVersion(selectedVersion);
7169
}
@@ -93,4 +91,4 @@ export function deactivate(): Thenable<void> | undefined {
9391
return undefined;
9492
}
9593
return client.stop();
96-
}
94+
}

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"version": "0.1.0",
66
"main": "./client/out/extension",
77
"engines": {
8-
"vscode": "^1.96.0"
8+
"vscode": "^1.93.0"
99
},
1010
"categories": [
1111
"Programming Languages"

0 commit comments

Comments
 (0)