-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add a clear diagnostics command to flycheck. #14590
Conversation
@@ -461,6 +470,9 @@ impl CargoActor { | |||
let mut read_at_least_one_stdout_message = false; | |||
let mut read_at_least_one_stderr_message = false; | |||
let process_line = |line: &str, error: &mut String| { | |||
if line == "CLEAR" { |
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.
I'm open to some sort of json format or something instead to be consistent to the rest of the file, but didn't bother implementing it since I don't know what the right structure for something like that would be.
This will allow for watcher-style flychecks. Currently, we can only run flychecks on every save. This allows for a long-running flycheck that can update diagnostics between file saves (eg. update on every build). Rationale: I'm trying to improve the experience developing using bazel + rust (see [issue](bazelbuild/rules_rust#1657)). The developer experience I'm looking at is: 1. Dev invokes "ibazel build //:my_crate //:my_crate_test". This ensures that whenever the source code changes, it rebuilds. both the crate and the test for the crate. 2. The discover project command is automatically invoked when you open main.rs, which generates a file listing the `.rustc-output` files mentioned below. 3. Dev modifies `my_crate/src/main.rs` and saves in vscode. 4. bazel is automatically invoked on save, and under the hood invokes rustc, which generates `bazel-out/k8-fastbuild/bin/my_crate/my_crate.rustc-output` and `bazel-out/k8-fastbuild/bin/my_crate_test/my_crate_test.rustc_output` for the original crate and the test crate respectively. 5. The non-test crate finishes building 6. A watcher script would see that `my_crate.rustc-output` has been updated, and update the rust-analyzer result for the file. 7. The test crate finishes building 8. The watcher script would see that `my_crate_test.rustc-output` has been updated, and update the rust-analyzer result for the file.
It is not clear to me that how bazel can preemptively send commands to the r-a process? Is it keep itself alive first time server invoke it on save? If so, what will happen on later saves? If it is not about some interactive and long time user experience, I assume the clear command is used to de-duplicate diagnostics. In this case, isn't it possible for bazel to deduplicate diagnostics in itself and only send the new diagnostics to the rust-analyzer? |
To clarify, bazel doesn't send anything to r-a. When you run the discover project command, bazel generates a list of I'll give an example where we have 3 build targets:
Let's assume we update As a user, my expectation would be that it updates main.rs with either the updated contents of
This leaves us with a few options for the check command, each of which has its own problems:
Even if we ensured that the check command was told which file is updated, we come across the following race condition from above:
|
Current rust-analyzer assumes oneshot processes for flycheck. I could see us maybe (not 100% certain) adding support for watcher style processes, but those should probably be handled differently than an adhoc CLEAR message |
Closing because as discussed elsewhere, an extension for rust-analyzer with vscode is required anyway, so we can just have that extension call the command clearFlycheck. |
This will allow for watcher-style flychecks. Currently, we can only run flychecks on every save. This allows for a long-running flycheck that can update diagnostics between file saves (eg. update on every build).
Rationale:
I'm trying to improve the experience developing using bazel + rust (see issue). The developer experience I'm looking at is:
.rustc-output
files mentioned below.my_crate/src/main.rs
and saves in vscode.bazel-out/k8-fastbuild/bin/my_crate/my_crate.rustc-output
andbazel-out/k8-fastbuild/bin/my_crate_test/my_crate_test.rustc_output
for the original crate and the test crate respectively.my_crate.rustc-output
has been updated, and update the rust-analyzer result for the file.my_crate_test.rustc-output
has been updated, and update the rust-analyzer result for the file.