Commit graph

767 commits

Author SHA1 Message Date
bors[bot]
3f550d2e38
Merge #11000
11000: fix: insert whitespaces into assoc items for assist when macro generated r=Veykril a=Veykril

This is obviously only a temporary hack which still produces ugly looking items, but as long as the syntax is valid one can at least have rustfmt fix the formatting again. 
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6588
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-13 15:43:12 +00:00
Lukas Wirth
749eeef3e7 fix: insert whitespaces into assoc items for assist when macro generated 2021-12-13 16:35:32 +01:00
Lukas Wirth
328419534d Move ws insert rendering for macro expansion into ide_db 2021-12-13 15:55:13 +01:00
bors[bot]
40159150aa
Merge #10951
10951: feat: assist to generate documentation templates r=Veykril a=numero-744

Closes #10878, #1915 and #4767

Full description is in #10878, better read [the tests](https://github.com/rust-analyzer/rust-analyzer/pull/10951/files#diff-7a64e2efb66b2625443340fcbc96d531baff12c17cc0aaf51885ea94f67de254R424) to understand what this feature does.

- [x] There is one remaining thing about non-`pub` functions, what do you think about it?
- [x] In this PR [empty examples are generated](https://github.com/rust-analyzer/rust-analyzer/pull/10951/files#diff-7a64e2efb66b2625443340fcbc96d531baff12c17cc0aaf51885ea94f67de254R99) for `trait` functions, but maybe no examples should be provided at all.
- [x] If there is already a documentation, add another one with a separator ([currently done](https://github.com/rust-analyzer/rust-analyzer/pull/10951/files#diff-7a64e2efb66b2625443340fcbc96d531baff12c17cc0aaf51885ea94f67de254R74)) or simply disable this assist?
- [x] I will check once more that the generated examples are correct (ie. they are easy to fill before that they are built and tested)

Comments appreciated 😄 

Co-authored-by: Côme ALLART <come.allart@etu.emse.fr>
2021-12-11 22:58:49 +00:00
Côme ALLART
0e89f2f346 feat: remove should_panic example generation 2021-12-11 22:46:54 +01:00
Côme ALLART
9e53db274b refactor: use hir to test if a value is returned 2021-12-11 20:52:14 +01:00
Côme ALLART
80a68685db refactor: use Itertools::intersperse 2021-12-11 20:41:23 +01:00
Côme ALLART
7266fdb5a4 refactor: use hir to compare returned and self types 2021-12-11 20:33:08 +01:00
bors[bot]
48cd733c9e
Merge #10956 #10986
10956: minor: Bump deps r=Veykril a=lnicola

bors r+

10986: fix: Fix lint completions not working for unclosed attributes r=Veykril a=Veykril

Fixes #10682
Uses keywords and nested `TokenTree`s as a heuristic to figure out when to stop parsing in case the attribute is unclosed which should work pretty well as attributes are usually followed by either of those.
bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-11 14:58:07 +00:00
bors[bot]
d97f2f6b9b
Merge #10976
10976: fix: Show case-insensitive exact matches instead of fuzzy flyimport for short paths r=Veykril a=Veykril

And raise the fuzzy trigger from 2 to 3 chars. This way we keep the ability of flyimporting short names like `Rc`.
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6917
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-11 13:50:55 +00:00
Lukas Wirth
143a30aa51 Show case-insensitive exact matches instead of fuzzy flyimport for short paths 2021-12-11 14:47:11 +01:00
Lukas Wirth
c81aa68afe Don't show trait flyimports for impl trait and placeholders 2021-12-10 19:18:21 +01:00
Côme ALLART
9c0f9d02bf feat: trait fn: add panicking example only if default panicks 2021-12-10 15:53:43 +01:00
Côme ALLART
f5e0998402 refactor: use hir to check if fn in trait/impl 2021-12-10 15:16:04 +01:00
Côme ALLART
c3d151ada6 fix: check correctly if function is exported 2021-12-10 14:42:31 +01:00
Côme ALLART
dc4e4c7daa fix: add mod files in path in generated examples 2021-12-07 23:34:53 +01:00
Côme ALLART
220137f1cf fix: disable assist for documented functions 2021-12-07 18:02:18 +01:00
Laurențiu Nicola
9a624abc84 Bump deps 2021-12-07 13:15:14 +02:00
Côme ALLART
3a82548c5e fix: reduce assist scope: pub fn's in pub modules 2021-12-06 23:33:24 +01:00
Côme ALLART
d55d3b63cb fix: format assist doc for sourcegen_assists_docs 2021-12-06 19:04:44 +01:00
Côme ALLART
998b91af9c feat: assist to generate documentation templates 2021-12-06 18:32:25 +01:00
rainy-me
79b4e67b4f fix: defer condition construction 2021-12-04 04:50:06 +09:00
rainy-me
fb90bf9cad feat: handle while let to loop 2021-12-04 03:19:19 +09:00
Skyler Rain Ross
5b59a5eca8
refactor(assist/add_return_type): avoid threading needs_whitespace 2021-12-02 10:46:07 -08:00
Skyler Rain Ross
e031267602
fix: add return type works when there's missing whitespace 2021-12-02 09:28:18 -08:00
rainy-me
0bb08ccb8f fix: derive path handling 2021-11-25 00:21:29 +09:00
bors[bot]
b69eee6487
Merge #10809
10809: fix: don't discard formatting of `use` lines r=Veykril a=iDawer

Use mutable syntax trees in `merge_imports`, `split_imports`. This tries to resolve #9013. But I haven't much managed to simplify code of merging.

Also resolve #9361. It reuses a use tree under the cursor so that comments+indentation are preserved. Merged trees are just appended to the end.

This touches bunch of tests. I removed the sorting of use trees as it needs a proper implementation that takes into account comments and line wrapping. I think it is rustfmt's job or at least until we get a close implementation.

Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
2021-11-22 14:29:24 +00:00
rainy-me
ebffaa4274 fix: check inline left of binary_expression 2021-11-21 01:48:04 +09:00
iDawer
601413df8f Use mutable syntax trees in merge_imports, split_imports 2021-11-19 20:02:27 +05:00
bors[bot]
6c7be6cd84
Merge #10734
10734: fix: add generic parameters in convert to manual impl assist r=Veykril a=TheDoctor314

Fixes #10041.

Co-authored-by: TheDoctor314 <64731940+TheDoctor314@users.noreply.github.com>
2021-11-16 11:27:11 +00:00
Lukas Wirth
92f7db447c minor: Lift out FxIndex{Map/Set} types into ide_db 2021-11-16 12:15:47 +01:00
TheDoctor314
58a24de7d8 Fix impl_def_from_trait
Revert "Fix `impl_trait` function to emit correct ast"

This reverts commit 55a4813151.

Fix `impl_def_from_trait`

It now generates the correct `ast::Impl` using
`generate_trait_impl_text` and parses it to form the right node (copied
from the private fn 'make::ast_from_text').
2021-11-15 22:28:22 +05:30
rainy-me
1f3da38d94 adjust test case and stop deleting newline 2021-11-14 20:56:28 +09:00
rainy-me
c9949c040c add missing match arms end of last arm 2021-11-14 02:32:10 +09:00
TheDoctor314
55a4813151 Fix impl_trait function to emit correct ast
`impl_trait` code copied from `generate_impl_text_inner` to properly
handle the bounds for the generic parameters.
2021-11-11 14:16:59 +05:30
TheDoctor314
e0e8d877c0 Add generic bounds in test 2021-11-11 14:16:29 +05:30
Lukas Wirth
7776aad166 internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
TheDoctor314
05b368f065 Add generic parameters for manual impl assist
The `impl_trait` function takes an optional `GenericParamList` to create
the trait impl.
2021-11-10 12:53:48 +05:30
TheDoctor314
4f93fa1213 Add failing tests for generic struct 2021-11-10 12:53:48 +05:30
bors[bot]
c96481e25f
Merge #10691
10691: minor: Use array `into_iter` in more places r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-11-04 05:52:05 +00:00
Laurențiu Nicola
139bf9b4e1 Use array into_iter in more places 2021-11-04 07:51:20 +02:00
Lukas Wirth
96db0d8bdd Add Semantics::original_ast_node for upmapping nodes out of macro files 2021-11-03 21:12:36 +01:00
Lukas Wirth
7fdbdc4ab2 Enable auto-import and qualify-path in derive attributes 2021-10-28 18:40:38 +02:00
Lukas Wirth
3018ffd85e Refactor ide handling for paths in derive inputs 2021-10-28 16:47:19 +02:00
bors[bot]
210a1d5ece
Merge #10629
10629: Add assist for replacing turbofish with explicit type. r=Veykril a=terrynsun

Converts `::<_>` to an explicit type assignment.

```
let args = args.collect::<Vec<String>>();
```
->
```
let args: Vec<String> = args.collect();
```

Closes #10285

Co-authored-by: Terry Sun <terrynsun@gmail.com>
2021-10-27 21:40:28 +00:00
Terry Sun
d800a1bc93 fixup! rustfmt 2021-10-27 10:58:31 -07:00
Terry Sun
3bbd61d674 fixup! delay to_string() until assist is called 2021-10-27 10:46:25 -07:00
Terry Sun
6abdbdd0c9 fixup! narrow range; method calls; check for only one type 2021-10-26 17:50:25 -07:00
Lukas Wirth
a2365ea18a fix: fix extract_variable not working on macro_call 2021-10-25 21:46:44 +02:00
Terry Sun
324d7d33e8 Add assist for replacing turbofish with explicit type.
Converts `::<_>` to an explicit type assignment.

```
let args = args.collect::<Vec<String>>();
```
->
```
let args: Vec<String> = args.collect();
```

Closes #10285
2021-10-24 17:38:45 -07:00