remove inherent source impls
This commit is contained in:
parent
dd63f17027
commit
c4512fadb1
@ -1,6 +1,6 @@
|
||||
use crate::{Assist, AssistId, AssistCtx, ast_editor::{AstEditor, AstBuilder}};
|
||||
|
||||
use hir::db::HirDatabase;
|
||||
use hir::{HasSource, db::HirDatabase};
|
||||
use ra_syntax::{SmolStr, TreeArc};
|
||||
use ra_syntax::ast::{self, AstNode, FnDef, ImplItem, ImplItemKind, NameOwner};
|
||||
use ra_db::FilePosition;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::fmt::Write;
|
||||
|
||||
use hir::{
|
||||
AdtDef, FieldSource,
|
||||
AdtDef, FieldSource, HasSource,
|
||||
db::HirDatabase,
|
||||
};
|
||||
use ra_syntax::ast::{self, AstNode};
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
use crate::{
|
||||
Name, AsName, Struct, Union, Enum, EnumVariant, Crate, AstDatabase,
|
||||
HirDatabase, HirFileId, StructField, FieldSource, Source,
|
||||
HirDatabase, HirFileId, StructField, FieldSource, Source, HasSource,
|
||||
type_ref::TypeRef, DefDatabase,
|
||||
};
|
||||
|
||||
|
@ -355,10 +355,6 @@ pub fn name(&self, db: &impl HirDatabase) -> Name {
|
||||
self.parent.variant_data(db).fields().unwrap()[self.id].name.clone()
|
||||
}
|
||||
|
||||
pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> Source<FieldSource> {
|
||||
self.source_impl(db).into()
|
||||
}
|
||||
|
||||
pub fn ty(&self, db: &impl HirDatabase) -> Ty {
|
||||
db.type_for_field(*self)
|
||||
}
|
||||
@ -381,10 +377,6 @@ fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::St
|
||||
}
|
||||
|
||||
impl Struct {
|
||||
pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::StructDef>> {
|
||||
self.id.source(db).into()
|
||||
}
|
||||
|
||||
pub fn module(self, db: &impl HirDatabase) -> Module {
|
||||
self.id.module(db)
|
||||
}
|
||||
@ -446,10 +438,6 @@ fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::St
|
||||
}
|
||||
|
||||
impl Union {
|
||||
pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::StructDef>> {
|
||||
self.id.source(db).into()
|
||||
}
|
||||
|
||||
pub fn name(self, db: &impl DefDatabase) -> Option<Name> {
|
||||
db.struct_data(Struct { id: self.id }).name.clone()
|
||||
}
|
||||
@ -483,10 +471,6 @@ fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::En
|
||||
}
|
||||
|
||||
impl Enum {
|
||||
pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::EnumDef>> {
|
||||
self.id.source(db).into()
|
||||
}
|
||||
|
||||
pub fn module(self, db: &impl HirDatabase) -> Module {
|
||||
self.id.module(db)
|
||||
}
|
||||
@ -537,12 +521,6 @@ fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::En
|
||||
}
|
||||
|
||||
impl EnumVariant {
|
||||
pub fn source(
|
||||
&self,
|
||||
db: &(impl DefDatabase + AstDatabase),
|
||||
) -> Source<TreeArc<ast::EnumVariant>> {
|
||||
self.source_impl(db)
|
||||
}
|
||||
pub fn module(&self, db: &impl HirDatabase) -> Module {
|
||||
self.parent.module(db)
|
||||
}
|
||||
@ -692,10 +670,6 @@ pub fn has_self_param(&self) -> bool {
|
||||
}
|
||||
|
||||
impl Function {
|
||||
pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::FnDef>> {
|
||||
self.id.source(db).into()
|
||||
}
|
||||
|
||||
pub fn module(self, db: &impl DefDatabase) -> Module {
|
||||
self.id.module(db)
|
||||
}
|
||||
@ -778,10 +752,6 @@ fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::Co
|
||||
}
|
||||
|
||||
impl Const {
|
||||
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 {
|
||||
self.id.module(db)
|
||||
}
|
||||
@ -866,10 +836,6 @@ fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::St
|
||||
}
|
||||
|
||||
impl Static {
|
||||
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 {
|
||||
self.id.module(db)
|
||||
}
|
||||
@ -902,10 +868,6 @@ fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::Tr
|
||||
}
|
||||
|
||||
impl Trait {
|
||||
pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::TraitDef>> {
|
||||
self.id.source(db).into()
|
||||
}
|
||||
|
||||
pub fn module(self, db: &impl DefDatabase) -> Module {
|
||||
self.id.module(db)
|
||||
}
|
||||
@ -952,13 +914,6 @@ fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::Ty
|
||||
}
|
||||
|
||||
impl TypeAlias {
|
||||
pub fn source(
|
||||
self,
|
||||
db: &(impl DefDatabase + AstDatabase),
|
||||
) -> Source<TreeArc<ast::TypeAliasDef>> {
|
||||
self.id.source(db).into()
|
||||
}
|
||||
|
||||
pub fn module(self, db: &impl DefDatabase) -> Module {
|
||||
self.id.module(db)
|
||||
}
|
||||
@ -1015,11 +970,7 @@ fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::Ma
|
||||
}
|
||||
}
|
||||
|
||||
impl MacroDef {
|
||||
pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::MacroCall>> {
|
||||
(self.id.0.file_id(), self.id.0.to_node(db)).into()
|
||||
}
|
||||
}
|
||||
impl MacroDef {}
|
||||
|
||||
pub enum Container {
|
||||
Trait(Trait),
|
||||
|
@ -3,7 +3,7 @@
|
||||
use ra_syntax::ast;
|
||||
|
||||
use crate::{
|
||||
HirDatabase, DefDatabase, AstDatabase,
|
||||
HirDatabase, DefDatabase, AstDatabase, HasSource,
|
||||
Module, StructField, Struct, Enum, EnumVariant, Static, Const, Function, Union, Trait, TypeAlias, FieldSource, MacroDef,
|
||||
};
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
use crate::{
|
||||
Path, Name, HirDatabase, Resolver,DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind,
|
||||
HasSource,
|
||||
name::AsName,
|
||||
type_ref::{Mutability, TypeRef},
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
use crate::{
|
||||
expr::AstPtr,
|
||||
HirDatabase, Function, Name,
|
||||
HirDatabase, Function, Name, HasSource,
|
||||
diagnostics::{DiagnosticSink, MissingFields},
|
||||
adt::AdtDef,
|
||||
Path,
|
||||
|
@ -8,8 +8,10 @@
|
||||
use ra_syntax::ast::{self, NameOwner, TypeParamsOwner, TypeBoundsOwner, DefaultTypeParamOwner};
|
||||
|
||||
use crate::{
|
||||
HasSource,
|
||||
Name, AsName, Function, Struct, Union, Enum, Trait, TypeAlias, ImplBlock, Container, AdtDef,
|
||||
db::{HirDatabase, DefDatabase, AstDatabase},
|
||||
Name, AsName, Function, Struct, Union, Enum, Trait, TypeAlias, ImplBlock, Container, path::Path, type_ref::TypeRef, AdtDef
|
||||
path::Path, type_ref::TypeRef,
|
||||
};
|
||||
|
||||
/// Data about a generic parameter (to a function, struct, impl, ...).
|
||||
|
@ -6,7 +6,7 @@
|
||||
use ra_syntax::ast::{self, NameOwner};
|
||||
|
||||
use crate::{
|
||||
Function, Const, TypeAlias, Name, DefDatabase, Trait, AstDatabase, Module,
|
||||
Function, Const, TypeAlias, Name, DefDatabase, Trait, AstDatabase, Module, HasSource,
|
||||
ids::LocationCtx, name::AsName,
|
||||
};
|
||||
|
||||
|
@ -1415,7 +1415,7 @@ mod diagnostics {
|
||||
use crate::{
|
||||
expr::ExprId,
|
||||
diagnostics::{DiagnosticSink, NoSuchField},
|
||||
HirDatabase, Function,
|
||||
HirDatabase, Function, HasSource,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{TypeAlias, DefDatabase, AstDatabase, type_ref::TypeRef};
|
||||
use crate::{TypeAlias, DefDatabase, AstDatabase, HasSource, type_ref::TypeRef};
|
||||
|
||||
pub(crate) fn type_alias_ref_query(
|
||||
db: &(impl DefDatabase + AstDatabase),
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! This modules takes care of rendering various defenitions as completion items.
|
||||
use join_to_string::join;
|
||||
use test_utils::tested_by;
|
||||
use hir::{Docs, PerNs, Resolution, HirDisplay};
|
||||
use hir::{Docs, PerNs, Resolution, HirDisplay, HasSource};
|
||||
use ra_syntax::ast::NameOwner;
|
||||
|
||||
use crate::completion::{
|
||||
|
@ -1,10 +1,11 @@
|
||||
use super::{where_predicates, generic_parameters};
|
||||
use crate::db;
|
||||
use std::fmt::{self, Display};
|
||||
|
||||
use join_to_string::join;
|
||||
use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
|
||||
use std::convert::From;
|
||||
use hir::{Docs, Documentation};
|
||||
use hir::{Docs, Documentation, HasSource};
|
||||
|
||||
use crate::{db, display::{where_predicates, generic_parameters}};
|
||||
|
||||
/// Contains information about a function signature
|
||||
#[derive(Debug)]
|
||||
|
@ -5,7 +5,7 @@
|
||||
ast::{self, DocCommentsOwner},
|
||||
algo::visit::{visitor, Visitor},
|
||||
};
|
||||
use hir::{ModuleSource, FieldSource, ImplItem};
|
||||
use hir::{ModuleSource, FieldSource, ImplItem, HasSource};
|
||||
|
||||
use crate::{FileSymbol, db::RootDatabase};
|
||||
use super::short_label::ShortLabel;
|
||||
@ -182,7 +182,7 @@ pub(crate) fn from_field(db: &RootDatabase, field: hir::StructField) -> Navigati
|
||||
|
||||
pub(crate) fn from_def_source<A, D>(db: &RootDatabase, def: D) -> NavigationTarget
|
||||
where
|
||||
D: hir::HasSource<Ast = TreeArc<A>>,
|
||||
D: HasSource<Ast = TreeArc<A>>,
|
||||
A: ast::DocCommentsOwner + ast::NameOwner + ShortLabel,
|
||||
{
|
||||
let src = def.source(db);
|
||||
|
@ -4,7 +4,7 @@
|
||||
ast::{self, DocCommentsOwner},
|
||||
algo::{find_covering_element, find_node_at_offset, ancestors_at_offset, visit::{visitor, Visitor}},
|
||||
};
|
||||
use hir::HirDisplay;
|
||||
use hir::{HirDisplay, HasSource};
|
||||
|
||||
use crate::{
|
||||
db::RootDatabase,
|
||||
@ -226,7 +226,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
|
||||
|
||||
fn from_def_source<A, D>(db: &RootDatabase, def: D) -> Option<String>
|
||||
where
|
||||
D: hir::HasSource<Ast = TreeArc<A>>,
|
||||
D: HasSource<Ast = TreeArc<A>>,
|
||||
A: ast::DocCommentsOwner + ast::NameOwner + ShortLabel,
|
||||
{
|
||||
let src = def.source(db);
|
||||
|
Loading…
Reference in New Issue
Block a user