Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions crates/ra_assists/src/assist_ctx.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This module defines `AssistCtx` -- the API surface that is exposed to assists.
use either::Either;
use hir::{db::HirDatabase, InFile, SourceAnalyzer};
use hir::{db::HirDatabase, InFile, SourceAnalyzer, SourceBinder};
use ra_db::FileRange;
use ra_fmt::{leading_indent, reindent};
use ra_syntax::{
Expand Down Expand Up @@ -142,12 +142,16 @@ impl<'a, DB: HirDatabase> AssistCtx<'a, DB> {
pub(crate) fn covering_element(&self) -> SyntaxElement {
find_covering_element(self.source_file.syntax(), self.frange.range)
}
pub(crate) fn source_binder(&self) -> SourceBinder<'a, DB> {
SourceBinder::new(self.db)
}
pub(crate) fn source_analyzer(
&self,
node: &SyntaxNode,
offset: Option<TextUnit>,
) -> SourceAnalyzer {
SourceAnalyzer::new(self.db, InFile::new(self.frange.file_id.into(), node), offset)
let src = InFile::new(self.frange.file_id.into(), node);
self.source_binder().analyze(src, offset)
}

pub(crate) fn covering_node_for_range(&self, range: TextRange) -> SyntaxElement {
Expand Down
7 changes: 4 additions & 3 deletions crates/ra_assists/src/assists/add_new.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use format_buf::format;
use hir::{db::HirDatabase, FromSource, InFile};
use hir::{db::HirDatabase, InFile};
use join_to_string::join;
use ra_syntax::{
ast::{
Expand Down Expand Up @@ -136,15 +136,16 @@ fn find_struct_impl(
let module = strukt.syntax().ancestors().find(|node| {
ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind())
})?;
let mut sb = ctx.source_binder();

let struct_ty = {
let src = InFile { file_id: ctx.frange.file_id.into(), value: strukt.clone() };
hir::Struct::from_source(db, src)?.ty(db)
sb.to_def(src)?.ty(db)
};

let block = module.descendants().filter_map(ast::ImplBlock::cast).find_map(|impl_blk| {
let src = InFile { file_id: ctx.frange.file_id.into(), value: impl_blk.clone() };
let blk = hir::ImplBlock::from_source(db, src)?;
let blk = sb.to_def(src)?;

let same_ty = blk.target_ty(db) == struct_ty;
let not_trait_impl = blk.target_trait(db).is_none();
Expand Down
265 changes: 0 additions & 265 deletions crates/ra_hir/src/from_source.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/ra_hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ mod from_id;
mod code_model;

mod has_source;
mod from_source;

pub use crate::{
code_model::{
Expand All @@ -45,7 +44,6 @@ pub use crate::{
MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, StructField, Trait, Type, TypeAlias,
TypeParam, Union, VariantDef,
},
from_source::FromSource,
has_source::HasSource,
source_analyzer::{PathResolution, ScopeEntryWithSyntax, SourceAnalyzer},
source_binder::SourceBinder,
Expand Down
Loading