diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-03 16:41:46 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-03 16:41:46 +0300 |
| commit | 3ee19139a95441a3ce10690377de8f453c7aec3f (patch) | |
| tree | b627097b2b2863e493e9ef0f9f4a88057c96c228 /internal/lsp/handlers_execute.go | |
| parent | f3a1a41d92651d6d19ee6b078c0ffdc825015bde (diff) | |
lsp: add 'Hexai: implement unit test' code action for Gov0.4.1
- Generate or append tests to _test.go
- Jump to generated test via showDocument (command + server-initiated)
- Document the feature in docs/go-unit-tests.md
- Prefix action titles with 'Hexai: '
- Bump version to 0.4.1
Diffstat (limited to 'internal/lsp/handlers_execute.go')
| -rw-r--r-- | internal/lsp/handlers_execute.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/lsp/handlers_execute.go b/internal/lsp/handlers_execute.go new file mode 100644 index 0000000..2e3ec52 --- /dev/null +++ b/internal/lsp/handlers_execute.go @@ -0,0 +1,35 @@ +// Summary: ExecuteCommand handler to support post-edit navigation (jump to generated test). +package lsp + +import ( + "encoding/json" +) + +func (s *Server) handleExecuteCommand(req Request) { + var p ExecuteCommandParams + if err := json.Unmarshal(req.Params, &p); err != nil { + s.reply(req.ID, nil, nil) + return + } + switch p.Command { + case "hexai.showDocument": + if len(p.Arguments) >= 2 { + uri, _ := p.Arguments[0].(string) + var r Range + // Convert second arg to Range via re-marshal to be robust across clients + if b, err := json.Marshal(p.Arguments[1]); err == nil { + _ = json.Unmarshal(b, &r) + } + if uri != "" { + s.clientShowDocument(uri, &r) + } + } + s.reply(req.ID, nil, nil) + return + default: + // Unknown command; no-op + s.reply(req.ID, nil, nil) + return + } +} + |
