aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-23 18:23:17 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-23 18:23:17 +0100
commit1dc9adc6e27d603f05f794adda91bca8b6dec8ac (patch)
treec2ebe02614abf66618ed3975f7108cd03689416a /crates/ra_ide_api/src
parentef00b5af1c7a7a7cac685eff661a10252825d84a (diff)
parent5d54aa678153d0af0edc8b4dd2d74709d10ca66c (diff)
Merge #1290
1290: Add Union to code_model r=matklad a=matklad @flodiebold I am conflicted about two possible implementation approaches: * we can add a separate `struct Union` to code model * we can add `fn is_union(&self)` to existing `Struct` This PR goes with the former approach, because it seems like Unions are sufficiently different in semantics to warrant a separate types. Which is in contrast to Syntax Tree, where both structs and unions share the same node kind, because their syntax is the same. What would be the right thing to do here? Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/completion/complete_struct_literal.rs1
-rw-r--r--crates/ra_ide_api/src/completion/presentation.rs1
-rw-r--r--crates/ra_ide_api/src/display/navigation_target.rs8
-rw-r--r--crates/ra_ide_api/src/syntax_highlighting.rs1
4 files changed, 11 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_struct_literal.rs b/crates/ra_ide_api/src/completion/complete_struct_literal.rs
index 48fbf67f7..a00c1b60b 100644
--- a/crates/ra_ide_api/src/completion/complete_struct_literal.rs
+++ b/crates/ra_ide_api/src/completion/complete_struct_literal.rs
@@ -20,6 +20,7 @@ pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionCon
20 } 20 }
21 21
22 // FIXME unions 22 // FIXME unions
23 AdtDef::Union(_) => (),
23 AdtDef::Enum(_) => (), 24 AdtDef::Enum(_) => (),
24 }; 25 };
25} 26}
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs
index 9aa346688..064d379a4 100644
--- a/crates/ra_ide_api/src/completion/presentation.rs
+++ b/crates/ra_ide_api/src/completion/presentation.rs
@@ -63,6 +63,7 @@ impl Completions {
63 return self.add_function_with_name(ctx, Some(local_name), *func); 63 return self.add_function_with_name(ctx, Some(local_name), *func);
64 } 64 }
65 Resolution::Def(Struct(it)) => (CompletionItemKind::Struct, it.docs(ctx.db)), 65 Resolution::Def(Struct(it)) => (CompletionItemKind::Struct, it.docs(ctx.db)),
66 Resolution::Def(Union(it)) => (CompletionItemKind::Struct, it.docs(ctx.db)),
66 Resolution::Def(Enum(it)) => (CompletionItemKind::Enum, it.docs(ctx.db)), 67 Resolution::Def(Enum(it)) => (CompletionItemKind::Enum, it.docs(ctx.db)),
67 Resolution::Def(EnumVariant(it)) => (CompletionItemKind::EnumVariant, it.docs(ctx.db)), 68 Resolution::Def(EnumVariant(it)) => (CompletionItemKind::EnumVariant, it.docs(ctx.db)),
68 Resolution::Def(Const(it)) => (CompletionItemKind::Const, it.docs(ctx.db)), 69 Resolution::Def(Const(it)) => (CompletionItemKind::Const, 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 1c694cbc9..7f81483f7 100644
--- a/crates/ra_ide_api/src/display/navigation_target.rs
+++ b/crates/ra_ide_api/src/display/navigation_target.rs
@@ -154,6 +154,10 @@ impl NavigationTarget {
154 let (file_id, node) = s.source(db); 154 let (file_id, node) = s.source(db);
155 NavigationTarget::from_named(file_id.original_file(db), &*node) 155 NavigationTarget::from_named(file_id.original_file(db), &*node)
156 } 156 }
157 hir::AdtDef::Union(s) => {
158 let (file_id, node) = s.source(db);
159 NavigationTarget::from_named(file_id.original_file(db), &*node)
160 }
157 hir::AdtDef::Enum(s) => { 161 hir::AdtDef::Enum(s) => {
158 let (file_id, node) = s.source(db); 162 let (file_id, node) = s.source(db);
159 NavigationTarget::from_named(file_id.original_file(db), &*node) 163 NavigationTarget::from_named(file_id.original_file(db), &*node)
@@ -169,6 +173,10 @@ impl NavigationTarget {
169 let (file_id, node) = s.source(db); 173 let (file_id, node) = s.source(db);
170 NavigationTarget::from_named(file_id.original_file(db), &*node) 174 NavigationTarget::from_named(file_id.original_file(db), &*node)
171 } 175 }
176 hir::ModuleDef::Union(s) => {
177 let (file_id, node) = s.source(db);
178 NavigationTarget::from_named(file_id.original_file(db), &*node)
179 }
172 hir::ModuleDef::Const(s) => { 180 hir::ModuleDef::Const(s) => {
173 let (file_id, node) = s.source(db); 181 let (file_id, node) = s.source(db);
174 NavigationTarget::from_named(file_id.original_file(db), &*node) 182 NavigationTarget::from_named(file_id.original_file(db), &*node)
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs
index 89f20260f..77c9ae3b1 100644
--- a/crates/ra_ide_api/src/syntax_highlighting.rs
+++ b/crates/ra_ide_api/src/syntax_highlighting.rs
@@ -57,6 +57,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
57 Some(Def(ModuleDef::Module(_))) => "module", 57 Some(Def(ModuleDef::Module(_))) => "module",
58 Some(Def(ModuleDef::Function(_))) => "function", 58 Some(Def(ModuleDef::Function(_))) => "function",
59 Some(Def(ModuleDef::Struct(_))) => "type", 59 Some(Def(ModuleDef::Struct(_))) => "type",
60 Some(Def(ModuleDef::Union(_))) => "type",
60 Some(Def(ModuleDef::Enum(_))) => "type", 61 Some(Def(ModuleDef::Enum(_))) => "type",
61 Some(Def(ModuleDef::EnumVariant(_))) => "constant", 62 Some(Def(ModuleDef::EnumVariant(_))) => "constant",
62 Some(Def(ModuleDef::Const(_))) => "constant", 63 Some(Def(ModuleDef::Const(_))) => "constant",