mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Remove hir for imports
This commit is contained in:
parent
3ebf15c9b2
commit
67ba9072fa
5 changed files with 23 additions and 36 deletions
|
@ -9,8 +9,8 @@ use hir_def::{
|
|||
use ra_syntax::ast;
|
||||
|
||||
use crate::{
|
||||
db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplBlock, Import, MacroDef,
|
||||
Module, Static, Struct, StructField, Trait, TypeAlias, TypeParam, Union,
|
||||
db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplBlock, MacroDef, Module,
|
||||
Static, Struct, StructField, Trait, TypeAlias, TypeParam, Union,
|
||||
};
|
||||
|
||||
pub use hir_expand::InFile;
|
||||
|
@ -117,18 +117,6 @@ impl HasSource for ImplBlock {
|
|||
self.id.lookup(db).source(db)
|
||||
}
|
||||
}
|
||||
impl HasSource for Import {
|
||||
type Ast = Either<ast::UseTree, ast::ExternCrateItem>;
|
||||
|
||||
/// Returns the syntax of the last path segment corresponding to this import
|
||||
fn source(self, db: &impl DefDatabase) -> InFile<Self::Ast> {
|
||||
let src = self.parent.definition_source(db);
|
||||
let (_, source_map) = db.raw_items_with_source_map(src.file_id);
|
||||
let root = db.parse_or_expand(src.file_id).unwrap();
|
||||
let ptr = source_map.get(self.id);
|
||||
src.with_value(ptr.map_left(|it| it.to_node(&root)).map_right(|it| it.to_node(&root)))
|
||||
}
|
||||
}
|
||||
|
||||
impl HasSource for TypeParam {
|
||||
type Ast = Either<ast::TraitDef, ast::TypeParam>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue