wasp/waspc/waspls/test/Wasp/LSP
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
..
completionTests [waspls] add dictionary autocomplete and signature help (#1230) 2023-06-20 07:31:20 -04:00
CompletionTest.hs [waspls] diagnostics for external imports and goto definition (#1268) 2023-06-22 15:37:07 -04:00
DebouncerTest.hs [waspls] fix debouncer tests (#1284) 2023-06-23 10:28:22 -04:00
SyntaxTest.hs [waspls] Add code actions for scaffolding external code (#1316) 2023-07-26 08:00:16 -04:00