Commit Graph

12579 Commits

Author SHA1 Message Date
Lukas Wirth
73b7b34f89 Fill out expected type for functional update syntax completion 2021-08-11 18:12:44 +02:00
Lukas Wirth
6045059916 extract_variable handles selection ranges better 2021-08-11 17:52:09 +02:00
bors[bot]
f438dbb100
Merge #9860
9860: fix: Fix extract_function tagging params as mut unnecessarily r=Veykril a=Veykril

Fixes #9822
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-11 15:10:26 +00:00
Lukas Wirth
6d960ab032 Fix extract_function tagging params as mut unnecessarily 2021-08-11 17:09:51 +02:00
bors[bot]
50617ee5c5
Merge #9856
9856: Show type actions on ranged type hover r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-11 11:53:25 +00:00
Lukas Wirth
ec443886ea Show type actions on ranged type hover 2021-08-11 13:52:57 +02:00
Aleksey Kladov
629c68e80d internal: document that ascription is preferred to a turbo fish 2021-08-11 14:16:15 +03:00
bors[bot]
145b51f9da
Merge #9836
9836: Refactor: quick clean-up of iteration idioms in the `vfs` crate r=matklad a=Some-Dood

This PR cleans up some of the iteration idioms used in the `vfs` crate. Most of the changes simply converted `for` loops into their `std::iter::Iterator`-method counterpart. Other changes required some inversion of logic to accommodate for better short-circuiting. Overall, there should be no behavioral changes. If there are any stylistic issues, I will gladly adhere to them and adjust the PR accordingly. Thanks!

Co-authored-by: Basti Ortiz <39114273+Some-Dood@users.noreply.github.com>
2021-08-11 09:54:09 +00:00
bors[bot]
6c80c42c57
Merge #9828
9828: Remove dependency on the system graphviz when rendering crate graph r=lnicola a=p32blo


This PR removes the need for having `graphviz` installed on the user system by using the `d3-graphviz` npm package.

The responsibility of rendering the svg output is moved to the extension while the rust side only handles the generation of the dot file.

This change also brings the following additional features:
- Allow zooming the view
- Ctrl+click to reset the zoom 
- Adjust the color scheme to dark themes
- Works on any platform without installing graphviz locally

---

I’m not sure if this fits what you had in mind for the crates graph feature but I decided to submit it anyway to see if this is useful to anyone else. 

A potential downside might be that it increases the extension size ( haven’t checked) but this feature already required the installation of graphviz on the user side, so the cost is just moved explicitly to the extension.

Feel free to make any suggestion or comments. 

Co-authored-by: André Oliveira <p32blo@gmail.com>
2021-08-11 08:30:53 +00:00
Lukas Wirth
f6d6fda85b Refine functional update completion some more 2021-08-10 17:03:38 +02:00
Basti Ortiz
0986632c04
Fix: revert strange usage of ? operator 2021-08-10 22:44:15 +08:00
Basti Ortiz
27605b402e
Fix: prefer the usage of for loops over fold 2021-08-10 22:40:04 +08:00
Basti Ortiz
0e480a6e9c
Chore: add comments to explicitly express two-step check
See https://github.com/rust-analyzer/rust-analyzer/pull/9836#discussion_r685953381
2021-08-10 22:30:08 +08:00
Basti Ortiz
ae1288eeed
Fix: revert complex conditional in Directories::contains_file
This reverts commit 6d0336b2e4.
2021-08-10 22:25:43 +08:00
André Oliveira
11bbaecca0 Formatting issues 2021-08-10 13:43:57 +00:00
André Oliveira
b29508949d Remove debug logs 2021-08-10 13:43:57 +00:00
André Oliveira
8a563e4a46 Use local node_modules to allow the graph to load offline
- Fix some warnings
2021-08-10 13:43:08 +00:00
André Oliveira
f4f68e62c2 Use d3-graphviz for rendering crates graph on the extension side 2021-08-10 13:40:49 +00:00
bors[bot]
e1dcec0e02
Merge #9846
9846: feat: Generate default trait fn impl when generating `Clone` r=Veykril a=yoshuawuyts

Implements a default trait function body when generating the `Clone` trait for a type. Thanks!

r? `@\veykril`

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2021-08-10 13:18:09 +00:00
bors[bot]
f6ef043a88
Merge #9845
9845: fix: Do not drop `..Default::default()` completion when typing `..` r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/issues/9839
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-10 13:08:58 +00:00
Lukas Wirth
e729529410 Do not drop ..Default::default() completion when typing .. 2021-08-10 15:08:35 +02:00
Yoshua Wuyts
2f866974d9 gen clone for tuple enums 2021-08-10 15:07:13 +02:00
Yoshua Wuyts
e0adb39de3 gen clone for record enums 2021-08-10 14:43:20 +02:00
bors[bot]
cb3201188f
Merge #9842
9842: fix: Substitute generic types in inline_call r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-10 12:40:37 +00:00
Lukas Wirth
7e6eb67f0d Substitute generic types in inline_call 2021-08-10 14:39:56 +02:00
bors[bot]
a739a579cd
Merge #9841
9841: internal: print total size of source code in analysis-stats r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-10 12:31:35 +00:00
Aleksey Kladov
a379bd715f
Update crates/rust-analyzer/src/cli/analysis_stats.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2021-08-10 15:31:12 +03:00
Aleksey Kladov
5d5d5182c1 internal: print total size of source code in analysis-stats 2021-08-10 15:28:48 +03:00
Yoshua Wuyts
7ddc26aea1 add clone generation for structs and bare enums 2021-08-10 13:55:26 +02:00
Yoshua Wuyts
7d7a50daf7 Add clone generation tests 2021-08-10 13:20:24 +02:00
Lukas Wirth
b7d7dd6163 Implement bool_then_to_if assist 2021-08-10 13:17:45 +02:00
Yoshua Wuyts
4b5139e8a5 impl gen hash for structs 2021-08-10 12:37:10 +02:00
Yoshua Wuyts
ec2535e9ce impl gen hash for enums 2021-08-10 12:37:10 +02:00
bors[bot]
e652545472
Merge #9830
9830: Enable more assists to generate default trait body impls r=Veykril a=yoshuawuyts

Enable more assists to benefit from trait body generation. Follow-up to #9825 and #9814.

__edit:__ I'd like to move the existing tests to this new file too, but I'll do that in a follow-up PR.

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2021-08-10 10:27:55 +00:00
Yoshua Wuyts
326890753c implement feedback from review 2021-08-10 12:21:48 +02:00
Basti Ortiz
7ee6cca3d7
Refactor: use iterator methods over for loops 2021-08-10 17:51:11 +08:00
Aleksey Kladov
9cf5914c45 internal: unify subcommand handling between ra and xtask 2021-08-10 12:49:55 +03:00
Aleksey Kladov
e8a67b67bf internal: prepare to use standard .run pattern for subcommands 2021-08-10 12:25:47 +03:00
Basti Ortiz
6d0336b2e4
Refactor: simplify logic for Directories::contains_file
The logic was simply inverted to accomodate for the short-circuiting `&&` operator.
2021-08-10 16:32:00 +08:00
Yoshua Wuyts
d6b788a9ee Add trait codegen to add_missing_impl_members assist 2021-08-10 10:27:52 +02:00
Basti Ortiz
0765c9713b
Refactor: use filter_map when iterating over stored IDs and 2021-08-10 15:56:16 +08:00
Basti Ortiz
e912d6507f
Chore: use short-circuiting for file ID getter 2021-08-10 15:43:51 +08:00
Jake Heinz
4fba518b02 [semantic-highlighting] functions that consume are marked as HlMod::Consuming 2021-08-10 07:31:30 +00:00
Yoshua Wuyts
4d2e25a034 move trait body gen code to utils 2021-08-09 21:47:44 +02:00
bors[bot]
8e4fb4f518
Merge #9804
9804: Generate method from call r=matklad a=mahdi-frms

Needs a bit of refactoring. Tests also should be added.

Co-authored-by: mahdi-frms <mahdif1380@outlook.com>
2021-08-09 17:09:13 +00:00
bors[bot]
63427afb69
Merge #9825
9825: Generate default impl when converting #[derive(Default)] to manual impl r=Veykril a=yoshuawuyts

Similar to https://github.com/rust-analyzer/rust-analyzer/pull/9814, but for `#[derive(Default)]`. Thanks!

## Follow-up steps
I've added the tests inside `handlers/replace_derive_with_manual_impl.rs` again, but I'm planning a follow-up PR to extract these to `utils/` so we can share them between assists - and maybe even add another assist just for the purpose of testing these impls (e.g. `generate_default_trait_body`).

The step after _that_ is likely to fill out the remaining traits, so we can make it so whenever RA auto-completes a trait which also can be derived, we provide a default function body.


Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2021-08-09 16:59:10 +00:00
mahdi-frms
05a789c09d refactor method generation assist 2021-08-09 21:06:24 +04:30
mahdi-frms
9217f6dcf7 method gen assist usable in all of expression 2021-08-09 21:06:24 +04:30
mahdi-frms
311dc5b04f add test for method generation assist 2021-08-09 21:06:24 +04:30
mahdi-frms
3c31f3831d One assist for function and method generation 2021-08-09 21:06:24 +04:30