Skip to content

Commit 48f43df

Browse files
committed
docs: Improve the comments in crates/ide/src/hover.rs
1 parent 6310786 commit 48f43df

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

crates/ide/src/hover.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ pub struct HoverResult {
7171
pub actions: Vec<HoverAction>,
7272
}
7373

74-
// Feature: Hover
75-
//
76-
// Shows additional information, like type of an expression or documentation for definition when "focusing" code.
77-
// Focusing is usually hovering with a mouse, but can also be triggered with a shortcut.
78-
//
79-
// image::https://user-images.githubusercontent.com/48062697/113020658-b5f98b80-917a-11eb-9f88-3dbc27320c95.gif[]
74+
/// Feature: Hover
75+
///
76+
/// Shows additional information, like the type of an expression or the documentation for a definition when "focusing" code.
77+
/// Focusing is usually hovering with a mouse, but can also be triggered with a shortcut.
78+
///
79+
/// image::https://user-images.githubusercontent.com/48062697/113020658-b5f98b80-917a-11eb-9f88-3dbc27320c95.gif
8080
pub(crate) fn hover(
8181
db: &RootDatabase,
8282
position: FilePosition,
@@ -98,8 +98,8 @@ pub(crate) fn hover(
9898
let mut range = None;
9999
let definition = match_ast! {
100100
match node {
101-
// we don't use NameClass::referenced_or_defined here as we do not want to resolve
102-
// field pattern shorthands to their definition
101+
// We don't use NameClass::referenced_or_defined here as we do not want to resolve
102+
// field pattern shorthands to their definition.
103103
ast::Name(name) => NameClass::classify(&sema, &name).map(|class| match class {
104104
NameClass::Definition(it) | NameClass::ConstReference(it) => it,
105105
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
245245
))
246246
}
247247

248+
/// LSP Extension: Hover over a range
249+
///
250+
/// Gets the type of the expression closest to the selection if the user is hovering inside
251+
/// the selection. If not, it is handled by `handle_hover`.
252+
///
253+
/// https://user-images.githubusercontent.com/22298999/126914293-0ce49a92-545d-4005-a59e-9294fa2330d6.gif
248254
pub(crate) fn hover_range(
249255
db: &RootDatabase,
250256
range: FileRange,

0 commit comments

Comments
 (0)