Skip to content

Commit d0e8857

Browse files
committed
docs: attaching a debugger
1 parent 142352e commit d0e8857

File tree

2 files changed

+50
-18
lines changed

2 files changed

+50
-18
lines changed

.vscode/launch.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
"outFiles": ["${workspaceRoot}/extension/dist/main.js"],
1212
"autoAttachChildProcesses": true,
1313
"preLaunchTask": "npm: build - extension"
14-
}
14+
},
15+
{
16+
"name": "Attach to language server",
17+
"request": "attach",
18+
"type": "dart",
19+
"cwd": "pkgs/sass_language_server",
20+
"vmServiceUri": "${command:dart.promptForVmService}" // Prompt for the VM Service URI
21+
},
1522
]
1623
}

docs/contributing/testing-and-debugging.md

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,42 +13,65 @@ The quickest way to test the language server is to debug the language extension
1313

1414
This will open another window of Visual Studio Code, this one running as an `[Extension Development Host]`.
1515

16-
### Testing in isolation
16+
### Find the link to Dart DevTools or VM service
1717

18-
VS Code ships with some built-in support for SCSS and CSS. To test this language server in isolation you can disable the built-in extension.
18+
When debugging, the client runs [`dart run --enable-vm-service`](https://github.com/sass/dart-sass-language-server/blob/main/extension/src/server.ts#L49)
19+
in the local `sass_language_server` package.
1920

20-
1. Go to the Extensions tab and search for `@builtin css language features`.
21-
2. Click the settings icon and pick Disable from the list.
22-
3. Click Restart extension to turn it off.
21+
Use the `[Extension Development Host]` window to find the link to open Dart DevTools or to [attach the debugger](#attach-to-language-server).
2322

24-
You should also turn off extensions like SCSS IntelliSense or Some Sass.
23+
1. Open a CSS, SCSS or Sass file to activate the language server.
24+
2. Open the Output pane (View -> Output in the menu).
25+
3. Choose Sass in the dropdown to the top right of the Output pane.
26+
4. Scroll to the top of the output.
2527

26-
### Open the Dart DevTools
28+
You should see something similar to this.
2729

28-
In this configuration, the client has run `dart run --enable-vm-service` in the local `sass_language_server` package. You can now use [Dart DevTools](https://dart.dev/tools/dart-devtools) to debug the language server.
30+
```
31+
The Dart VM service is listening on http://127.0.0.1:8181/SMIxtkPzlAY=/
32+
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/SMIxtkPzlAY=/devtools/?uri=ws://127.0.0.1:8181/SMIxtkPzlAY=/ws
33+
```
2934

30-
To find the link to open Dart DevTools, use the `[Extension Development Host]`.
35+
Click the second link to open Dart DevTools, or copy the first link to [attach a debugger](#attach-to-language-server).
3136

32-
1. Open a CSS, SCSS or Sass file to activate the language server.
33-
2. Open the Output pane (View -> Output in the menu).
34-
3. In the dropdown in the top right, choose Sass from the list.
37+
![screenshot showing the output pane and the dropdown with sass selected](https://github.com/user-attachments/assets/85839d2f-4305-4fb9-aeb0-d78f435e8b7d)
38+
39+
### Attach to language server
3540

36-
You should see output similar to this.
41+
The debugger in Dart DevTools is deprecated in favor the debugger that ships with [Dart for Visual Studio Code][vscodedart].
42+
43+
To start debugging in VS Code (provided you have the Dart extension):
44+
45+
1. [Run the language server and extension](#run-the-language-extension-and-server) in debug mode.
46+
2. [Find the link to the Dart VM](#find-the-link-to-dart-devtools-or-vm-service).
47+
48+
You should see output similar to this in the `[Extension Development Host]`.
3749

3850
```
3951
The Dart VM service is listening on http://127.0.0.1:8181/SMIxtkPzlAY=/
4052
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/SMIxtkPzlAY=/devtools/?uri=ws://127.0.0.1:8181/SMIxtkPzlAY=/ws
4153
```
4254

43-
![screenshot showing the output pane and the dropdown with sass selected](https://github.com/user-attachments/assets/85839d2f-4305-4fb9-aeb0-d78f435e8b7d)
55+
Copy the first link, then go back to the Run and debug window where you started the language server and extension.
56+
57+
1. Click the Run and debug drop-down and run `Attach to language server`.
58+
2. Paste the link you copied and hit Enter.
59+
60+
Your debugger should be attached, allowing you to place breakpoints and step through code.
61+
62+
### Test in VS Code without built-in SCSS features
4463

45-
Click the second link to open Dart DevTools.
64+
VS Code ships with some built-in support for SCSS and CSS. To test this language server in isolation you can disable the built-in extension.
4665

47-
The Debugger tab has a File explorer in which you can find `package:sass_language_server`. Go to `src/language_server.dart` to find the request handlers for messages coming in from the client.
66+
1. Go to the Extensions tab and search for `@builtin css language features`.
67+
2. Click the settings icon and pick Disable from the list.
68+
3. Click Restart extension to turn it off.
69+
70+
You should also turn off extensions like SCSS IntelliSense or Some Sass.
4871

4972
## Debug unit tests
5073

51-
Assuming you installed [Dart for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code) you can debug individual unit tests by right-clicking the Run button in the editor gutter.
74+
Assuming you installed [Dart for Visual Studio Code][vscodedart] you can debug individual unit tests by right-clicking the Run button in the editor gutter.
5275

5376
Writing a test is often faster when debugging an issue with a specific language feature, and helps improve test coverage.
5477

@@ -71,3 +94,5 @@ test profile in the Run and Debug view in VS Code.
7194
]
7295
}
7396
```
97+
98+
[vscodedart]: https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code

0 commit comments

Comments
 (0)