Skip to content

Commit 9c906bd

Browse files
bors[bot]matklad
andauthored
Merge #3469
3469: Cleanup SourceAnalyzer r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 parents e15cef7 + 7d873fc commit 9c906bd

File tree

3 files changed

+19
-26
lines changed

3 files changed

+19
-26
lines changed

crates/ra_hir/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ pub use crate::{
4545
StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef,
4646
},
4747
has_source::HasSource,
48-
semantics::{original_range, Semantics, SemanticsScope},
49-
source_analyzer::PathResolution,
48+
semantics::{original_range, PathResolution, Semantics, SemanticsScope},
5049
};
5150

5251
pub use hir_def::{

crates/ra_hir/src/semantics.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,23 @@ use crate::{
2020
db::HirDatabase,
2121
semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx},
2222
source_analyzer::{resolve_hir_path, SourceAnalyzer},
23-
Function, HirFileId, InFile, Local, MacroDef, Module, ModuleDef, Name, Origin, Path,
24-
PathResolution, ScopeDef, StructField, Trait, Type, TypeParam, VariantDef,
23+
AssocItem, Function, HirFileId, ImplDef, InFile, Local, MacroDef, Module, ModuleDef, Name,
24+
Origin, Path, ScopeDef, StructField, Trait, Type, TypeParam, VariantDef,
2525
};
2626

27+
#[derive(Debug, Clone, PartialEq, Eq)]
28+
pub enum PathResolution {
29+
/// An item
30+
Def(ModuleDef),
31+
/// A local binding (only value namespace)
32+
Local(Local),
33+
/// A generic parameter
34+
TypeParam(TypeParam),
35+
SelfType(ImplDef),
36+
Macro(MacroDef),
37+
AssocItem(AssocItem),
38+
}
39+
2740
/// Primary API to get semantic information, like types, from syntax trees.
2841
pub struct Semantics<'db, DB> {
2942
pub db: &'db DB,

crates/ra_hir/src/source_analyzer.rs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile};
2020
use hir_ty::{InEnvironment, InferenceResult, TraitEnvironment};
2121
use ra_syntax::{
2222
ast::{self, AstNode},
23-
SyntaxNode, SyntaxNodePtr, TextRange, TextUnit,
23+
SyntaxNode, SyntaxNodePtr, TextUnit,
2424
};
2525

2626
use crate::{
27-
db::HirDatabase, Adt, Const, EnumVariant, Function, Local, MacroDef, ModPath, ModuleDef, Path,
28-
PathKind, Static, Struct, Trait, Type, TypeAlias, TypeParam,
27+
db::HirDatabase, semantics::PathResolution, Adt, Const, EnumVariant, Function, Local, MacroDef,
28+
ModPath, ModuleDef, Path, PathKind, Static, Struct, Trait, Type, TypeAlias, TypeParam,
2929
};
3030

3131
/// `SourceAnalyzer` is a convenience wrapper which exposes HIR API in terms of
@@ -40,25 +40,6 @@ pub(crate) struct SourceAnalyzer {
4040
scopes: Option<Arc<ExprScopes>>,
4141
}
4242

43-
#[derive(Debug, Clone, PartialEq, Eq)]
44-
pub enum PathResolution {
45-
/// An item
46-
Def(crate::ModuleDef),
47-
/// A local binding (only value namespace)
48-
Local(Local),
49-
/// A generic parameter
50-
TypeParam(TypeParam),
51-
SelfType(crate::ImplDef),
52-
Macro(MacroDef),
53-
AssocItem(crate::AssocItem),
54-
}
55-
56-
#[derive(Debug)]
57-
pub struct ReferenceDescriptor {
58-
pub range: TextRange,
59-
pub name: String,
60-
}
61-
6243
impl SourceAnalyzer {
6344
pub(crate) fn new_for_body(
6445
db: &impl HirDatabase,

0 commit comments

Comments
 (0)