@@ -15,7 +15,7 @@ use ide_db::{
15
15
FxIndexSet , RootDatabase ,
16
16
} ;
17
17
use itertools:: Itertools ;
18
- use syntax:: { ast, match_ast , AstNode , SyntaxKind :: * , SyntaxNode , SyntaxToken , T } ;
18
+ use syntax:: { ast, AstNode , SyntaxKind :: * , SyntaxNode , T } ;
19
19
20
20
use crate :: {
21
21
doc_links:: token_as_doc_comment,
@@ -203,14 +203,10 @@ fn hover_simple(
203
203
} )
204
204
} ) ;
205
205
206
- result
207
- . map ( |mut res : HoverResult | {
208
- res. actions = dedupe_or_merge_hover_actions ( res. actions ) ;
209
- RangeInfo :: new ( original_token. text_range ( ) , res)
210
- } )
211
- // fallback to type hover if there aren't any other suggestions
212
- // this finds its own range instead of using the closest token's range
213
- . or_else ( || descended ( ) . find_map ( |token| hover_type_fallback ( sema, config, token, token) ) )
206
+ result. map ( |mut res : HoverResult | {
207
+ res. actions = dedupe_or_merge_hover_actions ( res. actions ) ;
208
+ RangeInfo :: new ( original_token. text_range ( ) , res)
209
+ } )
214
210
}
215
211
216
212
fn hover_ranged (
@@ -220,8 +216,11 @@ fn hover_ranged(
220
216
config : & HoverConfig ,
221
217
) -> Option < RangeInfo < HoverResult > > {
222
218
// FIXME: make this work in attributes
223
- let expr_or_pat =
224
- file. covering_element ( range) . ancestors ( ) . find_map ( Either :: < ast:: Expr , ast:: Pat > :: cast) ?;
219
+ let expr_or_pat = file
220
+ . covering_element ( range)
221
+ . ancestors ( )
222
+ . take_while ( |it| ast:: Item :: can_cast ( it. kind ( ) ) )
223
+ . find_map ( Either :: < ast:: Expr , ast:: Pat > :: cast) ?;
225
224
let res = match & expr_or_pat {
226
225
Either :: Left ( ast:: Expr :: TryExpr ( try_expr) ) => render:: try_expr ( sema, config, try_expr) ,
227
226
Either :: Left ( ast:: Expr :: PrefixExpr ( prefix_expr) )
@@ -268,39 +267,6 @@ pub(crate) fn hover_for_definition(
268
267
} )
269
268
}
270
269
271
- fn hover_type_fallback (
272
- sema : & Semantics < ' _ , RootDatabase > ,
273
- config : & HoverConfig ,
274
- token : & SyntaxToken ,
275
- original_token : & SyntaxToken ,
276
- ) -> Option < RangeInfo < HoverResult > > {
277
- let node =
278
- token. parent_ancestors ( ) . take_while ( |it| !ast:: Item :: can_cast ( it. kind ( ) ) ) . find ( |n| {
279
- ast:: Expr :: can_cast ( n. kind ( ) )
280
- || ast:: Pat :: can_cast ( n. kind ( ) )
281
- || ast:: Type :: can_cast ( n. kind ( ) )
282
- } ) ?;
283
-
284
- let expr_or_pat = match_ast ! {
285
- match node {
286
- ast:: Expr ( it) => Either :: Left ( it) ,
287
- ast:: Pat ( it) => Either :: Right ( it) ,
288
- // If this node is a MACRO_CALL, it means that `descend_into_macros_many` failed to resolve.
289
- // (e.g expanding a builtin macro). So we give up here.
290
- ast:: MacroCall ( _it) => return None ,
291
- _ => return None ,
292
- }
293
- } ;
294
-
295
- let res = render:: type_info_of ( sema, config, & expr_or_pat) ?;
296
-
297
- let range = sema
298
- . original_range_opt ( & node)
299
- . map ( |frange| frange. range )
300
- . unwrap_or_else ( || original_token. text_range ( ) ) ;
301
- Some ( RangeInfo :: new ( range, res) )
302
- }
303
-
304
270
fn show_implementations_action ( db : & RootDatabase , def : Definition ) -> Option < HoverAction > {
305
271
fn to_action ( nav_target : NavigationTarget ) -> HoverAction {
306
272
HoverAction :: Implementation ( FilePosition {
0 commit comments