diff options
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r-- | crates/ra_hir_def/src/resolver.rs | 78 |
1 files changed, 37 insertions, 41 deletions
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index 1bc9c1760..7b5c3ec06 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs | |||
@@ -369,47 +369,6 @@ impl Resolver { | |||
369 | } | 369 | } |
370 | } | 370 | } |
371 | 371 | ||
372 | impl Resolver { | ||
373 | pub(crate) fn push_scope(mut self, scope: Scope) -> Resolver { | ||
374 | self.scopes.push(scope); | ||
375 | self | ||
376 | } | ||
377 | |||
378 | pub(crate) fn push_generic_params_scope( | ||
379 | self, | ||
380 | db: &impl DefDatabase2, | ||
381 | def: GenericDefId, | ||
382 | ) -> Resolver { | ||
383 | let params = db.generic_params(def); | ||
384 | if params.params.is_empty() { | ||
385 | self | ||
386 | } else { | ||
387 | self.push_scope(Scope::GenericParams { def, params }) | ||
388 | } | ||
389 | } | ||
390 | |||
391 | pub(crate) fn push_impl_block_scope(self, impl_block: ImplId) -> Resolver { | ||
392 | self.push_scope(Scope::ImplBlockScope(impl_block)) | ||
393 | } | ||
394 | |||
395 | pub(crate) fn push_module_scope( | ||
396 | self, | ||
397 | crate_def_map: Arc<CrateDefMap>, | ||
398 | module_id: CrateModuleId, | ||
399 | ) -> Resolver { | ||
400 | self.push_scope(Scope::ModuleScope(ModuleItemMap { crate_def_map, module_id })) | ||
401 | } | ||
402 | |||
403 | pub(crate) fn push_expr_scope( | ||
404 | self, | ||
405 | owner: DefWithBodyId, | ||
406 | expr_scopes: Arc<ExprScopes>, | ||
407 | scope_id: ScopeId, | ||
408 | ) -> Resolver { | ||
409 | self.push_scope(Scope::ExprScope(ExprScope { owner, expr_scopes, scope_id })) | ||
410 | } | ||
411 | } | ||
412 | |||
413 | pub enum ScopeDef { | 372 | pub enum ScopeDef { |
414 | PerNs(PerNs), | 373 | PerNs(PerNs), |
415 | ImplSelfType(ImplId), | 374 | ImplSelfType(ImplId), |
@@ -489,6 +448,43 @@ pub fn resolver_for_scope( | |||
489 | r | 448 | r |
490 | } | 449 | } |
491 | 450 | ||
451 | impl Resolver { | ||
452 | fn push_scope(mut self, scope: Scope) -> Resolver { | ||
453 | self.scopes.push(scope); | ||
454 | self | ||
455 | } | ||
456 | |||
457 | fn push_generic_params_scope(self, db: &impl DefDatabase2, def: GenericDefId) -> Resolver { | ||
458 | let params = db.generic_params(def); | ||
459 | if params.params.is_empty() { | ||
460 | self | ||
461 | } else { | ||
462 | self.push_scope(Scope::GenericParams { def, params }) | ||
463 | } | ||
464 | } | ||
465 | |||
466 | fn push_impl_block_scope(self, impl_block: ImplId) -> Resolver { | ||
467 | self.push_scope(Scope::ImplBlockScope(impl_block)) | ||
468 | } | ||
469 | |||
470 | fn push_module_scope( | ||
471 | self, | ||
472 | crate_def_map: Arc<CrateDefMap>, | ||
473 | module_id: CrateModuleId, | ||
474 | ) -> Resolver { | ||
475 | self.push_scope(Scope::ModuleScope(ModuleItemMap { crate_def_map, module_id })) | ||
476 | } | ||
477 | |||
478 | fn push_expr_scope( | ||
479 | self, | ||
480 | owner: DefWithBodyId, | ||
481 | expr_scopes: Arc<ExprScopes>, | ||
482 | scope_id: ScopeId, | ||
483 | ) -> Resolver { | ||
484 | self.push_scope(Scope::ExprScope(ExprScope { owner, expr_scopes, scope_id })) | ||
485 | } | ||
486 | } | ||
487 | |||
492 | pub trait HasResolver { | 488 | pub trait HasResolver { |
493 | /// Builds a resolver for type references inside this def. | 489 | /// Builds a resolver for type references inside this def. |
494 | fn resolver(self, db: &impl DefDatabase2) -> Resolver; | 490 | fn resolver(self, db: &impl DefDatabase2) -> Resolver; |