From 7d873fcfa1cb56cf6e9571ece4e70bef90772469 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 5 Mar 2020 11:08:31 +0100 Subject: Move PathResolution --- crates/ra_hir/src/lib.rs | 3 +-- crates/ra_hir/src/semantics.rs | 17 +++++++++++++++-- crates/ra_hir/src/source_analyzer.rs | 17 ++--------------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index e1cb12cca..9f59d590c 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs @@ -45,8 +45,7 @@ pub use crate::{ StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, }, has_source::HasSource, - semantics::{original_range, Semantics, SemanticsScope}, - source_analyzer::PathResolution, + semantics::{original_range, PathResolution, Semantics, SemanticsScope}, }; pub use hir_def::{ diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 7ce785791..965d185a4 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -20,10 +20,23 @@ use crate::{ db::HirDatabase, semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, source_analyzer::{resolve_hir_path, SourceAnalyzer}, - Function, HirFileId, InFile, Local, MacroDef, Module, ModuleDef, Name, Origin, Path, - PathResolution, ScopeDef, StructField, Trait, Type, TypeParam, VariantDef, + AssocItem, Function, HirFileId, ImplDef, InFile, Local, MacroDef, Module, ModuleDef, Name, + Origin, Path, ScopeDef, StructField, Trait, Type, TypeParam, VariantDef, }; +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum PathResolution { + /// An item + Def(ModuleDef), + /// A local binding (only value namespace) + Local(Local), + /// A generic parameter + TypeParam(TypeParam), + SelfType(ImplDef), + Macro(MacroDef), + AssocItem(AssocItem), +} + /// Primary API to get semantic information, like types, from syntax trees. pub struct Semantics<'db, DB> { pub db: &'db DB, diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index af2a8b57c..f3f1ed05a 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs @@ -24,8 +24,8 @@ use ra_syntax::{ }; use crate::{ - db::HirDatabase, Adt, Const, EnumVariant, Function, Local, MacroDef, ModPath, ModuleDef, Path, - PathKind, Static, Struct, Trait, Type, TypeAlias, TypeParam, + db::HirDatabase, semantics::PathResolution, Adt, Const, EnumVariant, Function, Local, MacroDef, + ModPath, ModuleDef, Path, PathKind, Static, Struct, Trait, Type, TypeAlias, TypeParam, }; /// `SourceAnalyzer` is a convenience wrapper which exposes HIR API in terms of @@ -40,19 +40,6 @@ pub(crate) struct SourceAnalyzer { scopes: Option>, } -#[derive(Debug, Clone, PartialEq, Eq)] -pub enum PathResolution { - /// An item - Def(crate::ModuleDef), - /// A local binding (only value namespace) - Local(Local), - /// A generic parameter - TypeParam(TypeParam), - SelfType(crate::ImplDef), - Macro(MacroDef), - AssocItem(crate::AssocItem), -} - impl SourceAnalyzer { pub(crate) fn new_for_body( db: &impl HirDatabase, -- cgit v1.2.3