774: Batch crate & command r=matklad a=flodiebold
This adds a new crate, `ra_batch`, which is intended for scenarios where you're loading a workspace once and then running some analyses using the HIR API. Also, it adds a command to `ra_cli` which uses that to type-check all crates in a workspace and print some statistics:
E.g. in rust-analyzer:
```
> $ time target/release/ra_cli analysis-stats
Database loaded, 21 roots
Crates in this dir: 28
Total modules found: 231
Total declarations: 3694
Total functions: 2408
Total expressions: 47017
Expressions of unknown type: 19826 (42%)
Expressions of partially unknown type: 4482 (9%)
target/release/ra_cli analysis-stats 3,23s user 0,60s system 100% cpu 3,821 total
```
Or in rust-lang/rust:
```
> $ time ../opensource/rust-analyzer/target/release/ra_cli analysis-stats
Database loaded, 77 roots
Crates in this dir: 130
Total modules found: 1820
Total declarations: 35038
Total functions: 25914
Total expressions: 753678
Expressions of unknown type: 337975 (44%)
Expressions of partially unknown type: 92314 (12%)
../opensource/rust-analyzer/target/release/ra_cli analysis-stats 13,45s user 2,08s system 100% cpu 15,477 total
```
~This still needs a test. Type-checking all of rust-analyzer sadly takes almost a minute when compiled in debug mode 😅 So I'll need to add something simpler (maybe just looking at a few modules).~
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
776: Add support for a seperate output channel for trace messages r=DJMcNab a=DJMcNab
See https://github.com/Microsoft/vscode-languageserver-node/pull/444
I am just working on testing this now, but I think it should work.
Co-authored-by: DJMcNab <36049421+djmcnab@users.noreply.github.com>
770: Fix introduce var duplicating newlines r=matklad a=vipentti
This fixes#713.
If the block before the statement we want to use introduce var on, had empty
lines these empty lines would also be added between the let-statement and
the current line where the new variable is used.
This fixes that by trimming excess newlines from the start of the indent chunk
and simply adding a single newline (when the chunk had newlines) between the
let-statement and the current statement. If there were no newlines this
matches the previous behaviour.
Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
773: Crash fixes r=matklad a=flodiebold
This fixes a bunch of crashes found while running type inference on the whole rustc repo 😅
- avoid infinite recursion with ref bind patterns
- avoid another infinite recursion
- handle literal patterns, add a new LITERAL_PAT syntax node for this
- fix an expect that's wrong on some invalid code
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
771: update notify with fix for hight cpu usage r=matklad a=vemoo
Should fix the ocasional 100% CPU hangs.
I've tried `yes > test.rs` which would cause it before, and now on my computer it stays below 10%, and stops as soon as I interrupt the command, unlike previously which would stay at 100% for a while.
Co-authored-by: Bernardo <berublan@gmail.com>
This fixes#713.
If the block before the statement we want to use introduce var on, had empty
lines these empty lines would also be added between the let-statement and
the current line where the new variable is used.
This fixes that by trimming excess newlines from the start of the indent chunk
and simply adding a single newline (when the chunk had newlines) between the
let-statement and the current statement. If there were no newlines this
matches the previous behaviour.
767: Extract project model to separate crate r=matklad a=flodiebold
I'm looking into creating a separate crate that would allow getting a HIR db for a project for 'batch' analyses, and this seems to be an obvious first step. We'd probably want to change the error handling to not rely on failure, though, right?
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
768: Sort assists by the range of the affected element r=matklad a=robojumper
Closes#763.
3be98f2ac9/crates/ra_assists/src/lib.rs (L233-L236)
This could be made more robust by a) adding a way to identify actions by things other than their label and b) allowing arbitrary actions to appear in the list as long as the tested actions are there in the correct order. Let me know if I should do any of that.
Co-authored-by: robojumper <robojumper@gmail.com>
760: Add new assist to remove dbg!() calls r=matklad a=vipentti
This fixes#758.
Currently we try to maintain the cursor position relative to the statement under
cursor, if the cursor is inside the dbg! macro call.
Meaning:
```rust
let foo = dbg!(some.complex<|>().expression());
```
Should turn into:
```rust
let foo = some.complex<|>().expression();
```
With the cursor staying in place.
Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>