-
Notifications
You must be signed in to change notification settings - Fork 1.8k
docs: add documentation for find_all_refs constructor search #19861
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
docs: add documentation for find_all_refs constructor search #19861
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
abc321e
to
0902094
Compare
|
1a68f66
to
a2b58e2
Compare
crates/ide/src/lib.rs
Outdated
/// Find all references to the item at the cursor position. | ||
/// | ||
/// # Examples | ||
/// | ||
/// Basic struct reference search: | ||
/// ```rust | ||
/// struct S { | ||
/// pub x: usize, | ||
/// } | ||
/// | ||
/// fn print_s(s: S) { | ||
/// println!("{}", s.x) | ||
/// } | ||
/// | ||
/// fn main() { | ||
/// let s = S { x: 42 }; // This is a constructor usage | ||
/// print_s(s); // This is a type reference | ||
/// } | ||
/// ``` | ||
/// | ||
/// To find only constructor/initialization usages: | ||
/// 1. Position cursor on special tokens in struct/enum definition: | ||
/// ```rust | ||
/// // On '{' - finds record struct initializations | ||
/// struct Point { // <- cursor here on '{' | ||
/// x: i32, | ||
/// y: i32, | ||
/// } | ||
/// | ||
/// // On '(' - finds tuple struct initializations | ||
/// struct Tuple(i32, i32); // <- cursor here on '(' | ||
/// | ||
/// // On ';' - finds unit struct initializations | ||
/// struct Unit; // <- cursor here on ';' | ||
/// ``` | ||
/// | ||
/// 2. Examples of what will be found: | ||
/// ```rust | ||
/// struct Point{x: i32, y: i32}; | ||
/// struct Tuple(i32, i32); | ||
/// struct Unit; | ||
/// | ||
/// | ||
/// let p1 = Point { x: 0, y: 0 }; // Found when cursor on '{' | ||
/// let p2 = Tuple(1, 2); // Found when cursor on '(' | ||
/// let u = Unit; // Found when cursor on ';' | ||
/// ``` | ||
/// | ||
/// 3. For enum variants: | ||
/// ```rust | ||
/// enum E { | ||
/// Struct { // <- cursor here on '{' | ||
/// x: i32 | ||
/// }, | ||
/// Tuple(i32), // <- cursor here on '(' | ||
/// Unit // <- cursor here on identifier | ||
/// } | ||
/// | ||
/// let e1 = E::Struct { x: 0 }; // Found for Struct variant | ||
/// let e2 = E::Tuple(1); // Found for Tuple variant | ||
/// let e3 = E::Unit; // Found for Unit variant | ||
/// ``` | ||
/// | ||
/// # Parameters | ||
/// * `position` - The position in the file to find references for | ||
/// * `search_scope` - Optional scope to limit the search | ||
/// | ||
/// # Returns | ||
/// Returns a vector of reference search results if references are found, | ||
/// or None if no valid item is found at the position. |
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.
This seems duplicated-ish. We already have the relevant docs on the implementation now, so I don't think retelling this here is beneficial (aspecially as we now have multiple places to update the docs of the features change)
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.
Thanks!
docs(find_all_refs): document constructor search behavior