-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: goto definition on range operators #18362
Conversation
… struct definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(shouldve said that in the issue as a mentoring instruction sorry)
I think we should add a couple new OperatorClass
es (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)
crates/hir/src/source_analyzer.rs
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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