aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-20 10:10:03 +0000
committerGitHub <[email protected]>2019-11-20 10:10:03 +0000
commit3d56e3d85516fe9061aea84571ac88c3322a687c (patch)
treebd923b623ffe43df04ef00e1f0662c00c0d919d1
parentfa50b16cb2309c0c4fcb4e90378993a1f3d2ffb6 (diff)
parent51baaf298d4ac56036062786bf070aeab7ab8e79 (diff)
Merge #2323
2323: Rename with_ast -> with_value r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/ra_hir/src/source_binder.rs12
-rw-r--r--crates/ra_hir_expand/src/lib.rs8
-rw-r--r--crates/ra_ide_api/src/display/navigation_target.rs10
-rw-r--r--crates/ra_ide_api/src/expand.rs4
-rw-r--r--crates/ra_ide_api/src/goto_definition.rs30
-rw-r--r--crates/ra_ide_api/src/goto_type_definition.rs2
-rw-r--r--crates/ra_ide_api/src/hover.rs4
-rw-r--r--crates/ra_ide_api/src/references/classify.rs32
8 files changed, 51 insertions, 51 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 471b0b089..a1c1daacd 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -33,19 +33,19 @@ fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -
33 match_ast! { 33 match_ast! {
34 match (node.value) { 34 match (node.value) {
35 ast::Module(it) => { 35 ast::Module(it) => {
36 let src = node.with_ast(it); 36 let src = node.with_value(it);
37 Some(crate::Module::from_declaration(db, src)?.resolver(db)) 37 Some(crate::Module::from_declaration(db, src)?.resolver(db))
38 }, 38 },
39 ast::SourceFile(it) => { 39 ast::SourceFile(it) => {
40 let src = node.with_ast(crate::ModuleSource::SourceFile(it)); 40 let src = node.with_value(crate::ModuleSource::SourceFile(it));
41 Some(crate::Module::from_definition(db, src)?.resolver(db)) 41 Some(crate::Module::from_definition(db, src)?.resolver(db))
42 }, 42 },
43 ast::StructDef(it) => { 43 ast::StructDef(it) => {
44 let src = node.with_ast(it); 44 let src = node.with_value(it);
45 Some(Struct::from_source(db, src)?.resolver(db)) 45 Some(Struct::from_source(db, src)?.resolver(db))
46 }, 46 },
47 ast::EnumDef(it) => { 47 ast::EnumDef(it) => {
48 let src = node.with_ast(it); 48 let src = node.with_value(it);
49 Some(Enum::from_source(db, src)?.resolver(db)) 49 Some(Enum::from_source(db, src)?.resolver(db))
50 }, 50 },
51 _ => match node.value.kind() { 51 _ => match node.value.kind() {
@@ -157,7 +157,7 @@ impl SourceAnalyzer {
157 let scopes = def.expr_scopes(db); 157 let scopes = def.expr_scopes(db);
158 let scope = match offset { 158 let scope = match offset {
159 None => scope_for(&scopes, &source_map, node), 159 None => scope_for(&scopes, &source_map, node),
160 Some(offset) => scope_for_offset(&scopes, &source_map, node.with_ast(offset)), 160 Some(offset) => scope_for_offset(&scopes, &source_map, node.with_value(offset)),
161 }; 161 };
162 let resolver = expr::resolver_for_scope(db, def, scope); 162 let resolver = expr::resolver_for_scope(db, def, scope);
163 SourceAnalyzer { 163 SourceAnalyzer {
@@ -173,7 +173,7 @@ impl SourceAnalyzer {
173 resolver: node 173 resolver: node
174 .value 174 .value
175 .ancestors() 175 .ancestors()
176 .find_map(|it| try_get_resolver_for_node(db, node.with_ast(&it))) 176 .find_map(|it| try_get_resolver_for_node(db, node.with_value(&it)))
177 .unwrap_or_default(), 177 .unwrap_or_default(),
178 body_owner: None, 178 body_owner: None,
179 body_source_map: None, 179 body_source_map: None,
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index 6ca4bc7a3..1389f64ce 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -174,7 +174,7 @@ impl ExpansionInfo {
174 174
175 let token = algo::find_covering_element(&self.expanded.value, range).into_token()?; 175 let token = algo::find_covering_element(&self.expanded.value, range).into_token()?;
176 176
177 Some(self.expanded.with_ast(token)) 177 Some(self.expanded.with_value(token))
178 } 178 }
179 179
180 pub fn map_token_up(&self, token: Source<&SyntaxToken>) -> Option<Source<SyntaxToken>> { 180 pub fn map_token_up(&self, token: Source<&SyntaxToken>) -> Option<Source<SyntaxToken>> {
@@ -192,7 +192,7 @@ impl ExpansionInfo {
192 range + tt.value.syntax().text_range().start(), 192 range + tt.value.syntax().text_range().start(),
193 ) 193 )
194 .into_token()?; 194 .into_token()?;
195 Some(tt.with_ast(token)) 195 Some(tt.with_value(token))
196 } 196 }
197} 197}
198 198
@@ -259,7 +259,7 @@ impl<T> Source<T> {
259 } 259 }
260 260
261 // Similarly, naming here is stupid... 261 // Similarly, naming here is stupid...
262 pub fn with_ast<U>(&self, value: U) -> Source<U> { 262 pub fn with_value<U>(&self, value: U) -> Source<U> {
263 Source::new(self.file_id, value) 263 Source::new(self.file_id, value)
264 } 264 }
265 265
@@ -267,7 +267,7 @@ impl<T> Source<T> {
267 Source::new(self.file_id, f(self.value)) 267 Source::new(self.file_id, f(self.value))
268 } 268 }
269 pub fn as_ref(&self) -> Source<&T> { 269 pub fn as_ref(&self) -> Source<&T> {
270 self.with_ast(&self.value) 270 self.with_value(&self.value)
271 } 271 }
272 pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode { 272 pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode {
273 db.parse_or_expand(self.file_id).expect("source created from invalid file") 273 db.parse_or_expand(self.file_id).expect("source created from invalid file")
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs
index 50accafd0..6ac60722b 100644
--- a/crates/ra_ide_api/src/display/navigation_target.rs
+++ b/crates/ra_ide_api/src/display/navigation_target.rs
@@ -148,7 +148,7 @@ impl NavigationTarget {
148 //FIXME: use `_` instead of empty string 148 //FIXME: use `_` instead of empty string
149 let name = node.value.name().map(|it| it.text().clone()).unwrap_or_default(); 149 let name = node.value.name().map(|it| it.text().clone()).unwrap_or_default();
150 let focus_range = 150 let focus_range =
151 node.value.name().map(|it| original_range(db, node.with_ast(it.syntax())).range); 151 node.value.name().map(|it| original_range(db, node.with_value(it.syntax())).range);
152 let frange = original_range(db, node.map(|it| it.syntax())); 152 let frange = original_range(db, node.map(|it| it.syntax()));
153 153
154 NavigationTarget::from_syntax( 154 NavigationTarget::from_syntax(
@@ -232,7 +232,7 @@ impl ToNav for hir::Module {
232 let name = self.name(db).map(|it| it.to_string().into()).unwrap_or_default(); 232 let name = self.name(db).map(|it| it.to_string().into()).unwrap_or_default();
233 match &src.value { 233 match &src.value {
234 ModuleSource::SourceFile(node) => { 234 ModuleSource::SourceFile(node) => {
235 let frange = original_range(db, src.with_ast(node.syntax())); 235 let frange = original_range(db, src.with_value(node.syntax()));
236 236
237 NavigationTarget::from_syntax( 237 NavigationTarget::from_syntax(
238 frange.file_id, 238 frange.file_id,
@@ -245,7 +245,7 @@ impl ToNav for hir::Module {
245 ) 245 )
246 } 246 }
247 ModuleSource::Module(node) => { 247 ModuleSource::Module(node) => {
248 let frange = original_range(db, src.with_ast(node.syntax())); 248 let frange = original_range(db, src.with_value(node.syntax()));
249 249
250 NavigationTarget::from_syntax( 250 NavigationTarget::from_syntax(
251 frange.file_id, 251 frange.file_id,
@@ -285,12 +285,12 @@ impl ToNav for hir::StructField {
285 match &src.value { 285 match &src.value {
286 FieldSource::Named(it) => NavigationTarget::from_named( 286 FieldSource::Named(it) => NavigationTarget::from_named(
287 db, 287 db,
288 src.with_ast(it), 288 src.with_value(it),
289 it.doc_comment_text(), 289 it.doc_comment_text(),
290 it.short_label(), 290 it.short_label(),
291 ), 291 ),
292 FieldSource::Pos(it) => { 292 FieldSource::Pos(it) => {
293 let frange = original_range(db, src.with_ast(it.syntax())); 293 let frange = original_range(db, src.with_value(it.syntax()));
294 NavigationTarget::from_syntax( 294 NavigationTarget::from_syntax(
295 frange.file_id, 295 frange.file_id,
296 "".into(), 296 "".into(),
diff --git a/crates/ra_ide_api/src/expand.rs b/crates/ra_ide_api/src/expand.rs
index 0228bced9..0ad125a9e 100644
--- a/crates/ra_ide_api/src/expand.rs
+++ b/crates/ra_ide_api/src/expand.rs
@@ -28,7 +28,7 @@ pub(crate) fn original_range(db: &RootDatabase, node: Source<&SyntaxNode>) -> Fi
28 .value 28 .value
29 .descendants_with_tokens() 29 .descendants_with_tokens()
30 .filter_map(|it| it.into_token()) 30 .filter_map(|it| it.into_token())
31 .find_map(|it| expansion.map_token_up(node.with_ast(&it))); 31 .find_map(|it| expansion.map_token_up(node.with_value(&it)));
32 32
33 match token { 33 match token {
34 Some(it) => { 34 Some(it) => {
@@ -54,7 +54,7 @@ pub(crate) fn descend_into_macros(
54 return None; 54 return None;
55 } 55 }
56 let source_analyzer = 56 let source_analyzer =
57 hir::SourceAnalyzer::new(db, token.with_ast(token.value.parent()).as_ref(), None); 57 hir::SourceAnalyzer::new(db, token.with_value(token.value.parent()).as_ref(), None);
58 let exp = source_analyzer.expand(db, &macro_call)?; 58 let exp = source_analyzer.expand(db, &macro_call)?;
59 exp.map_token_down(db, token.as_ref()) 59 exp.map_token_down(db, token.as_ref())
60 }) 60 })
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs
index ed9d99a7f..b6c72efdf 100644
--- a/crates/ra_ide_api/src/goto_definition.rs
+++ b/crates/ra_ide_api/src/goto_definition.rs
@@ -25,11 +25,11 @@ pub(crate) fn goto_definition(
25 let res = match_ast! { 25 let res = match_ast! {
26 match (token.value.parent()) { 26 match (token.value.parent()) {
27 ast::NameRef(name_ref) => { 27 ast::NameRef(name_ref) => {
28 let navs = reference_definition(db, token.with_ast(&name_ref)).to_vec(); 28 let navs = reference_definition(db, token.with_value(&name_ref)).to_vec();
29 RangeInfo::new(name_ref.syntax().text_range(), navs.to_vec()) 29 RangeInfo::new(name_ref.syntax().text_range(), navs.to_vec())
30 }, 30 },
31 ast::Name(name) => { 31 ast::Name(name) => {
32 let navs = name_definition(db, token.with_ast(&name))?; 32 let navs = name_definition(db, token.with_value(&name))?;
33 RangeInfo::new(name.syntax().text_range(), navs) 33 RangeInfo::new(name.syntax().text_range(), navs)
34 34
35 }, 35 },
@@ -99,7 +99,7 @@ pub(crate) fn name_definition(
99 99
100 if let Some(module) = ast::Module::cast(parent.clone()) { 100 if let Some(module) = ast::Module::cast(parent.clone()) {
101 if module.has_semi() { 101 if module.has_semi() {
102 let src = name.with_ast(module); 102 let src = name.with_value(module);
103 if let Some(child_module) = hir::Module::from_declaration(db, src) { 103 if let Some(child_module) = hir::Module::from_declaration(db, src) {
104 let nav = child_module.to_nav(db); 104 let nav = child_module.to_nav(db);
105 return Some(vec![nav]); 105 return Some(vec![nav]);
@@ -107,7 +107,7 @@ pub(crate) fn name_definition(
107 } 107 }
108 } 108 }
109 109
110 if let Some(nav) = named_target(db, name.with_ast(&parent)) { 110 if let Some(nav) = named_target(db, name.with_value(&parent)) {
111 return Some(vec![nav]); 111 return Some(vec![nav]);
112 } 112 }
113 113
@@ -120,7 +120,7 @@ fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option<Navigati
120 ast::StructDef(it) => { 120 ast::StructDef(it) => {
121 Some(NavigationTarget::from_named( 121 Some(NavigationTarget::from_named(
122 db, 122 db,
123 node.with_ast(&it), 123 node.with_value(&it),
124 it.doc_comment_text(), 124 it.doc_comment_text(),
125 it.short_label(), 125 it.short_label(),
126 )) 126 ))
@@ -128,7 +128,7 @@ fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option<Navigati
128 ast::EnumDef(it) => { 128 ast::EnumDef(it) => {
129 Some(NavigationTarget::from_named( 129 Some(NavigationTarget::from_named(
130 db, 130 db,
131 node.with_ast(&it), 131 node.with_value(&it),
132 it.doc_comment_text(), 132 it.doc_comment_text(),
133 it.short_label(), 133 it.short_label(),
134 )) 134 ))
@@ -136,7 +136,7 @@ fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option<Navigati
136 ast::EnumVariant(it) => { 136 ast::EnumVariant(it) => {
137 Some(NavigationTarget::from_named( 137 Some(NavigationTarget::from_named(
138 db, 138 db,
139 node.with_ast(&it), 139 node.with_value(&it),
140 it.doc_comment_text(), 140 it.doc_comment_text(),
141 it.short_label(), 141 it.short_label(),
142 )) 142 ))
@@ -144,7 +144,7 @@ fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option<Navigati
144 ast::FnDef(it) => { 144 ast::FnDef(it) => {
145 Some(NavigationTarget::from_named( 145 Some(NavigationTarget::from_named(
146 db, 146 db,
147 node.with_ast(&it), 147 node.with_value(&it),
148 it.doc_comment_text(), 148 it.doc_comment_text(),
149 it.short_label(), 149 it.short_label(),
150 )) 150 ))
@@ -152,7 +152,7 @@ fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option<Navigati
152 ast::TypeAliasDef(it) => { 152 ast::TypeAliasDef(it) => {
153 Some(NavigationTarget::from_named( 153 Some(NavigationTarget::from_named(
154 db, 154 db,
155 node.with_ast(&it), 155 node.with_value(&it),
156 it.doc_comment_text(), 156 it.doc_comment_text(),
157 it.short_label(), 157 it.short_label(),
158 )) 158 ))
@@ -160,7 +160,7 @@ fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option<Navigati
160 ast::ConstDef(it) => { 160 ast::ConstDef(it) => {
161 Some(NavigationTarget::from_named( 161 Some(NavigationTarget::from_named(
162 db, 162 db,
163 node.with_ast(&it), 163 node.with_value(&it),
164 it.doc_comment_text(), 164 it.doc_comment_text(),
165 it.short_label(), 165 it.short_label(),
166 )) 166 ))
@@ -168,7 +168,7 @@ fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option<Navigati
168 ast::StaticDef(it) => { 168 ast::StaticDef(it) => {
169 Some(NavigationTarget::from_named( 169 Some(NavigationTarget::from_named(
170 db, 170 db,
171 node.with_ast(&it), 171 node.with_value(&it),
172 it.doc_comment_text(), 172 it.doc_comment_text(),
173 it.short_label(), 173 it.short_label(),
174 )) 174 ))
@@ -176,7 +176,7 @@ fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option<Navigati
176 ast::TraitDef(it) => { 176 ast::TraitDef(it) => {
177 Some(NavigationTarget::from_named( 177 Some(NavigationTarget::from_named(
178 db, 178 db,
179 node.with_ast(&it), 179 node.with_value(&it),
180 it.doc_comment_text(), 180 it.doc_comment_text(),
181 it.short_label(), 181 it.short_label(),
182 )) 182 ))
@@ -184,7 +184,7 @@ fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option<Navigati
184 ast::RecordFieldDef(it) => { 184 ast::RecordFieldDef(it) => {
185 Some(NavigationTarget::from_named( 185 Some(NavigationTarget::from_named(
186 db, 186 db,
187 node.with_ast(&it), 187 node.with_value(&it),
188 it.doc_comment_text(), 188 it.doc_comment_text(),
189 it.short_label(), 189 it.short_label(),
190 )) 190 ))
@@ -192,7 +192,7 @@ fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option<Navigati
192 ast::Module(it) => { 192 ast::Module(it) => {
193 Some(NavigationTarget::from_named( 193 Some(NavigationTarget::from_named(
194 db, 194 db,
195 node.with_ast(&it), 195 node.with_value(&it),
196 it.doc_comment_text(), 196 it.doc_comment_text(),
197 it.short_label(), 197 it.short_label(),
198 )) 198 ))
@@ -200,7 +200,7 @@ fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option<Navigati
200 ast::MacroCall(it) => { 200 ast::MacroCall(it) => {
201 Some(NavigationTarget::from_named( 201 Some(NavigationTarget::from_named(
202 db, 202 db,
203 node.with_ast(&it), 203 node.with_value(&it),
204 it.doc_comment_text(), 204 it.doc_comment_text(),
205 None, 205 None,
206 )) 206 ))
diff --git a/crates/ra_ide_api/src/goto_type_definition.rs b/crates/ra_ide_api/src/goto_type_definition.rs
index 6aeeefa1f..28a83a3e2 100644
--- a/crates/ra_ide_api/src/goto_type_definition.rs
+++ b/crates/ra_ide_api/src/goto_type_definition.rs
@@ -22,7 +22,7 @@ pub(crate) fn goto_type_definition(
22 .find(|n| ast::Expr::cast(n.clone()).is_some() || ast::Pat::cast(n.clone()).is_some()) 22 .find(|n| ast::Expr::cast(n.clone()).is_some() || ast::Pat::cast(n.clone()).is_some())
23 })?; 23 })?;
24 24
25 let analyzer = hir::SourceAnalyzer::new(db, token.with_ast(&node), None); 25 let analyzer = hir::SourceAnalyzer::new(db, token.with_value(&node), None);
26 26
27 let ty: hir::Ty = if let Some(ty) = 27 let ty: hir::Ty = if let Some(ty) =
28 ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e)) 28 ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e))
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index e8a340ba4..ae87ab9f9 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -174,7 +174,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
174 ast::NameRef(name_ref) => { 174 ast::NameRef(name_ref) => {
175 let mut no_fallback = false; 175 let mut no_fallback = false;
176 if let Some(name_kind) = 176 if let Some(name_kind) =
177 classify_name_ref(db, token.with_ast(&name_ref)).map(|d| d.kind) 177 classify_name_ref(db, token.with_value(&name_ref)).map(|d| d.kind)
178 { 178 {
179 res.extend(hover_text_from_name_kind(db, name_kind, &mut no_fallback)) 179 res.extend(hover_text_from_name_kind(db, name_kind, &mut no_fallback))
180 } 180 }
@@ -196,7 +196,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
196 } 196 }
197 }, 197 },
198 ast::Name(name) => { 198 ast::Name(name) => {
199 if let Some(name_kind) = classify_name(db, token.with_ast(&name)).map(|d| d.kind) { 199 if let Some(name_kind) = classify_name(db, token.with_value(&name)).map(|d| d.kind) {
200 res.extend(hover_text_from_name_kind(db, name_kind, &mut true)); 200 res.extend(hover_text_from_name_kind(db, name_kind, &mut true));
201 } 201 }
202 202
diff --git a/crates/ra_ide_api/src/references/classify.rs b/crates/ra_ide_api/src/references/classify.rs
index 333264540..4a4b030f8 100644
--- a/crates/ra_ide_api/src/references/classify.rs
+++ b/crates/ra_ide_api/src/references/classify.rs
@@ -18,7 +18,7 @@ pub(crate) fn classify_name(db: &RootDatabase, name: Source<&ast::Name>) -> Opti
18 match_ast! { 18 match_ast! {
19 match parent { 19 match parent {
20 ast::BindPat(it) => { 20 ast::BindPat(it) => {
21 let src = name.with_ast(it); 21 let src = name.with_value(it);
22 let local = hir::Local::from_source(db, src)?; 22 let local = hir::Local::from_source(db, src)?;
23 Some(NameDefinition { 23 Some(NameDefinition {
24 visibility: None, 24 visibility: None,
@@ -28,7 +28,7 @@ pub(crate) fn classify_name(db: &RootDatabase, name: Source<&ast::Name>) -> Opti
28 }, 28 },
29 ast::RecordFieldDef(it) => { 29 ast::RecordFieldDef(it) => {
30 let ast = hir::FieldSource::Named(it); 30 let ast = hir::FieldSource::Named(it);
31 let src = name.with_ast(ast); 31 let src = name.with_value(ast);
32 let field = hir::StructField::from_source(db, src)?; 32 let field = hir::StructField::from_source(db, src)?;
33 Some(from_struct_field(db, field)) 33 Some(from_struct_field(db, field))
34 }, 34 },
@@ -36,42 +36,42 @@ pub(crate) fn classify_name(db: &RootDatabase, name: Source<&ast::Name>) -> Opti
36 let def = { 36 let def = {
37 if !it.has_semi() { 37 if !it.has_semi() {
38 let ast = hir::ModuleSource::Module(it); 38 let ast = hir::ModuleSource::Module(it);
39 let src = name.with_ast(ast); 39 let src = name.with_value(ast);
40 hir::Module::from_definition(db, src) 40 hir::Module::from_definition(db, src)
41 } else { 41 } else {
42 let src = name.with_ast(it); 42 let src = name.with_value(it);
43 hir::Module::from_declaration(db, src) 43 hir::Module::from_declaration(db, src)
44 } 44 }
45 }?; 45 }?;
46 Some(from_module_def(db, def.into(), None)) 46 Some(from_module_def(db, def.into(), None))
47 }, 47 },
48 ast::StructDef(it) => { 48 ast::StructDef(it) => {
49 let src = name.with_ast(it); 49 let src = name.with_value(it);
50 let def = hir::Struct::from_source(db, src)?; 50 let def = hir::Struct::from_source(db, src)?;
51 Some(from_module_def(db, def.into(), None)) 51 Some(from_module_def(db, def.into(), None))
52 }, 52 },
53 ast::EnumDef(it) => { 53 ast::EnumDef(it) => {
54 let src = name.with_ast(it); 54 let src = name.with_value(it);
55 let def = hir::Enum::from_source(db, src)?; 55 let def = hir::Enum::from_source(db, src)?;
56 Some(from_module_def(db, def.into(), None)) 56 Some(from_module_def(db, def.into(), None))
57 }, 57 },
58 ast::TraitDef(it) => { 58 ast::TraitDef(it) => {
59 let src = name.with_ast(it); 59 let src = name.with_value(it);
60 let def = hir::Trait::from_source(db, src)?; 60 let def = hir::Trait::from_source(db, src)?;
61 Some(from_module_def(db, def.into(), None)) 61 Some(from_module_def(db, def.into(), None))
62 }, 62 },
63 ast::StaticDef(it) => { 63 ast::StaticDef(it) => {
64 let src = name.with_ast(it); 64 let src = name.with_value(it);
65 let def = hir::Static::from_source(db, src)?; 65 let def = hir::Static::from_source(db, src)?;
66 Some(from_module_def(db, def.into(), None)) 66 Some(from_module_def(db, def.into(), None))
67 }, 67 },
68 ast::EnumVariant(it) => { 68 ast::EnumVariant(it) => {
69 let src = name.with_ast(it); 69 let src = name.with_value(it);
70 let def = hir::EnumVariant::from_source(db, src)?; 70 let def = hir::EnumVariant::from_source(db, src)?;
71 Some(from_module_def(db, def.into(), None)) 71 Some(from_module_def(db, def.into(), None))
72 }, 72 },
73 ast::FnDef(it) => { 73 ast::FnDef(it) => {
74 let src = name.with_ast(it); 74 let src = name.with_value(it);
75 let def = hir::Function::from_source(db, src)?; 75 let def = hir::Function::from_source(db, src)?;
76 if parent.parent().and_then(ast::ItemList::cast).is_some() { 76 if parent.parent().and_then(ast::ItemList::cast).is_some() {
77 Some(from_assoc_item(db, def.into())) 77 Some(from_assoc_item(db, def.into()))
@@ -80,7 +80,7 @@ pub(crate) fn classify_name(db: &RootDatabase, name: Source<&ast::Name>) -> Opti
80 } 80 }
81 }, 81 },
82 ast::ConstDef(it) => { 82 ast::ConstDef(it) => {
83 let src = name.with_ast(it); 83 let src = name.with_value(it);
84 let def = hir::Const::from_source(db, src)?; 84 let def = hir::Const::from_source(db, src)?;
85 if parent.parent().and_then(ast::ItemList::cast).is_some() { 85 if parent.parent().and_then(ast::ItemList::cast).is_some() {
86 Some(from_assoc_item(db, def.into())) 86 Some(from_assoc_item(db, def.into()))
@@ -89,7 +89,7 @@ pub(crate) fn classify_name(db: &RootDatabase, name: Source<&ast::Name>) -> Opti
89 } 89 }
90 }, 90 },
91 ast::TypeAliasDef(it) => { 91 ast::TypeAliasDef(it) => {
92 let src = name.with_ast(it); 92 let src = name.with_value(it);
93 let def = hir::TypeAlias::from_source(db, src)?; 93 let def = hir::TypeAlias::from_source(db, src)?;
94 if parent.parent().and_then(ast::ItemList::cast).is_some() { 94 if parent.parent().and_then(ast::ItemList::cast).is_some() {
95 Some(from_assoc_item(db, def.into())) 95 Some(from_assoc_item(db, def.into()))
@@ -98,11 +98,11 @@ pub(crate) fn classify_name(db: &RootDatabase, name: Source<&ast::Name>) -> Opti
98 } 98 }
99 }, 99 },
100 ast::MacroCall(it) => { 100 ast::MacroCall(it) => {
101 let src = name.with_ast(it); 101 let src = name.with_value(it);
102 let def = hir::MacroDef::from_source(db, src.clone())?; 102 let def = hir::MacroDef::from_source(db, src.clone())?;
103 103
104 let module_src = ModuleSource::from_child_node(db, src.as_ref().map(|it| it.syntax())); 104 let module_src = ModuleSource::from_child_node(db, src.as_ref().map(|it| it.syntax()));
105 let module = Module::from_definition(db, src.with_ast(module_src))?; 105 let module = Module::from_definition(db, src.with_value(module_src))?;
106 106
107 Some(NameDefinition { 107 Some(NameDefinition {
108 visibility: None, 108 visibility: None,
@@ -149,9 +149,9 @@ pub(crate) fn classify_name_ref(
149 } 149 }
150 } 150 }
151 151
152 let ast = ModuleSource::from_child_node(db, name_ref.with_ast(&parent)); 152 let ast = ModuleSource::from_child_node(db, name_ref.with_value(&parent));
153 // FIXME: find correct container and visibility for each case 153 // FIXME: find correct container and visibility for each case
154 let container = Module::from_definition(db, name_ref.with_ast(ast))?; 154 let container = Module::from_definition(db, name_ref.with_value(ast))?;
155 let visibility = None; 155 let visibility = None;
156 156
157 if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) { 157 if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) {