diff options
Diffstat (limited to 'crates/ra_ide_db/src/defs.rs')
-rw-r--r-- | crates/ra_ide_db/src/defs.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index 785613b82..7cd2384e9 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs | |||
@@ -6,8 +6,8 @@ | |||
6 | // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). | 6 | // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). |
7 | 7 | ||
8 | use hir::{ | 8 | use hir::{ |
9 | HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, Semantics, | 9 | Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, |
10 | StructField, TypeParam, Visibility, | 10 | Semantics, TypeParam, Visibility, |
11 | }; | 11 | }; |
12 | use ra_prof::profile; | 12 | use ra_prof::profile; |
13 | use ra_syntax::{ | 13 | use ra_syntax::{ |
@@ -22,7 +22,7 @@ use crate::RootDatabase; | |||
22 | #[derive(Debug, PartialEq, Eq)] | 22 | #[derive(Debug, PartialEq, Eq)] |
23 | pub enum Definition { | 23 | pub enum Definition { |
24 | Macro(MacroDef), | 24 | Macro(MacroDef), |
25 | StructField(StructField), | 25 | Field(Field), |
26 | ModuleDef(ModuleDef), | 26 | ModuleDef(ModuleDef), |
27 | SelfType(ImplDef), | 27 | SelfType(ImplDef), |
28 | Local(Local), | 28 | Local(Local), |
@@ -33,7 +33,7 @@ impl Definition { | |||
33 | pub fn module(&self, db: &RootDatabase) -> Option<Module> { | 33 | pub fn module(&self, db: &RootDatabase) -> Option<Module> { |
34 | match self { | 34 | match self { |
35 | Definition::Macro(it) => it.module(db), | 35 | Definition::Macro(it) => it.module(db), |
36 | Definition::StructField(it) => Some(it.parent_def(db).module(db)), | 36 | Definition::Field(it) => Some(it.parent_def(db).module(db)), |
37 | Definition::ModuleDef(it) => it.module(db), | 37 | Definition::ModuleDef(it) => it.module(db), |
38 | Definition::SelfType(it) => Some(it.module(db)), | 38 | Definition::SelfType(it) => Some(it.module(db)), |
39 | Definition::Local(it) => Some(it.module(db)), | 39 | Definition::Local(it) => Some(it.module(db)), |
@@ -46,7 +46,7 @@ impl Definition { | |||
46 | 46 | ||
47 | match self { | 47 | match self { |
48 | Definition::Macro(_) => None, | 48 | Definition::Macro(_) => None, |
49 | Definition::StructField(sf) => Some(sf.visibility(db)), | 49 | Definition::Field(sf) => Some(sf.visibility(db)), |
50 | Definition::ModuleDef(def) => module?.visibility_of(db, def), | 50 | Definition::ModuleDef(def) => module?.visibility_of(db, def), |
51 | Definition::SelfType(_) => None, | 51 | Definition::SelfType(_) => None, |
52 | Definition::Local(_) => None, | 52 | Definition::Local(_) => None, |
@@ -57,7 +57,7 @@ impl Definition { | |||
57 | pub fn name(&self, db: &RootDatabase) -> Option<Name> { | 57 | pub fn name(&self, db: &RootDatabase) -> Option<Name> { |
58 | let name = match self { | 58 | let name = match self { |
59 | Definition::Macro(it) => it.name(db)?, | 59 | Definition::Macro(it) => it.name(db)?, |
60 | Definition::StructField(it) => it.name(db), | 60 | Definition::Field(it) => it.name(db), |
61 | Definition::ModuleDef(def) => match def { | 61 | Definition::ModuleDef(def) => match def { |
62 | hir::ModuleDef::Module(it) => it.name(db)?, | 62 | hir::ModuleDef::Module(it) => it.name(db)?, |
63 | hir::ModuleDef::Function(it) => it.name(db), | 63 | hir::ModuleDef::Function(it) => it.name(db), |
@@ -124,8 +124,8 @@ fn classify_name_inner(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Opti | |||
124 | Some(Definition::Local(local)) | 124 | Some(Definition::Local(local)) |
125 | }, | 125 | }, |
126 | ast::RecordFieldDef(it) => { | 126 | ast::RecordFieldDef(it) => { |
127 | let field: hir::StructField = sema.to_def(&it)?; | 127 | let field: hir::Field = sema.to_def(&it)?; |
128 | Some(Definition::StructField(field)) | 128 | Some(Definition::Field(field)) |
129 | }, | 129 | }, |
130 | ast::Module(it) => { | 130 | ast::Module(it) => { |
131 | let def = sema.to_def(&it)?; | 131 | let def = sema.to_def(&it)?; |
@@ -213,7 +213,7 @@ pub fn classify_name_ref( | |||
213 | if let Some(field_expr) = ast::FieldExpr::cast(parent.clone()) { | 213 | if let Some(field_expr) = ast::FieldExpr::cast(parent.clone()) { |
214 | tested_by!(goto_def_for_fields; force); | 214 | tested_by!(goto_def_for_fields; force); |
215 | if let Some(field) = sema.resolve_field(&field_expr) { | 215 | if let Some(field) = sema.resolve_field(&field_expr) { |
216 | return Some(NameRefClass::Definition(Definition::StructField(field))); | 216 | return Some(NameRefClass::Definition(Definition::Field(field))); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
@@ -221,7 +221,7 @@ pub fn classify_name_ref( | |||
221 | tested_by!(goto_def_for_record_fields; force); | 221 | tested_by!(goto_def_for_record_fields; force); |
222 | tested_by!(goto_def_for_field_init_shorthand; force); | 222 | tested_by!(goto_def_for_field_init_shorthand; force); |
223 | if let Some((field, local)) = sema.resolve_record_field(&record_field) { | 223 | if let Some((field, local)) = sema.resolve_record_field(&record_field) { |
224 | let field = Definition::StructField(field); | 224 | let field = Definition::Field(field); |
225 | let res = match local { | 225 | let res = match local { |
226 | None => NameRefClass::Definition(field), | 226 | None => NameRefClass::Definition(field), |
227 | Some(local) => NameRefClass::FieldShorthand { field, local }, | 227 | Some(local) => NameRefClass::FieldShorthand { field, local }, |
@@ -233,7 +233,7 @@ pub fn classify_name_ref( | |||
233 | if let Some(record_field_pat) = ast::RecordFieldPat::cast(parent.clone()) { | 233 | if let Some(record_field_pat) = ast::RecordFieldPat::cast(parent.clone()) { |
234 | tested_by!(goto_def_for_record_field_pats; force); | 234 | tested_by!(goto_def_for_record_field_pats; force); |
235 | if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { | 235 | if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { |
236 | let field = Definition::StructField(field); | 236 | let field = Definition::Field(field); |
237 | return Some(NameRefClass::Definition(field)); | 237 | return Some(NameRefClass::Definition(field)); |
238 | } | 238 | } |
239 | } | 239 | } |