Commit graph

1045 commits

Author SHA1 Message Date
Chayim Refael Friedman
ce323627c5 Support the new CoercePointee derive 2025-01-04 18:35:53 +02:00
yanglsh
60c3fb12d3 Fix replace-if-let-with-match generates non-exhausive match 2024-12-31 07:40:45 -07:00
yanglsh
fc847323f9 Add test cases for #10583 2024-12-30 12:07:35 -07:00
Lukas Wirth
2e13684be1
Merge pull request #18790 from ChayimFriedman2/proper-make
internal: Create a quoting mechanism instead of textual AST make
2024-12-30 11:39:29 +00:00
Lukas Wirth
bd083d0cd9
Merge pull request #18794 from 1hakusai1/fix_fill_match_arm_in_tokio_main
Fix bug of "fill match arm" action in tokio::main macro
2024-12-30 11:30:32 +00:00
1hakusai1
9451d64315 Fix bug of "fill match arm" action in tokio::main macro
https://github.com/rust-lang/rust-analyzer/issues/18027
2024-12-30 20:06:17 +09:00
roife
f8c04166dc fix: avoid generating colliding names in extract_variable 2024-12-30 15:30:05 +08:00
Chayim Refael Friedman
791a63255b Move some more AST makers to the quote macro
And implement addons as necessary.

There are many more makers to be moved, and I'm not completely satisfied with this (due to the ease of making a mistake in the AST structure, and slightly less but also because of the need to remember whitespaces), but this is already enough to see how this will look like.
2024-12-30 05:46:06 +02:00
Lukas Wirth
e30ce42671
Merge pull request #18707 from ChayimFriedman2/subst
feat: Show substitution where hovering over generic things
2024-12-24 14:16:16 +00:00
Chayim Refael Friedman
b5486ffc42 Show substitution where hovering over generic things
There are few things to note in the implementation:

First, this is a best-effort implementation. Mainly, type aliases may not be shown (due to their eager nature it's harder) and partial pathes (aka. hovering over `Struct` in `Struct::method`) are not supported at all.

Second, we only need to show substitutions in expression and pattern position, because in type position all generic arguments always have to be written explicitly.
2024-12-20 11:30:19 +02:00
Lukas Wirth
0be03285f9 fix: Reduce applicability of unnecessary_async assist 2024-12-20 08:41:46 +01:00
Lukas Wirth
ada5f2059c fix: Fix path qualified auto-importing completions not working with re-exports
Prior to this commit we used to generate import paths, then zipped them with the existing qualifier to check if they agree on the path to import.
This is brittle when re-exports come into play causing items to have multiple applicable paths that refer to them.
This commit instead rewrites this logic by generating the import path for the qualifier, verifying that the rest of the qualifier resolves and then doing a final lookup on that resolution result for the final segment instead.
2024-12-16 13:20:55 +01:00
Lukas Wirth
61c222e1af
Merge pull request #18690 from Giga-Bowser/extract-variable-string
feat: Use string literal contents as a name when extracting into variable
2024-12-16 10:29:05 +00:00
Lukas Wirth
0189a8937b
Merge pull request #18695 from roife/improve-tuple-destruction
minor: improve name suggestion for destructure_tuple_binding
2024-12-16 10:25:01 +00:00
roife
ad63e6957f refactor: simplify edit_tuple_usages in destructure_tuple_binding 2024-12-16 14:12:19 +08:00
Lukas Wirth
15239f612d internal: Show mir eval errors on hover with debug env var set 2024-12-15 17:38:37 +01:00
Giga Bowser
620af0ef2f feat: Use string literal contents as a name when extracting into variable 2024-12-14 13:36:57 -05:00
roife
cb1533f7e9 feat: improve name generation in destructure_tuple_binding 2024-12-13 23:34:03 +08:00
Laurențiu Nicola
dc978a976f Bump typos 2024-12-13 11:45:44 +02:00
Lukas Wirth
a6c291ed07
Merge pull request #18652 from Giga-Bowser/extract-constant
feat: Add an assist to extract an expression into a constant
2024-12-12 13:22:05 +00:00
1hakusai1
fc2b70132f Generate implementation with items even if snippet text edit is disabled 2024-12-12 18:55:14 +09:00
Giga Bowser
21782b9a8d minor: Group extract_function with other extraction assists 2024-12-11 14:11:20 -05:00
Giga Bowser
0cad614b3b feat: Add an assist to extract an expression into a static 2024-12-11 14:04:54 -05:00
Giga Bowser
1979d3f9b5 feat: Add an assist to extract an expression into a constant 2024-12-11 09:52:03 -05:00
Giga Bowser
17e482b1a9 internal: Move is_body_const to ide_assists::utils 2024-12-11 09:52:03 -05:00
Lukas Wirth
002fcea441
Merge pull request #18657 from Giga-Bowser/generate-enum-variant
minor: Migrate `generate_enum_variant` to `SyntaxEditor`
2024-12-11 07:07:22 +00:00
roife
78fb0e47ca feat: preserve order of parameters in extract_functions 2024-12-11 02:26:58 +08:00
Giga Bowser
547f75a2ce minor: Migrate generate_enum_variant to SyntaxEditor 2024-12-10 13:11:33 -05:00
Giga Bowser
c70bf568bb minor: Add item_enum constructor to SyntaxFactory
I recursively added all constructors it depends on. I also changed the old `make::` constructors to support more of the grammar.
2024-12-10 11:12:44 -05:00
Lukas Wirth
956ff4d8c5 Rename test fixture crates to ra_test_fixture 2024-12-09 11:40:21 +01:00
Giga Bowser
e66b4f336d fix: Map new replacement nodes to their mutable equivalents in SyntaxEditor 2024-12-08 15:55:34 -05:00
Giga Bowser
d329329b76 feat: Migrate flip_comma assist to SyntaxEditor 2024-12-06 10:03:09 -05:00
Giga Bowser
d55879d1cb feat: Migrate flip_trait_bound assist to SyntaxEditor 2024-12-06 10:02:34 -05:00
Giga Bowser
09dee81412 feat: Migrate flip_binexpr assist to SyntaxEditor 2024-12-06 10:02:34 -05:00
Lukas Wirth
4b350f2f11
Merge pull request #18551 from ShoyuVanilla/migrate-turbofish-assist
Migrate `add_turbo_fish` to `SyntaxEditor`
2024-12-06 13:44:54 +00:00
David Barsky
5d23772649
Merge pull request #18538 from tareknaser/syntax_factory_sort_items
Migrate `sort_items` Assist to Use `SyntaxFactory`
2024-12-05 19:21:51 +00:00
Tarek
8954a7f9e9
fix: rename syntax_editor_add_generic_param to add_generic_param
Signed-off-by: Tarek <tareknaser360@gmail.com>
2024-12-05 13:50:43 +02:00
Tarek
b7e613c0dc
fix: update introduce_named_generic to use type_param directly
Signed-off-by: Tarek <tareknaser360@gmail.com>
2024-12-04 16:02:03 +02:00
Tarek
9157761f5d
refactor: move editing for ast using SyntaxEditor to a separate file
Signed-off-by: Tarek <tareknaser360@gmail.com>
2024-12-04 14:51:48 +02:00
Tarek
2fb563f192 fix: refactor introduce_named_generic assist
Signed-off-by: Tarek <tareknaser360@gmail.com>
2024-12-04 14:50:03 +02:00
Tarek
70ef2f23c2 fix: refactor syntax_editor_add_generic_param
Signed-off-by: Tarek <tareknaser360@gmail.com>
2024-12-04 14:50:03 +02:00
Tarek
54f7ed13f5 fix: refactor syntax_editor_add_generic_param to handle adding new generic parameters
Signed-off-by: Tarek <tareknaser360@gmail.com>
2024-12-04 14:50:03 +02:00
Tarek
0990d5956d fix: implement syntax_editor_create_generic_param_list
Signed-off-by: Tarek <tareknaser360@gmail.com>
2024-12-04 14:50:03 +02:00
Tarek
642d4f3385 define syntax_editor_add_generic_param
Signed-off-by: Tarek <tareknaser360@gmail.com>
2024-12-04 14:50:03 +02:00
Tarek
4af3d6f598 fix: remove make_mut from introduce_named_generic assist
Signed-off-by: Tarek <tareknaser360@gmail.com>
2024-12-04 14:50:03 +02:00
Tarek
1400aec433 feat: migrate introduce_named_generic assist to use SyntaxFactory
Signed-off-by: Tarek <tareknaser360@gmail.com>
2024-12-04 14:50:03 +02:00
Tarek
c43d565def refactor: change target parameter to a reference in add_rewrite method
Signed-off-by: Tarek <tareknaser360@gmail.com>
2024-12-04 12:42:27 +02:00
Tarek
7149c4dab9 feat: migrate sort_items assist to use SyntaxFactory
Signed-off-by: Tarek <tareknaser360@gmail.com>
2024-12-04 12:42:26 +02:00
Lukas Wirth
e6276c8b64
Merge pull request #18555 from ChayimFriedman2/issue-17321
fix: Fix a bug when synthetic AST node were searched in the AST ID map and caused panics
2024-12-03 15:39:52 +00:00
Shoyu Vanilla
6aa5ea5411 Migrate add_turbo_fish to SyntaxEditor 2024-11-26 01:47:15 +09:00