2837: Accidentally quadratic r=matklad a=matklad
Our syntax highlighting is accdentally quadratic. Current state of the PR fixes it in a pretty crude way, looks like for the proper fix we need to redo how source-analyzer works.
**NB:** don't be scared by diff stats, that's mostly a test-data file
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2716: Allow assists with multiple selectable actions r=SomeoneToIgnore a=SomeoneToIgnore
This PR prepares an infra for https://github.com/rust-analyzer/rust-analyzer/issues/2180 task by adding a possibility to specify multiple actions in one assist as multiple edit parameters to the `applySourceChange` command.
When this is done, the command opens a selection dialog, allowing the user to pick the edit to be applied.
I have no working example to test in this PR, but here's a demo of an auto import feature (a separate PR coming later for that one) using this functionality:
![out](https://user-images.githubusercontent.com/2690773/71633614-f8ea4d80-2c1d-11ea-9b15-0e13611a7aa4.gif)
The PR is not that massive as it may seem: all the assist files' changes are very generic and similar.
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2853: Manage `cargo check` state updates in `main_loop` to reduce lock contention r=matklad a=kiljacken
State is now updated exclusively from `main_loop` so several threads theoretically can't compete for the lock. Updates to the state are requested via the existing task channel.
Also updates some naming to make slightly more sense.
Based upon an idea/suggestion from @matklad on Zulip:
> I think I've noticed at leas something suspicious!
>
> In WorldSnapshot, we store an Arc<RwLock<CheckWatcherSharedState>>. We read lock this lock in handle_diagnostics.
>
> Additionally, we .write this lock from the watcher thread in CheckWatcherState::run.
>
> I think in general this is less then ideal, b/c diagnostics request can be blocked on another thread. I think it makes sense to architect this in a way which does not block.
>
> For that, we stop sharing the state between ServerWorld and CheckWatcherState. Instead, the watcher thread sends new diagnostics via a channel, and we accomodate thouse diagnostics intot he server state in the main loop.
>
> So, instead of:
> ```rust
> struct Server {
> diagnostics: Arc<Mutex<Vec<Diagnostics>>>,
> }
>
> struct Watcher {
> diagnostics: Arc<Mutex<Vec<Diagnostics>>>,
> }
> ```
> we'll have something like this:
> ```rust
> struct Server {
> // this bit now *owns* diagnostics
> diagnostisc: Vec<Diagnostics>
> }
>
> struct Watcher {
> diagnostics_sink: Sender<Vec<Diagnostics>>,
> }
> ```
> I am not sure this is the cuprit of slowness on widnows, but I think we should fix it, because it's very useful when all changes to the server's state can occur only via the main loop.
>
> Note how VFS is set up in a similar way: instead of modifing some global hash map with files, VFS sends a message to the main looop that hey, I have these new files for you. The main loop than incorporates the changes itself.
>
> Note that I think we'll still need some locks here, to share the state between ServerWorld and WorldSnapshot, but we won't actually be changing anyting mid-snapshot
Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2850: Use types from vscode-languageclient r=matklad a=kiljacken
Now that we're running with 3.15 of the LSP for VSCode we don't need to define these interfaces ourselves. Yay!
Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2849: Display vscode message after changing cargo-watch options r=edwin0cheng a=memoryruins
Currently, changed cargo-watch settings do not go into effect until after a reload.
This PR checks for changed `cargoWatchOptions` in the same way as the current `cargoFeatures` check.
![2020-01-14_20-52-20](https://user-images.githubusercontent.com/6868531/72398362-b5f5a300-3710-11ea-9bc1-9943bef08447.gif)
Co-authored-by: memoryruins <memoryruinsmusic@gmail.com>
2844: Use dummy value for line! and column! macro r=matklad a=edwin0cheng
Use dummy value `0` for line! and column! macro.
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2834: refactor(ra_syntax.validation): removed code duplication from validate_literal() r=kiljacken a=Veetaha
Hi! This is my first ever contribution to this project.
I've taken some dirty job from issue #223
This is a simple atomic PR to remove code duplication according to FIXME comment in the function that is the main focus of the further development.
I just didn't want to mix refactoring with the implementation of new features...
I am not sure whether you prefer such atomic PRs here or you'd rather have a single PR that contains all atomic commits inside of it?
So if you want me to add all that validation in one PR I'll mark this one as WIP and update it when the work is finished, otherwise, I'll go with the option of creating separate PRs per each feature of validation of strings, numbers, and comments respectively.
### Comments about refactoring
Yeah, reducing the duplication is quite hard here, extracting into stateless functions could be another option but the number of their arguments would be very big and repeated across char and string implementations so that just writing their types and names would become cumbersome.
I tried the option of having everything captured implicitly in the closure but failed since rust doesn't have templated (or generic) closures as C++ does, this is needed because `unescape_byte*()` and `unescape_char|str()` have different return types...
Maybe I am missing something here? I may be wrong because I am not enough experienced in Rust...
Well, I am awaiting any kind of feedback!
Co-authored-by: Veetaha <gerzoh1@gmail.com>