Commit graph

694 commits

Author SHA1 Message Date
Aleksey Kladov
9c3acd3028 Cleanup 2020-05-20 01:23:05 +02:00
Aleksey Kladov
0146a95a39 Cleanup 2020-05-20 01:23:05 +02:00
Aleksey Kladov
80545e5d3a New assist: add turbo fish 2020-05-20 00:27:10 +02:00
Aleksey Kladov
2bf6b16a7f Server side of SnippetTextEdit 2020-05-19 20:28:27 +02:00
Aleksey Kladov
fa2e5299c3 Add snippet support for some assists 2020-05-19 20:28:27 +02:00
Aleksey Kladov
c847c079fd Add AssistConfig 2020-05-19 20:28:27 +02:00
bors[bot]
12d82687cd
Merge #4273
4273: Trigger add_vis assist on paths/record fields as well r=flodiebold a=TimoFreiberg

Resolves #4037.

- [x] Function defs
- [x] ADT defs
- [x] Enum variants
- [x] Consts
- [x] Statics
- [x] Traits
- [x] Type aliases
- [x] Modules
- [x] Record fields (using different implementation)
    - [x] struct fields
    - [x] enum variant fields
    -   union fields (`Semantics::resolve_record_field` seems to not work for union fields, so I think this can be handled in a future PR)
- [x] More tests? 
- [x] Improve test fixture code and documentation a bit (see [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/resolve_path.20between.20fixture.20files))

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-05-14 14:29:22 +00:00
bors[bot]
f1587ac263
Merge #4445
4445: Correctly fill default type parameters r=flodiebold a=montekki

Fixes #3877 

So, basically even if the parameters are omitted from the `impl` block, check the parameters in `trait` if they have a default type, and if they do go from `hir` to `ast::TypeArg`. I've added a helper for that but I am not sure that it's a proper way to go from `hir` to `ast` here.

Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com>
2020-05-14 11:20:42 +00:00
Fedor Sakharov
2dfbec149f
Fix formatting 2020-05-14 10:31:34 +03:00
Fedor Sakharov
7e9396c7eb
Change type_arg to type_ref func 2020-05-14 10:14:04 +03:00
Fedor Sakharov
a55ad20388
Use generic_defaults and display_source_code 2020-05-14 09:56:20 +03:00
Trevor Spiteri
2d0a949236 Use back ticks instead of single quotes around code 2020-05-14 01:06:07 +02:00
Fedor Sakharov
00f3b6c59a
Correctly fill default type parameters 2020-05-13 16:07:44 +03:00
bors[bot]
0063ad970d
Merge #4358
4358: add if let and while let postfix for Option and Result #4348 r=matklad a=bnjjj

close #4348 

I also added `while let` for iterator or stream it could be useful 

![iflet](https://user-images.githubusercontent.com/5719034/81278000-676c6b80-9055-11ea-87ad-6b8476dd983f.gif)


Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-11 18:08:26 +00:00
bors[bot]
a3dbd272e0
Merge #4406 #4410 #4411 #4417
4406: Update cargo-metadata r=matklad a=edwin0cheng

This PR update `cargo-metadata` to  0.10.0 and it also relax the` serde-derive` deps to 1.0 for tests in `proc-macro-srv`.

cc @robojumper 

r= @matklad  , I think you would have something to say related to https://github.com/serde-rs/json/issues/647#issue-593788429 ?





4410: Improve wording in comment r=matklad a=edwin0cheng



4411: do not remove then block when you unwrap else block #4361 r=matklad a=bnjjj

close #4361 

4417: Omit default types in HirDisplay SourceCode mode r=matklad a=TimoFreiberg

Closes #4390

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-05-10 17:37:07 +00:00
Timo Freiberg
cbbbd48325 Omit default types in HirDisplay SourceCode mode 2020-05-10 18:10:15 +02:00
Timo Freiberg
66db88d226 Trigger change_visibility assist when on an invisible struct field
Union fields apparently don't work :(
2020-05-10 16:51:12 +02:00
Benjamin Coenen
98a7bb2435 do not remove then block when you unwrap else block #4361
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-10 15:31:51 +02:00
Timo Freiberg
7568d07709 Trigger change_visibility assist when on a path to an invisible def 2020-05-10 13:54:04 +02:00
Benjamin Coenen
92b2230fef add if let and while let postfix for Option and Result
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-10 12:45:35 +02:00
bors[bot]
f1cb5b8a29
Merge #4392
4392: Add From should not move the cursor r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-09 14:22:06 +00:00
Aleksey Kladov
d9828a57fc Add From should not move the cursor 2020-05-09 16:21:10 +02:00
Aleksey Kladov
e201e7834d Ascribe more correct types 2020-05-09 15:57:53 +02:00
Aleksey Kladov
5c04d8544c unindent -> dedent 2020-05-09 14:48:43 +02:00
Aleksey Kladov
231fddab54 More fluent indent API 2020-05-09 14:40:11 +02:00
Aleksey Kladov
c6334285e3 Fix visibility 2020-05-09 13:59:25 +02:00
Timo Freiberg
64e6b8200b Use new HirDisplay variant in add_function assist 2020-05-08 17:14:45 +02:00
Aleksey Kladov
1e790ea314 Simplify 2020-05-07 17:32:01 +02:00
Aleksey Kladov
28fcff125a Nicer API 2020-05-07 17:29:23 +02:00
Aleksey Kladov
c6b81bc013 Rename AssitLabel -> Assist 2020-05-07 17:18:28 +02:00
Aleksey Kladov
4867968d22 Refactor assists API to be more convenient for adding new assists
It now duplicates completion API in its shape.
2020-05-07 16:27:54 +02:00
Benjamin Coenen
51c02ab84f add Ok wrapping
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-06 17:45:55 +02:00
Aleksey Kladov
020ca6695f Simplify 2020-05-06 16:39:11 +02:00
Aleksey Kladov
0970c3454b Rename 2020-05-06 16:10:35 +02:00
Aleksey Kladov
fdd4df97ba Use SourceChange for assists 2020-05-06 15:43:47 +02:00
Aleksey Kladov
1116c9a0e9 Fix TODO 2020-05-06 13:21:49 +02:00
Aleksey Kladov
233f01c9ba Move target to AssistLabel
Target is used for assists sorting, so we need it before we compute
the action.
2020-05-06 12:51:28 +02:00
Aleksey Kladov
eea431180e Regenerate 2020-05-06 10:21:35 +02:00
Aleksey Kladov
d308ff910b Merge doc_tests and tests 2020-05-06 10:18:12 +02:00
Aleksey Kladov
25e6bbde01 Merge assits::test_helpers and tests 2020-05-06 10:16:55 +02:00
Aleksey Kladov
ca9e0f5fe9 Fixup tests 2020-05-05 23:48:26 +02:00
Aleksey Kladov
4a6fa8f0df Rename AtomTextEdit -> Indel 2020-05-05 23:15:49 +02:00
Aleksey Kladov
381cbc6088 Minor cleanups 2020-05-05 22:14:01 +02:00
Aleksey Kladov
df00da15c4 Fix compilation 2020-05-05 20:45:44 +02:00
Aleksey Kladov
aee22c73c3 Move group_label where it belongs 2020-05-05 20:42:52 +02:00
Aleksey Kladov
6c2414430a use GroupLabel for type safety 2020-05-05 20:34:45 +02:00
Aleksey Kladov
d5b9282ede Minor rename 2020-05-05 20:33:10 +02:00
Aleksey Kladov
13c078db9c Flip Assist::new arguments 2020-05-05 20:30:33 +02:00
Edwin Cheng
92665358cd Rename ImplItem to AssocItem 2020-05-05 23:56:10 +08:00
bors[bot]
f68e099777
Merge #4265
4265: Make `change_visibility` assist work for tuple struct fields r=matklad a=Jesse-Bakker

Fixes #4206 

Co-authored-by: Jesse Bakker <git@jessebakker.com>
2020-05-05 14:42:33 +00:00
Aleksey Kladov
d7450222a9 Simplify 2020-05-04 14:55:24 +02:00
Aleksey Kladov
802617ccc2 Simplify 2020-05-04 14:16:10 +02:00
Edwin Cheng
2034002413 Support auto-import in macro 2020-05-03 03:24:55 +08:00
Jesse Bakker
b5c330bf5a Make change_visibility assist work for tuple struct field visibility 2020-05-02 18:25:38 +02:00
Benjamin Coenen
6d5f3922f7 Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-02 12:31:11 +02:00
Benjamin Coenen
0b40876b99 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-05-02 12:25:04 +02:00
Benjamin Coenen
eea21738ab Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-02 12:20:39 +02:00
Aleksey Kladov
b73dbbfbf2 Add missing members generates indented blocks 2020-05-02 11:53:07 +02:00
Aleksey Kladov
4f2134cc33 Introduce EffectExpr 2020-05-02 11:21:39 +02:00
Benjamin Coenen
df7899e47a Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-01 16:41:29 +02:00
Benjamin Coenen
dc34162450 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-05-01 16:26:30 +02:00
Edwin Cheng
44f5e2048c Remove lower_path from AssistCtx to Semantic 2020-05-01 20:05:12 +08:00
Edwin Cheng
bdcf6f5658 Introduce LowerCtx for path lowering 2020-05-01 20:01:17 +08:00
Benjamin Coenen
bbe22640b8 Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-29 14:53:47 +02:00
Aleksey Kladov
b4dd475257 More principled approach for finding From trait 2020-04-29 14:51:44 +02:00
Benjamin Coenen
76733f0cd4 Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-29 14:08:30 +02:00
Aleksey Kladov
7c3c289dab Use specific pattern when translating if-let-else to match
We *probably* should actually use the same machinery here, as we do
for fill match arms, but just special-casing options and results seems
to be a good first step.
2020-04-29 11:59:11 +02:00
Aleksey Kladov
73bef854ab Move shared assist code to utils 2020-04-29 10:38:51 +02:00
Aleksey Kladov
63a462f37c Switch to TryFrom 2020-04-25 11:59:18 +02:00
Aleksey Kladov
8843588fca Convert tests to text-size 2020-04-25 11:59:18 +02:00
Aleksey Kladov
b1d5817dd1 Convert code to text-size 2020-04-25 11:59:18 +02:00
Timo Freiberg
f2f882bc44 Add pub(crate) to functions generated in other module 2020-04-21 23:04:44 +02:00
Timo Freiberg
74780a15f6 Jump to sourceChanges in other files 2020-04-21 23:04:44 +02:00
Timo Freiberg
ba8faf3efc Add target file information to AssistAction 2020-04-21 23:04:44 +02:00
Timo Freiberg
317fc650d5 Make add_function generate functions in other modules via qualified path 2020-04-21 23:04:44 +02:00
Kirill Bulatov
ce06a6b422 Do not add default and closure types in 'add explicit type' assist 2020-04-21 22:56:40 +03:00
Aleksey Kladov
8a04372fec Fix panic in split_imports assist
The fix is admittedly quit literally just papering over.

Long-term, I see two more principled approaches:

* we switch to a fully tree-based impl, without parse . to_string
  step; with this approach, there shouldn't be any panics. The results
  might be nonsensical, but so was the original input.

* we preserve the invariant that re-parsing constructed node is an
  identity, and make all the `make_xxx` method return an `Option`.

closes #4044
2020-04-20 16:34:01 +02:00
Jeremy Kolb
d7f3d858ad Some clippy fixes 2020-04-19 15:15:49 -04:00
Timo Freiberg
1231418f31 Change add_function assist to use todo!() 2020-04-13 22:17:06 +02:00
IceSentry
ed0eedb1dd Fix PR 2020-04-13 13:59:30 -04:00
IceSentry
2e279ca031 Generalize test and clean up imports 2020-04-12 21:34:01 -04:00
IceSentry
abdf725c55 Fix double comma when merge imports on second line
This fixes the a bug when merging imports from the second line when it already has a comma it would previously insert a comma.

There's probably a better way to check for a COMMA. 

This also ends up with a weird indentation, but rust-fmt can easily deal with it so I'm not sure how to resolve that.

Closes #3832
2020-04-12 21:29:14 -04:00
Laurențiu Nicola
e809328c12 Remove more unnecessary braces 2020-04-12 18:20:03 +03:00
Aleksey Kladov
5e5eb6a108 Align grammar for record patterns and literals
The grammar now looks like this

   [name_ref :] pat
2020-04-12 00:00:15 +02:00
bors[bot]
fd06fe7b13
Merge #3925
3925: Implement assist "Reorder field names" r=matklad a=geoffreycopin

This PR implements the "Reorder record fields" assist as discussed in issue #3821 .

Adding a `RecordFieldPat` variant to the `Pat` enum seemed like the easiest way to handle the `RecordPat` children as a single sequence of elements, maybe there is a better way ?

Co-authored-by: Geoffrey Copin <copin.geoffrey@gmail.com>
2020-04-11 18:40:46 +00:00
Geoffrey Copin
d9089245fe Generate doc 2020-04-11 20:32:58 +02:00
Geoffrey Copin
d362fcfc1c Fix doc tests 2020-04-11 20:32:48 +02:00
Geoffrey Copin
25a0ce2e9e Add documentation comment 2020-04-11 19:39:10 +02:00
Geoffrey Copin
270bcfdfc2 Avoid adding a RecordFieldPat variant to the Pat enum 2020-04-11 19:30:41 +02:00
Geoffrey Copin
21443f1b48 Remove Option unwraping 2020-04-11 12:58:20 +02:00
Chris Hopman
af04d45d32 Change missing impl assist to use todo!() instead of unimplemented()
todo!() "Indicates unfinished code" (https://doc.rust-lang.org/std/macro.todo.html)

Rust documentation provides further clarification:

> The difference between unimplemented! and todo! is that while todo!
> conveys an intent of implementing the functionality later and the
> message is "not yet implemented", unimplemented! makes no such claims.

todo!() seems more appropriate for assists that insert missing impls.
2020-04-10 13:56:12 -07:00
Aleksey Kladov
5c5bde47fb Rename some tokens 2020-04-10 17:07:09 +02:00
Aleksey Kladov
8d71a6bf0c Scale token generation back 2020-04-10 16:10:28 +02:00
Aleksey Kladov
779f06ed77 Convert more tokens 2020-04-10 16:10:28 +02:00
Aleksey Kladov
460c8bbdec Curley tokens 2020-04-10 16:10:28 +02:00
Aleksey Kladov
c8b4c36f81 Semicolon token 2020-04-10 16:10:28 +02:00
Geoffrey Copin
730a927c5e Implement assist "Reorder field names" 2020-04-10 00:57:03 +02:00
Aleksey Kladov
30084a56a5 Simpler acessors for keywords 2020-04-09 23:42:01 +02:00
Aleksey Kladov
2bfb65db93 Be consistent about token accesors 2020-04-09 18:48:13 +02:00
Aleksey Kladov
e6d22187a6 Add _token suffix to token accessors
I think this makes is more clear which things are : AstNode and which
are : AstToken
2020-04-09 18:25:36 +02:00
Aleksey Kladov
689661c959 Scale back to only two traits 2020-04-09 13:00:09 +02:00
Luca Barbieri
60f4d7bd8c Provide more complete AST accessors to support usage in rustc 2020-04-09 11:50:37 +02:00
Aleksey Kladov
dd2e8e86a9 Fix add missing items assist order
closes #3904
2020-04-09 10:00:27 +02:00
Aleksey Kladov
bf569f8b29 Check for eprintln on CI 2020-04-06 17:00:18 +02:00
bors[bot]
77462bba62
Merge #3746
3746: Add create_function assist r=flodiebold a=TimoFreiberg

The function part of #3639, creating methods will come later

- [X] Function arguments
     - [X] Function call arguments
     - [x] Method call arguments
     - [x] Literal arguments
     - [x] Variable reference arguments
- [X] Migrate to `ast::make` API
    Done, but there are some ugly spots.

Issues to handle in another PR:
- function reference arguments: Their type isn't printed properly right now.
    The "insert explicit type" assist has the same issue and this is probably a relatively rare usecase.

- generating proper names for all kinds of argument expressions (if, loop, ...?)
    Without this, it's totally possible for the assist to generate invalid argument names.
    I think the assist it's already helpful enough to be shipped as it is, at least for me the main usecase involves passing in named references.
    Besides, the Rust tooling ecosystem is immature enough that some janky behaviour in a new assist probably won't scare anyone off.

- select the generated placeholder body so it's a bit easier to overwrite it

- create method (`self.foo<|>(..)` or `some_foo.foo<|>(..)`) instead of create_function.
    The main difference would be finding (or creating) the impl block and inserting the `self` argument correctly

- more specific default arg names for literals.
    So far, every generated argument whose name can't be taken from the call site is called `arg` (with a number suffix if necessary).

- creating functions in another module of the same crate.
    E.g. when typing `some_mod::foo<|>(...)` when in `lib.rs`, I'd want to have `foo` generated in `some_mod.rs` and jump there.
    Issues: the mod could exist in `some_mod.rs`, in `lib.rs` as `mod some_mod`, or inside another mod but be imported via `use other_mod::some_mod`.

- refer to arguments of the generated function with a qualified path if the types aren't imported yet
    (alternative: run autoimport. i think starting with a qualified path is cleaner and there's already an assist to replace a qualified path with an import and an unqualified path)

- add type arguments of the arguments to the generated function

- Autocomplete functions with information from unresolved calls (see https://github.com/rust-analyzer/rust-analyzer/pull/3746#issuecomment-605281323)
    Issues: see https://github.com/rust-analyzer/rust-analyzer/pull/3746#issuecomment-605282542. The unresolved call could be anywhere. But just offering this autocompletion for unresolved calls in the same module would already be cool.

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-04-03 08:23:44 +00:00
bors[bot]
2cee8531c5
Merge #3814
3814: Add impl From for enum variant assist r=flodiebold a=mattyhall

Basically adds a From impl for tuple enum variants with one field. It was recommended to me on the zulip to maybe try using the trait solver, but I had trouble with that as, although it could resolve the trait impl, it couldn't resolve the variable unambiguously in real use. I'm also unsure of how it would work if there were already multiple From impls to resolve - I can't see a way we could get more than one solution to my query.

Fixes #3766

Co-authored-by: Matthew Hall <matthew@quickbeam.me.uk>
2020-04-03 07:46:46 +00:00
Matthew Hall
6a2127be28 Cleanup checking for existing impls in impl From assist
Use the trait solver to check if there's an existing implementation of
From<type_in_enum_variant> for the enum.
2020-04-02 18:42:30 +01:00
Matthew Hall
1fee60181f Add impl From for enum variant assist
Basically adds a From impl for tuple enum variants with one field. Added
to cover the fairly common case of implementing your own Error that can
be created from another one, although other use cases exist.
2020-04-01 22:26:41 +01:00
Timo Freiberg
10667753c7 Use ast::make API in add_function assist 2020-04-01 23:06:14 +02:00
Timo Freiberg
e5fc42cbc1 Add create_function assist 2020-04-01 23:06:14 +02:00
Aleksey Kladov
2fe6e23138 When adding match arm, don't let the floating comma 2020-03-31 14:52:20 +02:00
Aleksey Kladov
0cfa9eb445 Use IntoIter 2020-03-30 12:28:22 +02:00
Matthew Hall
77bb9a56f1 Remove "TODO" in comment in test 2020-03-28 21:24:26 +00:00
Matthew Hall
ecc2615ba2 Append new match arms rather than replacing all of them
This means we now retain comments when filling in match arms.
2020-03-28 20:58:46 +00:00
Aleksey Kladov
b764c38436 Start stdx
This crate will hold everything to small to be worth publishing
2020-03-28 11:01:25 +01:00
Piotr Szpetkowski
f016d8b900
Fix merge-imports assist for wildcard imports 2020-03-27 17:28:25 +01:00
Aleksey Kladov
dc311b10f3 Fix assist description 2020-03-27 13:23:19 +01:00
bors[bot]
a4901fdcfd
Merge #3742
3742: Replace if with if-let r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-27 11:21:57 +00:00
Aleksey Kladov
91e482b46d Replace if with if-let 2020-03-27 12:15:46 +01:00
bors[bot]
f9cf86475c
Merge #3741
3741: More general ctor for ifs r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-27 10:38:31 +00:00
Aleksey Kladov
cbb53cf55c More general ctor for ifs 2020-03-27 11:38:00 +01:00
bors[bot]
20c110e57f
Merge #3732
3732: Assist: replace unwrap with match r=matklad a=unrealhoang

attempt on #3669

Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
2020-03-26 15:38:03 +00:00
Aleksey Kladov
db34abeb85 Get rid of ItemOrMacro 2020-03-26 16:10:01 +01:00
Unreal Hoang
d9df0f43ac
Assist: replace unwrap with match 2020-03-27 00:08:12 +09:00
Aleksey Kladov
72c6fc3ff0 Fix add visibility false-positive 2020-03-25 15:55:57 +01:00
bors[bot]
9690f6bc43
Merge #3708
3708: Generalise syntax rewriting infrastructure to allow removal of nodes r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-24 16:15:08 +00:00
Aleksey Kladov
062f6e3bbe Generalise syntax rewriting infrastructure to allow removal of nodes 2020-03-24 17:14:33 +01:00
bors[bot]
7c2cc85806
Merge #3705
3705: Align naming r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-24 11:56:43 +00:00
Aleksey Kladov
9bf2cd609c Align naming 2020-03-24 12:56:07 +01:00
bors[bot]
6ef64622af
Merge #3700
3700: fill match arms with empty block rather than unit tuple r=matklad a=JoshMcguigan

As requested by @Veetaha in #3689 and #3687, this modifies the fill match arms assist to create match arms as an empty block `{}` rather than a unit tuple `()`.

In one test I left one of the pre-existing match arms as a unit tuple, and added a body to another match arm, to demonstrate that the contents of existing match arms persist. 

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-03-24 11:48:32 +00:00
Kirill Bulatov
dd3b64124b Add a test 2020-03-24 10:43:24 +02:00
Kirill Bulatov
944f28fe5b Use more generic public api 2020-03-24 10:43:22 +02:00
Kirill Bulatov
d221ff4f9e Auto import macros 2020-03-24 10:43:00 +02:00
Josh Mcguigan
7ba934fe58 fill match arms with empty block rather than unit tuple 2020-03-23 19:23:30 -07:00
Josh Mcguigan
df58ab8963 update itertools version to 0.9.0 2020-03-23 16:22:46 -07:00
Aleksey Kladov
3bd119a4c1 Add a test 2020-03-23 20:57:42 +01:00
Josh Mcguigan
bc48c9d511 review comments 2020-03-23 05:19:09 -07:00
Josh Mcguigan
2afccbe477 implement fill match arm assist for tuple of enums 2020-03-22 23:28:25 -07:00
Josh Mcguigan
c3702a6b71 disable invert if assist for if-let to fix #3281 2020-03-21 06:40:18 -07:00
Steffen Lyngbaek
b5ba9c3e3a Address nits and suggestions.
Simplify the logic a lot by removing the check for a placeholder pat.
This means the auto-fill no longer returns a compile-able value.
2020-03-19 11:49:01 -07:00
Steffen Lyngbaek
5f8f8a38a2 Don't show assist if all arms are present 2020-03-19 11:47:33 -07:00
Steffen Lyngbaek
6087c01460 'Fill match arms' should work with existing match arms
Addresses #3039

This essentially adds missing match arms. The algorithm for this
can get complicated rather quickly so bail in certain conditions
and rely on a PlaceholderPat.

The algorighm works as such:
- Iterate through the Enum Def Variants
- Attempt to see if the variant already exists as a match arm
- If yes, skip the enum variant. If no, include it.
- If it becomes complicated, rather than exhaustively deal with every
  branch, mark it as a "partial match" and simply include the
  placeholder.

  Conditions for "complication":
  - The match arm contains a match guard
  - Any kind of nested destrucuring

Order the resulting merged match branches as such:
1. Provided match arms
2. Missing enum variant branch arms
3. End with Placeholder if required

- Add extra tests
2020-03-19 11:47:33 -07:00
Aleksey Kladov
7e2bca4ec3 Cleanup imports 2020-03-19 12:36:33 +01:00
Aleksey Kladov
0c55c06944 Merge nested use trees 2020-03-19 12:18:59 +01:00
Aleksey Kladov
ef3bf906c4 Generalize 2020-03-19 11:38:26 +01:00
Aleksey Kladov
0bf903411c Use match_ast 2020-03-18 20:51:47 +01:00
Aleksey Kladov
3f6dc20d3c Merge imports assist
Work towards #2220
2020-03-18 19:34:47 +01:00
Aleksey Kladov
3c88ef76d6 Reduce visibility 2020-03-18 16:48:45 +01:00
Aleksey Kladov
6eb05c4a14 Simplify 2020-03-13 18:02:04 +01:00
Aleksey Kladov
687bec117c Don't use generic DB where a concrete one will do 2020-03-13 17:58:49 +01:00
CAD97
88c944f96b Remove some TextUnit->usize escapees 2020-03-12 22:33:27 -04:00
Aleksey Kladov
ea0c124219 Rerail split_import API onto AST
The code is more verbose and less efficient now, but should be
reusable in add_import context as well
2020-03-06 14:08:43 +01:00
Kirill Bulatov
0ff8c55246 Unfold groups with single assists into plain assists 2020-03-06 00:17:26 +02:00
Aleksey Kladov
f57682c0b3 Remove old find refs infra 2020-03-04 14:25:22 +01:00
Aleksey Kladov
cf0ececb7a Highlight assist tests 2020-03-03 17:03:46 +01:00
Aleksey Kladov
1cca6b2a3d Fix applicability of inline local 2020-03-03 16:56:42 +01:00
Aleksey Kladov
503ffb4893 One more assert 2020-03-02 13:59:35 +01:00
Aleksey Kladov
a1e1869554 Rename ast::ImplBlock -> ast::ImplDef 2020-02-29 21:33:15 +01:00
Aleksey Kladov
f316e074d2 Add a FIXME 2020-02-29 21:23:16 +01:00
Aleksey Kladov
9abcab1669 Fix typo 2020-02-29 13:51:23 +01:00
Aleksey Kladov
5f8b37563e Cleanup editing API 2020-02-29 13:51:23 +01:00
Aleksey Kladov
ca713e462b More orthogonal API for building paths 2020-02-29 11:55:36 +01:00
Aleksey Kladov
067cb928f0 Simplify 2020-02-28 22:43:13 +01:00
Aleksey Kladov
ff42008679 Move insert_use util to utils 2020-02-28 21:53:20 +01:00
Douglas Campos
34a7e4fbaf introduce const visibility assist 2020-02-28 01:15:17 +00:00
Aleksey Kladov
e74484e133 Refactor string literals 2020-02-27 17:19:53 +01:00
Shotaro Yamada
33de107ed9 Remove unused dependencies 2020-02-27 14:04:13 +09:00
Aleksey Kladov
c3a4c4429d Refactor primary IDE API
This introduces the new type -- Semantics.
Semantics maps SyntaxNodes to various semantic info, such as type,
name resolution or macro expansions.

To do so, Semantics maintains a HashMap which maps every node it saw
to the file from which the node originated. This is enough to get all
the necessary hir bits just from syntax.
2020-02-26 12:55:50 +01:00
Aleksey Kladov
52fd19621c Remove code duplication in tests 2020-02-26 11:25:07 +01:00
Aleksey Kladov
136151515a Replace generic with a concrete type 2020-02-25 12:43:08 +01:00
Aleksey Kladov
312a779610 Add remove_mut assist 2020-02-19 12:44:54 +01:00
Shotaro Yamada
d06733efeb Cleanup 2020-02-19 13:36:59 +09:00
Kirill Bulatov
f6816c253b Update versions 2020-02-18 16:12:40 +02:00
Kirill Bulatov
eceaf94f19 More manual clippy fixes 2020-02-18 16:12:37 +02:00
Kirill Bulatov
b8ddcb0652 Run cargo +nightly fix --clippy -Z unstable-options 2020-02-18 16:03:08 +02:00
bors[bot]
8d8d542dfa
Merge #3108
3108: Magic Completion for `impl Trait for` Associated Items r=matklad a=kdelorey

# Summary
This PR adds a set of magic completions to auto complete associated trait items (functions/consts/types). 

![Associated Trait Impl](https://user-images.githubusercontent.com/2295721/74493144-d8f1af00-4e96-11ea-93a4-82725bf89646.gif)

## Notes
Since the assist and completion share the same logic when figuring out the associated items that are missing, a shared utility was created in the `ra_assists::utils` module.

Resolves #1046 

As this is my first PR to the rust-analyzer project, I'm new to the codebase, feedback welcomed!

Co-authored-by: Kevin DeLorey <2295721+kdelorey@users.noreply.github.com>
2020-02-17 09:34:08 +00:00
Kirill Bulatov
e4f4cd77a0 Do not collect all traits 2020-02-12 23:27:19 +02:00
Kirill Bulatov
e008b08054 Support associated consts 2020-02-12 22:38:19 +02:00
Kirill Bulatov
3ccf8b746a Also consider associated constants 2020-02-12 18:52:29 +02:00
Kirill Bulatov
afc1d18ff3 Fix post-rebase issues 2020-02-12 17:18:42 +02:00
Kirill Bulatov
acf5f43639 Refactor the code 2020-02-12 17:18:42 +02:00
Kirill Bulatov
07058cbf9f Adjust the assist group name 2020-02-12 17:18:42 +02:00
Kirill Bulatov
24f7028d3f Add profiling 2020-02-12 17:18:42 +02:00
Kirill Bulatov
d5c3808545 Support trait method call autoimports 2020-02-12 17:18:42 +02:00
Kirill Bulatov
8f959f20ee Trait location draft 2020-02-12 17:18:42 +02:00
Kirill Bulatov
9b6db7bbd4 Refactor path for imports extraction 2020-02-12 17:18:42 +02:00
Kirill Bulatov
2b9b16cb45 Add method tests 2020-02-12 17:18:41 +02:00
Kirill Bulatov
24ab3e80ca Resolve methods and functions better 2020-02-12 17:18:41 +02:00
Kirill Bulatov
848c576266 Introduce AttrKind 2020-02-12 16:44:52 +02:00
Kirill Bulatov
1596b31698 Do not add imports before inner attributes 2020-02-12 16:21:55 +02:00
Kevin DeLorey
47d314e856 Fixing minor suggestions and added module level documentation. 2020-02-11 10:04:30 -06:00
Kevin DeLorey
e664cd73e3 Removed doc comments entirely from the changes. 2020-02-11 09:48:26 -06:00
Kevin DeLorey
3aaf46afa1 Formatted changes. 2020-02-11 09:40:08 -06:00
Kevin DeLorey
b4429a9d64 Fixed warning generated after refactoring. 2020-02-11 07:10:06 -06:00
Kevin DeLorey
ca43bb3ff7 Updated the add_missing_impl_members to use the shared utility. 2020-02-11 06:57:26 -06:00
Kevin DeLorey
f0f242cb4f Adjusted the hashset buckets to lump functions/consts together as their names must be unique. 2020-02-10 21:09:04 -06:00
Matthew Jasper
8c8d0bb34f Add or- and parenthesized-patterns 2020-02-09 22:06:15 +00:00
Kevin DeLorey
d85abd77b9 Added a utility function that can be used to determine the missing impl items. 2020-02-09 12:24:59 -06:00
Kirill Bulatov
d39d401612 Fix rebase leftovers 2020-02-09 17:25:51 +02:00
Kirill Bulatov
48abcaaabe Do not import anything if first segment of FQN resolves 2020-02-09 17:22:59 +02:00