aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/code_model.rs21
-rw-r--r--crates/ra_hir/src/docs.rs2
-rw-r--r--crates/ra_hir/src/generics.rs2
-rw-r--r--crates/ra_hir/src/traits.rs10
4 files changed, 23 insertions, 12 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 20a8d7d80..0a750b590 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -528,6 +528,13 @@ pub struct EnumVariant {
528 pub(crate) id: EnumVariantId, 528 pub(crate) id: EnumVariantId,
529} 529}
530 530
531impl HasSource for EnumVariant {
532 type Ast = TreeArc<ast::EnumVariant>;
533 fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::EnumVariant>> {
534 self.source_impl(db)
535 }
536}
537
531impl EnumVariant { 538impl EnumVariant {
532 pub fn source( 539 pub fn source(
533 &self, 540 &self,
@@ -886,12 +893,16 @@ pub struct Trait {
886 pub(crate) id: TraitId, 893 pub(crate) id: TraitId,
887} 894}
888 895
896impl HasSource for Trait {
897 type Ast = TreeArc<ast::TraitDef>;
898 fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::TraitDef>> {
899 self.id.source(db).into()
900 }
901}
902
889impl Trait { 903impl Trait {
890 pub fn source( 904 pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::TraitDef>> {
891 self, 905 self.id.source(db).into()
892 db: &(impl DefDatabase + AstDatabase),
893 ) -> (HirFileId, TreeArc<ast::TraitDef>) {
894 self.id.source(db)
895 } 906 }
896 907
897 pub fn module(self, db: &impl DefDatabase) -> Module { 908 pub fn module(self, db: &impl DefDatabase) -> Module {
diff --git a/crates/ra_hir/src/docs.rs b/crates/ra_hir/src/docs.rs
index 1c6b4f205..0cb0c0db8 100644
--- a/crates/ra_hir/src/docs.rs
+++ b/crates/ra_hir/src/docs.rs
@@ -83,7 +83,7 @@ pub(crate) fn documentation_query(
83 DocDef::Const(it) => docs_from_ast(&*it.source(db).ast), 83 DocDef::Const(it) => docs_from_ast(&*it.source(db).ast),
84 DocDef::Function(it) => docs_from_ast(&*it.source(db).ast), 84 DocDef::Function(it) => docs_from_ast(&*it.source(db).ast),
85 DocDef::Union(it) => docs_from_ast(&*it.source(db).1), 85 DocDef::Union(it) => docs_from_ast(&*it.source(db).1),
86 DocDef::Trait(it) => docs_from_ast(&*it.source(db).1), 86 DocDef::Trait(it) => docs_from_ast(&*it.source(db).ast),
87 DocDef::TypeAlias(it) => docs_from_ast(&*it.source(db).ast), 87 DocDef::TypeAlias(it) => docs_from_ast(&*it.source(db).ast),
88 DocDef::MacroDef(it) => docs_from_ast(&*it.source(db).1), 88 DocDef::MacroDef(it) => docs_from_ast(&*it.source(db).1),
89 } 89 }
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs
index b7e255c17..08d711754 100644
--- a/crates/ra_hir/src/generics.rs
+++ b/crates/ra_hir/src/generics.rs
@@ -79,7 +79,7 @@ impl GenericParams {
79 name: Name::self_type(), 79 name: Name::self_type(),
80 default: None, 80 default: None,
81 }); 81 });
82 generics.fill(&*it.source(db).1, start + 1); 82 generics.fill(&*it.source(db).ast, start + 1);
83 } 83 }
84 GenericDef::TypeAlias(it) => generics.fill(&*it.source(db).ast, start), 84 GenericDef::TypeAlias(it) => generics.fill(&*it.source(db).ast, start),
85 GenericDef::ImplBlock(it) => generics.fill(&*it.source(db).1, start), 85 GenericDef::ImplBlock(it) => generics.fill(&*it.source(db).1, start),
diff --git a/crates/ra_hir/src/traits.rs b/crates/ra_hir/src/traits.rs
index 967654e97..86dceb2e0 100644
--- a/crates/ra_hir/src/traits.rs
+++ b/crates/ra_hir/src/traits.rs
@@ -22,12 +22,12 @@ impl TraitData {
22 db: &(impl DefDatabase + AstDatabase), 22 db: &(impl DefDatabase + AstDatabase),
23 tr: Trait, 23 tr: Trait,
24 ) -> Arc<TraitData> { 24 ) -> Arc<TraitData> {
25 let (file_id, node) = tr.source(db); 25 let src = tr.source(db);
26 let name = node.name().map(|n| n.as_name()); 26 let name = src.ast.name().map(|n| n.as_name());
27 let module = tr.module(db); 27 let module = tr.module(db);
28 let ctx = LocationCtx::new(db, module, file_id); 28 let ctx = LocationCtx::new(db, module, src.file_id);
29 let auto = node.is_auto(); 29 let auto = src.ast.is_auto();
30 let items = if let Some(item_list) = node.item_list() { 30 let items = if let Some(item_list) = src.ast.item_list() {
31 item_list 31 item_list
32 .impl_items() 32 .impl_items()
33 .map(|item_node| match item_node.kind() { 33 .map(|item_node| match item_node.kind() {