mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Simplify
This commit is contained in:
parent
d157812cd1
commit
e48430cbae
8 changed files with 30 additions and 104 deletions
|
@ -2,11 +2,10 @@
|
|||
|
||||
use hir_def::{AstItemDef, HasChildSource, HasSource as _, Lookup, VariantId};
|
||||
use hir_expand::either::Either;
|
||||
use ra_syntax::ast::{self, AstNode};
|
||||
use ra_syntax::ast;
|
||||
|
||||
use crate::{
|
||||
db::{DefDatabase, HirDatabase},
|
||||
Const, Enum, EnumVariant, FieldSource, Function, HasBody, Import, MacroDef, Module,
|
||||
db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, Import, MacroDef, Module,
|
||||
ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
|
||||
};
|
||||
|
||||
|
@ -121,27 +120,3 @@ impl HasSource for Import {
|
|||
src.with_value(ptr.map(|it| it.to_node(&root), |it| it.to_node(&root)))
|
||||
}
|
||||
}
|
||||
|
||||
pub trait HasBodySource: HasBody + HasSource
|
||||
where
|
||||
Self::Ast: AstNode,
|
||||
{
|
||||
fn expr_source(
|
||||
self,
|
||||
db: &impl HirDatabase,
|
||||
expr_id: crate::expr::ExprId,
|
||||
) -> Option<Source<Either<ast::Expr, ast::RecordField>>> {
|
||||
let source_map = self.body_source_map(db);
|
||||
let source_ptr = source_map.expr_syntax(expr_id)?;
|
||||
let root = source_ptr.file_syntax(db);
|
||||
let source = source_ptr.map(|ast| ast.map(|it| it.to_node(&root), |it| it.to_node(&root)));
|
||||
Some(source)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> HasBodySource for T
|
||||
where
|
||||
T: HasBody + HasSource,
|
||||
T::Ast: AstNode,
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue