aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_impl/konst.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/code_model_impl/konst.rs')
-rw-r--r--crates/ra_hir/src/code_model_impl/konst.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/ra_hir/src/code_model_impl/konst.rs b/crates/ra_hir/src/code_model_impl/konst.rs
new file mode 100644
index 000000000..ee03e3374
--- /dev/null
+++ b/crates/ra_hir/src/code_model_impl/konst.rs
@@ -0,0 +1,26 @@
1use std::sync::Arc;
2
3use ra_syntax::ast::{NameOwner};
4
5use crate::{
6 Name, AsName, Const, ConstSignature,
7 type_ref::{TypeRef},
8 PersistentHirDatabase,
9};
10
11impl ConstSignature {
12 pub(crate) fn const_signature_query(
13 db: &impl PersistentHirDatabase,
14 konst: Const,
15 ) -> Arc<ConstSignature> {
16 let (_, node) = konst.source(db);
17
18 let name = node.name().map(|n| n.as_name()).unwrap_or_else(Name::missing);
19
20 let type_ref = TypeRef::from_ast_opt(node.type_ref());
21
22 let sig = ConstSignature { name, type_ref };
23
24 Arc::new(sig)
25 }
26}