@@ -71,12 +71,12 @@ pub struct HoverResult {
71
71
pub actions : Vec < HoverAction > ,
72
72
}
73
73
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
80
80
pub ( crate ) fn hover (
81
81
db : & RootDatabase ,
82
82
position : FilePosition ,
@@ -98,8 +98,8 @@ pub(crate) fn hover(
98
98
let mut range = None ;
99
99
let definition = match_ast ! {
100
100
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.
103
103
ast:: Name ( name) => NameClass :: classify( & sema, & name) . map( |class| match class {
104
104
NameClass :: Definition ( it) | NameClass :: ConstReference ( it) => it,
105
105
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
245
245
) )
246
246
}
247
247
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
248
254
pub ( crate ) fn hover_range (
249
255
db : & RootDatabase ,
250
256
range : FileRange ,
0 commit comments