mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
push either to hir_expand
This commit is contained in:
parent
0bc7d28518
commit
b05d6e53fb
7 changed files with 16 additions and 22 deletions
|
@ -60,6 +60,13 @@ use crate::{ids::MacroFileKind, resolve::Resolver};
|
|||
|
||||
pub use crate::{
|
||||
adt::VariantDef,
|
||||
code_model::{
|
||||
docs::{DocDef, Docs, Documentation},
|
||||
src::{HasBodySource, HasSource, Source},
|
||||
Adt, AssocItem, BuiltinType, Const, ConstData, Container, Crate, CrateDependency,
|
||||
DefWithBody, Enum, EnumVariant, FieldSource, FnData, Function, HasBody, MacroDef, Module,
|
||||
ModuleDef, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
|
||||
},
|
||||
expr::ExprScopes,
|
||||
from_source::FromSource,
|
||||
generics::{GenericDef, GenericParam, GenericParams, HasGenericParams},
|
||||
|
@ -73,17 +80,9 @@ pub use crate::{
|
|||
},
|
||||
};
|
||||
|
||||
pub use self::code_model::{
|
||||
docs::{DocDef, Docs, Documentation},
|
||||
src::{HasBodySource, HasSource, Source},
|
||||
Adt, AssocItem, BuiltinType, Const, ConstData, Container, Crate, CrateDependency, DefWithBody,
|
||||
Enum, EnumVariant, FieldSource, FnData, Function, HasBody, MacroDef, Module, ModuleDef,
|
||||
ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
|
||||
};
|
||||
|
||||
pub use hir_def::{
|
||||
either::Either,
|
||||
name::Name,
|
||||
path::{Path, PathKind},
|
||||
type_ref::Mutability,
|
||||
};
|
||||
pub use hir_expand::either::Either;
|
||||
|
|
|
@ -4,14 +4,12 @@
|
|||
//! this moment, this is horribly incomplete and handles only `$crate`.
|
||||
// Should this be moved to `hir_expand`? Seems like it.
|
||||
|
||||
use hir_expand::either::Either;
|
||||
use hir_expand::{db::AstDatabase, HirFileId};
|
||||
use ra_db::CrateId;
|
||||
use ra_syntax::ast;
|
||||
|
||||
use crate::{
|
||||
either::Either,
|
||||
name::{AsName, Name},
|
||||
};
|
||||
use crate::name::{AsName, Name};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Hygiene {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
//! actually true.
|
||||
|
||||
pub mod db;
|
||||
pub mod either;
|
||||
pub mod attr;
|
||||
pub mod name;
|
||||
pub mod path;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use std::{ops::Index, sync::Arc};
|
||||
|
||||
use hir_expand::{ast_id_map::AstIdMap, db::AstDatabase};
|
||||
use hir_expand::{ast_id_map::AstIdMap, db::AstDatabase, either::Either};
|
||||
use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
|
||||
use ra_syntax::{
|
||||
ast::{self, AttrsOwner, NameOwner},
|
||||
|
@ -12,7 +12,6 @@ use ra_syntax::{
|
|||
use crate::{
|
||||
attr::Attr,
|
||||
db::DefDatabase2,
|
||||
either::Either,
|
||||
hygiene::Hygiene,
|
||||
name::{AsName, Name},
|
||||
path::Path,
|
||||
|
@ -41,10 +40,8 @@ pub struct ImportSourceMap {
|
|||
type ImportSourcePtr = Either<AstPtr<ast::UseTree>, AstPtr<ast::ExternCrateItem>>;
|
||||
type ImportSource = Either<ast::UseTree, ast::ExternCrateItem>;
|
||||
|
||||
impl ImportSourcePtr {
|
||||
fn to_node(self, file: &SourceFile) -> ImportSource {
|
||||
self.map(|ptr| ptr.to_node(file.syntax()), |ptr| ptr.to_node(file.syntax()))
|
||||
}
|
||||
fn to_node(ptr: ImportSourcePtr, file: &SourceFile) -> ImportSource {
|
||||
ptr.map(|ptr| ptr.to_node(file.syntax()), |ptr| ptr.to_node(file.syntax()))
|
||||
}
|
||||
|
||||
impl ImportSourceMap {
|
||||
|
@ -58,7 +55,7 @@ impl ImportSourceMap {
|
|||
ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(),
|
||||
};
|
||||
|
||||
self.map[import].to_node(&file)
|
||||
to_node(self.map[import], &file)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use std::{iter, sync::Arc};
|
||||
|
||||
use hir_expand::either::Either;
|
||||
use ra_db::CrateId;
|
||||
use ra_syntax::{
|
||||
ast::{self, NameOwner, TypeAscriptionOwner},
|
||||
|
@ -9,7 +10,6 @@ use ra_syntax::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
either::Either,
|
||||
hygiene::Hygiene,
|
||||
name::{self, AsName, Name},
|
||||
type_ref::TypeRef,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
pub mod db;
|
||||
pub mod ast_id_map;
|
||||
pub mod either;
|
||||
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
|
|
Loading…
Reference in a new issue