diff options
Diffstat (limited to 'crates/ra_hir/src/code_model')
-rw-r--r-- | crates/ra_hir/src/code_model/attrs.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model/docs.rs | 24 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model/src.rs | 24 |
3 files changed, 27 insertions, 27 deletions
diff --git a/crates/ra_hir/src/code_model/attrs.rs b/crates/ra_hir/src/code_model/attrs.rs index f7db36b66..9e304217c 100644 --- a/crates/ra_hir/src/code_model/attrs.rs +++ b/crates/ra_hir/src/code_model/attrs.rs | |||
@@ -49,9 +49,9 @@ pub(crate) fn attributes_query( | |||
49 | AttrDef::Module(it) => { | 49 | AttrDef::Module(it) => { |
50 | let src = it.declaration_source(db)?; | 50 | let src = it.declaration_source(db)?; |
51 | let hygiene = Hygiene::new(db, src.file_id); | 51 | let hygiene = Hygiene::new(db, src.file_id); |
52 | Attr::from_attrs_owner(&src.ast, &hygiene) | 52 | Attr::from_attrs_owner(&src.value, &hygiene) |
53 | } | 53 | } |
54 | AttrDef::StructField(it) => match it.source(db).ast { | 54 | AttrDef::StructField(it) => match it.source(db).value { |
55 | FieldSource::Named(named) => { | 55 | FieldSource::Named(named) => { |
56 | let src = it.source(db); | 56 | let src = it.source(db); |
57 | let hygiene = Hygiene::new(db, src.file_id); | 57 | let hygiene = Hygiene::new(db, src.file_id); |
@@ -82,7 +82,7 @@ where | |||
82 | { | 82 | { |
83 | let src = node.source(db); | 83 | let src = node.source(db); |
84 | let hygiene = Hygiene::new(db, src.file_id); | 84 | let hygiene = Hygiene::new(db, src.file_id); |
85 | Attr::from_attrs_owner(&src.ast, &hygiene) | 85 | Attr::from_attrs_owner(&src.value, &hygiene) |
86 | } | 86 | } |
87 | 87 | ||
88 | impl<T: Into<AttrDef> + Copy> Attrs for T { | 88 | impl<T: Into<AttrDef> + Copy> Attrs for T { |
diff --git a/crates/ra_hir/src/code_model/docs.rs b/crates/ra_hir/src/code_model/docs.rs index 8533b4f5e..e40efef34 100644 --- a/crates/ra_hir/src/code_model/docs.rs +++ b/crates/ra_hir/src/code_model/docs.rs | |||
@@ -70,23 +70,23 @@ pub(crate) fn documentation_query( | |||
70 | def: DocDef, | 70 | def: DocDef, |
71 | ) -> Option<Documentation> { | 71 | ) -> Option<Documentation> { |
72 | match def { | 72 | match def { |
73 | DocDef::Module(it) => docs_from_ast(&it.declaration_source(db)?.ast), | 73 | DocDef::Module(it) => docs_from_ast(&it.declaration_source(db)?.value), |
74 | DocDef::StructField(it) => match it.source(db).ast { | 74 | DocDef::StructField(it) => match it.source(db).value { |
75 | FieldSource::Named(named) => docs_from_ast(&named), | 75 | FieldSource::Named(named) => docs_from_ast(&named), |
76 | FieldSource::Pos(..) => None, | 76 | FieldSource::Pos(..) => None, |
77 | }, | 77 | }, |
78 | DocDef::Adt(it) => match it { | 78 | DocDef::Adt(it) => match it { |
79 | Adt::Struct(it) => docs_from_ast(&it.source(db).ast), | 79 | Adt::Struct(it) => docs_from_ast(&it.source(db).value), |
80 | Adt::Enum(it) => docs_from_ast(&it.source(db).ast), | 80 | Adt::Enum(it) => docs_from_ast(&it.source(db).value), |
81 | Adt::Union(it) => docs_from_ast(&it.source(db).ast), | 81 | Adt::Union(it) => docs_from_ast(&it.source(db).value), |
82 | }, | 82 | }, |
83 | DocDef::EnumVariant(it) => docs_from_ast(&it.source(db).ast), | 83 | DocDef::EnumVariant(it) => docs_from_ast(&it.source(db).value), |
84 | DocDef::Static(it) => docs_from_ast(&it.source(db).ast), | 84 | DocDef::Static(it) => docs_from_ast(&it.source(db).value), |
85 | DocDef::Const(it) => docs_from_ast(&it.source(db).ast), | 85 | DocDef::Const(it) => docs_from_ast(&it.source(db).value), |
86 | DocDef::Function(it) => docs_from_ast(&it.source(db).ast), | 86 | DocDef::Function(it) => docs_from_ast(&it.source(db).value), |
87 | DocDef::Trait(it) => docs_from_ast(&it.source(db).ast), | 87 | DocDef::Trait(it) => docs_from_ast(&it.source(db).value), |
88 | DocDef::TypeAlias(it) => docs_from_ast(&it.source(db).ast), | 88 | DocDef::TypeAlias(it) => docs_from_ast(&it.source(db).value), |
89 | DocDef::MacroDef(it) => docs_from_ast(&it.source(db).ast), | 89 | DocDef::MacroDef(it) => docs_from_ast(&it.source(db).value), |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index 247ae3e55..556417b0f 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs | |||
@@ -25,9 +25,9 @@ impl Module { | |||
25 | let def_map = db.crate_def_map(self.id.krate); | 25 | let def_map = db.crate_def_map(self.id.krate); |
26 | let decl_id = def_map[self.id.module_id].declaration; | 26 | let decl_id = def_map[self.id.module_id].declaration; |
27 | let file_id = def_map[self.id.module_id].definition; | 27 | let file_id = def_map[self.id.module_id].definition; |
28 | let ast = ModuleSource::new(db, file_id, decl_id); | 28 | let value = ModuleSource::new(db, file_id, decl_id); |
29 | let file_id = file_id.map(HirFileId::from).unwrap_or_else(|| decl_id.unwrap().file_id()); | 29 | let file_id = file_id.map(HirFileId::from).unwrap_or_else(|| decl_id.unwrap().file_id()); |
30 | Source { file_id, ast } | 30 | Source { file_id, value } |
31 | } | 31 | } |
32 | 32 | ||
33 | /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. | 33 | /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. |
@@ -38,8 +38,8 @@ impl Module { | |||
38 | ) -> Option<Source<ast::Module>> { | 38 | ) -> Option<Source<ast::Module>> { |
39 | let def_map = db.crate_def_map(self.id.krate); | 39 | let def_map = db.crate_def_map(self.id.krate); |
40 | let decl = def_map[self.id.module_id].declaration?; | 40 | let decl = def_map[self.id.module_id].declaration?; |
41 | let ast = decl.to_node(db); | 41 | let value = decl.to_node(db); |
42 | Some(Source { file_id: decl.file_id(), ast }) | 42 | Some(Source { file_id: decl.file_id(), value }) |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
@@ -53,11 +53,11 @@ impl HasSource for StructField { | |||
53 | let (file_id, struct_kind) = match self.parent { | 53 | let (file_id, struct_kind) = match self.parent { |
54 | VariantDef::Struct(s) => { | 54 | VariantDef::Struct(s) => { |
55 | ss = s.source(db); | 55 | ss = s.source(db); |
56 | (ss.file_id, ss.ast.kind()) | 56 | (ss.file_id, ss.value.kind()) |
57 | } | 57 | } |
58 | VariantDef::EnumVariant(e) => { | 58 | VariantDef::EnumVariant(e) => { |
59 | es = e.source(db); | 59 | es = e.source(db); |
60 | (es.file_id, es.ast.kind()) | 60 | (es.file_id, es.value.kind()) |
61 | } | 61 | } |
62 | }; | 62 | }; |
63 | 63 | ||
@@ -66,13 +66,13 @@ impl HasSource for StructField { | |||
66 | ast::StructKind::Named(fl) => fl.fields().map(|it| FieldSource::Named(it)).collect(), | 66 | ast::StructKind::Named(fl) => fl.fields().map(|it| FieldSource::Named(it)).collect(), |
67 | ast::StructKind::Unit => Vec::new(), | 67 | ast::StructKind::Unit => Vec::new(), |
68 | }; | 68 | }; |
69 | let ast = field_sources | 69 | let value = field_sources |
70 | .into_iter() | 70 | .into_iter() |
71 | .zip(fields.iter()) | 71 | .zip(fields.iter()) |
72 | .find(|(_syntax, (id, _))| *id == self.id) | 72 | .find(|(_syntax, (id, _))| *id == self.id) |
73 | .unwrap() | 73 | .unwrap() |
74 | .0; | 74 | .0; |
75 | Source { file_id, ast } | 75 | Source { file_id, value } |
76 | } | 76 | } |
77 | } | 77 | } |
78 | impl HasSource for Struct { | 78 | impl HasSource for Struct { |
@@ -98,8 +98,8 @@ impl HasSource for EnumVariant { | |||
98 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::EnumVariant> { | 98 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::EnumVariant> { |
99 | let enum_data = db.enum_data(self.parent.id); | 99 | let enum_data = db.enum_data(self.parent.id); |
100 | let src = self.parent.id.source(db); | 100 | let src = self.parent.id.source(db); |
101 | let ast = src | 101 | let value = src |
102 | .ast | 102 | .value |
103 | .variant_list() | 103 | .variant_list() |
104 | .into_iter() | 104 | .into_iter() |
105 | .flat_map(|it| it.variants()) | 105 | .flat_map(|it| it.variants()) |
@@ -107,7 +107,7 @@ impl HasSource for EnumVariant { | |||
107 | .find(|(_syntax, (id, _))| *id == self.id) | 107 | .find(|(_syntax, (id, _))| *id == self.id) |
108 | .unwrap() | 108 | .unwrap() |
109 | .0; | 109 | .0; |
110 | Source { file_id: src.file_id, ast } | 110 | Source { file_id: src.file_id, value } |
111 | } | 111 | } |
112 | } | 112 | } |
113 | impl HasSource for Function { | 113 | impl HasSource for Function { |
@@ -143,7 +143,7 @@ impl HasSource for TypeAlias { | |||
143 | impl HasSource for MacroDef { | 143 | impl HasSource for MacroDef { |
144 | type Ast = ast::MacroCall; | 144 | type Ast = ast::MacroCall; |
145 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::MacroCall> { | 145 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::MacroCall> { |
146 | Source { file_id: self.id.ast_id.file_id(), ast: self.id.ast_id.to_node(db) } | 146 | Source { file_id: self.id.ast_id.file_id(), value: self.id.ast_id.to_node(db) } |
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||