Skip to content

Conversation

zth
Copy link
Member

@zth zth commented Sep 16, 2024

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:
image

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.

Comment on lines +276 to +278
"-code-action-data", unit_call(fun _ -> Js_config.code_action_data := true),
"*internal* Emit code action data";

Copy link
Member Author

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.

match !code_action_data with
| [] -> ()
| code_actions ->
Format.fprintf ppf "@\n=== CODE ACTIONS ===@\n";
Copy link
Member Author

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.

@zth
Copy link
Member Author

zth commented Sep 17, 2024

Maybe this should incorporate #6203 at the same time. This type of functionality opens up for a JSON format anyway.

@cknitt cknitt assigned zth and nojaf Feb 6, 2025
@zth
Copy link
Member Author

zth commented Sep 10, 2025

Superseded by the new work on actions overall.

@zth zth closed this Sep 10, 2025
@github-project-automation github-project-automation bot moved this from Ready to Done in ReScript development Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants