Skip to content

Commit f84c8b1

Browse files
committed
refactor(deno): prefix models with Deno and add cattrs hooks
1 parent aa41b1c commit f84c8b1

File tree

3 files changed

+219
-127
lines changed

3 files changed

+219
-127
lines changed

src/lsp_client/clients/deno/README.md

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,53 @@ This document summarizes the custom LSP capabilities and protocol extensions pro
44

55
## Custom Requests (Client → Server)
66

7-
| Request | Purpose |
8-
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
9-
| `deno/cache` | Instructs Deno to cache a module and its dependencies. Usually sent as a response to a code action for un-cached modules. |
10-
| `deno/performance` | Requests timing averages for Deno's internal instrumentation for monitoring and debugging. |
11-
| `deno/reloadImportRegistries` | Reloads cached responses from import registries. |
12-
| `deno/virtualTextDocument` | Requests read-only virtual text documents (e.g., cached remote modules or Deno library files) using the `deno:` schema. |
13-
| `deno/task` | Retrieves a list of available Deno tasks defined in `deno.json` or `deno.jsonc`. |
7+
| Request | Python Method | Purpose |
8+
| ----------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
9+
| `deno/cache` | `request_deno_cache` | Instructs Deno to cache a module and its dependencies. Usually sent as a response to a code action for un-cached modules. |
10+
| `deno/performance` | `request_deno_performance` | Requests timing averages for Deno's internal instrumentation for monitoring and debugging. |
11+
| `deno/reloadImportRegistries` | `request_deno_reload_import_registries` | Reloads cached responses from import registries. |
12+
| `deno/virtualTextDocument` | `request_deno_virtual_text_document` | Requests read-only virtual text documents (e.g., cached remote modules or Deno library files) using the `deno:` schema. |
13+
| `deno/task` | `request_deno_task` | Retrieves a list of available Deno tasks defined in `deno.json` or `deno.jsonc`. |
1414

1515
## Custom Notifications (Server → Client)
1616

17-
| Notification | Purpose |
18-
| -------------------- | ------------------------------------------------------------------------------------------------------------ |
19-
| `deno/registryState` | Notifies the client about import registry discovery status, providing suggestions for configuration updates. |
17+
| Notification | Python Method | Default Behavior |
18+
| -------------------- | ----------------------------- | ---------------------------------------------------------------------------------- |
19+
| `deno/registryState` | `receive_deno_registry_state` | Logs the registry discovery status and configuration suggestions at `DEBUG` level. |
2020

2121
## Testing API (Experimental)
2222

2323
Requires `experimental.testingApi` capability to be enabled by both client and server.
2424

2525
### Requests (Client → Server)
2626

27-
- `deno/testRun`: Initiates a test execution for specified modules or tests.
28-
- `deno/testRunCancel`: Cancels an ongoing test run by ID.
27+
| Request | Python Method | Purpose |
28+
| -------------------- | ------------------------------ | ---------------------------------------------------------- |
29+
| `deno/testRun` | `request_deno_test_run` | Initiates a test execution for specified modules or tests. |
30+
| `deno/testRunCancel` | `request_deno_test_run_cancel` | Cancels an ongoing test run by ID. |
2931

3032
### Notifications (Server → Client)
3133

32-
- `deno/testModule`: Sent when a test module is discovered.
33-
- `deno/testModuleDelete`: Sent when a test module is deleted.
34-
- `deno/testRunProgress`: Tracks the progress and state of a test run (`enqueued`, `started`, `passed`, `failed`, etc.).
34+
| Notification | Python Method | Default Behavior |
35+
| ----------------------- | --------------------------------- | ------------------------------------------------------------------------------------------ |
36+
| `deno/testModule` | `receive_deno_test_module` | Logs discovered test module information at `DEBUG` level. |
37+
| `deno/testModuleDelete` | `receive_deno_test_module_delete` | Logs deleted test module information at `DEBUG` level. |
38+
| `deno/testRunProgress` | `receive_deno_test_run_progress` | Logs test run state (`enqueued`, `started`, `passed`, etc.) and progress at `DEBUG` level. |
3539

3640
## Other Experimental Capabilities
3741

3842
- `denoConfigTasks`: Support for tasks defined in Deno configuration files.
3943
- `didRefreshDenoConfigurationTreeNotifications`: Notifications for when the configuration tree is refreshed.
44+
45+
## Deno LSP Documentation
46+
47+
### Official Documentation
48+
49+
- [Language Server Integration](https://docs.deno.com/runtime/reference/lsp_integration/) - Comprehensive guide for integrating with Deno's LSP, including custom capabilities and testing API
50+
- [deno lsp CLI Reference](https://docs.deno.com/runtime/reference/cli/lsp/) - Basic information about the `deno lsp` subcommand
51+
- [Deno & Visual Studio Code](https://docs.deno.com/runtime/reference/vscode/) - Complete integration guide and setup
52+
53+
### Source Code & Development
54+
55+
- [Deno CLI LSP Source](https://github.com/denoland/deno/tree/main/cli/lsp) - The actual LSP implementation in Rust
56+
- [VS Code Extension](https://github.com/denoland/vscode_deno) - Official VS Code extension source code

src/lsp_client/clients/deno/extension.py

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,29 @@
2828
DENO_TEST_RUN_CANCEL,
2929
DENO_TEST_RUN_PROGRESS,
3030
DENO_VIRTUAL_TEXT_DOCUMENT,
31-
CacheParams,
32-
CacheRequest,
33-
CacheResponse,
34-
PerformanceRequest,
35-
PerformanceResponse,
36-
RegistryStatusNotification,
37-
ReloadImportRegistriesRequest,
38-
ReloadImportRegistriesResponse,
39-
TaskRequest,
40-
TaskResponse,
41-
TestModuleDeleteNotification,
42-
TestModuleNotification,
43-
TestRunCancelParams,
44-
TestRunCancelRequest,
45-
TestRunCancelResponse,
46-
TestRunProgressNotification,
47-
TestRunRequest,
48-
TestRunRequestParams,
49-
TestRunResponse,
50-
TestRunResponseParams,
51-
VirtualTextDocumentParams,
52-
VirtualTextDocumentRequest,
53-
VirtualTextDocumentResponse,
31+
DenoCacheParams,
32+
DenoCacheRequest,
33+
DenoCacheResponse,
34+
DenoPerformanceRequest,
35+
DenoPerformanceResponse,
36+
DenoRegistryStatusNotification,
37+
DenoReloadImportRegistriesRequest,
38+
DenoReloadImportRegistriesResponse,
39+
DenoTaskRequest,
40+
DenoTaskResponse,
41+
DenoTestModuleDeleteNotification,
42+
DenoTestModuleNotification,
43+
DenoTestRunCancelParams,
44+
DenoTestRunCancelRequest,
45+
DenoTestRunCancelResponse,
46+
DenoTestRunProgressNotification,
47+
DenoTestRunRequest,
48+
DenoTestRunRequestParams,
49+
DenoTestRunResponse,
50+
DenoTestRunResponseParams,
51+
DenoVirtualTextDocumentParams,
52+
DenoVirtualTextDocumentRequest,
53+
DenoVirtualTextDocumentResponse,
5454
)
5555

5656

@@ -71,17 +71,17 @@ async def request_deno_cache(
7171
uris: Sequence[AnyPath] = (),
7272
) -> None:
7373
return await self.request(
74-
CacheRequest(
74+
DenoCacheRequest(
7575
id=jsonrpc_uuid(),
76-
params=CacheParams(
76+
params=DenoCacheParams(
7777
referrer=lsp_type.TextDocumentIdentifier(uri=self.as_uri(referrer)),
7878
uris=[
7979
lsp_type.TextDocumentIdentifier(uri=self.as_uri(uri))
8080
for uri in uris
8181
],
8282
),
8383
),
84-
schema=CacheResponse,
84+
schema=DenoCacheResponse,
8585
)
8686

8787

@@ -98,8 +98,8 @@ def methods(cls) -> Sequence[str]:
9898

9999
async def request_deno_performance(self) -> Any:
100100
return await self.request(
101-
PerformanceRequest(id=jsonrpc_uuid()),
102-
schema=PerformanceResponse,
101+
DenoPerformanceRequest(id=jsonrpc_uuid()),
102+
schema=DenoPerformanceResponse,
103103
)
104104

105105

@@ -116,8 +116,8 @@ def methods(cls) -> Sequence[str]:
116116

117117
async def request_deno_reload_import_registries(self) -> None:
118118
return await self.request(
119-
ReloadImportRegistriesRequest(id=jsonrpc_uuid()),
120-
schema=ReloadImportRegistriesResponse,
119+
DenoReloadImportRegistriesRequest(id=jsonrpc_uuid()),
120+
schema=DenoReloadImportRegistriesResponse,
121121
)
122122

123123

@@ -137,13 +137,13 @@ async def request_deno_virtual_text_document(
137137
uri: str,
138138
) -> str:
139139
return await self.request(
140-
VirtualTextDocumentRequest(
140+
DenoVirtualTextDocumentRequest(
141141
id=jsonrpc_uuid(),
142-
params=VirtualTextDocumentParams(
142+
params=DenoVirtualTextDocumentParams(
143143
text_document=lsp_type.TextDocumentIdentifier(uri=uri)
144144
),
145145
),
146-
schema=VirtualTextDocumentResponse,
146+
schema=DenoVirtualTextDocumentResponse,
147147
)
148148

149149

@@ -160,16 +160,16 @@ def methods(cls) -> Sequence[str]:
160160

161161
async def request_deno_task(self) -> list[Any]:
162162
return await self.request(
163-
TaskRequest(id=jsonrpc_uuid()),
164-
schema=TaskResponse,
163+
DenoTaskRequest(id=jsonrpc_uuid()),
164+
schema=DenoTaskResponse,
165165
)
166166

167167

168168
@runtime_checkable
169169
class WithRequestDenoTestRun(
170+
ExperimentalCapabilityProtocol,
170171
CapabilityProtocol,
171172
CapabilityClientProtocol,
172-
ExperimentalCapabilityProtocol,
173173
Protocol,
174174
):
175175
@override
@@ -184,14 +184,14 @@ def register_experimental_capability(cls, cap: dict[str, Any]) -> None:
184184

185185
async def request_deno_test_run(
186186
self,
187-
params: TestRunRequestParams,
188-
) -> TestRunResponseParams:
187+
params: DenoTestRunRequestParams,
188+
) -> DenoTestRunResponseParams:
189189
return await self.request(
190-
TestRunRequest(
190+
DenoTestRunRequest(
191191
id=jsonrpc_uuid(),
192192
params=params,
193193
),
194-
schema=TestRunResponse,
194+
schema=DenoTestRunResponse,
195195
)
196196

197197

@@ -211,11 +211,11 @@ async def request_deno_test_run_cancel(
211211
test_run_id: int,
212212
) -> None:
213213
return await self.request(
214-
TestRunCancelRequest(
214+
DenoTestRunCancelRequest(
215215
id=jsonrpc_uuid(),
216-
params=TestRunCancelParams(id=test_run_id),
216+
params=DenoTestRunCancelParams(id=test_run_id),
217217
),
218-
schema=TestRunCancelResponse,
218+
schema=DenoTestRunCancelResponse,
219219
)
220220

221221

@@ -231,7 +231,7 @@ def methods(cls) -> Sequence[str]:
231231
return (DENO_REGISTRY_STATE,)
232232

233233
async def receive_deno_registry_state(
234-
self, noti: RegistryStatusNotification
234+
self, noti: DenoRegistryStatusNotification
235235
) -> None:
236236
logger.debug("Received Deno registry state: {}", noti.params)
237237

@@ -243,7 +243,7 @@ def register_server_request_hooks(
243243
registry.register(
244244
DENO_REGISTRY_STATE,
245245
ServerNotificationHook(
246-
cls=RegistryStatusNotification,
246+
cls=DenoRegistryStatusNotification,
247247
execute=self.receive_deno_registry_state,
248248
),
249249
)
@@ -260,7 +260,7 @@ class WithReceiveDenoTestModule(
260260
def methods(cls) -> Sequence[str]:
261261
return (DENO_TEST_MODULE,)
262262

263-
async def receive_deno_test_module(self, noti: TestModuleNotification) -> None:
263+
async def receive_deno_test_module(self, noti: DenoTestModuleNotification) -> None:
264264
logger.debug("Received Deno test module: {}", noti.params)
265265

266266
@override
@@ -271,7 +271,7 @@ def register_server_request_hooks(
271271
registry.register(
272272
DENO_TEST_MODULE,
273273
ServerNotificationHook(
274-
cls=TestModuleNotification,
274+
cls=DenoTestModuleNotification,
275275
execute=self.receive_deno_test_module,
276276
),
277277
)
@@ -289,7 +289,7 @@ def methods(cls) -> Sequence[str]:
289289
return (DENO_TEST_MODULE_DELETE,)
290290

291291
async def receive_deno_test_module_delete(
292-
self, noti: TestModuleDeleteNotification
292+
self, noti: DenoTestModuleDeleteNotification
293293
) -> None:
294294
logger.debug("Received Deno test module delete: {}", noti.params)
295295

@@ -301,7 +301,7 @@ def register_server_request_hooks(
301301
registry.register(
302302
DENO_TEST_MODULE_DELETE,
303303
ServerNotificationHook(
304-
cls=TestModuleDeleteNotification,
304+
cls=DenoTestModuleDeleteNotification,
305305
execute=self.receive_deno_test_module_delete,
306306
),
307307
)
@@ -319,7 +319,7 @@ def methods(cls) -> Sequence[str]:
319319
return (DENO_TEST_RUN_PROGRESS,)
320320

321321
async def receive_deno_test_run_progress(
322-
self, noti: TestRunProgressNotification
322+
self, noti: DenoTestRunProgressNotification
323323
) -> None:
324324
logger.debug("Received Deno test run progress: {}", noti.params)
325325

@@ -331,7 +331,7 @@ def register_server_request_hooks(
331331
registry.register(
332332
DENO_TEST_RUN_PROGRESS,
333333
ServerNotificationHook(
334-
cls=TestRunProgressNotification,
334+
cls=DenoTestRunProgressNotification,
335335
execute=self.receive_deno_test_run_progress,
336336
),
337337
)

0 commit comments

Comments
 (0)