diff options
Diffstat (limited to 'crates/ide/src/diagnostics.rs')
-rw-r--r-- | crates/ide/src/diagnostics.rs | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index 3d05dd093..1a4800832 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs | |||
@@ -7,6 +7,7 @@ | |||
7 | mod unresolved_module; | 7 | mod unresolved_module; |
8 | mod unresolved_extern_crate; | 8 | mod unresolved_extern_crate; |
9 | mod unresolved_import; | 9 | mod unresolved_import; |
10 | mod unresolved_macro_call; | ||
10 | mod missing_fields; | 11 | mod missing_fields; |
11 | 12 | ||
12 | mod fixes; | 13 | mod fixes; |
@@ -16,9 +17,8 @@ mod unlinked_file; | |||
16 | use std::cell::RefCell; | 17 | use std::cell::RefCell; |
17 | 18 | ||
18 | use hir::{ | 19 | use hir::{ |
19 | db::AstDatabase, | ||
20 | diagnostics::{AnyDiagnostic, Diagnostic as _, DiagnosticCode, DiagnosticSinkBuilder}, | 20 | diagnostics::{AnyDiagnostic, Diagnostic as _, DiagnosticCode, DiagnosticSinkBuilder}, |
21 | InFile, Semantics, | 21 | Semantics, |
22 | }; | 22 | }; |
23 | use ide_assists::AssistResolveStrategy; | 23 | use ide_assists::AssistResolveStrategy; |
24 | use ide_db::{base_db::SourceDatabase, RootDatabase}; | 24 | use ide_db::{base_db::SourceDatabase, RootDatabase}; |
@@ -203,20 +203,6 @@ pub(crate) fn diagnostics( | |||
203 | res.borrow_mut() | 203 | res.borrow_mut() |
204 | .push(Diagnostic::hint(display_range, d.message()).with_code(Some(d.code()))); | 204 | .push(Diagnostic::hint(display_range, d.message()).with_code(Some(d.code()))); |
205 | }) | 205 | }) |
206 | .on::<hir::diagnostics::UnresolvedMacroCall, _>(|d| { | ||
207 | let last_path_segment = sema.db.parse_or_expand(d.file).and_then(|root| { | ||
208 | d.node | ||
209 | .to_node(&root) | ||
210 | .path() | ||
211 | .and_then(|it| it.segment()) | ||
212 | .and_then(|it| it.name_ref()) | ||
213 | .map(|it| InFile::new(d.file, SyntaxNodePtr::new(it.syntax()))) | ||
214 | }); | ||
215 | let diagnostics = last_path_segment.unwrap_or_else(|| d.display_source()); | ||
216 | let display_range = sema.diagnostics_display_range(diagnostics).range; | ||
217 | res.borrow_mut() | ||
218 | .push(Diagnostic::error(display_range, d.message()).with_code(Some(d.code()))); | ||
219 | }) | ||
220 | .on::<hir::diagnostics::UnimplementedBuiltinMacro, _>(|d| { | 206 | .on::<hir::diagnostics::UnimplementedBuiltinMacro, _>(|d| { |
221 | let display_range = sema.diagnostics_display_range(d.display_source()).range; | 207 | let display_range = sema.diagnostics_display_range(d.display_source()).range; |
222 | res.borrow_mut() | 208 | res.borrow_mut() |
@@ -259,6 +245,7 @@ pub(crate) fn diagnostics( | |||
259 | AnyDiagnostic::UnresolvedModule(d) => unresolved_module::unresolved_module(&ctx, &d), | 245 | AnyDiagnostic::UnresolvedModule(d) => unresolved_module::unresolved_module(&ctx, &d), |
260 | AnyDiagnostic::UnresolvedExternCrate(d) => unresolved_extern_crate::unresolved_extern_crate(&ctx, &d), | 246 | AnyDiagnostic::UnresolvedExternCrate(d) => unresolved_extern_crate::unresolved_extern_crate(&ctx, &d), |
261 | AnyDiagnostic::UnresolvedImport(d) => unresolved_import::unresolved_import(&ctx, &d), | 247 | AnyDiagnostic::UnresolvedImport(d) => unresolved_import::unresolved_import(&ctx, &d), |
248 | AnyDiagnostic::UnresolvedMacroCall(d) => unresolved_macro_call::unresolved_macro_call(&ctx, &d), | ||
262 | AnyDiagnostic::MissingFields(d) => missing_fields::missing_fields(&ctx, &d), | 249 | AnyDiagnostic::MissingFields(d) => missing_fields::missing_fields(&ctx, &d), |
263 | }; | 250 | }; |
264 | if let Some(code) = d.code { | 251 | if let Some(code) = d.code { |
@@ -481,16 +468,6 @@ mod tests { | |||
481 | } | 468 | } |
482 | 469 | ||
483 | #[test] | 470 | #[test] |
484 | fn test_unresolved_macro_range() { | ||
485 | check_diagnostics( | ||
486 | r#" | ||
487 | foo::bar!(92); | ||
488 | //^^^ unresolved macro `foo::bar!` | ||
489 | "#, | ||
490 | ); | ||
491 | } | ||
492 | |||
493 | #[test] | ||
494 | fn range_mapping_out_of_macros() { | 471 | fn range_mapping_out_of_macros() { |
495 | // FIXME: this is very wrong, but somewhat tricky to fix. | 472 | // FIXME: this is very wrong, but somewhat tricky to fix. |
496 | check_fix( | 473 | check_fix( |