From 035db0fbb94e35c78cc76798844db06bd6ad8451 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 15 Mar 2020 11:26:54 +0100 Subject: Add test, remove printlns --- crates/ra_hir_expand/src/db.rs | 1 - crates/ra_ide/src/completion/complete_scope.rs | 53 ++++++++++++++++++++++++++ crates/ra_mbe/src/mbe_expander.rs | 1 - crates/ra_mbe/src/syntax_bridge.rs | 1 - 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index ad4a0732e..f1918817e 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs @@ -206,7 +206,6 @@ fn macro_expand_with_arg( }; let (tt, err) = macro_rules.0.expand(db, lazy_id, ¯o_arg.0); // Set a hard limit for the expanded tt - eprintln!("expansion size: {}", tt.count()); let count = tt.count(); if count > 65536 { return (None, Some(format!("Total tokens count exceed limit : count = {}", count))); diff --git a/crates/ra_ide/src/completion/complete_scope.rs b/crates/ra_ide/src/completion/complete_scope.rs index 2733922f8..81d3cc1b6 100644 --- a/crates/ra_ide/src/completion/complete_scope.rs +++ b/crates/ra_ide/src/completion/complete_scope.rs @@ -905,6 +905,59 @@ mod tests { ); } + #[test] + fn completes_in_simple_macro_without_closing_parens() { + assert_debug_snapshot!( + do_reference_completion( + r" + macro_rules! m { ($e:expr) => { $e } } + fn quux(x: i32) { + let y = 92; + m!(x<|> + } + " + ), + @r###" + [ + CompletionItem { + label: "m!", + source_range: [145; 146), + delete: [145; 146), + insert: "m!($0)", + kind: Macro, + detail: "macro_rules! m", + }, + CompletionItem { + label: "quux(…)", + source_range: [145; 146), + delete: [145; 146), + insert: "quux(${1:x})$0", + kind: Function, + lookup: "quux", + detail: "fn quux(x: i32)", + trigger_call_info: true, + }, + CompletionItem { + label: "x", + source_range: [145; 146), + delete: [145; 146), + insert: "x", + kind: Binding, + detail: "i32", + }, + CompletionItem { + label: "y", + source_range: [145; 146), + delete: [145; 146), + insert: "y", + kind: Binding, + detail: "i32", + }, + ] + "### + ); + } + #[test] fn completes_unresolved_uses() { assert_debug_snapshot!( diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index c2a5702f0..5fb8414b3 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs @@ -11,7 +11,6 @@ use rustc_hash::FxHashMap; use crate::{ExpandError, ExpandResult}; pub(crate) fn expand(rules: &crate::MacroRules, input: &tt::Subtree) -> ExpandResult { - eprintln!("expanding input: {:?}", input); let (mut result, mut unmatched_tokens, mut unmatched_patterns, mut err) = ( tt::Subtree::default(), usize::max_value(), diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index 8aa3b906b..fcb73fbc7 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs @@ -73,7 +73,6 @@ pub fn token_tree_to_syntax_node( tt: &tt::Subtree, fragment_kind: FragmentKind, ) -> Result<(Parse, TokenMap), ExpandError> { - eprintln!("token_tree_to_syntax_node {:?} as {:?}", tt, fragment_kind); let tmp; let tokens = match tt { tt::Subtree { delimiter: None, token_trees } => token_trees.as_slice(), -- cgit v1.2.3