mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
docs: Improve the comments in crates/ide/src/hover.rs
This commit is contained in:
parent
6310786ca5
commit
48f43df7d6
1 changed files with 14 additions and 8 deletions
|
@ -71,12 +71,12 @@ pub struct HoverResult {
|
||||||
pub actions: Vec<HoverAction>,
|
pub actions: Vec<HoverAction>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Feature: Hover
|
/// Feature: Hover
|
||||||
//
|
///
|
||||||
// Shows additional information, like type of an expression or documentation for definition when "focusing" code.
|
/// Shows additional information, like the type of an expression or the documentation for a definition when "focusing" code.
|
||||||
// Focusing is usually hovering with a mouse, but can also be triggered with a shortcut.
|
/// Focusing is usually hovering with a mouse, but can also be triggered with a shortcut.
|
||||||
//
|
///
|
||||||
// image::https://user-images.githubusercontent.com/48062697/113020658-b5f98b80-917a-11eb-9f88-3dbc27320c95.gif[]
|
/// image::https://user-images.githubusercontent.com/48062697/113020658-b5f98b80-917a-11eb-9f88-3dbc27320c95.gif
|
||||||
pub(crate) fn hover(
|
pub(crate) fn hover(
|
||||||
db: &RootDatabase,
|
db: &RootDatabase,
|
||||||
position: FilePosition,
|
position: FilePosition,
|
||||||
|
@ -98,8 +98,8 @@ pub(crate) fn hover(
|
||||||
let mut range = None;
|
let mut range = None;
|
||||||
let definition = match_ast! {
|
let definition = match_ast! {
|
||||||
match node {
|
match node {
|
||||||
// we don't use NameClass::referenced_or_defined here as we do not want to resolve
|
// We don't use NameClass::referenced_or_defined here as we do not want to resolve
|
||||||
// field pattern shorthands to their definition
|
// field pattern shorthands to their definition.
|
||||||
ast::Name(name) => NameClass::classify(&sema, &name).map(|class| match class {
|
ast::Name(name) => NameClass::classify(&sema, &name).map(|class| match class {
|
||||||
NameClass::Definition(it) | NameClass::ConstReference(it) => it,
|
NameClass::Definition(it) | NameClass::ConstReference(it) => it,
|
||||||
NameClass::PatFieldShorthand { local_def, field_ref: _ } => Definition::Local(local_def),
|
NameClass::PatFieldShorthand { local_def, field_ref: _ } => Definition::Local(local_def),
|
||||||
|
@ -245,6 +245,12 @@ fn try_hover_for_lint(attr: &ast::Attr, token: &SyntaxToken) -> Option<RangeInfo
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// LSP Extension: Hover over a range
|
||||||
|
///
|
||||||
|
/// Gets the type of the expression closest to the selection if the user is hovering inside
|
||||||
|
/// the selection. If not, it is handled by `handle_hover`.
|
||||||
|
///
|
||||||
|
/// https://user-images.githubusercontent.com/22298999/126914293-0ce49a92-545d-4005-a59e-9294fa2330d6.gif
|
||||||
pub(crate) fn hover_range(
|
pub(crate) fn hover_range(
|
||||||
db: &RootDatabase,
|
db: &RootDatabase,
|
||||||
range: FileRange,
|
range: FileRange,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue