diff options
author | Ville Penttinen <[email protected]> | 2019-02-25 08:21:01 +0000 |
---|---|---|
committer | Ville Penttinen <[email protected]> | 2019-02-25 08:55:23 +0000 |
commit | 29f93a79069cf929fbc6d4efa194a0ab18bb1f45 (patch) | |
tree | 84c7e7bbff03b649287bb55c8c9488e4c6597068 /crates/ra_hir/src/code_model_impl | |
parent | 18b0bd9bffeeeaf664f4a21894d5bfff51e82b32 (diff) |
Add static type inference
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 | } |