rust-analyzer/crates
bors d092f7d78f Auto merge of #17542 - roife:fix-issue-17517, r=Veykril
feat: go-to-def and find-references on control-flow keywords

fix #17517.

This PR implements **go-to-definition** and **find-references** functionalities for control flow keywords, which is similar to the behaviors in the `highlight-related` module. Besides, this PR also fixes some incorrect behaviors in `highlight-related`.

## Changes

1. **Support for go-to-definition on control flow keywords**:
   This PR introduces functionality allowing users to navigate on the definition of control flow keywords (`return`, `break`, `continue`).
   Commit: 2a3244ee147f898dd828c06352645ae1713c260f..7391e7a608634709db002a4cb09229de4d12c056.

2. **Bug fixes and refactoring in highlight-related**:
   - **Handling return/break/continue within try_blocks**:
     This PR adjusted the behavior of these keywords when they occur within `try_blocks`. When encounter these keywords, the program should exit the outer function or loop which containing the `try_blocks`, rather than the `try_blocks` itself; while the `?` will cause the program to exit `try_blocks`.
     Commit: 59d697e807f0197f59814b37dca1563959da4aa1.
   - **Support highlighting keywords in macro expansion for highlight-related**:
     Commit: 88df24f01727c23a667a763ee3ee0cec22d5ad52.
   - Detailed description for the bug fixes
     + The previous implementation of `preorder_expr` incorrectly treated `try_blocks` as new contexts, thereby r-a will not continue to traverse inner `return` and `break/continue` statements. To resolve this, a new function `preorder_expr_with_ctx_checker` has been added, allowing users to specify which expressions to skip.
       * For example, when searching for the `?` in the context, r-a should skip `try_blocks` where the `?` insides just works for `try_blocks`. But when search for the `return` keyword, r-a should collect both the `return` keywords inside and outside the `try_blocks`
     + Thus, this PR added `WalkExpandedExprCtx` (builder pattern). It offers the following improvements: customizable context skipping, maintenance of loop depth (for `break`/`continue`), and handling macro expansion during traversal.

3. **Support for find-references on control flow keywords**:
   This PR enables users to find all references to control flow keywords.
   Commit: 9202a33f81218fb9c2edb5d42e6b4de85b0323a8.
2024-07-22 09:22:13 +00:00
..
base-db Make LRU opt-in 2024-07-19 18:38:08 +02:00
cfg Make CfgExpr slimmer 2024-07-21 14:50:44 +02:00
flycheck feature: move linked_projects discovery to the rust-analyzer server 2024-07-18 12:01:27 -04:00
hir Encode edition within FileId in the hir layer 2024-07-18 08:49:10 +02:00
hir-def Auto merge of #17586 - ShoyuVanilla:tuple-arg-macro-rest, r=Veykril 2024-07-22 09:08:12 +00:00
hir-expand Make CfgExpr slimmer 2024-07-21 14:50:44 +02:00
hir-ty fix: Panic in debug profile for tuple deconstruct with arity mismatch 2024-07-21 02:37:37 +09:00
ide Auto merge of #17542 - roife:fix-issue-17517, r=Veykril 2024-07-22 09:22:13 +00:00
ide-assists Auto merge of #17647 - joshka:jm/rename-commands, r=Veykril 2024-07-22 08:10:03 +00:00
ide-completion fix: Allow flyimport to import primitive shadowing modules 2024-07-21 13:26:19 +02:00
ide-db Auto merge of #17542 - roife:fix-issue-17517, r=Veykril 2024-07-22 09:22:13 +00:00
ide-diagnostics Auto merge of #17586 - ShoyuVanilla:tuple-arg-macro-rest, r=Veykril 2024-07-22 09:08:12 +00:00
ide-ssr Parse try as a keyword only in edition 2018 and up 2024-07-19 15:43:20 +02:00
intern Support rustc_skip_during_method_dispatch 2024-07-17 11:46:36 +02:00
limit Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
load-cargo Auto merge of #17639 - Veykril:salsa-perf, r=Veykril 2024-07-19 18:45:16 +00:00
mbe Parse contextual dyn keyword properly in edition 2015 2024-07-19 20:20:30 +02:00
parser Add missing dyn parse special cases in 2015 edition 2024-07-20 09:18:40 +02:00
paths Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
proc-macro-api Encode edition within FileId in the hir layer 2024-07-18 08:49:10 +02:00
proc-macro-srv Encode edition within FileId in the hir layer 2024-07-18 08:49:10 +02:00
proc-macro-srv-cli Abstract proc-macro-srv protocol format 2024-06-30 16:56:30 +02:00
profile Fix stop_watch on linux 2024-07-07 08:40:41 +02:00
project-model Auto merge of #17620 - Veykril:edition-aware-parser, r=Veykril 2024-07-19 14:56:56 +00:00
rust-analyzer Auto merge of #17647 - joshka:jm/rename-commands, r=Veykril 2024-07-22 08:10:03 +00:00
salsa Add back equality check that went missing 2024-07-19 20:39:09 +02:00
span Encode edition within FileId in the hir layer 2024-07-18 08:49:10 +02:00
stdx Merge from rust-lang/rust 2024-07-11 20:06:05 +03:00
syntax Auto merge of #17641 - nyurik:optimize-refs, r=Veykril 2024-07-20 06:40:27 +00:00
test-fixture Prefer standard library paths over shorter extern deps re-exports 2024-07-21 09:14:17 +02:00
test-utils fix: Allow flyimport to import primitive shadowing modules 2024-07-21 13:26:19 +02:00
text-edit Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
toolchain Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
tt Switch token trees to use Symbols 2024-07-16 10:11:59 +02:00
vfs Encode edition within FileId in the hir layer 2024-07-18 08:49:10 +02:00
vfs-notify Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00