-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PoC: emit code actions from the compiler that the editor tooling can use #7040
base: master
Are you sure you want to change the base?
Conversation
"-code-action-data", unit_call(fun _ -> Js_config.code_action_data := true), | ||
"*internal* Emit code action data"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't actually used yet, but we can probably have a bsc
config like this.
jscomp/ml/code_action_data.ml
Outdated
match !code_action_data with | ||
| [] -> () | ||
| code_actions -> | ||
Format.fprintf ppf "@\n=== CODE ACTIONS ===@\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Maybe this should incorporate #6203 at the same time. This type of functionality opens up for a JSON format anyway. |
Very messy PoC, but this is intended to show that we could fairly easily add a specific mode to
bsc
that 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.