Commit graph

9201 commits

Author SHA1 Message Date
bors[bot]
4a2f60cb7b
Merge #6964
6964: Add full pattern completions for Struct and Variant patterns r=matklad a=Veykril


Just gonna call it full pattern completion as pattern completion is already implemented in a sense by showing idents in pattern position. What this does is basically complete struct and variant patterns where applicable(function params, let statements and refutable pattern locations).

This does not replace just completing the corresponding idents of the structs and variants, instead two completions are shown for these, a completion for the ident itself and a completion for the pattern(if the pattern make sense to be used that is). I figured in some cases one would rather type out the pattern manually if it has a lot of fields but you only care about one since this completion would cause one more work in the end since you would have to delete all the extra matched fields again.

These completions are tagged as `CompletionKind::Snippet`, not sure if that is the right one here.
<details>
  <summary>some gifs</summary>

![dx2lxgzhj3](https://user-images.githubusercontent.com/3757771/102719967-6987ef80-42f1-11eb-8ae0-8aff53777860.gif)
![EP2E7sJLkB](https://user-images.githubusercontent.com/3757771/102785777-c7264580-439e-11eb-8a64-f142e19fb65b.gif)
![JMNHHWknr9](https://user-images.githubusercontent.com/3757771/102785796-d1e0da80-439e-11eb-934b-218ada31b51c.gif)
</details>

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-22 18:03:51 +00:00
Lukas Wirth
83121efcd5 Reduce some more code duplication 2020-12-22 19:00:38 +01:00
bors[bot]
b28322eed6
Merge #7005
7005: Improve extract_module_to_file assist r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-12-22 16:15:20 +00:00
Aleksey Kladov
41bc32368e Improve extract_module_to_file assist
* simplify code
* correctly handle crate roots and mod.rs files (nested inline modules
  are still mishandled)
* make sure that new text contains a trailing newline
2020-12-22 19:13:53 +03:00
bors[bot]
013739c73d
Merge #6993
6993: Clean up descriptions for settings r=matklad a=rherrmann

Use two consecutive newlines (`\n\n`) to actually continue text on a
new line.

Use proper markup to reference related settings.

Consistently format references to files, command line arguments, etc.
as `code`. Format mentions of UI elements in _italic_.

Fix typos, add missing full-stops, add missing default values.

Co-authored-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
2020-12-22 15:07:36 +00:00
Rüdiger Herrmann
9f070531a6 Clean up descriptions for settings
Use two consecutive newlines (`\n\n`) to actually continue text on a
new line.

Use proper markup to reference related settings.

Consistently format references to files, editor commands, command line
arguments, files, etc. as `code`.

Fix typos, add missing full-stops, add missing default values.
2020-12-22 14:51:17 +01:00
bors[bot]
b98ee075ee
Merge #6746
6746: Feature/add assist extract module to file r=matklad a=sasurau4

Fix #6522 

## Screenshot

<img src="https://user-images.githubusercontent.com/13580199/102748269-33a44300-43a5-11eb-9e37-f5fcb8e62f73.gif" width=600 />


## TODO

- [x] Remove all TODO comment
- [x] Pass the doc test



Co-authored-by: Daiki Ihara <sasurau4@gmail.com>
2020-12-22 10:04:24 +00:00
Rüdiger Herrmann
658ba9e29c Delete related whitespace when removing unused param
Include adjacent whitespace in the text edits to remove the
parameter declaration and its occurences in calling code.

https://github.com/rust-analyzer/rust-analyzer/issues/6663
2020-12-21 18:42:42 +01:00
bors[bot]
c8a73fe655
Merge #6982
6982: Remove parentheses when inverting `!(cond)` r=matklad a=Jesse-Bakker

Followup to #6894

When inverting a composite condition twice, the parentheses were left. This also removes those unnecessary parentheses when applying the invert-if assist.

Co-authored-by: Jesse Bakker <github@jessebakker.com>
2020-12-21 16:57:49 +00:00
Jesse Bakker
2e7abf8384 Remove parentheses when inverting !(cond) 2020-12-21 17:37:38 +01:00
Lukas Wirth
a4f34e2c8c Acquire original text range when searching for references 2020-12-21 17:28:47 +01:00
Jonas Schievink
ee8d7a7123 Filter out empty rustc spans 2020-12-21 15:38:27 +01:00
Lukas Wirth
2cd2947bf8 Insert snippet positions after fields names in record patterns 2020-12-21 15:10:27 +01:00
bors[bot]
9bb9fbab3a
Merge #6965
6965: Properly attach attributes to Param instead of parent ParamList r=matklad a=Veykril

Fixes #2783, fixes #2781

The problem with `let _a = [0,#[cfg(feature = "L")]0];` has already been fixed some time ago it seems:
<details>
  <summary>Syntax Tree for the const item</summary>

```
  LET_STMT@200..236
    LET_KW@200..203 "let"
    WHITESPACE@203..204 " "
    IDENT_PAT@204..206
      NAME@204..206
        IDENT@204..206 "_a"
    WHITESPACE@206..207 " "
    EQ@207..208 "="
    WHITESPACE@208..209 " "
    ARRAY_EXPR@209..235
      L_BRACK@209..210 "["
      LITERAL@210..211
        INT_NUMBER@210..211 "0"
      COMMA@211..212 ","
      LITERAL@212..234
        ATTR@212..233
          POUND@212..213 "#"
          L_BRACK@213..214 "["
          PATH@214..217
            PATH_SEGMENT@214..217
              NAME_REF@214..217
                IDENT@214..217 "cfg"
          TOKEN_TREE@217..232
            L_PAREN@217..218 "("
            IDENT@218..225 "feature"
            WHITESPACE@225..226 " "
            EQ@226..227 "="
            WHITESPACE@227..228 " "
            STRING@228..231 "\"L\""
            R_PAREN@231..232 ")"
          R_BRACK@232..233 "]"
        INT_NUMBER@233..234 "0"
      R_BRACK@234..235 "]"
    SEMICOLON@235..236 ";"
```
</details>

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-21 08:54:31 +00:00
bors[bot]
fa75e11eb6
Merge #6967
6967: Correctly parse legacy trait objects with leading ForType r=matklad a=Veykril

Fixes #1422

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-21 08:46:42 +00:00
Daiki Ihara
66fd262962 Fix assist test logic 2020-12-21 15:55:40 +09:00
Daiki Ihara
2b4a7848a8 Update test diagnostics in ide 2020-12-21 15:55:40 +09:00
Daiki Ihara
7a2eebde22 Add initial_contents field for CreateFile 2020-12-21 15:55:40 +09:00
Daiki Ihara
414576fb30 Add extract_module_to_file assist 2020-12-21 15:55:40 +09:00
Daiki Ihara
c8f5792a36 Add handling file_system_edit in test assists 2020-12-21 15:52:02 +09:00
Lukas Wirth
3ea4d43850 Properly parse legacy trait objects with leading ForType 2020-12-20 21:53:55 +01:00
Lukas Wirth
64caa027b8 Parse attributes in tuple expressions 2020-12-20 21:01:36 +01:00
Lukas Wirth
4be9ed675e Properly attach attributes to Param instead of parent ParamList 2020-12-20 20:30:18 +01:00
Lukas Wirth
33ecad4407 Create non-exhaustive patterns for non_exhaustive attributed items 2020-12-20 20:13:06 +01:00
Lukas Wirth
a5874a38cb Reduce code duplication in pattern completion 2020-12-20 19:20:55 +01:00
Lukas Wirth
2f6a24950a Emit snippets for struct pattern completion if enabled 2020-12-20 19:16:28 +01:00
Lukas Wirth
b184bfad7a Add completions for patterns 2020-12-20 18:19:23 +01:00
bors[bot]
8eea4c9d3b
Merge #6959
6959: Use pattern_single instead of pattern in mbe pat r=jonas-schievink a=edwin0cheng

Fix #6882

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-12-20 14:08:53 +00:00
bors[bot]
eefbae7ed4
Merge #6921
6921: Higher-ranked trait bounds for where clauses r=flodiebold a=Veykril

There is a slight problem with this which is also noted in a FIXME now but `LifetimeParameters` of these ForLifetime where clauses allocate the lifetimes in the corresponding arena as if they were lifetimes of the item itself and not just the clause they belong to. I wasn't entirely sure what I could do about this but given nothing really uses lifetimes like that currently I figured it might be fine? Open to suggestions for that problem.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-20 11:47:01 +00:00
Edwin Cheng
f942d10e80 Use pattern_single instead of pattern in mbe pat 2020-12-20 17:13:40 +08:00
Aleksey Kladov
f6ed16674c Align code_model name with ungrammar 2020-12-20 10:05:24 +03:00
bors[bot]
87886e8986
Merge #6929
6929: Handle $_ in mbe r=edwin0cheng a=lnicola

Fixes #6926

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-12-20 06:33:19 +00:00
Laurențiu Nicola
75a26f64ff mbe: treat _ as ident 2020-12-20 08:06:17 +02:00
bors[bot]
feff4f3a04
Merge #6953
6953: Add test_rename_bind_pat r=bjorn3 a=bjorn3

Fixes #2976

Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-12-19 18:56:50 +00:00
bjorn3
9fe85e1fdf Add test_rename_bind_pat 2020-12-19 19:55:44 +01:00
bors[bot]
052e7227b6
Merge #6946
6946: Better fuzzy heuristics r=matklad a=SomeoneToIgnore

Continuation of the https://github.com/rust-analyzer/rust-analyzer/pull/6922, mainly created for a test.

Turns out our current completions tests were sorting the completions by label, I had to remove that to test the order properly and update this order in a bunch of tests (ergo the changes)

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-12-19 18:43:20 +00:00
Kirill Bulatov
b45ec84739 Fewer allocations 2020-12-19 20:42:16 +02:00
Aleksey Kladov
9f6d76da77 Make sure that HighlightModifier::ALL is synchronized with enum 2020-12-19 18:47:36 +03:00
bors[bot]
df3652b663
Merge #6948
6948: Add API for mapping `Attr` back to its syntax node r=jonas-schievink a=jonas-schievink

This will be useful for emitting diagnostics pertaining to a specific attribute

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-19 14:25:33 +00:00
Aleksey Kladov
113688cef0 Clarify the meaning of no-op highlight tag 2020-12-19 17:16:05 +03:00
Jonas Schievink
218e88ab55 Add API for mapping Attr back to its syntax node 2020-12-19 15:15:02 +01:00
Aleksey Kladov
a13947abe6 Use more Rustic highlighting specifiers
*Method* works for OO languages, but in rust we can also have
associated constants & types, so let's move this to a modifier.
2020-12-19 17:10:47 +03:00
Kirill Bulatov
0415dcd832 Tidy up 2020-12-19 14:13:27 +02:00
Kirill Bulatov
8c292e3cc5 Keep the original completion order in tests 2020-12-19 13:18:40 +02:00
Kirill Bulatov
5fa078f26f Add a slightly better fuzzy search heuristics 2020-12-19 12:54:17 +02:00
Jonas Schievink
a2062d1892 Make RawAttrs crate-private
There should be no need to use this from outside
2020-12-19 02:44:22 +01:00
Jonas Schievink
81ccf37d3b Remove Attrs::merge
Only the `RawAttrs` version of this is in use
2020-12-19 02:43:00 +01:00
Jonas Schievink
0ac75f8982 Remove resolved FIXME 2020-12-19 02:32:31 +01:00
Jonas Schievink
aa00d1acd6 fixture -> ra_fixture 2020-12-19 01:12:41 +01:00
Jonas Schievink
d5edd0e928 Test paths to derive macros 2020-12-19 01:11:33 +01:00