mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
use Source for statics and consts
This commit is contained in:
parent
4f94af3c4a
commit
46bc8675ed
6 changed files with 41 additions and 56 deletions
|
@ -761,12 +761,17 @@ pub struct Const {
|
|||
pub(crate) id: ConstId,
|
||||
}
|
||||
|
||||
impl HasSource for Const {
|
||||
type Ast = TreeArc<ast::ConstDef>;
|
||||
|
||||
fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::ConstDef>> {
|
||||
self.id.source(db).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl Const {
|
||||
pub fn source(
|
||||
self,
|
||||
db: &(impl DefDatabase + AstDatabase),
|
||||
) -> (HirFileId, TreeArc<ast::ConstDef>) {
|
||||
self.id.source(db)
|
||||
pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::ConstDef>> {
|
||||
self.id.source(db).into()
|
||||
}
|
||||
|
||||
pub fn module(self, db: &impl DefDatabase) -> Module {
|
||||
|
@ -819,7 +824,7 @@ impl ConstSignature {
|
|||
db: &(impl DefDatabase + AstDatabase),
|
||||
konst: Const,
|
||||
) -> Arc<ConstSignature> {
|
||||
let (_, node) = konst.source(db);
|
||||
let node = konst.source(db).ast;
|
||||
const_signature_for(&*node)
|
||||
}
|
||||
|
||||
|
@ -827,7 +832,7 @@ impl ConstSignature {
|
|||
db: &(impl DefDatabase + AstDatabase),
|
||||
konst: Static,
|
||||
) -> Arc<ConstSignature> {
|
||||
let (_, node) = konst.source(db);
|
||||
let node = konst.source(db).ast;
|
||||
const_signature_for(&*node)
|
||||
}
|
||||
}
|
||||
|
@ -844,12 +849,17 @@ pub struct Static {
|
|||
pub(crate) id: StaticId,
|
||||
}
|
||||
|
||||
impl HasSource for Static {
|
||||
type Ast = TreeArc<ast::StaticDef>;
|
||||
|
||||
fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::StaticDef>> {
|
||||
self.id.source(db).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl Static {
|
||||
pub fn source(
|
||||
self,
|
||||
db: &(impl DefDatabase + AstDatabase),
|
||||
) -> (HirFileId, TreeArc<ast::StaticDef>) {
|
||||
self.id.source(db)
|
||||
pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::StaticDef>> {
|
||||
self.id.source(db).into()
|
||||
}
|
||||
|
||||
pub fn module(self, db: &impl DefDatabase) -> Module {
|
||||
|
|
|
@ -79,8 +79,8 @@ pub(crate) fn documentation_query(
|
|||
DocDef::Struct(it) => docs_from_ast(&*it.source(db).ast),
|
||||
DocDef::Enum(it) => docs_from_ast(&*it.source(db).ast),
|
||||
DocDef::EnumVariant(it) => docs_from_ast(&*it.source(db).ast),
|
||||
DocDef::Static(it) => docs_from_ast(&*it.source(db).1),
|
||||
DocDef::Const(it) => docs_from_ast(&*it.source(db).1),
|
||||
DocDef::Static(it) => docs_from_ast(&*it.source(db).ast),
|
||||
DocDef::Const(it) => docs_from_ast(&*it.source(db).ast),
|
||||
DocDef::Function(it) => docs_from_ast(&*it.source(db).ast),
|
||||
DocDef::Union(it) => docs_from_ast(&*it.source(db).1),
|
||||
DocDef::Trait(it) => docs_from_ast(&*it.source(db).1),
|
||||
|
|
|
@ -1018,9 +1018,9 @@ pub(crate) fn body_with_source_map_query(
|
|||
|
||||
match def {
|
||||
DefWithBody::Const(ref c) => {
|
||||
let (file_id, src) = c.source(db);
|
||||
collector = ExprCollector::new(def, file_id, def.resolver(db), db);
|
||||
collector.collect_const_body(&src)
|
||||
let src = c.source(db);
|
||||
collector = ExprCollector::new(def, src.file_id, def.resolver(db), db);
|
||||
collector.collect_const_body(&src.ast)
|
||||
}
|
||||
DefWithBody::Function(ref f) => {
|
||||
let src = f.source(db);
|
||||
|
@ -1028,9 +1028,9 @@ pub(crate) fn body_with_source_map_query(
|
|||
collector.collect_fn_body(&src.ast)
|
||||
}
|
||||
DefWithBody::Static(ref s) => {
|
||||
let (file_id, src) = s.source(db);
|
||||
collector = ExprCollector::new(def, file_id, def.resolver(db), db);
|
||||
collector.collect_static_body(&src)
|
||||
let src = s.source(db);
|
||||
collector = ExprCollector::new(def, src.file_id, def.resolver(db), db);
|
||||
collector.collect_static_body(&src.ast)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue