diff options
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_dot.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_path.rs | 13 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_pattern.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/presentation.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide_api/src/display/navigation_target.rs | 12 | ||||
-rw-r--r-- | crates/ra_ide_api/src/hover.rs | 14 | ||||
-rw-r--r-- | crates/ra_ide_api/src/name_ref_kind.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/syntax_highlighting.rs | 4 |
8 files changed, 28 insertions, 33 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 2325cdf08..9e64c8659 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use hir::{AdtDef, Ty, TypeCtor}; | 1 | use hir::{Adt, Ty, TypeCtor}; |
2 | 2 | ||
3 | use crate::completion::completion_item::CompletionKind; | 3 | use crate::completion::completion_item::CompletionKind; |
4 | use crate::{ | 4 | use crate::{ |
@@ -37,7 +37,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) | |||
37 | for receiver in ctx.analyzer.autoderef(ctx.db, receiver) { | 37 | for receiver in ctx.analyzer.autoderef(ctx.db, receiver) { |
38 | if let Ty::Apply(a_ty) = receiver { | 38 | if let Ty::Apply(a_ty) = receiver { |
39 | match a_ty.ctor { | 39 | match a_ty.ctor { |
40 | TypeCtor::Adt(AdtDef::Struct(s)) => { | 40 | TypeCtor::Adt(Adt::Struct(s)) => { |
41 | for field in s.fields(ctx.db) { | 41 | for field in s.fields(ctx.db) { |
42 | acc.add_field(ctx, field, &a_ty.parameters); | 42 | acc.add_field(ctx, field, &a_ty.parameters); |
43 | } | 43 | } |
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 457a3d10c..4d3414f33 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use hir::{Either, Resolution}; | 1 | use hir::{Adt, Either, Resolution}; |
2 | use ra_syntax::AstNode; | 2 | use ra_syntax::AstNode; |
3 | use test_utils::tested_by; | 3 | use test_utils::tested_by; |
4 | 4 | ||
@@ -37,19 +37,14 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { | |||
37 | acc.add_resolution(ctx, name.to_string(), &res.def.map(hir::Resolution::Def)); | 37 | acc.add_resolution(ctx, name.to_string(), &res.def.map(hir::Resolution::Def)); |
38 | } | 38 | } |
39 | } | 39 | } |
40 | hir::ModuleDef::Enum(_) | 40 | hir::ModuleDef::Adt(_) | hir::ModuleDef::TypeAlias(_) => { |
41 | | hir::ModuleDef::Struct(_) | 41 | if let hir::ModuleDef::Adt(Adt::Enum(e)) = def { |
42 | | hir::ModuleDef::Union(_) | ||
43 | | hir::ModuleDef::TypeAlias(_) => { | ||
44 | if let hir::ModuleDef::Enum(e) = def { | ||
45 | for variant in e.variants(ctx.db) { | 42 | for variant in e.variants(ctx.db) { |
46 | acc.add_enum_variant(ctx, variant); | 43 | acc.add_enum_variant(ctx, variant); |
47 | } | 44 | } |
48 | } | 45 | } |
49 | let ty = match def { | 46 | let ty = match def { |
50 | hir::ModuleDef::Enum(e) => e.ty(ctx.db), | 47 | hir::ModuleDef::Adt(adt) => adt.ty(ctx.db), |
51 | hir::ModuleDef::Struct(s) => s.ty(ctx.db), | ||
52 | hir::ModuleDef::Union(u) => u.ty(ctx.db), | ||
53 | hir::ModuleDef::TypeAlias(a) => a.ty(ctx.db), | 48 | hir::ModuleDef::TypeAlias(a) => a.ty(ctx.db), |
54 | _ => unreachable!(), | 49 | _ => unreachable!(), |
55 | }; | 50 | }; |
diff --git a/crates/ra_ide_api/src/completion/complete_pattern.rs b/crates/ra_ide_api/src/completion/complete_pattern.rs index fb02844fa..fb7f9feb8 100644 --- a/crates/ra_ide_api/src/completion/complete_pattern.rs +++ b/crates/ra_ide_api/src/completion/complete_pattern.rs | |||
@@ -15,7 +15,7 @@ pub(super) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) { | |||
15 | _ => continue, | 15 | _ => continue, |
16 | }; | 16 | }; |
17 | match def { | 17 | match def { |
18 | hir::ModuleDef::Enum(..) | 18 | hir::ModuleDef::Adt(hir::Adt::Enum(..)) |
19 | | hir::ModuleDef::EnumVariant(..) | 19 | | hir::ModuleDef::EnumVariant(..) |
20 | | hir::ModuleDef::Const(..) | 20 | | hir::ModuleDef::Const(..) |
21 | | hir::ModuleDef::Module(..) => (), | 21 | | hir::ModuleDef::Module(..) => (), |
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 5cabe9a32..95bbd34b7 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs | |||
@@ -67,9 +67,13 @@ impl Completions { | |||
67 | Resolution::Def(Function(func)) => { | 67 | Resolution::Def(Function(func)) => { |
68 | return self.add_function_with_name(ctx, Some(local_name), *func); | 68 | return self.add_function_with_name(ctx, Some(local_name), *func); |
69 | } | 69 | } |
70 | Resolution::Def(Struct(it)) => (CompletionItemKind::Struct, it.docs(ctx.db)), | 70 | Resolution::Def(Adt(hir::Adt::Struct(it))) => { |
71 | Resolution::Def(Union(it)) => (CompletionItemKind::Struct, it.docs(ctx.db)), | 71 | (CompletionItemKind::Struct, it.docs(ctx.db)) |
72 | Resolution::Def(Enum(it)) => (CompletionItemKind::Enum, it.docs(ctx.db)), | 72 | } |
73 | Resolution::Def(Adt(hir::Adt::Union(it))) => { | ||
74 | (CompletionItemKind::Struct, it.docs(ctx.db)) | ||
75 | } | ||
76 | Resolution::Def(Adt(hir::Adt::Enum(it))) => (CompletionItemKind::Enum, it.docs(ctx.db)), | ||
73 | Resolution::Def(EnumVariant(it)) => (CompletionItemKind::EnumVariant, it.docs(ctx.db)), | 77 | Resolution::Def(EnumVariant(it)) => (CompletionItemKind::EnumVariant, it.docs(ctx.db)), |
74 | Resolution::Def(Const(it)) => (CompletionItemKind::Const, it.docs(ctx.db)), | 78 | Resolution::Def(Const(it)) => (CompletionItemKind::Const, it.docs(ctx.db)), |
75 | Resolution::Def(Static(it)) => (CompletionItemKind::Static, it.docs(ctx.db)), | 79 | Resolution::Def(Static(it)) => (CompletionItemKind::Static, it.docs(ctx.db)), |
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index c85214bb3..03382ab3c 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs | |||
@@ -178,11 +178,11 @@ impl NavigationTarget { | |||
178 | ) | 178 | ) |
179 | } | 179 | } |
180 | 180 | ||
181 | pub(crate) fn from_adt_def(db: &RootDatabase, adt_def: hir::AdtDef) -> NavigationTarget { | 181 | pub(crate) fn from_adt_def(db: &RootDatabase, adt_def: hir::Adt) -> NavigationTarget { |
182 | match adt_def { | 182 | match adt_def { |
183 | hir::AdtDef::Struct(it) => NavigationTarget::from_def_source(db, it), | 183 | hir::Adt::Struct(it) => NavigationTarget::from_def_source(db, it), |
184 | hir::AdtDef::Union(it) => NavigationTarget::from_def_source(db, it), | 184 | hir::Adt::Union(it) => NavigationTarget::from_def_source(db, it), |
185 | hir::AdtDef::Enum(it) => NavigationTarget::from_def_source(db, it), | 185 | hir::Adt::Enum(it) => NavigationTarget::from_def_source(db, it), |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
@@ -193,9 +193,7 @@ impl NavigationTarget { | |||
193 | let nav = match module_def { | 193 | let nav = match module_def { |
194 | hir::ModuleDef::Module(module) => NavigationTarget::from_module(db, module), | 194 | hir::ModuleDef::Module(module) => NavigationTarget::from_module(db, module), |
195 | hir::ModuleDef::Function(func) => NavigationTarget::from_def_source(db, func), | 195 | hir::ModuleDef::Function(func) => NavigationTarget::from_def_source(db, func), |
196 | hir::ModuleDef::Struct(it) => NavigationTarget::from_adt_def(db, it.into()), | 196 | hir::ModuleDef::Adt(it) => NavigationTarget::from_adt_def(db, it), |
197 | hir::ModuleDef::Enum(it) => NavigationTarget::from_adt_def(db, it.into()), | ||
198 | hir::ModuleDef::Union(it) => NavigationTarget::from_adt_def(db, it.into()), | ||
199 | hir::ModuleDef::Const(it) => NavigationTarget::from_def_source(db, it), | 197 | hir::ModuleDef::Const(it) => NavigationTarget::from_def_source(db, it), |
200 | hir::ModuleDef::Static(it) => NavigationTarget::from_def_source(db, it), | 198 | hir::ModuleDef::Static(it) => NavigationTarget::from_def_source(db, it), |
201 | hir::ModuleDef::EnumVariant(it) => NavigationTarget::from_def_source(db, it), | 199 | hir::ModuleDef::EnumVariant(it) => NavigationTarget::from_def_source(db, it), |
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index 4b7847de8..28a6bef12 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use hir::{HasSource, HirDisplay}; | 1 | use hir::{Adt, HasSource, HirDisplay}; |
2 | use ra_db::SourceDatabase; | 2 | use ra_db::SourceDatabase; |
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | algo::{ | 4 | algo::{ |
@@ -129,9 +129,9 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn | |||
129 | } | 129 | } |
130 | } | 130 | } |
131 | hir::ModuleDef::Function(it) => res.extend(from_def_source(db, it)), | 131 | hir::ModuleDef::Function(it) => res.extend(from_def_source(db, it)), |
132 | hir::ModuleDef::Struct(it) => res.extend(from_def_source(db, it)), | 132 | hir::ModuleDef::Adt(Adt::Struct(it)) => res.extend(from_def_source(db, it)), |
133 | hir::ModuleDef::Union(it) => res.extend(from_def_source(db, it)), | 133 | hir::ModuleDef::Adt(Adt::Union(it)) => res.extend(from_def_source(db, it)), |
134 | hir::ModuleDef::Enum(it) => res.extend(from_def_source(db, it)), | 134 | hir::ModuleDef::Adt(Adt::Enum(it)) => res.extend(from_def_source(db, it)), |
135 | hir::ModuleDef::EnumVariant(it) => res.extend(from_def_source(db, it)), | 135 | hir::ModuleDef::EnumVariant(it) => res.extend(from_def_source(db, it)), |
136 | hir::ModuleDef::Const(it) => res.extend(from_def_source(db, it)), | 136 | hir::ModuleDef::Const(it) => res.extend(from_def_source(db, it)), |
137 | hir::ModuleDef::Static(it) => res.extend(from_def_source(db, it)), | 137 | hir::ModuleDef::Static(it) => res.extend(from_def_source(db, it)), |
@@ -145,9 +145,9 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn | |||
145 | Some(SelfType(ty)) => { | 145 | Some(SelfType(ty)) => { |
146 | if let Some((adt_def, _)) = ty.as_adt() { | 146 | if let Some((adt_def, _)) = ty.as_adt() { |
147 | res.extend(match adt_def { | 147 | res.extend(match adt_def { |
148 | hir::AdtDef::Struct(it) => from_def_source(db, it), | 148 | hir::Adt::Struct(it) => from_def_source(db, it), |
149 | hir::AdtDef::Union(it) => from_def_source(db, it), | 149 | hir::Adt::Union(it) => from_def_source(db, it), |
150 | hir::AdtDef::Enum(it) => from_def_source(db, it), | 150 | hir::Adt::Enum(it) => from_def_source(db, it), |
151 | }) | 151 | }) |
152 | } | 152 | } |
153 | } | 153 | } |
diff --git a/crates/ra_ide_api/src/name_ref_kind.rs b/crates/ra_ide_api/src/name_ref_kind.rs index 34a8bcc36..6c2a7b260 100644 --- a/crates/ra_ide_api/src/name_ref_kind.rs +++ b/crates/ra_ide_api/src/name_ref_kind.rs | |||
@@ -60,7 +60,7 @@ pub(crate) fn classify_name_ref( | |||
60 | let record_lit = field_expr.syntax().ancestors().find_map(ast::RecordLit::cast); | 60 | let record_lit = field_expr.syntax().ancestors().find_map(ast::RecordLit::cast); |
61 | 61 | ||
62 | if let Some(ty) = record_lit.and_then(|lit| analyzer.type_of(db, &lit.into())) { | 62 | if let Some(ty) = record_lit.and_then(|lit| analyzer.type_of(db, &lit.into())) { |
63 | if let Some((hir::AdtDef::Struct(s), _)) = ty.as_adt() { | 63 | if let Some((hir::Adt::Struct(s), _)) = ty.as_adt() { |
64 | let hir_path = hir::Path::from_name_ref(name_ref); | 64 | let hir_path = hir::Path::from_name_ref(name_ref); |
65 | let hir_name = hir_path.as_ident().unwrap(); | 65 | let hir_name = hir_path.as_ident().unwrap(); |
66 | 66 | ||
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index 06ccf0728..86ab3a260 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs | |||
@@ -107,9 +107,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa | |||
107 | Some(AssocItem(hir::ImplItem::TypeAlias(_))) => "type", | 107 | Some(AssocItem(hir::ImplItem::TypeAlias(_))) => "type", |
108 | Some(Def(hir::ModuleDef::Module(_))) => "module", | 108 | Some(Def(hir::ModuleDef::Module(_))) => "module", |
109 | Some(Def(hir::ModuleDef::Function(_))) => "function", | 109 | Some(Def(hir::ModuleDef::Function(_))) => "function", |
110 | Some(Def(hir::ModuleDef::Struct(_))) => "type", | 110 | Some(Def(hir::ModuleDef::Adt(_))) => "type", |
111 | Some(Def(hir::ModuleDef::Union(_))) => "type", | ||
112 | Some(Def(hir::ModuleDef::Enum(_))) => "type", | ||
113 | Some(Def(hir::ModuleDef::EnumVariant(_))) => "constant", | 111 | Some(Def(hir::ModuleDef::EnumVariant(_))) => "constant", |
114 | Some(Def(hir::ModuleDef::Const(_))) => "constant", | 112 | Some(Def(hir::ModuleDef::Const(_))) => "constant", |
115 | Some(Def(hir::ModuleDef::Static(_))) => "constant", | 113 | Some(Def(hir::ModuleDef::Static(_))) => "constant", |