From f9e825d95624129b66c34f25904f6ae46b9d5760 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 13 Apr 2019 11:24:09 +0300 Subject: move ScopeEntryWithSyntax --- crates/ra_hir/src/expr.rs | 4 ++-- crates/ra_hir/src/expr/scope.rs | 45 +++++++++++--------------------------- crates/ra_hir/src/lib.rs | 4 ++-- crates/ra_hir/src/source_binder.rs | 18 ++++++++++++++- 4 files changed, 34 insertions(+), 37 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 239874792..817e660f9 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs @@ -14,9 +14,9 @@ use crate::{ name::AsName, type_ref::{Mutability, TypeRef}, }; -use crate::{ path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}}; +use crate::{path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}}; -pub use self::scope::{ExprScopes, ScopeEntryWithSyntax}; +pub use self::scope::ExprScopes; pub(crate) mod scope; diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs index 6a6de5772..090343d12 100644 --- a/crates/ra_hir/src/expr/scope.rs +++ b/crates/ra_hir/src/expr/scope.rs @@ -1,14 +1,11 @@ use std::sync::Arc; -use rustc_hash::{FxHashMap}; -use ra_syntax::{ - TextRange, AstPtr, - ast, -}; +use rustc_hash::FxHashMap; +use ra_syntax::TextRange; use ra_arena::{Arena, RawId, impl_arena_id}; use crate::{ - Name, DefWithBody, Either, + Name, DefWithBody, expr::{PatId, ExprId, Pat, Expr, Body, Statement}, HirDatabase, }; @@ -30,6 +27,16 @@ pub(crate) struct ScopeEntry { pat: PatId, } +impl ScopeEntry { + pub(crate) fn name(&self) -> &Name { + &self.name + } + + pub(crate) fn pat(&self) -> PatId { + self.pat + } +} + #[derive(Debug, PartialEq, Eq)] pub(crate) struct ScopeData { parent: Option, @@ -100,32 +107,6 @@ impl ExprScopes { } } -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct ScopeEntryWithSyntax { - pub(crate) name: Name, - pub(crate) ptr: Either, AstPtr>, -} - -impl ScopeEntryWithSyntax { - pub fn name(&self) -> &Name { - &self.name - } - - pub fn ptr(&self) -> Either, AstPtr> { - self.ptr - } -} - -impl ScopeEntry { - pub fn name(&self) -> &Name { - &self.name - } - - pub fn pat(&self) -> PatId { - self.pat - } -} - fn compute_block_scopes( statements: &[Statement], tail: Option, diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 5eb2f32bd..a9db23060 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs @@ -65,9 +65,9 @@ pub use self::{ impl_block::{ImplBlock, ImplItem}, docs::{Docs, Documentation}, adt::AdtDef, - expr::{ExprScopes, ScopeEntryWithSyntax}, + expr::ExprScopes, resolve::Resolution, - source_binder::{SourceAnalyzer, PathResolution}, + source_binder::{SourceAnalyzer, PathResolution, ScopeEntryWithSyntax}, }; pub use self::code_model_api::{ diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index a50287339..34a00a300 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -19,7 +19,7 @@ use ra_syntax::{ use crate::{ HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name, AsName, Module, HirFileId, Crate, Trait, Resolver, - expr::{BodySourceMap, scope::{ReferenceDescriptor, ScopeEntryWithSyntax, ScopeId, ExprScopes}}, + expr::{BodySourceMap, scope::{ReferenceDescriptor, ScopeId, ExprScopes}}, ids::LocationCtx, expr, AstId }; @@ -187,6 +187,22 @@ pub enum PathResolution { AssocItem(crate::ImplItem), } +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ScopeEntryWithSyntax { + pub(crate) name: Name, + pub(crate) ptr: Either, AstPtr>, +} + +impl ScopeEntryWithSyntax { + pub fn name(&self) -> &Name { + &self.name + } + + pub fn ptr(&self) -> Either, AstPtr> { + self.ptr + } +} + impl SourceAnalyzer { pub fn new( db: &impl HirDatabase, -- cgit v1.2.3