Skip to content

Commit 44f5e20

Browse files
committed
Remove lower_path from AssistCtx to Semantic
1 parent bdcf6f5 commit 44f5e20

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

crates/ra_assists/src/assist_ctx.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! This module defines `AssistCtx` -- the API surface that is exposed to assists.
22
use hir::Semantics;
3-
use ra_db::{FileRange, Upcast};
3+
use ra_db::FileRange;
44
use ra_fmt::{leading_indent, reindent};
55
use ra_ide_db::RootDatabase;
66
use ra_syntax::{
77
algo::{self, find_covering_element, find_node_at_offset},
8-
ast, AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange,
9-
TextSize, TokenAtOffset,
8+
AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize,
9+
TokenAtOffset,
1010
};
1111
use ra_text_edit::TextEditBuilder;
1212

@@ -136,9 +136,6 @@ impl<'a> AssistCtx<'a> {
136136
pub(crate) fn covering_node_for_range(&self, range: TextRange) -> SyntaxElement {
137137
find_covering_element(self.source_file.syntax(), range)
138138
}
139-
pub(crate) fn lower_path(&self, path: ast::Path) -> Option<hir::Path> {
140-
hir::Path::from_src(path, &hir::Hygiene::new(self.db.upcast(), self.frange.file_id.into()))
141-
}
142139
}
143140

144141
pub(crate) struct AssistGroup<'a> {

crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(crate) fn replace_qualified_name_with_use(ctx: AssistCtx) -> Option<Assist>
2727
return None;
2828
}
2929

30-
let hir_path = ctx.lower_path(path.clone())?;
30+
let hir_path = ctx.sema.lower_path(&path)?;
3131
let segments = collect_hir_path_segments(&hir_path)?;
3232
if segments.len() < 2 {
3333
return None;

crates/ra_hir/src/semantics.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use hir_def::{
88
resolver::{self, HasResolver, Resolver},
99
AsMacroCall, TraitId,
1010
};
11-
use hir_expand::ExpansionInfo;
11+
use hir_expand::{hygiene::Hygiene, ExpansionInfo};
1212
use hir_ty::associated_type_shorthand_candidates;
1313
use itertools::Itertools;
1414
use ra_db::{FileId, FileRange};
@@ -246,6 +246,11 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
246246
self.analyze(path.syntax()).resolve_path(self.db, path)
247247
}
248248

249+
pub fn lower_path(&self, path: &ast::Path) -> Option<Path> {
250+
let src = self.find_file(path.syntax().clone());
251+
Path::from_src(path.clone(), &Hygiene::new(self.db.upcast(), src.file_id.into()))
252+
}
253+
249254
pub fn resolve_bind_pat_to_const(&self, pat: &ast::BindPat) -> Option<ModuleDef> {
250255
self.analyze(pat.syntax()).resolve_bind_pat_to_const(self.db, pat)
251256
}

0 commit comments

Comments
 (0)