From 29f93a79069cf929fbc6d4efa194a0ab18bb1f45 Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Mon, 25 Feb 2019 10:21:01 +0200 Subject: Add static type inference --- crates/ra_hir/src/code_model_impl/konst.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir/src/code_model_impl') 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; use ra_syntax::ast::{NameOwner}; use crate::{ - Name, AsName, Const, ConstSignature, + Name, AsName, Const, ConstSignature, Static, type_ref::{TypeRef}, PersistentHirDatabase, }; @@ -23,4 +23,19 @@ impl ConstSignature { Arc::new(sig) } + + pub(crate) fn static_signature_query( + db: &impl PersistentHirDatabase, + konst: Static, + ) -> Arc { + let (_, node) = konst.source(db); + + let name = node.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); + + let type_ref = TypeRef::from_ast_opt(node.type_ref()); + + let sig = ConstSignature { name, type_ref }; + + Arc::new(sig) + } } -- cgit v1.2.3