@@ -8,7 +8,7 @@ use test_utils::tested_by;
88use super :: { NameDefinition , NameKind } ;
99use ra_ide_db:: RootDatabase ;
1010
11- pub use ra_ide_db:: defs:: { classify_name, from_assoc_item , from_module_def, from_struct_field} ;
11+ pub use ra_ide_db:: defs:: { classify_name, from_module_def, from_struct_field} ;
1212
1313pub ( crate ) fn classify_name_ref (
1414 sb : & mut SourceBinder < RootDatabase > ,
@@ -22,7 +22,7 @@ pub(crate) fn classify_name_ref(
2222 if let Some ( method_call) = ast:: MethodCallExpr :: cast ( parent. clone ( ) ) {
2323 tested_by ! ( goto_def_for_methods) ;
2424 if let Some ( func) = analyzer. resolve_method_call ( & method_call) {
25- return Some ( from_assoc_item ( sb. db , func. into ( ) ) ) ;
25+ return Some ( from_module_def ( sb. db , func. into ( ) , None ) ) ;
2626 }
2727 }
2828
@@ -57,27 +57,35 @@ pub(crate) fn classify_name_ref(
5757
5858 let path = name_ref. value . syntax ( ) . ancestors ( ) . find_map ( ast:: Path :: cast) ?;
5959 let resolved = analyzer. resolve_path ( sb. db , & path) ?;
60- match resolved {
61- PathResolution :: Def ( def) => Some ( from_module_def ( sb. db , def, Some ( container) ) ) ,
62- PathResolution :: AssocItem ( item) => Some ( from_assoc_item ( sb. db , item) ) ,
60+ let res = match resolved {
61+ PathResolution :: Def ( def) => from_module_def ( sb. db , def, Some ( container) ) ,
62+ PathResolution :: AssocItem ( item) => {
63+ let def = match item {
64+ hir:: AssocItem :: Function ( it) => it. into ( ) ,
65+ hir:: AssocItem :: Const ( it) => it. into ( ) ,
66+ hir:: AssocItem :: TypeAlias ( it) => it. into ( ) ,
67+ } ;
68+ from_module_def ( sb. db , def, Some ( container) )
69+ }
6370 PathResolution :: Local ( local) => {
6471 let kind = NameKind :: Local ( local) ;
6572 let container = local. module ( sb. db ) ;
66- Some ( NameDefinition { kind, container, visibility : None } )
73+ NameDefinition { kind, container, visibility : None }
6774 }
6875 PathResolution :: TypeParam ( par) => {
6976 let kind = NameKind :: TypeParam ( par) ;
7077 let container = par. module ( sb. db ) ;
71- Some ( NameDefinition { kind, container, visibility } )
78+ NameDefinition { kind, container, visibility }
7279 }
7380 PathResolution :: Macro ( def) => {
7481 let kind = NameKind :: Macro ( def) ;
75- Some ( NameDefinition { kind, container, visibility } )
82+ NameDefinition { kind, container, visibility }
7683 }
7784 PathResolution :: SelfType ( impl_block) => {
7885 let kind = NameKind :: SelfType ( impl_block) ;
7986 let container = impl_block. module ( sb. db ) ;
80- Some ( NameDefinition { kind, container, visibility } )
87+ NameDefinition { kind, container, visibility }
8188 }
82- }
89+ } ;
90+ Some ( res)
8391}
0 commit comments