PoC: emit code actions from the compiler that the editor tooling can use#7040
Closed
PoC: emit code actions from the compiler that the editor tooling can use#7040
Conversation
zth
commented
Sep 16, 2024
Comment on lines
+276
to
+278
| "-code-action-data", unit_call(fun _ -> Js_config.code_action_data := true), | ||
| "*internal* Emit code action data"; | ||
|
|
Member
Author
There was a problem hiding this comment.
This isn't actually used yet, but we can probably have a bsc config like this.
zth
commented
Sep 16, 2024
jscomp/ml/code_action_data.ml
Outdated
| match !code_action_data with | ||
| | [] -> () | ||
| | code_actions -> | ||
| Format.fprintf ppf "@\n=== CODE ACTIONS ===@\n"; |
Member
Author
There was a problem hiding this comment.
Build system and editor tooling can extract this line + the rest of the content whenever it encounters it, and extract the code actions from there. And show the actual error in the terminal and in the editor without this text.
Member
Author
|
Maybe this should incorporate #6203 at the same time. This type of functionality opens up for a JSON format anyway. |
Member
Author
|
Superseded by the new work on actions overall. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Very messy PoC, but this is intended to show that we could fairly easily add a specific mode to
bscthat the editor tooling and/or build system can enable to get the compiler to emit code action data.The main advantage here is that we can co-locate the code that produces code actions with the actual type checker and what produces the error messages. Currently, we parse the error log to extract these things. This would make it more robust and easier to maintain, and automatically tied to the current ReScript version.
Example:

To start we could port all actions in https://github.com/rescript-lang/rescript-vscode/blob/fd911045515edd1c82e981e407281ee9f311a8ed/server/src/codeActions.ts and then add more as needed.