zhoufan
8690cfb868
Change the style of the code
2021-09-22 06:32:23 +08:00
zhoufan
7912d3a4b3
Generate function assist creates bad param names for const/static item args
2021-09-22 00:15:57 +08:00
Dawer
1d94e234d5
Handle tuple indexing expression in argument position in Generate function
2021-09-16 23:45:41 +05:00
Dawer
4dc33140a3
Imrove fn name computation in Generate function
2021-09-16 21:03:37 +05:00
Lukas Wirth
a044175412
Simplify
2021-09-13 18:50:19 +02:00
Dawer
a6c650edf6
fix: use placeholder as default type in Generate function
.
2021-09-04 14:24:54 +05:00
mahdi-frms
cf5f1c102c
add static method generation assist
2021-08-23 12:14:23 +04:30
mahdi-frms
c1edbfbacc
better assist label
2021-08-22 12:31:16 +04:30
mahdi-frms
50923ad741
func gen: seperate generation form position(3)
2021-08-21 19:13:14 +04:30
mahdi-frms
1ac9400100
func gen: seperate generation form position(2)
2021-08-21 17:31:37 +04:30
mahdi-frms
87439b1d6a
func gen: seperate generation form position(1)
2021-08-21 13:29:15 +04:30
mahdi-frms
e2c233a42b
simplify
2021-08-21 11:52:07 +04:30
Lukas Wirth
37ad9cb2a5
Don't use non cache syntaxnodes in generate_function for lookups
2021-08-14 17:51:11 +02:00
bors[bot]
43af7920af
Merge #9871
...
9871: Jump to generated func r=mahdi-frms a=rylev
Worked on this with `@yoshuawuyts.`
We thought we ran into an issue with the `generate_function` assist where the code was not being generated in a certain situations. However, it wasn't actually a bug just a very confusing implementation where the cursor is not moved to the newly generated function. This happened when the return type was successfully inferred (and not unit). The function would be generated, but selection would not be changed.
This can be very confusing: If the function is generated somewhat far from where the assist is being invoked, the user never sees that the code was generated (nor are they given the chance to actually implement the function body).
This PR makes it so that the cursor is _always_ moved to somewhere in the newly generated function. In addition, if we can infer unit as the type, then we do not still generate `-> ()` as the return type. Instead, we simply omit the return type.
This means the selection will move to either one of two places:
* A generated `-> ()` return type when we cannot successfully infer the return type.
* The `todo!()` body when we can successfully infer the return type.
Co-authored-by: Ryan Levick <me@ryanlevick.com>
2021-08-13 11:19:16 +00:00
Ryan Levick
1cc43ab7f4
Add documentation on how whether a generated return type should be focused or not
2021-08-13 11:46:08 +02:00
bors[bot]
baf1494374
Merge #9807
...
9807: Implicit `Sized` bounds r=iDawer a=iDawer
This should close #8984
`hir_ty`:
- Type parameters, associated types and `impl Trait` are `Sized` by deafault except `Self` in a trait.
- Implicit `Sized` bound is added to end of predicate list. It does not check if such bound is present already. Also it does not track the bound is implicit.
- Allowed ambiguous unsize coercion if Chalk returns definite guidance.
- Allowed ambiguous autoderef if Chalk returns definite guidance.
`hir_def`:
- `ItemTree` pretty printing shows `?Sized` bounds.
`HirDisplay`:
- `impl Trait` with weird bounds rendered correctly.
- `Sized`/`?Sized` bounds are not shown if they are default.
### Perf
`./target/rust-analyzer-baseline_8a843113 -q analysis-stats --memory-usage .`
```
Database loaded: 1.63s, 287minstr, 91mb
crates: 38, mods: 741, decls: 15914, fns: 11835
Item Collection: 26.80s, 73ginstr, 338mb
exprs: 318994, ??ty: 398 (0%), ?ty: 435 (0%), !ty: 174
Inference: 50.28s, 116ginstr, 516mb
Total: 77.08s, 189ginstr, 855mb
```
`./target/rust-analyzer-sized-fixed_ambig_coercion-de074fe6 -q analysis-stats --memory-usage .`
```
Database loaded: 1.63s, 287minstr, 91mb
crates: 38, mods: 741, decls: 15914, fns: 11835
Item Collection: 26.95s, 73ginstr, 338mb
exprs: 318994, ??ty: 398 (0%), ?ty: 435 (0%), !ty: 166
Inference: 96.39s, 234ginstr, 543mb
Total: 123.33s, 307ginstr, 881mb
```
Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-08-12 17:55:29 +00:00
Dawer
6c366ade00
Clean up
2021-08-12 21:20:28 +05:00
Ryan Levick
a5c46e5a88
Factor out return type handling for both function and method
2021-08-12 16:05:32 +02:00
Ryan Levick
0834e05045
Always fall back to focusing on generated function body
2021-08-12 14:56:39 +02:00
Ryan Levick
e8de34b6b3
Use term on label for generating method impl
2021-08-12 14:01:15 +02:00
mahdi-frms
05a789c09d
refactor method generation assist
2021-08-09 21:06:24 +04:30
mahdi-frms
9217f6dcf7
method gen assist usable in all of expression
2021-08-09 21:06:24 +04:30
mahdi-frms
311dc5b04f
add test for method generation assist
2021-08-09 21:06:24 +04:30
mahdi-frms
3c31f3831d
One assist for function and method generation
2021-08-09 21:06:24 +04:30
mahdi-frms
02f5b5e0e2
method generation assist: store owned ast nodes
2021-08-09 21:06:24 +04:30
mahdi-frms
6240b2dae2
generate method adds pub keyword
2021-08-09 21:06:24 +04:30
mahdi-frms
d38f36e5af
generate method assist uses existing impl blocks
2021-08-09 21:06:24 +04:30
mahdi-frms
99570f32d8
refactor: use single next space
2021-08-09 21:06:24 +04:30
mahdi-frms
b777e498fe
refactor: use single fn_args
2021-08-09 21:06:24 +04:30
mahdi-frms
9ca73528ee
generate method assist
2021-08-09 21:06:24 +04:30
Dawer
0f6621fbfa
Fix tests.
2021-08-04 20:20:14 +05:00
Lukas Wirth
b96f1adf5c
Give TypeInfo fields and methods more appropriate names
2021-08-03 17:28:51 +02:00
Lukas Wirth
8afa2722b2
Revise TypeInfo::ty usage
2021-08-03 17:24:43 +02:00
Lukas Wirth
25ff7171c4
Introduce TypeInfo
2021-08-03 16:41:53 +02:00
mahdi-frms
a5edf6de79
generate function assist favors deref cmpt types
2021-07-31 16:34:09 +04:30
vi_mi
57f119b5fa
fix: Adding async keyword when await is present in generate_function assist
2021-07-09 20:04:55 +05:30
Lukas Wirth
688398febc
feat: Implement inline_method
assist
2021-07-03 01:33:34 +02:00
Aleksey Kladov
4584868a7a
internal: don't #[ignore] tests
...
See the style.md for motivation
2021-06-15 16:37:58 +03:00
Maan2003
c9b4ac5be4
clippy::redudant_borrow
2021-06-13 09:24:16 +05:30
Aleksey Kladov
4f3c0adc5a
internal: introduce ast::make::ext
module with common shortcuts
...
There's a tension between keeping a well-architectured minimal
orthogonal set of constructs, and providing convenience functions.
Relieve this pressure by introducing an dedicated module for
non-orthogonal shortcuts.
This is inspired by the django.shortcuts module which serves a similar
purpose architecturally.
2021-05-09 19:55:43 +03:00
Josh Mcguigan
b275e60905
generate_function assist don't render snippet if ret type inferred
2021-03-08 14:38:36 -08:00
Josh Mcguigan
d645b81b28
generate_function assist infer return type
2021-03-06 14:28:54 -08:00
Josh Mcguigan
e29b53f1e6
generate function assist convert arg names to lower snake case
2021-03-06 09:53:21 -08:00
Chetan Khilosiya
e4756cb4f6
7526: Rename crate assists to ide_assists.
2021-02-23 00:59:16 +05:30