mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Remove impl_block module
This commit is contained in:
parent
d87c16bea6
commit
191b1d238f
4 changed files with 43 additions and 55 deletions
|
@ -973,6 +973,41 @@ pub struct ImplBlock {
|
||||||
pub(crate) id: ImplId,
|
pub(crate) id: ImplId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ImplBlock {
|
||||||
|
pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> {
|
||||||
|
db.impl_data(self.id).target_trait.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn target_type(&self, db: &impl DefDatabase) -> TypeRef {
|
||||||
|
db.impl_data(self.id).target_type.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn target_ty(&self, db: &impl HirDatabase) -> Ty {
|
||||||
|
Ty::from_hir(db, &self.id.resolver(db), &self.target_type(db))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn target_trait_ref(&self, db: &impl HirDatabase) -> Option<TraitRef> {
|
||||||
|
let target_ty = self.target_ty(db);
|
||||||
|
TraitRef::from_hir(db, &self.id.resolver(db), &self.target_trait(db)?, Some(target_ty))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn items(&self, db: &impl DefDatabase) -> Vec<AssocItem> {
|
||||||
|
db.impl_data(self.id).items.iter().map(|it| (*it).into()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_negative(&self, db: &impl DefDatabase) -> bool {
|
||||||
|
db.impl_data(self.id).is_negative
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn module(&self, db: &impl DefDatabase) -> Module {
|
||||||
|
self.id.module(db).into()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn krate(&self, db: &impl DefDatabase) -> Crate {
|
||||||
|
Crate { crate_id: self.module(db).id.krate }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// For IDE only
|
/// For IDE only
|
||||||
pub enum ScopeDef {
|
pub enum ScopeDef {
|
||||||
ModuleDef(ModuleDef),
|
ModuleDef(ModuleDef),
|
||||||
|
|
|
@ -5,8 +5,8 @@ use hir_expand::either::Either;
|
||||||
use ra_syntax::ast;
|
use ra_syntax::ast;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, Import, MacroDef, Module,
|
db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplBlock, Import, MacroDef,
|
||||||
ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
|
Module, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use hir_expand::Source;
|
pub use hir_expand::Source;
|
||||||
|
@ -108,6 +108,12 @@ impl HasSource for MacroDef {
|
||||||
Source { file_id: self.id.ast_id.file_id(), value: self.id.ast_id.to_node(db) }
|
Source { file_id: self.id.ast_id.file_id(), value: self.id.ast_id.to_node(db) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl HasSource for ImplBlock {
|
||||||
|
type Ast = ast::ImplBlock;
|
||||||
|
fn source(self, db: &impl DefDatabase) -> Source<ast::ImplBlock> {
|
||||||
|
self.id.source(db)
|
||||||
|
}
|
||||||
|
}
|
||||||
impl HasSource for Import {
|
impl HasSource for Import {
|
||||||
type Ast = Either<ast::UseTree, ast::ExternCrateItem>;
|
type Ast = Either<ast::UseTree, ast::ExternCrateItem>;
|
||||||
|
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
//! FIXME: write short doc here
|
|
||||||
|
|
||||||
use hir_def::{resolver::HasResolver, type_ref::TypeRef, AstItemDef};
|
|
||||||
use ra_syntax::ast;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
|
||||||
ty::Ty,
|
|
||||||
AssocItem, Crate, HasSource, ImplBlock, Module, Source, TraitRef,
|
|
||||||
};
|
|
||||||
|
|
||||||
impl HasSource for ImplBlock {
|
|
||||||
type Ast = ast::ImplBlock;
|
|
||||||
fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::ImplBlock> {
|
|
||||||
self.id.source(db)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ImplBlock {
|
|
||||||
pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> {
|
|
||||||
db.impl_data(self.id).target_trait.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn target_type(&self, db: &impl DefDatabase) -> TypeRef {
|
|
||||||
db.impl_data(self.id).target_type.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn target_ty(&self, db: &impl HirDatabase) -> Ty {
|
|
||||||
Ty::from_hir(db, &self.id.resolver(db), &self.target_type(db))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn target_trait_ref(&self, db: &impl HirDatabase) -> Option<TraitRef> {
|
|
||||||
let target_ty = self.target_ty(db);
|
|
||||||
TraitRef::from_hir(db, &self.id.resolver(db), &self.target_trait(db)?, Some(target_ty))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn items(&self, db: &impl DefDatabase) -> Vec<AssocItem> {
|
|
||||||
db.impl_data(self.id).items.iter().map(|it| (*it).into()).collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_negative(&self, db: &impl DefDatabase) -> bool {
|
|
||||||
db.impl_data(self.id).is_negative
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn module(&self, db: &impl DefDatabase) -> Module {
|
|
||||||
self.id.module(db).into()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn krate(&self, db: &impl DefDatabase) -> Crate {
|
|
||||||
Crate { crate_id: self.module(db).id.krate }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -32,7 +32,6 @@ pub mod db;
|
||||||
pub mod source_binder;
|
pub mod source_binder;
|
||||||
|
|
||||||
mod ty;
|
mod ty;
|
||||||
mod impl_block;
|
|
||||||
mod expr;
|
mod expr;
|
||||||
pub mod diagnostics;
|
pub mod diagnostics;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue