From 59e29aef633e906837f8fed604435976a46be691 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 28 Nov 2018 04:09:44 +0300 Subject: Move hir to a separate crate --- crates/ra_hir/src/function/mod.rs | 16 ++++++++-------- crates/ra_hir/src/function/scope.rs | 17 +++++++---------- 2 files changed, 15 insertions(+), 18 deletions(-) (limited to 'crates/ra_hir/src/function') diff --git a/crates/ra_hir/src/function/mod.rs b/crates/ra_hir/src/function/mod.rs index a3ed00f02..c8af2e54f 100644 --- a/crates/ra_hir/src/function/mod.rs +++ b/crates/ra_hir/src/function/mod.rs @@ -15,10 +15,10 @@ use crate::{ FnId, HirDatabase, SourceItemId, }; -pub(crate) use self::scope::FnScopes; +pub use self::scope::FnScopes; impl FnId { - pub(crate) fn get(db: &impl HirDatabase, file_id: FileId, fn_def: ast::FnDef) -> FnId { + pub fn get(db: &impl HirDatabase, file_id: FileId, fn_def: ast::FnDef) -> FnId { let file_items = db.file_items(file_id); let item_id = file_items.id_of(fn_def.syntax()); let item_id = SourceItemId { file_id, item_id }; @@ -26,12 +26,12 @@ impl FnId { } } -pub(crate) struct Function { +pub struct Function { fn_id: FnId, } impl Function { - pub(crate) fn guess_from_source( + pub fn guess_from_source( db: &impl HirDatabase, file_id: FileId, fn_def: ast::FnDef, @@ -40,7 +40,7 @@ impl Function { Function { fn_id } } - pub(crate) fn guess_for_name_ref( + pub fn guess_for_name_ref( db: &impl HirDatabase, file_id: FileId, name_ref: ast::NameRef, @@ -48,7 +48,7 @@ impl Function { Function::guess_for_node(db, file_id, name_ref.syntax()) } - pub(crate) fn guess_for_bind_pat( + pub fn guess_for_bind_pat( db: &impl HirDatabase, file_id: FileId, bind_pat: ast::BindPat, @@ -66,11 +66,11 @@ impl Function { Some(res) } - pub(crate) fn scope(&self, db: &impl HirDatabase) -> Arc { + pub fn scope(&self, db: &impl HirDatabase) -> Arc { db.fn_scopes(self.fn_id) } - pub(crate) fn signature_info(&self, db: &impl HirDatabase) -> Option { + pub fn signature_info(&self, db: &impl HirDatabase) -> Option { let syntax = db.fn_syntax(self.fn_id); FnSignatureInfo::new(syntax.borrowed()) } diff --git a/crates/ra_hir/src/function/scope.rs b/crates/ra_hir/src/function/scope.rs index c8b6b1934..863453291 100644 --- a/crates/ra_hir/src/function/scope.rs +++ b/crates/ra_hir/src/function/scope.rs @@ -15,7 +15,7 @@ pub(crate) type ScopeId = Id; #[derive(Debug, PartialEq, Eq)] pub struct FnScopes { - pub(crate) self_param: Option, + pub self_param: Option, scopes: Arena, scope_for: FxHashMap, } @@ -27,13 +27,13 @@ pub struct ScopeEntry { } #[derive(Debug, PartialEq, Eq)] -pub(crate) struct ScopeData { +pub struct ScopeData { parent: Option, entries: Vec, } impl FnScopes { - pub(crate) fn new(fn_def: ast::FnDef) -> FnScopes { + pub fn new(fn_def: ast::FnDef) -> FnScopes { let mut scopes = FnScopes { self_param: fn_def .param_list() @@ -49,7 +49,7 @@ impl FnScopes { } scopes } - pub(crate) fn entries(&self, scope: ScopeId) -> &[ScopeEntry] { + pub fn entries(&self, scope: ScopeId) -> &[ScopeEntry] { &self.scopes[scope].entries } pub fn scope_chain<'a>(&'a self, node: SyntaxNodeRef) -> impl Iterator + 'a { @@ -57,10 +57,7 @@ impl FnScopes { self.scopes[scope].parent }) } - pub(crate) fn resolve_local_name<'a>( - &'a self, - name_ref: ast::NameRef, - ) -> Option<&'a ScopeEntry> { + pub fn resolve_local_name<'a>(&'a self, name_ref: ast::NameRef) -> Option<&'a ScopeEntry> { let mut shadowed = FxHashSet::default(); let ret = self .scope_chain(name_ref.syntax()) @@ -138,10 +135,10 @@ impl ScopeEntry { }; Some(res) } - pub(crate) fn name(&self) -> &SmolStr { + pub fn name(&self) -> &SmolStr { &self.name } - pub(crate) fn ptr(&self) -> LocalSyntaxPtr { + pub fn ptr(&self) -> LocalSyntaxPtr { self.ptr } } -- cgit v1.2.3