Commit Graph

267 Commits

Author SHA1 Message Date
bors[bot]
77f0c92fd8
Merge #8794
8794: Give MergeBehaviour variants better names r=Veykril a=Veykril

I never really liked the variant names I gave this enum from the beginning and then I found out about rustfmt's `imports_granularity` config:

> imports_granularity
>
> How imports should be grouped into use statements. Imports will be merged or split to the configured level of granularity.
> 
>     Default value: Preserve
>     Possible values: Preserve, Crate, Module, Item
>     Stable: No

I personally prefer using `crate` over `full` and `module` over last, they seem more descriptive. Keeping these similar between tooling also seems like a good plus point to me.

We might even wanna take over the entire enum at some point if we have a `format/cleanup imports` assists in the future which would probably want to also have the `preserve` and `item` options.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-10 20:10:59 +00:00
Lukas Wirth
6a8d47e7f0 Give MergeBehaviour variants better names 2021-05-10 21:14:59 +02:00
mixio
aa9002c68a
Corrected 2 typos on line 83 2021-05-10 20:05:32 +02:00
Lukas Wirth
174f043c8d Add = to pattern recovery 2021-05-08 23:14:08 +02:00
Kirill Bulatov
607d8a2f61 Small macro fix 2021-05-06 20:12:30 +03:00
Aleksey Kladov
6a16ec52aa internal: use API stabilized in 1.52 2021-05-06 20:12:15 +03:00
Edwin Cheng
1fb20e3231 Simplify 2021-05-06 22:39:51 +08:00
Jesse Bakker
10254b5d95 Fix: Do not overwrite comments and attrs in trait impl completion 2021-05-06 16:16:38 +02:00
Lukas Tobias Wirth
3f796fea9f simplify 2021-05-05 22:55:12 +02:00
Lukas Tobias Wirth
d26fb188c1 Add some cov marks for qualified_path completion 2021-05-04 22:35:37 +02:00
Lukas Tobias Wirth
8b94bf7b2d Complete enum variants through type aliases 2021-05-04 21:04:19 +02:00
Lukas Tobias Wirth
121bd5c533 Make CompletionContext expected_type smarter 2021-05-03 21:34:34 +02:00
Brandon
43c79a35a8 Fix feature description inconsistency 2021-04-30 19:47:41 -07:00
Aleksey Kladov
cb3ef552e8 internal: normalize name
All def types in hir are unsubstituted
2021-04-30 11:52:31 +03:00
Lukas Wirth
050c69c19d Split out merge_imports module from helpers::insert_use 2021-04-24 13:31:43 +02:00
Lukas Wirth
b290cd5782 Add cov_marks to insert_use tests 2021-04-20 19:34:43 +02:00
Lukas Wirth
fa20a5064b Remove SyntaxRewriter usage in insert_use in favor of ted 2021-04-20 02:09:12 +02:00
Kirill Bulatov
739edfd5cf Exclude inherent traits from flyimports 2021-04-16 11:13:17 +03:00
Kirill Bulatov
1c75d64c70 Do not show flyimports in trait or impl declarations 2021-04-15 11:51:43 +03:00
Lukas Wirth
8fa3011908 Use CompletionTextEdit::InsertAndReplace if supported by the client 2021-04-08 15:21:27 +02:00
memoryruins
e1e6e3b925 Fix typo 2021-04-06 19:38:59 -04:00
memoryruins
c201cce527 Do not import on the fly during fields of record literal syntax 2021-04-06 18:40:06 -04:00
Aleksey Kladov
1f00191de2 internal: document hypothetical completion problem 2021-04-05 16:27:45 +03:00
Lukas Wirth
444f6caaba Resolve associated types 2021-04-01 21:31:25 +02:00
bors[bot]
55d7d71590
Merge #8267
8267: Adding gifs and screenshots for features in manual r=matklad a=MozarellaMan

For #6539

This includes most of gif or screenshot examples of most items in the "Features" header. With the exceptions of:

- **On Typing Assists** - couldn't get it to work for a demo, I'm probably missing something?
- **Structural search and replace** - looked to be already a visual example of the feature
- **Workspace symbol** - wasn't sure how best to show this, all of the examples maybe? Also wasn't sure of the best code example to show it off
- **Semantic Syntax Highlighting** - seemed obvious enough to not need a screenshot, but I could easily add this

All the gifs/pngs are hosted in this [comment](https://github.com/rust-analyzer/rust-analyzer/issues/6539#issuecomment-809574840). Please let me know if any of them aren't suitable (and why) and I'll improve it! Or if you don't like the theme/font

Co-authored-by: Ayomide Bamidele <48062697+MozarellaMan@users.noreply.github.com>
2021-03-31 10:01:56 +00:00
Ayomide Bamidele
276022682b Gifs and screenshots for features in manual 2021-03-31 00:08:10 +01:00
Lukas Wirth
c2a63b97a8 Rename target_ty to self_ty 2021-03-29 17:47:47 +02:00
Josh Mcguigan
0e31ae2cef completion relevance distinguish between exact type match and could unify 2021-03-26 09:18:18 -07:00
Josh Mcguigan
957939292e completion relevance consider if types can be unified 2021-03-26 09:11:50 -07:00
Lukas Wirth
7c4eb66c1a Merge hir::MacroDef::is_* into hir::MacroDef::kind 2021-03-23 11:32:14 +01:00
Josh Mcguigan
18c3fb2df5 add unit test to demonstrate struct fields/methods do not get ref match completions 2021-03-22 20:34:02 -07:00
Josh Mcguigan
8cd94900f7 implement a temporary workaround for #8058 2021-03-21 17:30:56 -07:00
bors[bot]
1ae20d2b89
Merge #8132
8132: Add `'` to trigger_characters, allowing more direct lifetime completions r=Veykril a=Veykril

Fixes having to type a character after `'` to complete lifetimes and labels

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-21 15:57:14 +00:00
Matthias Krüger
ae7e55c1dd clippy::complexity simplifications related to Iterators 2021-03-21 13:13:34 +01:00
Lukas Wirth
f3c7499be5 Add ' to trigger_characters, allowing more direct lifetime completions 2021-03-21 11:05:04 +01:00
Kirill Bulatov
eaa4fcbbde Less reallocations 2021-03-21 11:45:37 +02:00
Kirill Bulatov
ec731e19df Use smart case in flyimport items lookup 2021-03-21 11:45:37 +02:00
bors[bot]
09412d85fc
Merge #8123
8123: Do not display unqualified assoc item completions r=SomeoneToIgnore a=SomeoneToIgnore

Part of https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/autoimport.20weirdness

Removes all flyimport completions for any unqualified associated type, effectively reverting https://github.com/rust-analyzer/rust-analyzer/pull/8095 
I've explained the reasoning in the corresponding FIXME and open to discussions.
As an alternative way, we could add yet another parameter in the method that's used by the `qualify_path` and enable it for the qualify assists only.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2021-03-21 09:37:08 +00:00
Lukas Wirth
64957acb5f Fix incorrect scoping in while expressions 2021-03-21 01:28:42 +01:00
Lukas Wirth
62a4677dbc Add label completion 2021-03-21 01:02:22 +01:00
bors[bot]
090e013161
Merge #8124
8124: Add basic lifetime completion r=Veykril a=Veykril

This adds basic lifetime completion, basic in the sense that the completions for lifetimes are only shown when the user enters `'` followed by a char. Showing them when nothing is entered is kind of a pain, as we would want them to only show up where they are useful which in turn requires a lot of tree traversal and cursor position checking to verify whether the position is valid for a lifetime. This in itself doesn't seem too bad as usually when you know you want to write a lifetime putting `'` to ask for lifetime completions seems fine.

~~I'll take a look at whether its possible to lift the restriction of having to put a char after `'`.~~ This actually already works so I guess this is the clients responsibility, in which case VSCode doesn't like it.

![TYH9gIlyVo](https://user-images.githubusercontent.com/3757771/111886437-c9b02f80-89cd-11eb-9bee-340f1536b0de.gif)


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-20 22:32:25 +00:00
Lukas Wirth
3c000c6364 Add basic lifetime completion 2021-03-20 23:25:07 +01:00
Lukas Wirth
38048c35d8 Don't use an untyped String for ActiveParam tracking 2021-03-20 23:22:09 +01:00
Kirill Bulatov
56a7d246d5 Disable unqualified assoc items completion for now 2021-03-20 23:08:44 +02:00
Kirill Bulatov
879432452d Docs 2021-03-20 22:55:34 +02:00
Kirill Bulatov
a631108d2d Do not query item search by name eagerly 2021-03-20 22:33:54 +02:00
Kirill Bulatov
81961dc035 Do not propose assoc items without qualifiers 2021-03-20 22:18:43 +02:00
Jonas Schievink
c05a1a6e37 Store an AstId for procedural macros 2021-03-18 16:11:18 +01:00
Lukas Wirth
ec824a92d0 Better handling of block doc comments 2021-03-17 14:48:57 +01:00
Matthias Krüger
048dad8c2e don't clone types that are copy (clippy::clone_on_copy) 2021-03-17 01:56:31 +01:00
Matthias Krüger
966c23f529 avoid converting types into themselves via .into() (clippy::useless-conversion)
example: let x: String = String::from("hello world").into();
2021-03-17 01:27:56 +01:00
bors[bot]
b4ed3e1551
Merge #8052
8052: minor style fixes per feedback on #8036 r=JoshMcguigan a=JoshMcguigan

cc @matklad  - this PR addresses your comments in #8036. 

changelog fixup #8036

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2021-03-16 13:56:53 +00:00
Josh Mcguigan
81f51fcd65 minor style fixes per feedback on #8036 2021-03-16 06:54:17 -07:00
bors[bot]
da5328a01b
Merge #8051
8051: Fix more unused wariable warnings r=lnicola a=lnicola

bors r+

changelog skip

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-03-16 13:35:26 +00:00
Laurențiu Nicola
a7cf976c63 Fix more unused wariable warnings 2021-03-16 15:34:19 +02:00
bors[bot]
c49b5b7468
Merge #7498
7498: Clone for update r=matklad a=matklad

rowan counterpart https://github.com/rust-analyzer/rowan/pull/93

#6857

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-16 13:14:48 +00:00
Aleksey Kladov
f5a81ec468 Upgrade rowan
Notably, new rowan comes with support for mutable syntax trees.
2021-03-16 16:10:49 +03:00
bors[bot]
1a82af3527
Merge #7900 #8000
7900: show function params in completion detail r=matklad a=JoshMcguigan

This resolves #7842 by updating the detail for function completions from `-> T` to `fn(T, U) -> V`. I added an expicit unit test for this, `ide_completion::render::fn_detail_includes_args_and_return_type`, which passes.

Lots of other unit tests fail (~60 of them) due to this change, although I believe the failures are purely cosmetic (they were testing the exact format of this output). I'm happy to go update those tests, but before I do that I'd like to make sure this is in fact the format we want for the detail?

edit - I realized `UPDATE_EXPECT=1 cargo test` automatically updates `expect!` tests. Big 👍 to whoever worked on that! So I'll go ahead and update all these tests soon. But I still would like to confirm `fn(T, U) -> V` is the desired content in the `detail` field. 

8000: Use hir formatter for hover text r=matklad a=oxalica

Fix #2765 , (should) fix #4665

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
Co-authored-by: oxalica <oxalicc@pm.me>
2021-03-16 08:05:24 +00:00
Josh Mcguigan
405bbb3aa4 completions: centralize calculation of relevance and ref matches 2021-03-15 19:40:42 -07:00
bors[bot]
ce3125165a
Merge #8035
8035: unqualfied_path completions aren't responsible for variant pattern completions r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-15 16:51:53 +00:00
Lukas Wirth
4a0ab832f3 unqualfied_path completions aren't responsible for pattern completions 2021-03-15 17:23:08 +01:00
Josh Mcguigan
db8bcf132c implement function completion scoring 2021-03-15 08:35:28 -07:00
Laurențiu Nicola
e941cb0238 Drop non-working mark 2021-03-15 16:05:16 +02:00
Laurențiu Nicola
88cee24c6c Enable thread-local coverage marks 2021-03-15 16:02:50 +02:00
Josh Mcguigan
67d59aeb7c remove expected_name_and_type method on completion context in favor of using fields added in #8008 2021-03-15 06:25:39 -07:00
Josh Mcguigan
d91151c3b1 update algorithm for determining expected type of completion 2021-03-15 05:38:19 -07:00
Matthias Krüger
cad617bba0 some clippy::performance fixes
use vec![] instead of Vec::new() +  push()
avoid redundant clones
use chars instead of &str for single char patterns in ends_with() and starts_with()
allocate some Vecs with capacity to avoid unneccessary resizing
2021-03-15 10:19:59 +01:00
Josh Mcguigan
ba924d04b3 increase completion relevance for items in local scope 2021-03-14 08:00:47 -07:00
ivan770
8a9ebe62a1
Skip ref_match on same types, remove sorting in tests 2021-03-14 12:25:37 +02:00
ivan770
661cc7f0c8
Added both references and original matches to tests 2021-03-13 18:31:52 +02:00
ivan770
32ad929b82
Fix incorrect DerefMut test reference type 2021-03-13 17:28:05 +02:00
ivan770
3bc5d81a33
Make relevance tests display references, suggest derefs only when needed 2021-03-13 17:25:41 +02:00
ivan770
75cb441fba
Simplify call site and deref completion test 2021-03-13 15:32:37 +02:00
ivan770
d064ed5f63
Count derefs as matched types if possible 2021-03-13 14:34:11 +02:00
Josh Mcguigan
d5f0f58e63 add params_display and ty_display 2021-03-12 13:46:40 -08:00
Josh Mcguigan
53bb46fa85 show function params in completion detail 2021-03-12 13:36:13 -08:00
Josh Mcguigan
acbe297fbd update relevance score u8 -> u32 2021-03-12 06:16:04 -08:00
Josh Mcguigan
10fb065b14 add relevance score test 2021-03-12 06:16:04 -08:00
Josh Mcguigan
9ee3914c61 remove unused CompletionScore enum 2021-03-12 06:16:04 -08:00
Josh Mcguigan
3679821eea add completion relevance score 2021-03-12 06:16:01 -08:00
Aleksey Kladov
7e217a42e1 Unify naming 2021-03-12 12:22:45 +03:00
yonip23
99c4a41cd1 use references in CompletionItem's builder 2021-03-11 17:46:41 +02:00
Aleksey Kladov
842d8ad9c8 Compilation speed 2021-03-09 22:30:58 +03:00
Aleksey Kladov
b2764a6641 Future proof completion scores 2021-03-09 20:24:09 +03:00
Aleksey Kladov
12fe301a0c Cleanup auto-ref in completion 2021-03-09 18:06:08 +03:00
Aleksey Kladov
abc0ed36bd Cleanup 2021-03-09 17:44:27 +03:00
Aleksey Kladov
444d67ae18 Cleanup 2021-03-09 17:42:05 +03:00
bors[bot]
21913d0fdb
Merge #7873 #7933
7873: Consider unresolved qualifiers during flyimport r=matklad a=SomeoneToIgnore

Closes https://github.com/rust-analyzer/rust-analyzer/issues/7679

Takes unresolved qualifiers into account, providing better completions (or none, if the path is resolved or do not match).

Does not handle cases when both path qualifier and some trait has to be imported: there are many extra issues with those (such as overlapping imports, for instance) that will require large diffs to address.

Also does not do a fuzzy search on qualifier, that requires some adjustments in `import_map` for better queries and changes to the default replace range which also seems relatively big to include here.

![qualifier_completion](https://user-images.githubusercontent.com/2690773/110040808-0af8dc00-7d4c-11eb-83db-65af94e843bb.gif)


7933: Improve compilation speed r=matklad a=matklad

bors r+
🤖

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-09 11:58:48 +00:00
Duong Do Minh Chau
73590f0f0b
Fix format 2021-03-09 16:38:07 +07:00
Duong Do Minh Chau
a068cedee0
Add trailing commas 2021-03-09 16:00:06 +07:00
Duong Do Minh Chau
ea835fc800
Update the test to match the change 2021-03-09 15:48:53 +07:00
Duong Do Minh Chau
5fc91058ff
Add completion to turn x.err into Err(x) 2021-03-09 15:36:41 +07:00
Kirill Bulatov
dccbb38d2e Less lifetines: derive SemanticsScope in place 2021-03-08 23:59:20 +02:00
Kirill Bulatov
db61d4ea13 Rebase leftovers 2021-03-08 23:59:20 +02:00
Kirill Bulatov
c56b59d377 Cleanup 2021-03-08 23:59:20 +02:00
Kirill Bulatov
84c575a212 Restrict fuzzy qualifiers for now 2021-03-08 23:59:20 +02:00
Kirill Bulatov
6ca6f101c1 Test for fuzzy unresolved path maatch 2021-03-08 23:59:20 +02:00
Kirill Bulatov
24a5d3b19d Fix the completion labels and tests 2021-03-08 23:59:20 +02:00
Kirill Bulatov
33c83e72b9 Work towards better import labels 2021-03-08 23:59:20 +02:00
Kirill Bulatov
821e8369d9 Update the docs 2021-03-08 23:59:20 +02:00
Kirill Bulatov
e214c3a6bd Simplify 2021-03-08 23:59:20 +02:00
Kirill Bulatov
e74c55bb4a Refactor the import location 2021-03-08 23:59:20 +02:00
Kirill Bulatov
89d410cef5 Do not propose already imported imports 2021-03-08 23:59:20 +02:00
Kirill Bulatov
9482353fa8 Properly handle turbofishes in qualifiers 2021-03-08 23:59:20 +02:00
Kirill Bulatov
d386481fac Fix some tests 2021-03-08 23:59:20 +02:00
Kirill Bulatov
582cee2cdf Return more data about located imports 2021-03-08 23:59:18 +02:00
Kirill Bulatov
309421c117 Draft the qualifier import resolution 2021-03-08 23:58:48 +02:00
Kirill Bulatov
005bc49d74 Test and initial refactoring 2021-03-08 23:58:32 +02:00
Laurențiu Nicola
fc9eed4836 Use upstream cov-mark 2021-03-08 22:19:44 +02:00
asv
96fc01a30b Make group imports configurable 2021-03-07 10:15:17 +02:00
Lukas Wirth
02e9440e23 Complete while let 2021-03-03 23:04:11 +01:00
Lukas Wirth
1914b7723f Don't complete super unless its valid in paths 2021-03-03 21:58:48 +01:00
Laurențiu Nicola
0fb01367f5 Format generated features manually instead of relying on rustfmt 2021-02-27 16:25:06 +02:00
Jonas Schievink
cf456d72db Add test 2021-02-23 14:54:01 +01:00
Benjamin Coenen
cf32dbd9bf feat(completion): add doc(hidden) completion for attributes
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-02-20 15:16:05 +01:00
Kirill Bulatov
4fe5786c0c Consider import prefix config settings during flyimports 2021-02-20 13:53:50 +02:00
Aleksey Kladov
3db64a400c rename completion -> ide_completion
We don't have completion-related PRs in flight, so lets do it
2021-02-17 17:53:31 +03:00