Commit Graph

5 Commits

Author SHA1 Message Date
Craig McIlwrath
76d9fc4213
[waspls] Add code actions for scaffolding external code (#1316)
When an external import tries to import a symbol from a TypeScript/JavaScript file, waspls now offers quickfix code actions to scaffold a function in that file.

It uses the surrounding context of the external import to determine what code to write for the code action. See [`ScaffoldTsSymbol.hs`](457911d5e9/waspc/waspls/src/Wasp/LSP/Commands/ScaffoldTsSymbol.hs) for a detailed description of how it works. At a high level, there is a `templateForFile` function in `Wasp.LSP.Commands.ScaffoldTsSymbol` that selects the correct template from `data/lsp/templates/ts`. For example, `action.fn.ts` contains a template for scaffolding an `action` function in a TypeScript file and would be used when a code action is requested with the cursor at the location marked by `|`:

```wasp
action createTask {
  fn: import { createTask } from "@server/actions.js"|
}
```

The scaffold action runs as a [LSP command](https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#workspace_executeCommand). To prepare for wanting to define more commands in waspls in the future, this PR also introduces the concept of `Commands` (`Wasp.LSP.Commands.Command`) that define some properties about each command waspls wants to handle.
2023-07-26 08:00:16 -04:00
Craig McIlwrath
d5c04a002a
[waspls] fix debouncer tests (#1284) 2023-06-23 10:28:22 -04:00
Craig McIlwrath
7c0d13d242
[waspls] diagnostics for external imports and goto definition (#1268) 2023-06-22 15:37:07 -04:00
Craig McIlwrath
e43b8f986c
[waspls] add dictionary autocomplete and signature help (#1230) 2023-06-20 07:31:20 -04:00
Craig McIlwrath
00e4966f06
Add test framework for language server autocompletion (#1223) 2023-06-01 11:03:01 -04:00