mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +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::{
|
pub use crate::{
|
||||||
adt::VariantDef,
|
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,
|
expr::ExprScopes,
|
||||||
from_source::FromSource,
|
from_source::FromSource,
|
||||||
generics::{GenericDef, GenericParam, GenericParams, HasGenericParams},
|
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::{
|
pub use hir_def::{
|
||||||
either::Either,
|
|
||||||
name::Name,
|
name::Name,
|
||||||
path::{Path, PathKind},
|
path::{Path, PathKind},
|
||||||
type_ref::Mutability,
|
type_ref::Mutability,
|
||||||
};
|
};
|
||||||
|
pub use hir_expand::either::Either;
|
||||||
|
|
|
@ -4,14 +4,12 @@
|
||||||
//! this moment, this is horribly incomplete and handles only `$crate`.
|
//! this moment, this is horribly incomplete and handles only `$crate`.
|
||||||
// Should this be moved to `hir_expand`? Seems like it.
|
// Should this be moved to `hir_expand`? Seems like it.
|
||||||
|
|
||||||
|
use hir_expand::either::Either;
|
||||||
use hir_expand::{db::AstDatabase, HirFileId};
|
use hir_expand::{db::AstDatabase, HirFileId};
|
||||||
use ra_db::CrateId;
|
use ra_db::CrateId;
|
||||||
use ra_syntax::ast;
|
use ra_syntax::ast;
|
||||||
|
|
||||||
use crate::{
|
use crate::name::{AsName, Name};
|
||||||
either::Either,
|
|
||||||
name::{AsName, Name},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Hygiene {
|
pub struct Hygiene {
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
//! actually true.
|
//! actually true.
|
||||||
|
|
||||||
pub mod db;
|
pub mod db;
|
||||||
pub mod either;
|
|
||||||
pub mod attr;
|
pub mod attr;
|
||||||
pub mod name;
|
pub mod name;
|
||||||
pub mod path;
|
pub mod path;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use std::{ops::Index, sync::Arc};
|
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_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
ast::{self, AttrsOwner, NameOwner},
|
ast::{self, AttrsOwner, NameOwner},
|
||||||
|
@ -12,7 +12,6 @@ use ra_syntax::{
|
||||||
use crate::{
|
use crate::{
|
||||||
attr::Attr,
|
attr::Attr,
|
||||||
db::DefDatabase2,
|
db::DefDatabase2,
|
||||||
either::Either,
|
|
||||||
hygiene::Hygiene,
|
hygiene::Hygiene,
|
||||||
name::{AsName, Name},
|
name::{AsName, Name},
|
||||||
path::Path,
|
path::Path,
|
||||||
|
@ -41,10 +40,8 @@ pub struct ImportSourceMap {
|
||||||
type ImportSourcePtr = Either<AstPtr<ast::UseTree>, AstPtr<ast::ExternCrateItem>>;
|
type ImportSourcePtr = Either<AstPtr<ast::UseTree>, AstPtr<ast::ExternCrateItem>>;
|
||||||
type ImportSource = Either<ast::UseTree, ast::ExternCrateItem>;
|
type ImportSource = Either<ast::UseTree, ast::ExternCrateItem>;
|
||||||
|
|
||||||
impl ImportSourcePtr {
|
fn to_node(ptr: ImportSourcePtr, file: &SourceFile) -> ImportSource {
|
||||||
fn to_node(self, file: &SourceFile) -> ImportSource {
|
ptr.map(|ptr| ptr.to_node(file.syntax()), |ptr| ptr.to_node(file.syntax()))
|
||||||
self.map(|ptr| ptr.to_node(file.syntax()), |ptr| ptr.to_node(file.syntax()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImportSourceMap {
|
impl ImportSourceMap {
|
||||||
|
@ -58,7 +55,7 @@ impl ImportSourceMap {
|
||||||
ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(),
|
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 std::{iter, sync::Arc};
|
||||||
|
|
||||||
|
use hir_expand::either::Either;
|
||||||
use ra_db::CrateId;
|
use ra_db::CrateId;
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
ast::{self, NameOwner, TypeAscriptionOwner},
|
ast::{self, NameOwner, TypeAscriptionOwner},
|
||||||
|
@ -9,7 +10,6 @@ use ra_syntax::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
either::Either,
|
|
||||||
hygiene::Hygiene,
|
hygiene::Hygiene,
|
||||||
name::{self, AsName, Name},
|
name::{self, AsName, Name},
|
||||||
type_ref::TypeRef,
|
type_ref::TypeRef,
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
pub mod db;
|
pub mod db;
|
||||||
pub mod ast_id_map;
|
pub mod ast_id_map;
|
||||||
|
pub mod either;
|
||||||
|
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue