Commit Graph

8739 Commits

Author SHA1 Message Date
Aleksey Kladov
018f826197 Support multi-file assist tests 2020-11-09 14:44:08 +01:00
Aleksey Kladov
e72cd4600e Fix debug for SyntaxRewriter 2020-11-09 14:09:49 +01:00
bors[bot]
73b08131df
Merge #6506
6506: Cleanup assists r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-11-09 12:28:57 +00:00
Aleksey Kladov
d31ce3b16c Use standard style for test code 2020-11-09 13:28:04 +01:00
Aleksey Kladov
3cecf78488 More consistent naming 2020-11-09 13:18:40 +01:00
Aleksey Kladov
29bf6bed9b More consistent naming 2020-11-09 13:07:18 +01:00
bors[bot]
2d3b0571bb
Merge #6465
6465: Support multiple file edits in AssistBuilder r=matklad a=Veykril

Fixes #6459

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-09 11:54:42 +00:00
bors[bot]
2f24714081
Merge #6501
6501: Remove text_edit_builder api from AssistBuilder r=matklad a=Veykril

Also fixes a small bug in `expand_glob_import` in regards to the very nice looking `something::{*}` import when only one item was used. Before it would duplicate the path and just append it, causing the following wrong import `something::something::UsedItem`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-09 11:40:08 +00:00
Lukas Wirth
4c03d98db4 Remove text_edit_builder api from AssistBuilder 2020-11-08 23:22:11 +01:00
Pavan Kumar Sunkara
ca3498bd84 Add some postfix snippet 2020-11-08 20:10:40 +01:00
bors[bot]
dac7060382
Merge #6476
6476: Add missing AssocItems in add_custom_impl assist r=matklad a=Veykril

```rust
use std::fmt;

#[derive(Debu<|>g)]
struct Foo {
    bar: String,
}
```
->
```rust
use std::fmt;

struct Foo {
    bar: String,
}

impl fmt::Debug for Foo {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        ${0:todo!()}
    }
}
```

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-07 18:21:11 +00:00
m-ysk
69ba62e6cd Minimize convert_integer_literal tests 2020-11-07 18:47:25 +09:00
Aleksey Kladov
5db789df9c Cleanup API 2020-11-06 22:52:42 +01:00
bors[bot]
7f12a1f225
Merge #6485
6485: Remove RAW literals r=matklad a=matklad

bors r+
🤖

closes https://github.com/rust-analyzer/rust-analyzer/issues/6308

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-11-06 21:39:02 +00:00
bors[bot]
cdddcaee85
Merge #6477
6477: Add infer_function_return_type assist r=matklad a=Veykril

This adds an assist to insert a functions return type if it hasn't been specified yet by inferring it from the functions tail expression. This assist only becomes active if the cursor is on the tail expression. See https://github.com/rust-analyzer/rust-analyzer/issues/6303#issuecomment-714657326

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-06 21:32:27 +00:00
Aleksey Kladov
6158304f8b Simplify 2020-11-06 22:30:58 +01:00
Aleksey Kladov
5ba4f949c2 Kill RAW_ literals
Syntactically, they are indistinguishable from non-raw versions, so it
doesn't make sense to separate then *at the syntax* level.
2020-11-06 22:23:14 +01:00
Lukas Wirth
186431e178 Adjust test-texts in infer_function_return_type 2020-11-06 21:51:15 +01:00
Lukas Wirth
4f0d02c276 Enable infer_function_return_type in return-type position 2020-11-06 21:49:03 +01:00
Aleksey Kladov
6725dcf847 Minor, cleanup style 2020-11-06 21:09:37 +01:00
bors[bot]
1faa9559fe
Merge #6480
6480: Support closure in change_return_type_to_result assist r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-06 19:41:13 +00:00
Lukas Wirth
e95a65ccaf Support closure in change_return_type_to_result assist 2020-11-06 20:40:03 +01:00
Aleksey Kladov
eb46033390 More orthogonal API 2020-11-06 19:09:01 +01:00
Aleksey Kladov
735aaa7b39 Move int parsing to IntNumber token 2020-11-06 18:54:01 +01:00
Aleksey Kladov
6bcc33e5b7 Better imports 2020-11-06 18:39:09 +01:00
Aleksey Kladov
3820b26a93 Generate token for ints and floats 2020-11-06 18:19:24 +01:00
Aleksey Kladov
85db47ac76 Ignore RUST_SRC_PATH if it is set to invalid value
Folks report a ton of hard-to-diagnose issues, the solution for which
is "unset RUST_SRC_PATH". Let's just ignore RUST_SRC_PATH when it
won't work anyway!
2020-11-06 11:30:57 +01:00
Lukas Wirth
c665884474 Wrap non-block expressions in closures with a block 2020-11-06 03:06:08 +01:00
Lukas Wirth
2e6e5d8f73 Ignore unit expressions in infer_function_return_type assist 2020-11-06 02:17:34 +01:00
Lukas Wirth
0a7c8512ff Support closures in infer_function_return_type assist 2020-11-06 02:15:13 +01:00
Lukas Wirth
a14df19d82 Add infer_function_return_type assist 2020-11-06 01:47:41 +01:00
Lukas Wirth
19443c1fa3 Add missing AssocItems in add_custom_impl assist 2020-11-05 23:41:46 +01:00
bors[bot]
4e8401af41
Merge #6467
6467: Don't stack overflow on circular modules r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-11-04 14:38:19 +00:00
Aleksey Kladov
2b108133ac Don't stack overflow on circular modules
closes #6453
2020-11-04 15:31:35 +01:00
bors[bot]
bd6eeffb2f
Merge #6456
6456: Support record variants in extract_struct_from_enum_variant r=matklad a=Veykril

As requested :)

This also prevents the assist from being disabled if a definition in the value namespace exists with the same name as our new struct since that won't cause a collision

#4468

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-04 12:37:29 +00:00
bors[bot]
99a8e59f68
Merge #6458
6458: Qualify trait impl created by add_custom_impl assist r=matklad a=Veykril

When we find at least one trait with the same name as the derive accessible from the current module we now generate a qualified path to that trait in the generated impl.
If we don't find any we just do what was done before and emit the trait name in the generated impl.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-04 12:30:09 +00:00
Lukas Wirth
db5c529781 Support multiple file edits in AssistBuilder 2020-11-04 12:34:33 +01:00
Lukas Wirth
4992b75e51 Qualify trait impl created by add_custom_impl assist 2020-11-03 23:41:35 +01:00
Lukas Wirth
6145234450 Support struct variants in extract_struct_from_enum_variant 2020-11-03 20:57:04 +01:00
bors[bot]
7c94f1cb5e
Merge #6454
6454: Fix overflow panic in convert_interger_literal assist r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-11-03 18:59:15 +00:00
Aleksey Kladov
9349353e04 Fix overflow panic in convert_interger_literal assist
This also seizes the opportunity to move integer literal parsing to
the syntax crate, were it logically belongs.

Note though that this is still done in an ad hoc manner -- we probably
should split kitchen sink ast::Literal into a separate APIs for
strings, ints, etc
2020-11-03 19:57:57 +01:00
Lukas Wirth
dc9842b64f only check type namespace in extract_struct_from_enum_variant for collisions 2020-11-03 19:55:14 +01:00
bors[bot]
060c8b2c96
Merge #6287
6287: Don't replace entire module and file nodes when inserting imports r=matklad a=Veykril

This change minifies the resulting diff of import insertions by inserting or replacing the produced use tree directly through an `action` return value instead replacing the entire container node. This action has to be applied by the caller now. This unfortunately pulls the `AssistBuilder` into scope of `insert_use` back again but I tried to at least keep it away from the `insert_use` fn itself.

I'm open to more/better ideas regarding this :)

Fixes #6196

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-03 17:34:59 +00:00
bors[bot]
5e62233277
Merge #6401
6401: Only show `self` ident when showing parameter self hints r=matklad a=Veykril

This just hints all self parameters with the `self` token, this is therefor equal to how all other parameters are displayed, but given the self param special in how its defined in a function signature it might make sense to keep the `&`/`&mut` parts as well as emitting those tokens for explict `Self` types that are taken by ref like `self: &Rc<Self>`?

Fixes #6400

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-11-03 16:43:26 +00:00
bors[bot]
8ad01d863b
Merge #6435
6435: Test Fixture ExplicitRoot + ModuleResolutionRelativePathOutsideRoot. r=matklad a=rickvanprim

Updates `module_resolution_relative_path_outside_root` test to check valid paths outside of the root, by moving the root to a subpath so that paths outside of it are possible.  If this would be more appropriate as a new test, or if the original check for an invalid path should be left, I'm happy to update.

Co-authored-by: James Leitch <rickvanprim@gmail.com>
2020-11-03 16:36:34 +00:00
bors[bot]
07c7f35eff
Merge #6430
6430: Move completions rendering into a separate module r=popzxc a=popzxc

This PR extracts rendering-related things from `Completions` structure to the new `render` module.

`render` module declares a `Render` structure (which is a generic renderer interface), `RenderContext` (interface for data/methods not required for completions generating, but required for rendering), and a bunch of smaller `*Render` structures which encapsulate logic behind rendering a certain item.

This is just a step in full separation direction, since the following this are still to be done:

- Move some data from `CompletionContext` to the `RenderContext`;
- Forbid any kind of rendering outside of `render` module;
- Extract score computing into a separate module.

This PR is already pretty big, so not to make it even harder to review I decided to split this process into several subsequent PRs.


Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
2020-11-03 07:54:45 +00:00
Igor Aleksanov
8efe43245b Remove intra-crate facade from completions 2020-11-03 10:36:01 +03:00
Igor Aleksanov
4d333ebb63 Get rid of do-er antipattern 2020-11-03 10:33:13 +03:00
Igor Aleksanov
caf0fa20a7 Provide only explicit constructor for RenderContext 2020-11-03 10:17:59 +03:00
Igor Aleksanov
2a214e15d3 Add doc-comments to the new files 2020-11-03 10:16:35 +03:00