bors
48cb059182
Auto merge of #16781 - DropDemBits:extract-format-args-escaping, r=Veykril
...
fix: Don't escape `\` and `$` in "Extract format expressions" assist
Fixes #16745
2024-03-07 20:04:33 +00:00
DropDemBits
1f37e5ac9a
fix: Don't escape \
and $
in "Extract format expressions" assist
2024-03-07 14:20:23 -05:00
roife
5c9ce7b11f
test: add tests for keeping attrs in assist 'generate_delegate_trait'
2024-03-06 15:32:49 +08:00
roife
faea7fca01
fix: keep attrs for assist 'generate_delegate_trait'
2024-03-06 15:32:26 +08:00
Niklas Lindorfer
2a4ba4295b
fix: hide destructure_struct_binding assist if no public fields
2024-03-04 21:50:01 +00:00
Lukas Wirth
0964374274
Move diagnostics docs generation into xtask/codegen
2024-03-04 17:14:14 +01:00
bors
4e8cbf36a8
Auto merge of #16708 - Veykril:codegen, r=Veykril
...
internal: Move ide-assists codegen tests into an xtask codegen command
2024-03-04 15:50:39 +00:00
bors
99a1b8f7a8
Auto merge of #16747 - Veykril:cleanup, r=Veykril
...
internal: Clean some stuff up
Just a bunch of small refactorings, mainly from browsing through `hir-def`
2024-03-04 10:30:17 +00:00
Lukas Wirth
4303e741de
Cleanup
2024-03-04 11:10:06 +01:00
bors
d8feb908be
Auto merge of #16703 - regexident:sema-ast-to-hir, r=Veykril
...
Add more methods for resolving definitions from AST to their corresponding HIR types
In order to be able to add these methods with consistent naming I had to also rename two existing methods that would otherwise be conflicting/confusing:
`Semantics::to_module_def(&self, file: FileId) -> Option<Module>` (before)
`Semantics::file_to_module_def(&self, file: FileId) -> Option<Module>` (after)
`Semantics::to_module_defs(&self, file: FileId) -> impl Iterator<Item = Module>` (before)
`Semantics::file_to_module_defs(&self, file: FileId) -> impl Iterator<Item = Module>` (after)
(the PR is motivated by an outside use of the `ra_ap_hir` crate that would benefit from being able to walk a `hir::Function`'s AST, resolving its exprs/stmts/items to their HIR equivalents)
2024-03-04 09:02:32 +00:00
bors
0b7d4cc6ff
Auto merge of #16690 - roife:fix-issue-16471, r=Veykril
...
fix: use 4 spaces for indentation in macro expansion
Partial fix for #16471 .
In the previous code, the indentation produced by macro expansion was set to 2 spaces. This PR modifies it to 4 spaces for the sake of consistency.
2024-03-04 08:49:51 +00:00
Lukas Wirth
ed7e9aa5d8
Simplify
2024-03-01 13:25:24 +01:00
Niklas Lindorfer
dc7b502689
Fix usage in other assist
2024-02-29 13:17:45 +00:00
Niklas Lindorfer
7c30c70658
Attempt resolving name collisions
2024-02-29 13:17:45 +00:00
Niklas Lindorfer
b203a07d92
Handle bindings to refs
2024-02-29 13:17:45 +00:00
Niklas Lindorfer
ed230048dc
Add destructure_struct_binding
action
...
Separate into create and apply edit
Rename usages
Hacky name map
Add more tests
Handle non-exhaustive
Add some more TODOs
Private fields
Use todo
Nesting
Improve rest token generation
Cleanup
Doc -> regular comment
Support mut
2024-02-29 13:17:44 +00:00
Lukas Wirth
03b02e6bd0
internal: Move ide-assists codegen tests into an xtask codegen command
2024-02-28 16:54:44 +01:00
Vincent Esche
6112ddfabb
Add prefix file_
to Semantics
's to_module_defs()
/to_module_def()
methods
2024-02-28 10:27:28 +01:00
roife
76b86b24bd
fix: clippy and format
2024-02-27 20:53:09 +08:00
roife
ec5236f3a8
test: use 4 spaces for indetation in macro expansion
2024-02-27 20:53:07 +08:00
roife
ce4ae41605
internal: simplify the process of inserting spaces after mut
2024-02-27 20:49:09 +08:00
bors
6b250a22c4
Auto merge of #16687 - kilpkonn:master, r=Veykril
...
feat: Add "make tuple" tactic to term search
Follow up to https://github.com/rust-lang/rust-analyzer/pull/16092
Now term search also supports tuples.
```rust
let a: i32 = 1;
let b: f64 = 0.0;
let c: (i32, (f64, i32)) = todo!(); // Finds (a, (b, a))
```
In addition to new tactic that handles tuples I changed how the generics are handled.
Previously it tried all possible options from types we had in scope but now it only tries useful ones that help us directly towards the goal or at least towards calling some other function.
This changes O(2^n) to O(n^2) where n is amount of rounds which in practice allows using types that take generics for multiple rounds (previously limited to 1). Average case that also used to be exponential is now roughly linear.
This means that deeply nested generics also work.
````rust
// Finds all valid combos, including `Some(Some(Some(...)))`
let a: Option<Option<Option<bool>>> = todo!();
````
_Note that although the complexity is smaller allowing more types with generics the search overall slows down considerably. I hope it's fine tho as the autocomplete is disabled by default and for code actions it's not super slow. Might have to tweak the depth hyper parameter tho_
This resulted in a huge increase of results found (benchmarks on `ripgrep` crate):
Before
````
Tail Expr syntactic hits: 149/1692 (8%)
Tail Exprs found: 749/1692 (44%)
Term search avg time: 18ms
```
After
```
Tail Expr syntactic hits: 291/1692 (17%)
Tail Exprs found: 1253/1692 (74%)
Term search avg time: 139ms
````
Most changes are local to term search except some tuple related stuff on `hir::Type`.
2024-02-27 09:41:14 +00:00
bors
d8c5a6128f
Auto merge of #16651 - dfireBird:new_assist_fill_fields, r=Veykril
...
Add assist for filling fields by replacing ellipsis in record syntax
I'm not sure if the tests cover the most cases, I'll add more if suggested.
2024-02-27 09:28:23 +00:00
Tavo Annus
be6f8e2648
Add make_tuple
tactic
2024-02-26 20:17:09 +02:00
Tavo Annus
8bd30e9b3f
Improve generics handling in term search
2024-02-26 20:17:09 +02:00
dfireBird
8fa903a447
add test for checking struct generated through macro
2024-02-26 21:32:59 +05:30
dfireBird
2ea70662f0
make assist not applicable if there is no missing field
2024-02-26 21:21:56 +05:30
roife
61b576c5ab
fix: fmt
2024-02-26 22:36:47 +08:00
roife
38a50cf1a4
test: callsites inside inline_into_callers
2024-02-26 20:24:44 +08:00
roife
36298c622e
fix:do not handle callsites in macros' parameters
2024-02-26 20:23:36 +08:00
dfireBird
6f4354f6ad
add assist for filling fields by replacing ellipsis in record syntax
2024-02-24 11:59:48 +05:30
Lukas Wirth
d93096ecc0
internal: Fetch toolchain and datalayout for DetachedFiles
2024-02-20 10:40:39 +01:00
DropDemBits
eb6d6ba17c
Migrate generate_trait_from_impl
to mutable ast
2024-02-15 21:34:29 -05:00
DropDemBits
115646d7d5
Align set_visibility
with the rest of the set_
edit-in-place methods
2024-02-15 20:40:14 -05:00
Chengxu Bian
ca64359945
remove eprintln! overwrite
2024-02-12 23:54:32 -05:00
Tavo Annus
125791386d
Cleanup term search related changes
2024-02-11 14:35:54 +02:00
Tavo Annus
88964c0b6a
Optionally disable term search for autocompletion
2024-02-11 13:33:29 +02:00
Tavo Annus
0b838e3e23
Expand target for autocompletion
2024-02-11 13:33:29 +02:00
Tavo Annus
a946970e2d
Add quantified trees to reduce autocomplete options
2024-02-11 13:33:29 +02:00
Tavo Annus
bdbdd83ec1
Initial version of term_search for autocomplete
2024-02-11 13:33:29 +02:00
Tavo Annus
627255dd5a
Add static method tactic
2024-02-11 13:33:29 +02:00
Tavo Annus
bb3c7cff60
Introduce term search to rust-analyzer
2024-02-11 13:33:29 +02:00
bors
0878cdef2a
Auto merge of #16524 - evertedsphere:swann/trait-bound-dyn, r=Veykril
...
minor: test that flip_trait_bound works with trait objects
Closes https://github.com/rust-lang/rust-analyzer/issues/16522 .
2024-02-10 10:59:46 +00:00
bors
1ef7a2329b
Auto merge of #16525 - Veykril:item-loc, r=Veykril
...
Abstract more over ItemTreeLoc-like structs
Allows reducing some code duplication by using functions generic over said structs. The diff isn't negative due to me adding some additional impls for completeness.
2024-02-10 10:47:37 +00:00
Soham Chowdhury
dcdfc35fce
test that flip_trait_bound works with trait objects
2024-02-10 11:06:07 +01:00
bors
aa97edb214
Auto merge of #16497 - evertedsphere:swann/fix-inline-for-macro-generated-method, r=Veykril
...
Fix incorrect inlining of functions that come from MBE macros
Partial fix for https://github.com/rust-lang/rust-analyzer/issues/16471 .
As a reminder, there are two issues there:
1. missing whitespace in parameter types (the first test)
2. the `self` parameter not being replaced by `this` in the function body (the second test)
The first part is fixed in this PR. See [this comment](https://github.com/rust-lang/rust-analyzer/pull/16497#issuecomment-1934243409 ) for the second.
2024-02-10 08:59:51 +00:00
Lukas Wirth
2ebf0c87c2
Deduplicate some code
2024-02-10 01:51:22 +01:00
Soham Chowdhury
18be556b37
inline_call: remove macro self->this test
...
To be added back later once we have a fix.
See #16471 and https://github.com/rust-lang/rust-analyzer/pull/16497#issuecomment-1934243409 .
2024-02-09 22:02:51 +01:00
Tetsuharu Ohzeki
80e684254d
ide-assists: Fix warnings about clippy str_to_string
rule
2024-02-10 01:00:40 +09:00
bors
65a644190d
Auto merge of #16424 - dfireBird:let-stmt-guarded-return-assist, r=Veykril
...
implement convert to guarded return assist for `let` statement with type that implements `std::ops::Try`
I've tried to implement the assist that #16390 talked about
If there are any improvements that I can make in implementation, please suggest them.
![Peek 2024-02-05 19-01](https://github.com/rust-lang/rust-analyzer/assets/40687700/d6af3222-4f23-4ade-a930-8a78cc75e821 )
2024-02-09 13:42:20 +00:00
David Barsky
2d09d69fbe
internal: fix crash inside filter_unnecessary_bounds
for a missing generic param
2024-02-08 20:58:48 -05:00
DropDemBits
05b8ccc378
Fix clippy lints
2024-02-08 19:39:04 -05:00
DropDemBits
1161082051
Remove unused code in utils
...
All usages of `render_snippet` and `Cursor` have been removed as part of the migration
2024-02-08 19:13:10 -05:00
DropDemBits
8eebf1701b
Migrate replace_derive_with_manual_impl
to mutable ast
2024-02-08 19:13:10 -05:00
DropDemBits
18ea09feca
Migrate generate_new
to mutable ast
2024-02-08 19:13:10 -05:00
DropDemBits
e0117154cf
Migrate generate_impl
to mutable ast
2024-02-08 19:13:10 -05:00
DropDemBits
ab2233e562
Migrate generate_getter_or_setter
to mutable ast
2024-02-08 19:13:09 -05:00
DropDemBits
f1293a8fc4
Add newline to body when where clause is present
2024-02-08 19:13:09 -05:00
DropDemBits
0519414c19
Make ReferenceConversion
methods return ast types
2024-02-08 19:13:09 -05:00
DropDemBits
0e39257e5b
Migrate extract_function
to mutable ast
2024-02-08 19:09:33 -05:00
DropDemBits
3924a0ef7c
Add ast versions of generate{_trait}_impl_text{_intransitive}
2024-02-08 19:09:33 -05:00
DropDemBits
8c0661b2de
Use GenericArgList
for make::impl{_trait}
...
`make::impl_` no longer merges generic params and args in order to be in line
with `make::impl_`, which doesn't do it either.
2024-02-08 19:09:32 -05:00
bors
e07183461f
Auto merge of #16487 - ShoyuVanilla:deref-generate-getter, r=Veykril
...
Remove unnecessary `.as_ref()` in generate getter assist
Resolves #12389
2024-02-08 15:15:52 +00:00
Soham Chowdhury
57a454233c
inline_call: ensure correct whitespace in parameter types
2024-02-06 20:24:16 +01:00
bors
66cec4d11a
Auto merge of #16470 - Veykril:clippy-disallow, r=lnicola
...
internal: Lint debug prints and disallowed types with clippy
2024-02-05 17:20:43 +00:00
dfireBird
53db37f9bf
restrict cursor range to show assists
2024-02-05 18:53:40 +05:30
Shoyu Vanilla
26715a8fde
cargo fmt
2024-02-05 10:48:34 +09:00
Shoyu Vanilla
983cce8c31
Typo fix
2024-02-05 10:37:58 +09:00
Shoyu Vanilla
f0428e57ea
Simplify redundant coercion
2024-02-05 10:35:12 +09:00
Shoyu Vanilla
97ecfe4fab
Remove unnecessary .as_ref()
in generate getter assist
2024-02-05 00:44:57 +09:00
bors
8f6a72871e
Auto merge of #16469 - Young-Flash:ci_typos, r=lnicola
...
internal: add typos check CI (part 2)
follow up https://github.com/rust-lang/rust-analyzer/pull/16448
2024-02-02 12:02:48 +00:00
Young-Flash
ba2910a3a7
minor: correct some typos
2024-02-02 18:22:54 +08:00
Lukas Wirth
9e8a0fae0c
Lint debug prints and disallowed types with clippy
2024-02-01 17:57:27 +01:00
Johann Hemmann
771c6c9271
format_collect
2024-01-31 19:06:36 +01:00
bors
355c9444e1
Auto merge of #16448 - Young-Flash:typos, r=lnicola
...
minor: correct typos
I use [crate-ci/typos](https://github.com/crate-ci/typos ) to check typos in codebase, if it's ok with you, I'd like to add a typo check CI using [typos](https://github.com/crate-ci/typos ) (with Apache-2.0, MIT licenses).
BTW, we can add a [_typos.toml](https://github.com/crate-ci/typos/blob/master/docs/reference.md ) as white list for some intentional typos
2024-01-31 13:29:55 +00:00
David Barsky
e1ea7c8844
internal: switch to tracing
from log
...
This commit also adds `tracing` to NotificationDispatcher/RequestDispatcher,
bumps `rust-analyzer-salsa` to 0.17.0-pre.6, `always-assert` to 0.2, and
removes the homegrown `hprof` implementation in favor of a vendored
tracing-span-tree.
2024-01-30 12:27:31 -05:00
Young-Flash
db9fd370ee
minor: correct typos
2024-01-30 21:43:43 +08:00
davidsemakula
84e13145ff
add more tests for normalize import assist
2024-01-28 11:55:01 +03:00
davidsemakula
fc00602723
merge imports assist avoids adding unnecessary braces when merging nested use tree selections
2024-01-28 11:55:01 +03:00
davidsemakula
b241593f36
merge imports assist always applies to covering use item except for nested use tree selections
2024-01-28 11:55:01 +03:00
davidsemakula
a8a18f3ccf
add normalize import assist
2024-01-28 11:55:01 +03:00
davidsemakula
8fab92feb2
normalize use trees when merging imports
2024-01-28 11:55:01 +03:00
Lukas Wirth
8a5829cf28
Re-order mod declarations
2024-01-27 11:02:34 +01:00
dfireBird
e0446a0eb5
implement assist for let stmt with TryEnum type to guarded return
2024-01-25 00:13:16 +05:30
r0cky
1a9ef233b7
Remove unused codes
2024-01-21 12:56:23 +08:00
bors
d4926c10b2
Auto merge of #16405 - dfireBird:guarded-return-for-loop, r=lnicola
...
fix: Include `for` construct in convert to guarded return conditions
2024-01-20 16:13:31 +00:00
dfireBird
721e79035d
include for
in convert to guarded return assist
2024-01-20 19:26:50 +05:30
bors
0c764216d5
Auto merge of #16396 - Young-Flash:fix_marco, r=Veykril
...
fix panic with reference in macro
it panic at `builder.make_mut(segment)`, where segment is from macro expand. And the usage reference in orginal macro call isn't a `PathSegment` so we can't update it in `apply_references`, I can't find a way to deal with it properly so here just filter out the reference in macro. LMK if there are better way to fix this
try to close https://github.com/rust-lang/rust-analyzer/issues/16328
2024-01-20 08:12:44 +00:00
Young-Flash
f9b5e0d219
minor: use reference.range
to get original range
2024-01-20 14:43:42 +08:00
Johann Hemmann
b1a0c9ac40
single_match
2024-01-19 18:31:15 +01:00
Johann Hemmann
71d4dba960
redundant_pattern_matching
2024-01-19 17:31:01 +01:00
Johann Hemmann
3cf1358eb8
question_mark
2024-01-19 17:31:01 +01:00
Johann Hemmann
6738edc259
ptr_arg
2024-01-19 17:31:01 +01:00
Johann Hemmann
e6f9f4c0e4
nonminimal_bool
2024-01-19 17:31:01 +01:00
Johann Hemmann
add40c8660
match_like_matches_macro
2024-01-19 17:31:01 +01:00
Johann Hemmann
b5eca5f2fc
collapsible_if
2024-01-19 17:31:00 +01:00
bors
85c9a83262
Auto merge of #16398 - Urhengulas:satisfy-clippy, r=Veykril
...
`cargo clippy --fix`
This PR is the result of running `cargo clippy --fix && cargo fmt` in the root of the repository. I did not manually review all the changes, but just skimmed through a few of them. The tests still pass, so it seems fine.
2024-01-19 09:43:35 +00:00
davidsemakula
67c1c2bd14
update merge item assist implementation for "one" import granularity
2024-01-18 17:26:53 +03:00
Johann Hemmann
fad4fa163c
cargo clippy --fix
2024-01-18 13:59:49 +01:00
Young-Flash
0bf986d718
add test case with marco reference
2024-01-18 17:43:44 +08:00