diff options
Diffstat (limited to 'crates/ra_ide_api/src/references')
-rw-r--r-- | crates/ra_ide_api/src/references/classify.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide_api/src/references/name_definition.rs | 30 | ||||
-rw-r--r-- | crates/ra_ide_api/src/references/rename.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/references/search_scope.rs | 10 |
4 files changed, 26 insertions, 26 deletions
diff --git a/crates/ra_ide_api/src/references/classify.rs b/crates/ra_ide_api/src/references/classify.rs index ea9d20e71..333264540 100644 --- a/crates/ra_ide_api/src/references/classify.rs +++ b/crates/ra_ide_api/src/references/classify.rs | |||
@@ -13,7 +13,7 @@ use crate::db::RootDatabase; | |||
13 | 13 | ||
14 | pub(crate) fn classify_name(db: &RootDatabase, name: Source<&ast::Name>) -> Option<NameDefinition> { | 14 | pub(crate) fn classify_name(db: &RootDatabase, name: Source<&ast::Name>) -> Option<NameDefinition> { |
15 | let _p = profile("classify_name"); | 15 | let _p = profile("classify_name"); |
16 | let parent = name.ast.syntax().parent()?; | 16 | let parent = name.value.syntax().parent()?; |
17 | 17 | ||
18 | match_ast! { | 18 | match_ast! { |
19 | match parent { | 19 | match parent { |
@@ -121,7 +121,7 @@ pub(crate) fn classify_name_ref( | |||
121 | ) -> Option<NameDefinition> { | 121 | ) -> Option<NameDefinition> { |
122 | let _p = profile("classify_name_ref"); | 122 | let _p = profile("classify_name_ref"); |
123 | 123 | ||
124 | let parent = name_ref.ast.syntax().parent()?; | 124 | let parent = name_ref.value.syntax().parent()?; |
125 | let analyzer = SourceAnalyzer::new(db, name_ref.map(|it| it.syntax()), None); | 125 | let analyzer = SourceAnalyzer::new(db, name_ref.map(|it| it.syntax()), None); |
126 | 126 | ||
127 | if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) { | 127 | if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) { |
@@ -142,7 +142,7 @@ pub(crate) fn classify_name_ref( | |||
142 | tested_by!(goto_definition_works_for_record_fields); | 142 | tested_by!(goto_definition_works_for_record_fields); |
143 | if let Some(record_lit) = record_field.syntax().ancestors().find_map(ast::RecordLit::cast) { | 143 | if let Some(record_lit) = record_field.syntax().ancestors().find_map(ast::RecordLit::cast) { |
144 | let variant_def = analyzer.resolve_record_literal(&record_lit)?; | 144 | let variant_def = analyzer.resolve_record_literal(&record_lit)?; |
145 | let hir_path = Path::from_name_ref(name_ref.ast); | 145 | let hir_path = Path::from_name_ref(name_ref.value); |
146 | let hir_name = hir_path.as_ident()?; | 146 | let hir_name = hir_path.as_ident()?; |
147 | let field = variant_def.field(db, hir_name)?; | 147 | let field = variant_def.field(db, hir_name)?; |
148 | return Some(from_struct_field(db, field)); | 148 | return Some(from_struct_field(db, field)); |
@@ -162,7 +162,7 @@ pub(crate) fn classify_name_ref( | |||
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | let path = name_ref.ast.syntax().ancestors().find_map(ast::Path::cast)?; | 165 | let path = name_ref.value.syntax().ancestors().find_map(ast::Path::cast)?; |
166 | let resolved = analyzer.resolve_path(db, &path)?; | 166 | let resolved = analyzer.resolve_path(db, &path)?; |
167 | match resolved { | 167 | match resolved { |
168 | PathResolution::Def(def) => Some(from_module_def(db, def, Some(container))), | 168 | PathResolution::Def(def) => Some(from_module_def(db, def, Some(container))), |
diff --git a/crates/ra_ide_api/src/references/name_definition.rs b/crates/ra_ide_api/src/references/name_definition.rs index ccd75278a..aca23f79e 100644 --- a/crates/ra_ide_api/src/references/name_definition.rs +++ b/crates/ra_ide_api/src/references/name_definition.rs | |||
@@ -32,9 +32,9 @@ pub(crate) struct NameDefinition { | |||
32 | pub(super) fn from_assoc_item(db: &RootDatabase, item: AssocItem) -> NameDefinition { | 32 | pub(super) fn from_assoc_item(db: &RootDatabase, item: AssocItem) -> NameDefinition { |
33 | let container = item.module(db); | 33 | let container = item.module(db); |
34 | let visibility = match item { | 34 | let visibility = match item { |
35 | AssocItem::Function(f) => f.source(db).ast.visibility(), | 35 | AssocItem::Function(f) => f.source(db).value.visibility(), |
36 | AssocItem::Const(c) => c.source(db).ast.visibility(), | 36 | AssocItem::Const(c) => c.source(db).value.visibility(), |
37 | AssocItem::TypeAlias(a) => a.source(db).ast.visibility(), | 37 | AssocItem::TypeAlias(a) => a.source(db).value.visibility(), |
38 | }; | 38 | }; |
39 | let kind = NameKind::AssocItem(item); | 39 | let kind = NameKind::AssocItem(item); |
40 | NameDefinition { kind, container, visibility } | 40 | NameDefinition { kind, container, visibility } |
@@ -45,8 +45,8 @@ pub(super) fn from_struct_field(db: &RootDatabase, field: StructField) -> NameDe | |||
45 | let parent = field.parent_def(db); | 45 | let parent = field.parent_def(db); |
46 | let container = parent.module(db); | 46 | let container = parent.module(db); |
47 | let visibility = match parent { | 47 | let visibility = match parent { |
48 | VariantDef::Struct(s) => s.source(db).ast.visibility(), | 48 | VariantDef::Struct(s) => s.source(db).value.visibility(), |
49 | VariantDef::EnumVariant(e) => e.source(db).ast.parent_enum().visibility(), | 49 | VariantDef::EnumVariant(e) => e.source(db).value.parent_enum().visibility(), |
50 | }; | 50 | }; |
51 | NameDefinition { kind, container, visibility } | 51 | NameDefinition { kind, container, visibility } |
52 | } | 52 | } |
@@ -60,22 +60,22 @@ pub(super) fn from_module_def( | |||
60 | let (container, visibility) = match def { | 60 | let (container, visibility) = match def { |
61 | ModuleDef::Module(it) => { | 61 | ModuleDef::Module(it) => { |
62 | let container = it.parent(db).or_else(|| Some(it)).unwrap(); | 62 | let container = it.parent(db).or_else(|| Some(it)).unwrap(); |
63 | let visibility = it.declaration_source(db).and_then(|s| s.ast.visibility()); | 63 | let visibility = it.declaration_source(db).and_then(|s| s.value.visibility()); |
64 | (container, visibility) | 64 | (container, visibility) |
65 | } | 65 | } |
66 | ModuleDef::EnumVariant(it) => { | 66 | ModuleDef::EnumVariant(it) => { |
67 | let container = it.module(db); | 67 | let container = it.module(db); |
68 | let visibility = it.source(db).ast.parent_enum().visibility(); | 68 | let visibility = it.source(db).value.parent_enum().visibility(); |
69 | (container, visibility) | 69 | (container, visibility) |
70 | } | 70 | } |
71 | ModuleDef::Function(it) => (it.module(db), it.source(db).ast.visibility()), | 71 | ModuleDef::Function(it) => (it.module(db), it.source(db).value.visibility()), |
72 | ModuleDef::Const(it) => (it.module(db), it.source(db).ast.visibility()), | 72 | ModuleDef::Const(it) => (it.module(db), it.source(db).value.visibility()), |
73 | ModuleDef::Static(it) => (it.module(db), it.source(db).ast.visibility()), | 73 | ModuleDef::Static(it) => (it.module(db), it.source(db).value.visibility()), |
74 | ModuleDef::Trait(it) => (it.module(db), it.source(db).ast.visibility()), | 74 | ModuleDef::Trait(it) => (it.module(db), it.source(db).value.visibility()), |
75 | ModuleDef::TypeAlias(it) => (it.module(db), it.source(db).ast.visibility()), | 75 | ModuleDef::TypeAlias(it) => (it.module(db), it.source(db).value.visibility()), |
76 | ModuleDef::Adt(Adt::Struct(it)) => (it.module(db), it.source(db).ast.visibility()), | 76 | ModuleDef::Adt(Adt::Struct(it)) => (it.module(db), it.source(db).value.visibility()), |
77 | ModuleDef::Adt(Adt::Union(it)) => (it.module(db), it.source(db).ast.visibility()), | 77 | ModuleDef::Adt(Adt::Union(it)) => (it.module(db), it.source(db).value.visibility()), |
78 | ModuleDef::Adt(Adt::Enum(it)) => (it.module(db), it.source(db).ast.visibility()), | 78 | ModuleDef::Adt(Adt::Enum(it)) => (it.module(db), it.source(db).value.visibility()), |
79 | ModuleDef::BuiltinType(..) => (module.unwrap(), None), | 79 | ModuleDef::BuiltinType(..) => (module.unwrap(), None), |
80 | }; | 80 | }; |
81 | NameDefinition { kind, container, visibility } | 81 | NameDefinition { kind, container, visibility } |
diff --git a/crates/ra_ide_api/src/references/rename.rs b/crates/ra_ide_api/src/references/rename.rs index 11f81cbb3..4ea372e6f 100644 --- a/crates/ra_ide_api/src/references/rename.rs +++ b/crates/ra_ide_api/src/references/rename.rs | |||
@@ -55,11 +55,11 @@ fn rename_mod( | |||
55 | ) -> Option<SourceChange> { | 55 | ) -> Option<SourceChange> { |
56 | let mut source_file_edits = Vec::new(); | 56 | let mut source_file_edits = Vec::new(); |
57 | let mut file_system_edits = Vec::new(); | 57 | let mut file_system_edits = Vec::new(); |
58 | let module_src = hir::Source { file_id: position.file_id.into(), ast: ast_module.clone() }; | 58 | let module_src = hir::Source { file_id: position.file_id.into(), value: ast_module.clone() }; |
59 | if let Some(module) = hir::Module::from_declaration(db, module_src) { | 59 | if let Some(module) = hir::Module::from_declaration(db, module_src) { |
60 | let src = module.definition_source(db); | 60 | let src = module.definition_source(db); |
61 | let file_id = src.file_id.original_file(db); | 61 | let file_id = src.file_id.original_file(db); |
62 | match src.ast { | 62 | match src.value { |
63 | ModuleSource::SourceFile(..) => { | 63 | ModuleSource::SourceFile(..) => { |
64 | let mod_path: RelativePathBuf = db.file_relative_path(file_id); | 64 | let mod_path: RelativePathBuf = db.file_relative_path(file_id); |
65 | // mod is defined in path/to/dir/mod.rs | 65 | // mod is defined in path/to/dir/mod.rs |
diff --git a/crates/ra_ide_api/src/references/search_scope.rs b/crates/ra_ide_api/src/references/search_scope.rs index 2907787c2..f5c9589f4 100644 --- a/crates/ra_ide_api/src/references/search_scope.rs +++ b/crates/ra_ide_api/src/references/search_scope.rs | |||
@@ -73,9 +73,9 @@ impl NameDefinition { | |||
73 | 73 | ||
74 | if let NameKind::Local(var) = self.kind { | 74 | if let NameKind::Local(var) = self.kind { |
75 | let range = match var.parent(db) { | 75 | let range = match var.parent(db) { |
76 | DefWithBody::Function(f) => f.source(db).ast.syntax().text_range(), | 76 | DefWithBody::Function(f) => f.source(db).value.syntax().text_range(), |
77 | DefWithBody::Const(c) => c.source(db).ast.syntax().text_range(), | 77 | DefWithBody::Const(c) => c.source(db).value.syntax().text_range(), |
78 | DefWithBody::Static(s) => s.source(db).ast.syntax().text_range(), | 78 | DefWithBody::Static(s) => s.source(db).value.syntax().text_range(), |
79 | }; | 79 | }; |
80 | let mut res = FxHashMap::default(); | 80 | let mut res = FxHashMap::default(); |
81 | res.insert(file_id, Some(range)); | 81 | res.insert(file_id, Some(range)); |
@@ -91,7 +91,7 @@ impl NameDefinition { | |||
91 | let parent_src = parent_module.definition_source(db); | 91 | let parent_src = parent_module.definition_source(db); |
92 | let file_id = parent_src.file_id.original_file(db); | 92 | let file_id = parent_src.file_id.original_file(db); |
93 | 93 | ||
94 | match parent_src.ast { | 94 | match parent_src.value { |
95 | ModuleSource::Module(m) => { | 95 | ModuleSource::Module(m) => { |
96 | let range = Some(m.syntax().text_range()); | 96 | let range = Some(m.syntax().text_range()); |
97 | res.insert(file_id, range); | 97 | res.insert(file_id, range); |
@@ -135,7 +135,7 @@ impl NameDefinition { | |||
135 | } | 135 | } |
136 | 136 | ||
137 | let mut res = FxHashMap::default(); | 137 | let mut res = FxHashMap::default(); |
138 | let range = match module_src.ast { | 138 | let range = match module_src.value { |
139 | ModuleSource::Module(m) => Some(m.syntax().text_range()), | 139 | ModuleSource::Module(m) => Some(m.syntax().text_range()), |
140 | ModuleSource::SourceFile(_) => None, | 140 | ModuleSource::SourceFile(_) => None, |
141 | }; | 141 | }; |