aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r--crates/ra_hir/src/code_model.rs48
1 files changed, 23 insertions, 25 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 6602d1220..ebbc37c0e 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -282,7 +282,7 @@ impl Module {
282 .collect() 282 .collect()
283 } 283 }
284 284
285 pub fn impl_blocks(self, db: &impl HirDatabase) -> Vec<ImplBlock> { 285 pub fn impl_blocks(self, db: &impl DefDatabase) -> Vec<ImplBlock> {
286 let module_impl_blocks = db.impls_in_module(self); 286 let module_impl_blocks = db.impls_in_module(self);
287 module_impl_blocks 287 module_impl_blocks
288 .impls 288 .impls
@@ -519,9 +519,8 @@ pub struct Function {
519 pub(crate) id: FunctionId, 519 pub(crate) id: FunctionId,
520} 520}
521 521
522/// The declared signature of a function.
523#[derive(Debug, Clone, PartialEq, Eq)] 522#[derive(Debug, Clone, PartialEq, Eq)]
524pub struct FnSignature { 523pub struct FnData {
525 pub(crate) name: Name, 524 pub(crate) name: Name,
526 pub(crate) params: Vec<TypeRef>, 525 pub(crate) params: Vec<TypeRef>,
527 pub(crate) ret_type: TypeRef, 526 pub(crate) ret_type: TypeRef,
@@ -530,11 +529,11 @@ pub struct FnSignature {
530 pub(crate) has_self_param: bool, 529 pub(crate) has_self_param: bool,
531} 530}
532 531
533impl FnSignature { 532impl FnData {
534 pub(crate) fn fn_signature_query( 533 pub(crate) fn fn_data_query(
535 db: &(impl DefDatabase + AstDatabase), 534 db: &(impl DefDatabase + AstDatabase),
536 func: Function, 535 func: Function,
537 ) -> Arc<FnSignature> { 536 ) -> Arc<FnData> {
538 let src = func.source(db); 537 let src = func.source(db);
539 let name = src.ast.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); 538 let name = src.ast.name().map(|n| n.as_name()).unwrap_or_else(Name::missing);
540 let mut params = Vec::new(); 539 let mut params = Vec::new();
@@ -569,7 +568,7 @@ impl FnSignature {
569 TypeRef::unit() 568 TypeRef::unit()
570 }; 569 };
571 570
572 let sig = FnSignature { name, params, ret_type, has_self_param }; 571 let sig = FnData { name, params, ret_type, has_self_param };
573 Arc::new(sig) 572 Arc::new(sig)
574 } 573 }
575 pub fn name(&self) -> &Name { 574 pub fn name(&self) -> &Name {
@@ -597,7 +596,7 @@ impl Function {
597 } 596 }
598 597
599 pub fn name(self, db: &impl HirDatabase) -> Name { 598 pub fn name(self, db: &impl HirDatabase) -> Name {
600 self.signature(db).name.clone() 599 self.data(db).name.clone()
601 } 600 }
602 601
603 pub(crate) fn body_source_map(self, db: &impl HirDatabase) -> Arc<BodySourceMap> { 602 pub(crate) fn body_source_map(self, db: &impl HirDatabase) -> Arc<BodySourceMap> {
@@ -612,8 +611,8 @@ impl Function {
612 db.type_for_def(self.into(), Namespace::Values) 611 db.type_for_def(self.into(), Namespace::Values)
613 } 612 }
614 613
615 pub fn signature(self, db: &impl HirDatabase) -> Arc<FnSignature> { 614 pub fn data(self, db: &impl HirDatabase) -> Arc<FnData> {
616 db.fn_signature(self) 615 db.fn_data(self)
617 } 616 }
618 617
619 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> { 618 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
@@ -670,8 +669,8 @@ impl Const {
670 self.id.module(db) 669 self.id.module(db)
671 } 670 }
672 671
673 pub fn signature(self, db: &impl HirDatabase) -> Arc<ConstSignature> { 672 pub fn data(self, db: &impl HirDatabase) -> Arc<ConstData> {
674 db.const_signature(self) 673 db.const_data(self)
675 } 674 }
676 675
677 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> { 676 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
@@ -696,14 +695,13 @@ impl Const {
696 } 695 }
697} 696}
698 697
699/// The declared signature of a const.
700#[derive(Debug, Clone, PartialEq, Eq)] 698#[derive(Debug, Clone, PartialEq, Eq)]
701pub struct ConstSignature { 699pub struct ConstData {
702 pub(crate) name: Name, 700 pub(crate) name: Name,
703 pub(crate) type_ref: TypeRef, 701 pub(crate) type_ref: TypeRef,
704} 702}
705 703
706impl ConstSignature { 704impl ConstData {
707 pub fn name(&self) -> &Name { 705 pub fn name(&self) -> &Name {
708 &self.name 706 &self.name
709 } 707 }
@@ -712,27 +710,27 @@ impl ConstSignature {
712 &self.type_ref 710 &self.type_ref
713 } 711 }
714 712
715 pub(crate) fn const_signature_query( 713 pub(crate) fn const_data_query(
716 db: &(impl DefDatabase + AstDatabase), 714 db: &(impl DefDatabase + AstDatabase),
717 konst: Const, 715 konst: Const,
718 ) -> Arc<ConstSignature> { 716 ) -> Arc<ConstData> {
719 let node = konst.source(db).ast; 717 let node = konst.source(db).ast;
720 const_signature_for(&*node) 718 const_data_for(&*node)
721 } 719 }
722 720
723 pub(crate) fn static_signature_query( 721 pub(crate) fn static_data_query(
724 db: &(impl DefDatabase + AstDatabase), 722 db: &(impl DefDatabase + AstDatabase),
725 konst: Static, 723 konst: Static,
726 ) -> Arc<ConstSignature> { 724 ) -> Arc<ConstData> {
727 let node = konst.source(db).ast; 725 let node = konst.source(db).ast;
728 const_signature_for(&*node) 726 const_data_for(&*node)
729 } 727 }
730} 728}
731 729
732fn const_signature_for<N: NameOwner + TypeAscriptionOwner>(node: &N) -> Arc<ConstSignature> { 730fn const_data_for<N: NameOwner + TypeAscriptionOwner>(node: &N) -> Arc<ConstData> {
733 let name = node.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); 731 let name = node.name().map(|n| n.as_name()).unwrap_or_else(Name::missing);
734 let type_ref = TypeRef::from_ast_opt(node.ascribed_type()); 732 let type_ref = TypeRef::from_ast_opt(node.ascribed_type());
735 let sig = ConstSignature { name, type_ref }; 733 let sig = ConstData { name, type_ref };
736 Arc::new(sig) 734 Arc::new(sig)
737} 735}
738 736
@@ -746,8 +744,8 @@ impl Static {
746 self.id.module(db) 744 self.id.module(db)
747 } 745 }
748 746
749 pub fn signature(self, db: &impl HirDatabase) -> Arc<ConstSignature> { 747 pub fn data(self, db: &impl HirDatabase) -> Arc<ConstData> {
750 db.static_signature(self) 748 db.static_data(self)
751 } 749 }
752 750
753 /// Builds a resolver for code inside this item. 751 /// Builds a resolver for code inside this item.