Skip to content

feat: goto definition on range operators#18362

Merged
bors merged 4 commits into
rust-lang:masterfrom
duncpro:goto-def-ranges
Oct 22, 2024
Merged

feat: goto definition on range operators#18362
bors merged 4 commits into
rust-lang:masterfrom
duncpro:goto-def-ranges

Conversation

@duncpro

@duncpro duncpro commented Oct 21, 2024

Copy link
Copy Markdown
Contributor

Closes #18342

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 21, 2024

@Veykril Veykril left a comment

Copy link
Copy Markdown
Member

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 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)

Comment thread crates/hir/src/source_analyzer.rs Outdated
Comment on lines +356 to +359
let path = match range_expr.op_kind()? {
RangeOp::Exclusive => path![core::ops::Range],
RangeOp::Inclusive => path![core::ops::RangeInclusive],
};

Copy link
Copy Markdown
Member

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

@Veykril

Veykril commented Oct 22, 2024

Copy link
Copy Markdown
Member

Thanks!
@bors r+

@bors

bors commented Oct 22, 2024

Copy link
Copy Markdown
Contributor

📌 Commit 2f6923b has been approved by Veykril

It is now in the queue for this repository.

@bors

bors commented Oct 22, 2024

Copy link
Copy Markdown
Contributor

⌛ Testing commit 2f6923b with merge 17055aa...

@bors

bors commented Oct 22, 2024

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 17055aa to master...

@bors bors merged commit 17055aa into rust-lang:master Oct 22, 2024
@duncpro

duncpro commented Oct 22, 2024

Copy link
Copy Markdown
Contributor Author

@Veykril Thank you for helping me along. This was my first real OSS contribution.

@Veykril

Veykril commented Oct 22, 2024

Copy link
Copy Markdown
Member

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 :)

@duncpro

duncpro commented Oct 22, 2024

Copy link
Copy Markdown
Contributor Author

I'm down. I'll open an issue for it right now

@rust-lang rust-lang deleted a comment Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Go to definition on ../..= should go to the corresponding Range* type

4 participants