Skip to content

Commit

Permalink
fix: make editing range accommodate for macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Flash committed Jan 2, 2024
1 parent 481fab1 commit 91bd596
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/ide-diagnostics/src/handlers/unresolved_method.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use hir::{db::ExpandDatabase, AssocItem, HirDisplay};
use hir::{db::ExpandDatabase, AssocItem, HirDisplay, InFile};
use ide_db::{
assists::{Assist, AssistId, AssistKind},
base_db::FileRange,
Expand Down Expand Up @@ -121,7 +121,9 @@ fn assoc_func_fix(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedMethodCall) -
let expr: ast::Expr = expr_ptr.value.to_node(&root);

let call = ast::MethodCallExpr::cast(expr.syntax().clone())?;
let range = call.syntax().text_range();
let range = InFile::new(expr_ptr.file_id, call.syntax().text_range())
.original_node_file_range_rooted(db)
.range;

let receiver = call.receiver()?;
let receiver_type = &ctx.sema.type_of_expr(&receiver)?.original;
Expand Down Expand Up @@ -241,7 +243,7 @@ impl A {
fn main() {
let a = A{};
a.hello();
// ^^^^^^^^^ 💡 error: no method `hello` on type `A`, but an associated function with a similar name exists
// ^^^^^ 💡 error: no method `hello` on type `A`, but an associated function with a similar name exists
}
"#,
);
Expand Down

0 comments on commit 91bd596

Please sign in to comment.