From f78b0926299f240e5f0d8c687b11c4ebd2301325 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 27 Jan 2019 00:32:27 +0300 Subject: fix panic in call info closes #317 closes #675 --- crates/ra_ide_api/src/call_info.rs | 22 ++++++++++++++++++++-- crates/ra_ide_api/src/marks.rs | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs index 3267fff96..f203a6bf1 100644 --- a/crates/ra_ide_api/src/call_info.rs +++ b/crates/ra_ide_api/src/call_info.rs @@ -1,3 +1,4 @@ +use test_utils::tested_by; use ra_db::SourceDatabase; use ra_syntax::{ AstNode, SyntaxNode, TextUnit, TextRange, @@ -41,7 +42,12 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option Vec { #[cfg(test)] mod tests { - use super::*; + use test_utils::covers; use crate::mock_analysis::single_file_with_position; + use super::*; + fn call_info(text: &str) -> CallInfo { let (analysis, position) = single_file_with_position(text); analysis.call_info(position).unwrap().unwrap() @@ -417,4 +425,14 @@ By default this method stops actor's `Context`."# ); } + #[test] + fn call_info_bad_offset() { + covers!(call_info_bad_offset); + let (analysis, position) = single_file_with_position( + r#"fn foo(x: u32, y: u32) -> u32 {x + y} + fn bar() { foo <|> (3, ); }"#, + ); + let call_info = analysis.call_info(position).unwrap(); + assert!(call_info.is_none()); + } } diff --git a/crates/ra_ide_api/src/marks.rs b/crates/ra_ide_api/src/marks.rs index e33bf6c91..21ce7289d 100644 --- a/crates/ra_ide_api/src/marks.rs +++ b/crates/ra_ide_api/src/marks.rs @@ -2,4 +2,5 @@ test_utils::marks!( inserts_parens_for_function_calls goto_definition_works_for_methods goto_definition_works_for_fields + call_info_bad_offset ); -- cgit v1.2.3