diff options
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r-- | crates/ra_hir/src/code_model_impl/konst.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/ra_hir/src/code_model_impl/konst.rs b/crates/ra_hir/src/code_model_impl/konst.rs index ee03e3374..d7722ccc2 100644 --- a/crates/ra_hir/src/code_model_impl/konst.rs +++ b/crates/ra_hir/src/code_model_impl/konst.rs | |||
@@ -3,7 +3,7 @@ use std::sync::Arc; | |||
3 | use ra_syntax::ast::{NameOwner}; | 3 | use ra_syntax::ast::{NameOwner}; |
4 | 4 | ||
5 | use crate::{ | 5 | use crate::{ |
6 | Name, AsName, Const, ConstSignature, | 6 | Name, AsName, Const, ConstSignature, Static, |
7 | type_ref::{TypeRef}, | 7 | type_ref::{TypeRef}, |
8 | PersistentHirDatabase, | 8 | PersistentHirDatabase, |
9 | }; | 9 | }; |
@@ -23,4 +23,19 @@ impl ConstSignature { | |||
23 | 23 | ||
24 | Arc::new(sig) | 24 | Arc::new(sig) |
25 | } | 25 | } |
26 | |||
27 | pub(crate) fn static_signature_query( | ||
28 | db: &impl PersistentHirDatabase, | ||
29 | konst: Static, | ||
30 | ) -> Arc<ConstSignature> { | ||
31 | let (_, node) = konst.source(db); | ||
32 | |||
33 | let name = node.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); | ||
34 | |||
35 | let type_ref = TypeRef::from_ast_opt(node.type_ref()); | ||
36 | |||
37 | let sig = ConstSignature { name, type_ref }; | ||
38 | |||
39 | Arc::new(sig) | ||
40 | } | ||
26 | } | 41 | } |