feat: goto definition on range operators#18362
Conversation
… struct definition
There was a problem hiding this comment.
(shouldve said that in the issue as a mentoring instruction sorry)
I think we should add a couple new OperatorClasses (OperatorClass::Range(Struct), etc) here for the range types https://github.com/rust-analyzer/rust-analyzer/blob/fb832ff2ba338105dda1c8172f89d580cb0a570f/crates/ide-db/src/defs.rs#L548-L554 and populate them here https://github.com/rust-analyzer/rust-analyzer/blob/fb832ff2ba338105dda1c8172f89d580cb0a570f/crates/ide-db/src/defs.rs#L309-L330
WIth that I think the go to def code needs no changes in fact (aside from tests) and this should automatically give us support for ranges in other ide features as well (like hover and stuff)
| let path = match range_expr.op_kind()? { | ||
| RangeOp::Exclusive => path![core::ops::Range], | ||
| RangeOp::Inclusive => path![core::ops::RangeInclusive], | ||
| }; |
There was a problem hiding this comment.
There is a bit more to check, we need to check if the first or second element is missing or not as well, so this should ultimately be able to produce one of Range, RangeFrom, RangeInclusive, RangeFull, RangeTo and RangeToInclusive
…e links to respective struct
|
Thanks! |
|
☀️ Test successful - checks-actions |
|
@Veykril Thank you for helping me along. This was my first real OSS contribution. |
|
Ah, if you want there is a follow up task. We can do the same for patterns I just realized, not just expressions since there are also range patterns :) |
|
I'm down. I'll open an issue for it right now |
Closes #18342