@@ -16,6 +16,7 @@ use rustc_hash::FxHashSet;
1616use salsa:: { Database , ParallelDatabase } ;
1717use hir:: {
1818 self ,
19+ source_binder,
1920 FnSignatureInfo ,
2021 Problem ,
2122} ;
@@ -166,7 +167,7 @@ impl AnalysisImpl {
166167 /// This return `Vec`: a module may be included from several places. We
167168 /// don't handle this case yet though, so the Vec has length at most one.
168169 pub fn parent_module ( & self , position : FilePosition ) -> Cancelable < Vec < ( FileId , FileSymbol ) > > {
169- let descr = match hir :: Module :: guess_from_position ( & * self . db , position) ? {
170+ let descr = match source_binder :: module_from_position ( & * self . db , position) ? {
170171 None => return Ok ( Vec :: new ( ) ) ,
171172 Some ( it) => it,
172173 } ;
@@ -185,7 +186,7 @@ impl AnalysisImpl {
185186 }
186187 /// Returns `Vec` for the same reason as `parent_module`
187188 pub fn crate_for ( & self , file_id : FileId ) -> Cancelable < Vec < CrateId > > {
188- let descr = match hir :: Module :: guess_from_file_id ( & * self . db , file_id) ? {
189+ let descr = match source_binder :: module_from_file_id ( & * self . db , file_id) ? {
189190 None => return Ok ( Vec :: new ( ) ) ,
190191 Some ( it) => it,
191192 } ;
@@ -209,9 +210,11 @@ impl AnalysisImpl {
209210 let file = self . db . source_file ( position. file_id ) ;
210211 let syntax = file. syntax ( ) ;
211212 if let Some ( name_ref) = find_node_at_offset :: < ast:: NameRef > ( syntax, position. offset ) {
212- if let Some ( fn_descr) =
213- hir:: Function :: guess_for_name_ref ( & * self . db , position. file_id , name_ref) ?
214- {
213+ if let Some ( fn_descr) = source_binder:: function_from_child_node (
214+ & * self . db ,
215+ position. file_id ,
216+ name_ref. syntax ( ) ,
217+ ) ? {
215218 let scope = fn_descr. scope ( & * self . db ) ;
216219 // First try to resolve the symbol locally
217220 if let Some ( entry) = scope. resolve_local_name ( name_ref) {
@@ -234,7 +237,7 @@ impl AnalysisImpl {
234237 if let Some ( module) = name. syntax ( ) . parent ( ) . and_then ( ast:: Module :: cast) {
235238 if module. has_semi ( ) {
236239 let parent_module =
237- hir :: Module :: guess_from_file_id ( & * self . db , position. file_id ) ?;
240+ source_binder :: module_from_file_id ( & * self . db , position. file_id ) ?;
238241 let child_name = module. name ( ) ;
239242 match ( parent_module, child_name) {
240243 ( Some ( parent_module) , Some ( child_name) ) => {
@@ -282,18 +285,18 @@ impl AnalysisImpl {
282285 ) -> Cancelable < Option < ( ast:: BindPat < ' a > , hir:: Function ) > > {
283286 let syntax = source_file. syntax ( ) ;
284287 if let Some ( binding) = find_node_at_offset :: < ast:: BindPat > ( syntax, position. offset ) {
285- let descr = ctry ! ( hir :: Function :: guess_for_bind_pat (
288+ let descr = ctry ! ( source_binder :: function_from_child_node (
286289 db,
287290 position. file_id,
288- binding
291+ binding. syntax ( ) ,
289292 ) ?) ;
290293 return Ok ( Some ( ( binding, descr) ) ) ;
291294 } ;
292295 let name_ref = ctry ! ( find_node_at_offset:: <ast:: NameRef >( syntax, position. offset) ) ;
293- let descr = ctry ! ( hir :: Function :: guess_for_name_ref (
296+ let descr = ctry ! ( source_binder :: function_from_child_node (
294297 db,
295298 position. file_id,
296- name_ref
299+ name_ref. syntax ( ) ,
297300 ) ?) ;
298301 let scope = descr. scope ( db) ;
299302 let resolved = ctry ! ( scope. resolve_local_name( name_ref) ) ;
@@ -327,7 +330,7 @@ impl AnalysisImpl {
327330 fix : None ,
328331 } )
329332 . collect :: < Vec < _ > > ( ) ;
330- if let Some ( m) = hir :: Module :: guess_from_file_id ( & * self . db , file_id) ? {
333+ if let Some ( m) = source_binder :: module_from_file_id ( & * self . db , file_id) ? {
331334 for ( name_node, problem) in m. problems ( & * self . db ) {
332335 let diag = match problem {
333336 Problem :: UnresolvedModule { candidate } => {
@@ -418,7 +421,7 @@ impl AnalysisImpl {
418421 if fs. kind == FN_DEF {
419422 let fn_file = self . db . source_file ( fn_file_id) ;
420423 if let Some ( fn_def) = find_node_at_offset ( fn_file. syntax ( ) , fs. node_range . start ( ) ) {
421- let descr = ctry ! ( hir :: Function :: guess_from_source (
424+ let descr = ctry ! ( source_binder :: function_from_source (
422425 & * self . db, fn_file_id, fn_def
423426 ) ?) ;
424427 if let Some ( descriptor) = descr. signature_info ( & * self . db ) {
0 commit comments