diff options
Diffstat (limited to 'crates/ra_hir/src/code_model/src.rs')
-rw-r--r-- | crates/ra_hir/src/code_model/src.rs | 24 |
1 files changed, 12 insertions, 12 deletions
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 | ||