Commit graph

8907 commits

Author SHA1 Message Date
bors[bot]
db6988d4e7
Merge #6614 #6632
6614: Improve autoimports on completion speed r=matklad a=SomeoneToIgnore

Presumably closes https://github.com/rust-analyzer/rust-analyzer/issues/6594
May help https://github.com/rust-analyzer/rust-analyzer/issues/6612

* Ignore modules eaferly
* Do less completion string rendering

6632: Pin cargo_metadata r=matklad a=kjeremy

See: https://github.com/oli-obk/cargo_metadata/pull/142#issuecomment-733653275

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-11-26 10:43:35 +00:00
kjeremy
9a3142664b Pin cargo_metadata 2020-11-25 10:11:53 -05:00
Kirill Bulatov
9812150047 Document experimental completions 2020-11-25 00:42:58 +02:00
Kirill Bulatov
4c95c6e25d Gate autoimports begind experimental completions flag 2020-11-25 00:30:28 +02:00
Jonas Schievink
9559bce311 Rename parse_macro to parse_macro_expansion
This does not parse macros, it expands a macro and parses the *result*
2020-11-24 21:57:51 +01:00
Jonas Schievink
f9d0d51101 hir_expand::db: reduce fn visibility 2020-11-24 21:55:08 +01:00
Jonas Schievink
9a3bb19d32 Remove fixed FIXME, propagate errors better 2020-11-24 21:52:19 +01:00
Jonas Schievink
d5e9bf80f9 hir_expand: propagate expansion errors 2020-11-24 19:00:23 +01:00
Lukas Wirth
377fa7db3f Check structs for match exhaustiveness 2020-11-24 18:50:56 +01:00
Lukas Wirth
4d841dc4e7 Add middle ellipsis missing arm text 2020-11-24 16:46:06 +01:00
Lukas Wirth
a4b5275656 Handle ellipsis in tuple patterns in match exhaustiveness checking 2020-11-24 16:43:28 +01:00
bors[bot]
67d45851bf
Merge #6618
6618: Properly infer tuple patterns when encountering ellipsis r=Veykril a=Veykril

We basically just split the subpatterns into two halves when the ellipsis is present and then offset the latter half to account for the ignored bindings.

Fixes #6616

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-24 15:13:25 +00:00
Lukas Wirth
a5efefd3d7 Properly infer tuple struct patterns when encountering ellipsis 2020-11-24 16:11:40 +01:00
kjeremy
e981485b76 New lsp-types to fix versioning
Fixes #6603
2020-11-24 08:52:24 -05:00
Lukas Wirth
35dd62e915 Properly infer tuple patterns when encountering ellipsis 2020-11-24 13:56:20 +01:00
Laurențiu Nicola
8af1ed6a09 Avoid string allocations in ignore_test 2020-11-24 12:08:54 +02:00
bors[bot]
6294286fee
Merge #6610
6610: add 'Re-enable this test' assist r=SomeoneToIgnore a=jakobhellermann

The `Ignore this test` assist previously allowed ignoring multiple times, each time adding a `#[ignore]` attribute.

This PR instead shows an assist to undo the ignoring.

Co-authored-by: Jakob Hellermann <jakob.hellermann@protonmail.com>
2020-11-24 00:54:53 +00:00
bors[bot]
2ff78cde31
Merge #6613
6613: Don't assume DidChangeTextDocument paths exist r=SomeoneToIgnore a=mjibson

Fixes #5933

Co-authored-by: Matt Jibson <matt.jibson@gmail.com>
2020-11-24 00:41:08 +00:00
Kirill Bulatov
4baac238a8 Improve autoimports on completion speed
* Ignore modules eaferly
* Do less completion string rendering
2020-11-24 02:28:45 +02:00
Matt Jibson
117c793e80 Don't assume DidChangeTextDocument paths exist
Fixes #5933
2020-11-23 16:35:34 -07:00
Jakob Hellermann
a172c2317c add 'Re-enable this test' assist 2020-11-23 20:31:57 +01:00
Aleksey Kladov
2c083c993f Minor, import style 2020-11-23 21:19:37 +03:00
David Tolnay
8a11da40a7
Parse unsafe extern block 2020-11-22 20:44:56 -08:00
Benjamin Coenen
775c69183c add let and letm postfix to turn expressions into variables
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-11-21 15:06:22 +01:00
Lukas Wirth
1f87a41989 Add attribute highlight modifier to all tokens inside attributes 2020-11-21 12:51:05 +01:00
Lukas Wirth
5d39f6a357 Don't wrap parens around expr in remove_dbg assist if its in conditions 2020-11-20 17:28:56 +01:00
Lukas Wirth
91a1a83601 Fill code_description for rust_analyzer diagnostics 2020-11-18 08:54:52 +01:00
Lukas Wirth
56a0021e61 update diagnostics test_data with code_description changes 2020-11-18 08:50:27 +01:00
Lukas Wirth
863fdcfa24 Link clippy lint codes in diagnostics 2020-11-18 08:50:27 +01:00
Lukas Wirth
132063ad96 Link rustc error codes in diagnostics 2020-11-18 08:50:27 +01:00
Lukas Wirth
e8282b37d4 Don't call a closure function in infer_function_return_type label 2020-11-17 22:34:15 +01:00
bors[bot]
156f7d6963
Merge #6553
6553: Auto imports in completion r=matklad a=SomeoneToIgnore

![completion](https://user-images.githubusercontent.com/2690773/99155339-ae4fb380-26bf-11eb-805a-655b1706ce70.gif)

Closes https://github.com/rust-analyzer/rust-analyzer/issues/1062 but does not handle the completion order, since it's a separate task for https://github.com/rust-analyzer/rust-analyzer/issues/4922 , https://github.com/rust-analyzer/rust-analyzer/issues/4922 and maybe something else.

2 quirks in the current implementation:

* traits are not auto imported during method completion

If I understand the current situation right, we cannot search for traits by a **part** of a method name, we need a full name with correct case to get a trait for it.

* VSCode (?) autocompletion is not as rigid as in Intellij Rust as you can notice on the animation.

Intellij is able to refresh the completions on every new symbol added, yet VS Code does not query the completions on every symbol for me.
With a few debug prints placed in RA, I've observed the following behaviour: after the first set of completion suggestions is received, next symbol input does not trigger a server request, if the completions contain this symbol.
When more symbols added, the existing completion suggestions are filtered out until none are left and only then, on the next symbol it queries for completions.
It seems like the only alternative to get an updated set of results is to manually retrigger it with Esc and Ctrl + Space.

Despite the eerie latter bullet, the completion seems to work pretty fine and fast nontheless, but if you have any ideas on how to make it more smooth, I'll gladly try it out.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-11-17 17:50:08 +00:00
bors[bot]
f4b4f17662
Merge #6582
6582: Fill the diagnostic code field in publish_diagnostics r=kjeremy a=Veykril

Fixes #6580
Before:
![Code_znn6VgLLH9](https://user-images.githubusercontent.com/3757771/99408084-213f7100-28f0-11eb-8317-3f5c2b93313d.png)
After:
![Code_c4jJsvzOEA](https://user-images.githubusercontent.com/3757771/99408096-23093480-28f0-11eb-9bb2-8ebf2fb3d5a1.png)


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-17 15:47:36 +00:00
Lukas Wirth
c868f0255f Fill the diagnostic code field in publish_diagnostics 2020-11-17 16:23:53 +01:00
Aleksey Kladov
e88b5fe916 Simplify 2020-11-17 15:25:58 +01:00
Aleksey Kladov
bd4d375a64 Make code more readable 2020-11-17 15:25:58 +01:00
Aleksey Kladov
a0c4dbc399 Minor 2020-11-17 15:25:58 +01:00
Aleksey Kladov
db218006c9 Remove dead code 2020-11-17 15:25:57 +01:00
Aleksey Kladov
0d19ee1d70 Simplify 2020-11-17 15:25:57 +01:00
Aleksey Kladov
17e8a00b0b Use standard code style for test fixtures 2020-11-17 14:43:23 +01:00
Aleksey Kladov
8c6f933773 **Unwrap Block** supports stand-alone blocks 2020-11-17 14:33:30 +01:00
Aleksey Kladov
10fa9c595a Simplify 2020-11-17 14:33:30 +01:00
Aleksey Kladov
8dd0b7d2b5 Assist target should point at *existing* code 2020-11-17 14:33:30 +01:00
Aleksey Kladov
9a30707281 Add **Ignore Test** assist 2020-11-17 14:22:04 +01:00
Kirill Bulatov
16f0b2fdde Actually enable eager completion 2020-11-17 13:19:56 +02:00
bors[bot]
10e3a9879c
Merge #6571
6571: Cleanup project model r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-11-17 10:53:12 +00:00
Aleksey Kladov
0dc1742187 Remove needless alloc 2020-11-17 11:52:28 +01:00
Aleksey Kladov
e4927d52e2 Compress code 2020-11-17 11:52:28 +01:00
Aleksey Kladov
a6960fb3b8 simplify 2020-11-17 11:31:40 +01:00
Kirill Bulatov
d4128beb3d Avoid turning completion objects into builders 2020-11-16 23:16:41 +02:00
kjeremy
233fdb12ce Latest LSP 3.16 protocol
Pulls in https://github.com/gluon-lang/lsp-types/pull/186
2020-11-16 15:10:13 -05:00
Kirill Bulatov
4109968934 Remove query aliases 2020-11-16 21:24:54 +02:00
Kirill Bulatov
d776c67226 Properly fill the completion settings 2020-11-16 21:19:06 +02:00
Kirill Bulatov
1de7848b57 Fix the other test 2020-11-16 21:19:06 +02:00
Kirill Bulatov
bbe1fbd178 Qualify autoimport completion suggestions 2020-11-16 21:19:06 +02:00
Kirill Bulatov
38ef1fd4ad Better filter mod paths 2020-11-16 21:19:06 +02:00
Kirill Bulatov
ee99620754 Move autoimport completion into the unqialified_path module 2020-11-16 21:19:06 +02:00
Kirill Bulatov
3b0fc4d7f2 Omit modules during autocompletion 2020-11-16 21:19:06 +02:00
Kirill Bulatov
46514448b7 Tweak the search limits a bit 2020-11-16 21:19:06 +02:00
Kirill Bulatov
1598740292 Reuse existing element rendering 2020-11-16 21:19:06 +02:00
Kirill Bulatov
4c8edd003a Use imports_locator 2020-11-16 21:19:06 +02:00
Kirill Bulatov
d1556550f8 Rename the module 2020-11-16 21:19:06 +02:00
Kirill Bulatov
0e050fc3eb Allow to configure the merge behavior 2020-11-16 21:19:06 +02:00
Kirill Bulatov
1e458efe62 Add braces to functions and macros 2020-11-16 21:19:06 +02:00
Kirill Bulatov
6ab97244b8 Tidy up the tests 2020-11-16 21:19:06 +02:00
Kirill Bulatov
6866a05e6f Use rewriter api to add both changes 2020-11-16 21:19:06 +02:00
Kirill Bulatov
f62e8616c8 Add imports in auto completion 2020-11-16 21:19:05 +02:00
Aleksey Kladov
682dd4dac0 Prepare to recompute completions on every keystroke
If we set `is_incomplete: true`, VS Code will re-query completions
after every keypress.
2020-11-16 17:27:36 +01:00
bors[bot]
789d9ca1d3
Merge #6563
6563: Don't complete keywords in struct initializers r=matklad a=Veykril

Fixes #6562

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-16 11:49:48 +00:00
Lukas Wirth
fb71185692 Don't complete keywords in struct literals 2020-11-16 12:23:18 +01:00
bors[bot]
e17d604888
Merge #6558
6558: format string highlighting: handle hex + debug type specifier r=matklad a=ruabmbua

Should fix https://github.com/rust-analyzer/rust-analyzer/issues/6427


Co-authored-by: Roland Ruckerbauer <roland.rucky@gmail.com>
2020-11-16 11:07:29 +00:00
bors[bot]
382361c252
Merge #6552
6552: Properly handle shorthands in destructure patterns when renaming r=SomeoneToIgnore a=Veykril

Fixes #6548 and #6551.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-15 18:51:23 +00:00
Roland Ruckerbauer
a15dda48c6 format string highlighting: handle hex + debug type specifier 2020-11-15 17:43:14 +01:00
Lukas Wirth
f3e297331c Cleanup edit_text_range_for_record_field_expr_or_pat 2020-11-15 16:11:06 +01:00
Lukas Wirth
cb60708274 Use shorthand field syntax in destructures 2020-11-14 21:08:20 +01:00
Lukas Wirth
924eecf4af Properly handle shorthands in destructure patterns when renaming 2020-11-14 19:11:09 +01:00
Lukas Wirth
e55a44a831 Use shorthand record syntax when renaming struct initializer field 2020-11-14 17:51:09 +01:00
bors[bot]
e8c803937c
Merge #6544
6544: add suggestion ..Default::default() for remaining struct fields in a constructor r=bnjjj a=bnjjj

I'm not sure I should import `assists` crate inside `completions`, maybe we should move out `FamousDefs` from `assists` ? Let me know :) 

close #6492

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-11-13 23:30:13 +00:00
Benjamin Coenen
9f15de77f9 add suggestion ..Default::default() for remaining struct fields in a constructor #6492
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-11-13 23:20:26 +01:00
Aleksey Kladov
b1377363df Remove dead code 2020-11-13 17:53:48 +01:00
Aleksey Kladov
4dfda64b39 Cleanup workspace loading a tiny bit 2020-11-13 17:38:26 +01:00
Benjamin Coenen
e73d140b51 add suggestion ..Default::default() for remaining struct fields in a constructor #6492
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-11-13 17:17:16 +01:00
Aleksey Kladov
aeda30e301 Move tricky workspace logic to a separate module 2020-11-13 16:44:48 +01:00
Aleksey Kladov
f0f13d8cfa cleanup 2020-11-13 16:32:57 +01:00
bors[bot]
b0ad492e3d
Merge #6519
6519: Add "Open Cargo.toml" action r=matklad a=p3achyjr

## What is it?

This adds an "open cargo.toml" action from the vscode shell, resolves #6462 

## Test

Ran ```cargo xtask install --server``` and ```cargo xtask install --client```, then ```Developer: Reload Window```.

![image](https://user-images.githubusercontent.com/8763808/98614382-2a578f00-22ad-11eb-9811-4a72a54ff6fb.png)

When clicked:

![image](https://user-images.githubusercontent.com/8763808/98618176-77d7fa00-22b5-11eb-8788-35256542f3a6.png)


Co-authored-by: Anatol Liu <axlui@anatols-mbp.lan>
2020-11-13 15:25:26 +00:00
Anatol Liu
b1b7727e04 add open Cargo.toml action 2020-11-12 17:48:07 -08:00
bors[bot]
ddccaecb79
Merge #6524
6524: Add support for loading rustc private crates r=matklad a=xldenis

This PR presents a solution to the problem of making`rustc_private` crates visible to `rust-analyzer`. 
Currently developers add dependencies to those crates behind a `cfg(NOT_A_TARGET)` target to prevent `cargo` from building them.
This solution is unsatisfactory since it requires modifying `Cargo.toml` and causes problems for collaboration or CI. 

The proposed solution suggested by @matklad is to allow users to give RA a path where the `rustc` sources could be found and then load that like a normal workspace. 

This PR implements this solution by adding a `rustcSource` configuration item and adding the cargo metadata to the crate graph if it is provided. 

------

I have no idea how this should be tested, or if this code is generally tested at all. I've locally run the extension with these changes and it correctly loads the relevant crates on a `rustc_private` project of mine. 

Co-authored-by: Xavier Denis <xldenis@gmail.com>
2020-11-12 17:55:32 +00:00
Xavier Denis
89ce6b6664 Address review comments 2020-11-12 18:49:22 +01:00
bors[bot]
cf73b6851b
Merge #6514
6514: Fix extract_struct_from_enum_variant not updating record references r=Veykril a=Veykril

Related to #6510

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-12 17:48:25 +00:00
Lukas Wirth
ccdcd52975 Add extra test to extract_struct_from_enum_variant 2020-11-12 18:44:37 +01:00
bors[bot]
13cf3b4886
Merge #6513
6513: Support qualified function calls in remove_unused_param r=Veykril a=Veykril

Also adds a test to check that it removes unused params across files.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-12 17:12:21 +00:00
Lukas Wirth
b6e2b28353 Support qualified function calls in remove_unused_param 2020-11-12 18:04:42 +01:00
Lukas Wirth
9454a9e536 Use Module::find_use_path_prefixed in extract_struct_from_enum_variant assist 2020-11-12 17:32:45 +01:00
Lukas Wirth
e24cc77cd1 Fix extract_struct_from_enum_variant not updating record references 2020-11-12 17:13:33 +01:00
Kirill Bulatov
07e633ef0a Remove the fixme 2020-11-12 13:52:24 +02:00
Kirill Bulatov
3481ea96bd Add a FIXME for non-unified inner attributes 2020-11-12 13:46:02 +02:00
Kirill Bulatov
335edf87bc Do not insert imports before inner comments 2020-11-12 13:46:02 +02:00
Aleksey Kladov
a27186636d Fix attachment of inner doc comments 2020-11-12 12:09:12 +01:00
Aleksey Kladov
81ac99f60a Simplify code 2020-11-12 11:45:18 +01:00
Aleksey Kladov
f73b874157 Update tests 2020-11-12 11:19:26 +01:00