Repository: rust-analyzer/rust-analyzer
Pull request #5026 (2020-06-24 10:28:00)

Disable file watching when running slow tests
This should rid us of the intermittent test failure

https://github.com/rust-analyzer/rust-analyzer/pull/5017#issuecomment-648717983



bors r+
🤖


Patch:
diff --git a/crates/ra_db/src/fixture.rs b/crates/ra_db/src/fixture.rs
index 4f4fb44943..ddf46e6c44 100644
--- a/crates/ra_db/src/fixture.rs
+++ b/crates/ra_db/src/fixture.rs
@@ -132,17 +132,10 @@ fn with_files(
 
     let mut file_position = None;
 
-    for entry in fixture {
-        let text = if entry.text.contains(CURSOR_MARKER) {
-            let (range_or_offset, text) = extract_range_or_offset(&entry.text);
-            assert!(file_position.is_none());
-            file_position = Some((file_id, range_or_offset));
-            text.to_string()
-        } else {
-            entry.text.clone()
+    for entry in fixture.iter() {
+        let meta = match ParsedMeta::from(entry) {
+            ParsedMeta::File(it) => it,
         };
-
-        let meta = FileMeta::from(entry);
         assert!(meta.path.starts_with(&source_root_prefix));
 
         if let Some(krate) = meta.krate {
@@ -164,6 +157,15 @@ fn with_files(
             default_crate_root = Some(file_id);
         }
 
+        let text = if entry.text.contains(CURSOR_MARKER) {
+            let (range_or_offset, text) = extract_range_or_offset(&entry.text);
+            assert!(file_position.is_none());
+            file_position = Some((file_id, range_or_offset));
+            text.to_string()
+        } else {
+            entry.text.to_string()
+        };
+
         db.set_file_text(file_id, Arc::new(text));
         db.set_file_source_root(file_id, source_root_id);
         let path = VfsPath::new_virtual_path(meta.path);
@@ -196,6 +198,10 @@ fn with_files(
     (file_position, files)
 }
 
+enum ParsedMeta {
+    File(FileMeta),
+}
+
 struct FileMeta {
     path: String,
     krate: Option<String>,
@@ -205,22 +211,22 @@ struct FileMeta {
     env: Env,
 }
 
-impl From<Fixture> for FileMeta {
-    fn from(f: Fixture) -> FileMeta {
+impl From<&Fixture> for ParsedMeta {
+    fn from(f: &Fixture) -> Self {
         let mut cfg = CfgOptions::default();
         f.cfg_atoms.iter().for_each(|it| cfg.insert_atom(it.into()));
         f.cfg_key_values.iter().for_each(|(k, v)| cfg.insert_key_value(k.into(), v.into()));
 
-        FileMeta {
-            path: f.path,
-            krate: f.krate,
-            deps: f.deps,
+        Self::File(FileMeta {
+            path: f.path.to_owned(),
+            krate: f.crate_name.to_owned(),
+            deps: f.deps.to_owned(),
             cfg,
             edition: f
                 .edition
                 .as_ref()
                 .map_or(Edition::Edition2018, |v| Edition::from_str(&v).unwrap()),
             env: Env::from(f.env.iter()),
-        }
+        })
     }
 }
diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs
index a6bdf1c9de..aa039e6fcd 100644
--- a/crates/ra_ide/src/call_info.rs
+++ b/crates/ra_ide/src/call_info.rs
@@ -215,7 +215,7 @@ impl CallInfo {
 mod tests {
     use test_utils::mark;
 
-    use crate::mock_analysis::analysis_and_position;
+    use crate::mock_analysis::single_file_with_position;
 
     use super::*;
 
@@ -231,7 +231,7 @@ mod tests {
     }
 
     fn call_info_helper(text: &str) -> Option<CallInfo> {
-        let (analysis, position) = analysis_and_position(text);
+        let (analysis, position) = single_file_with_position(text);
         analysis.call_info(position).unwrap()
     }
 
@@ -530,7 +530,7 @@ By default this method stops actor's `Context`."#
     #[test]
     fn call_info_bad_offset() {
         mark::check!(call_info_bad_offset);
-        let (analysis, position) = analysis_and_position(
+        let (analysis, position) = single_file_with_position(
             r#"fn foo(x: u32, y: u32) -> u32 {x + y}
                fn bar() { foo <|> (3, ); }"#,
         );
diff --git a/crates/ra_ide/src/completion/complete_attribute.rs b/crates/ra_ide/src/completion/complete_attribute.rs
index 6beeca457b..ade17a1ff5 100644
--- a/crates/ra_ide/src/completion/complete_attribute.rs
+++ b/crates/ra_ide/src/completion/complete_attribute.rs
@@ -333,69 +333,69 @@ mod tests {
         [
             CompletionItem {
                 label: "Clone",
-                source_range: 9..9,
-                delete: 9..9,
+                source_range: 30..30,
+                delete: 30..30,
                 insert: "Clone",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "Copy, Clone",
-                source_range: 9..9,
-                delete: 9..9,
+                source_range: 30..30,
+                delete: 30..30,
                 insert: "Copy, Clone",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "Debug",
-                source_range: 9..9,
-                delete: 9..9,
+                source_range: 30..30,
+                delete: 30..30,
                 insert: "Debug",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "Default",
-                source_range: 9..9,
-                delete: 9..9,
+                source_range: 30..30,
+                delete: 30..30,
                 insert: "Default",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "Eq, PartialEq",
-                source_range: 9..9,
-                delete: 9..9,
+                source_range: 30..30,
+                delete: 30..30,
                 insert: "Eq, PartialEq",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "Hash",
-                source_range: 9..9,
-                delete: 9..9,
+                source_range: 30..30,
+                delete: 30..30,
                 insert: "Hash",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "Ord, PartialOrd, Eq, PartialEq",
-                source_range: 9..9,
-                delete: 9..9,
+                source_range: 30..30,
+                delete: 30..30,
                 insert: "Ord, PartialOrd, Eq, PartialEq",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "PartialEq",
-                source_range: 9..9,
-                delete: 9..9,
+                source_range: 30..30,
+                delete: 30..30,
                 insert: "PartialEq",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "PartialOrd, PartialEq",
-                source_range: 9..9,
-                delete: 9..9,
+                source_range: 30..30,
+                delete: 30..30,
                 insert: "PartialOrd, PartialEq",
                 kind: Attribute,
             },
         ]
-        "###
+            "###
         );
     }
 
@@ -425,62 +425,62 @@ mod tests {
         [
             CompletionItem {
                 label: "Clone",
-                source_range: 38..38,
-                delete: 38..38,
+                source_range: 59..59,
+                delete: 59..59,
                 insert: "Clone",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "Copy, Clone",
-                source_range: 38..38,
-                delete: 38..38,
+                source_range: 59..59,
+                delete: 59..59,
                 insert: "Copy, Clone",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "Debug",
-                source_range: 38..38,
-                delete: 38..38,
+                source_range: 59..59,
+                delete: 59..59,
                 insert: "Debug",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "Default",
-                source_range: 38..38,
-                delete: 38..38,
+                source_range: 59..59,
+                delete: 59..59,
                 insert: "Default",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "Eq",
-                source_range: 38..38,
-                delete: 38..38,
+                source_range: 59..59,
+                delete: 59..59,
                 insert: "Eq",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "Hash",
-                source_range: 38..38,
-                delete: 38..38,
+                source_range: 59..59,
+                delete: 59..59,
                 insert: "Hash",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "Ord, PartialOrd, Eq",
-                source_range: 38..38,
-                delete: 38..38,
+                source_range: 59..59,
+                delete: 59..59,
                 insert: "Ord, PartialOrd, Eq",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "PartialOrd",
-                source_range: 38..38,
-                delete: 38..38,
+                source_range: 59..59,
+                delete: 59..59,
                 insert: "PartialOrd",
                 kind: Attribute,
             },
         ]
-        "###
+            "###
         );
     }
 
@@ -496,207 +496,207 @@ mod tests {
         [
             CompletionItem {
                 label: "allow(…)",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "allow(${0:lint})",
                 kind: Attribute,
                 lookup: "allow",
             },
             CompletionItem {
                 label: "cfg(…)",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "cfg(${0:predicate})",
                 kind: Attribute,
                 lookup: "cfg",
             },
             CompletionItem {
                 label: "cfg_attr(…)",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "cfg_attr(${1:predicate}, ${0:attr})",
                 kind: Attribute,
                 lookup: "cfg_attr",
             },
             CompletionItem {
                 label: "deny(…)",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "deny(${0:lint})",
                 kind: Attribute,
                 lookup: "deny",
             },
             CompletionItem {
                 label: "deprecated = \"…\"",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "deprecated = \"${0:reason}\"",
                 kind: Attribute,
                 lookup: "deprecated",
             },
             CompletionItem {
                 label: "derive(…)",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "derive(${0:Debug})",
                 kind: Attribute,
                 lookup: "derive",
             },
             CompletionItem {
                 label: "doc = \"…\"",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "doc = \"${0:docs}\"",
                 kind: Attribute,
                 lookup: "doc",
             },
             CompletionItem {
                 label: "forbid(…)",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "forbid(${0:lint})",
                 kind: Attribute,
                 lookup: "forbid",
             },
             CompletionItem {
                 label: "ignore(…)",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "ignore(${0:lint})",
                 kind: Attribute,
                 lookup: "ignore",
             },
             CompletionItem {
                 label: "inline(…)",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "inline(${0:lint})",
                 kind: Attribute,
                 lookup: "inline",
             },
             CompletionItem {
                 label: "link",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "link",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "link_name = \"…\"",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "link_name = \"${0:symbol_name}\"",
                 kind: Attribute,
                 lookup: "link_name",
             },
             CompletionItem {
                 label: "macro_export",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "macro_export",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "macro_use",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "macro_use",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "must_use = \"…\"",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "must_use = \"${0:reason}\"",
                 kind: Attribute,
                 lookup: "must_use",
             },
             CompletionItem {
                 label: "no_mangle",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "no_mangle",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "non_exhaustive",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "non_exhaustive",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "path = \"…\"",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "path =\"${0:path}\"",
                 kind: Attribute,
                 lookup: "path",
             },
             CompletionItem {
                 label: "proc_macro",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "proc_macro",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "proc_macro_attribute",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "proc_macro_attribute",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "proc_macro_derive(…)",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "proc_macro_derive(${0:Trait})",
                 kind: Attribute,
                 lookup: "proc_macro_derive",
             },
             CompletionItem {
                 label: "repr(…)",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "repr(${0:C})",
                 kind: Attribute,
                 lookup: "repr",
             },
             CompletionItem {
                 label: "should_panic(…)",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "should_panic(expected = \"${0:reason}\")",
                 kind: Attribute,
                 lookup: "should_panic",
             },
             CompletionItem {
                 label: "target_feature = \"…\"",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "target_feature = \"${0:feature}\"",
                 kind: Attribute,
                 lookup: "target_feature",
             },
             CompletionItem {
                 label: "test",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "test",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "used",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "used",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "warn(…)",
-                source_range: 2..2,
-                delete: 2..2,
+                source_range: 19..19,
+                delete: 19..19,
                 insert: "warn(${0:lint})",
                 kind: Attribute,
                 lookup: "warn",
@@ -732,252 +732,252 @@ mod tests {
         [
             CompletionItem {
                 label: "allow(…)",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "allow(${0:lint})",
                 kind: Attribute,
                 lookup: "allow",
             },
             CompletionItem {
                 label: "cfg(…)",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "cfg(${0:predicate})",
                 kind: Attribute,
                 lookup: "cfg",
             },
             CompletionItem {
                 label: "cfg_attr(…)",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "cfg_attr(${1:predicate}, ${0:attr})",
                 kind: Attribute,
                 lookup: "cfg_attr",
             },
             CompletionItem {
                 label: "deny(…)",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "deny(${0:lint})",
                 kind: Attribute,
                 lookup: "deny",
             },
             CompletionItem {
                 label: "deprecated = \"…\"",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "deprecated = \"${0:reason}\"",
                 kind: Attribute,
                 lookup: "deprecated",
             },
             CompletionItem {
                 label: "derive(…)",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "derive(${0:Debug})",
                 kind: Attribute,
                 lookup: "derive",
             },
             CompletionItem {
                 label: "doc = \"…\"",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "doc = \"${0:docs}\"",
                 kind: Attribute,
                 lookup: "doc",
             },
             CompletionItem {
                 label: "feature(…)",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "feature(${0:flag})",
                 kind: Attribute,
                 lookup: "feature",
             },
             CompletionItem {
                 label: "forbid(…)",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "forbid(${0:lint})",
                 kind: Attribute,
                 lookup: "forbid",
             },
             CompletionItem {
                 label: "global_allocator",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "global_allocator",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "ignore(…)",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "ignore(${0:lint})",
                 kind: Attribute,
                 lookup: "ignore",
             },
             CompletionItem {
                 label: "inline(…)",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "inline(${0:lint})",
                 kind: Attribute,
                 lookup: "inline",
             },
             CompletionItem {
                 label: "link",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "link",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "link_name = \"…\"",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "link_name = \"${0:symbol_name}\"",
                 kind: Attribute,
                 lookup: "link_name",
             },
             CompletionItem {
                 label: "macro_export",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "macro_export",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "macro_use",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "macro_use",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "must_use = \"…\"",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "must_use = \"${0:reason}\"",
                 kind: Attribute,
                 lookup: "must_use",
             },
             CompletionItem {
                 label: "no_mangle",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "no_mangle",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "no_std",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "no_std",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "non_exhaustive",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "non_exhaustive",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "panic_handler",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "panic_handler",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "path = \"…\"",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "path =\"${0:path}\"",
                 kind: Attribute,
                 lookup: "path",
             },
             CompletionItem {
                 label: "proc_macro",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "proc_macro",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "proc_macro_attribute",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "proc_macro_attribute",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "proc_macro_derive(…)",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "proc_macro_derive(${0:Trait})",
                 kind: Attribute,
                 lookup: "proc_macro_derive",
             },
             CompletionItem {
                 label: "recursion_limit = …",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "recursion_limit = ${0:128}",
                 kind: Attribute,
                 lookup: "recursion_limit",
             },
             CompletionItem {
                 label: "repr(…)",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "repr(${0:C})",
                 kind: Attribute,
                 lookup: "repr",
             },
             CompletionItem {
                 label: "should_panic(…)",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "should_panic(expected = \"${0:reason}\")",
                 kind: Attribute,
                 lookup: "should_panic",
             },
             CompletionItem {
                 label: "target_feature = \"…\"",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "target_feature = \"${0:feature}\"",
                 kind: Attribute,
                 lookup: "target_feature",
             },
             CompletionItem {
                 label: "test",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "test",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "used",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "used",
                 kind: Attribute,
             },
             CompletionItem {
                 label: "warn(…)",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "warn(${0:lint})",
                 kind: Attribute,
                 lookup: "warn",
             },
             CompletionItem {
                 label: "windows_subsystem = \"…\"",
-                source_range: 3..3,
-                delete: 3..3,
+                source_range: 20..20,
+                delete: 20..20,
                 insert: "windows_subsystem = \"${0:subsystem}\"",
                 kind: Attribute,
                 lookup: "windows_subsystem",
diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs
index ee4e24fcab..05f825c6fe 100644
--- a/crates/ra_ide/src/completion/complete_dot.rs
+++ b/crates/ra_ide/src/completion/complete_dot.rs
@@ -94,8 +94,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_field",
-                source_range: 45..45,
-                delete: 45..45,
+                source_range: 94..94,
+                delete: 94..94,
                 insert: "the_field",
                 kind: Field,
                 detail: "u32",
@@ -125,8 +125,8 @@ mod tests {
         [
             CompletionItem {
                 label: "foo()",
-                source_range: 102..102,
-                delete: 102..102,
+                source_range: 187..187,
+                delete: 187..187,
                 insert: "foo()$0",
                 kind: Method,
                 lookup: "foo",
@@ -134,8 +134,8 @@ mod tests {
             },
             CompletionItem {
                 label: "the_field",
-                source_range: 102..102,
-                delete: 102..102,
+                source_range: 187..187,
+                delete: 187..187,
                 insert: "the_field",
                 kind: Field,
                 detail: "(u32,)",
@@ -165,8 +165,8 @@ mod tests {
         [
             CompletionItem {
                 label: "foo()",
-                source_range: 77..77,
-                delete: 77..77,
+                source_range: 126..126,
+                delete: 126..126,
                 insert: "foo()$0",
                 kind: Method,
                 lookup: "foo",
@@ -174,8 +174,8 @@ mod tests {
             },
             CompletionItem {
                 label: "the_field",
-                source_range: 77..77,
-                delete: 77..77,
+                source_range: 126..126,
+                delete: 126..126,
                 insert: "the_field",
                 kind: Field,
                 detail: "(u32, i32)",
@@ -222,24 +222,24 @@ mod tests {
         [
             CompletionItem {
                 label: "crate_field",
-                source_range: 192..192,
-                delete: 192..192,
+                source_range: 313..313,
+                delete: 313..313,
                 insert: "crate_field",
                 kind: Field,
                 detail: "u32",
             },
             CompletionItem {
                 label: "pub_field",
-                source_range: 192..192,
-                delete: 192..192,
+                source_range: 313..313,
+                delete: 313..313,
                 insert: "pub_field",
                 kind: Field,
                 detail: "u32",
             },
             CompletionItem {
                 label: "super_field",
-                source_range: 192..192,
-                delete: 192..192,
+                source_range: 313..313,
+                delete: 313..313,
                 insert: "super_field",
                 kind: Field,
                 detail: "u32",
@@ -268,16 +268,16 @@ mod tests {
         [
             CompletionItem {
                 label: "field",
-                source_range: 67..67,
-                delete: 67..67,
+                source_range: 140..140,
+                delete: 140..140,
                 insert: "field",
                 kind: Field,
                 detail: "u8",
             },
             CompletionItem {
                 label: "other",
-                source_range: 67..67,
-                delete: 67..67,
+                source_range: 140..140,
+                delete: 140..140,
                 insert: "other",
                 kind: Field,
                 detail: "u16",
@@ -305,8 +305,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_method()",
-                source_range: 71..71,
-                delete: 71..71,
+                source_range: 144..144,
+                delete: 144..144,
                 insert: "the_method()$0",
                 kind: Method,
                 lookup: "the_method",
@@ -338,8 +338,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_method()",
-                source_range: 134..134,
-                delete: 134..134,
+                source_range: 243..243,
+                delete: 243..243,
                 insert: "the_method()$0",
                 kind: Method,
                 lookup: "the_method",
@@ -371,8 +371,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_method()",
-                source_range: 147..147,
-                delete: 147..147,
+                source_range: 256..256,
+                delete: 256..256,
                 insert: "the_method()$0",
                 kind: Method,
                 lookup: "the_method",
@@ -400,8 +400,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_method()",
-                source_range: 90..90,
-                delete: 90..90,
+                source_range: 151..151,
+                delete: 151..151,
                 insert: "the_method()$0",
                 kind: Method,
                 lookup: "the_method",
@@ -429,8 +429,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_method()",
-                source_range: 94..94,
-                delete: 94..94,
+                source_range: 155..155,
+                delete: 155..155,
                 insert: "the_method()$0",
                 kind: Method,
                 lookup: "the_method",
@@ -461,8 +461,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_method()",
-                source_range: 122..122,
-                delete: 122..122,
+                source_range: 219..219,
+                delete: 219..219,
                 insert: "the_method()$0",
                 kind: Method,
                 lookup: "the_method",
@@ -513,8 +513,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_method()",
-                source_range: 128..128,
-                delete: 128..128,
+                source_range: 249..249,
+                delete: 249..249,
                 insert: "the_method()$0",
                 kind: Method,
                 lookup: "the_method",
@@ -540,16 +540,16 @@ mod tests {
         [
             CompletionItem {
                 label: "0",
-                source_range: 38..38,
-                delete: 38..38,
+                source_range: 75..75,
+                delete: 75..75,
                 insert: "0",
                 kind: Field,
                 detail: "i32",
             },
             CompletionItem {
                 label: "1",
-                source_range: 38..38,
-                delete: 38..38,
+                source_range: 75..75,
+                delete: 75..75,
                 insert: "1",
                 kind: Field,
                 detail: "f64",
@@ -583,8 +583,8 @@ mod tests {
         [
             CompletionItem {
                 label: "blah()",
-                source_range: 190..191,
-                delete: 190..191,
+                source_range: 299..300,
+                delete: 299..300,
                 insert: "blah()$0",
                 kind: Method,
                 lookup: "blah",
@@ -610,8 +610,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_field",
-                source_range: 69..69,
-                delete: 69..69,
+                source_range: 106..106,
+                delete: 106..106,
                 insert: "the_field",
                 kind: Field,
                 detail: "u32",
@@ -676,15 +676,15 @@ mod tests {
         [
             CompletionItem {
                 label: "A",
-                source_range: 120..120,
-                delete: 120..120,
+                source_range: 217..217,
+                delete: 217..217,
                 insert: "A",
                 kind: Const,
             },
             CompletionItem {
                 label: "b",
-                source_range: 120..120,
-                delete: 120..120,
+                source_range: 217..217,
+                delete: 217..217,
                 insert: "b",
                 kind: Module,
             },
@@ -709,8 +709,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_field",
-                source_range: 91..92,
-                delete: 91..92,
+                source_range: 156..157,
+                delete: 156..157,
                 insert: "the_field",
                 kind: Field,
                 detail: "u32",
@@ -736,8 +736,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_field",
-                source_range: 91..92,
-                delete: 91..92,
+                source_range: 156..157,
+                delete: 156..157,
                 insert: "the_field",
                 kind: Field,
                 detail: "u32",
@@ -764,8 +764,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_field",
-                source_range: 91..91,
-                delete: 91..91,
+                source_range: 156..156,
+                delete: 156..156,
                 insert: "the_field",
                 kind: Field,
                 detail: "u32",
@@ -791,8 +791,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_field",
-                source_range: 97..98,
-                delete: 97..98,
+                source_range: 162..163,
+                delete: 162..163,
                 insert: "the_field",
                 kind: Field,
                 detail: "u32",
@@ -828,8 +828,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_field",
-                source_range: 327..327,
-                delete: 327..327,
+                source_range: 552..552,
+                delete: 552..552,
                 insert: "the_field",
                 kind: Field,
                 detail: "u32",
@@ -858,8 +858,8 @@ mod tests {
         [
             CompletionItem {
                 label: "the_method()",
-                source_range: 116..116,
-                delete: 116..116,
+                source_range: 201..201,
+                delete: 201..201,
                 insert: "the_method()$0",
                 kind: Method,
                 lookup: "the_method",
diff --git a/crates/ra_ide/src/completion/complete_fn_param.rs b/crates/ra_ide/src/completion/complete_fn_param.rs
index f5573ddf7c..a661932a31 100644
--- a/crates/ra_ide/src/completion/complete_fn_param.rs
+++ b/crates/ra_ide/src/completion/complete_fn_param.rs
@@ -75,8 +75,8 @@ mod tests {
         [
             CompletionItem {
                 label: "file_id: FileId",
-                source_range: 61..65,
-                delete: 61..65,
+                source_range: 110..114,
+                delete: 110..114,
                 insert: "file_id: FileId",
                 lookup: "file_id",
             },
@@ -99,8 +99,8 @@ mod tests {
         [
             CompletionItem {
                 label: "file_id: FileId",
-                source_range: 61..65,
-                delete: 61..65,
+                source_range: 110..114,
+                delete: 110..114,
                 insert: "file_id: FileId",
                 lookup: "file_id",
             },
@@ -126,8 +126,8 @@ mod tests {
         [
             CompletionItem {
                 label: "file_id: FileId",
-                source_range: 208..212,
-                delete: 208..212,
+                source_range: 289..293,
+                delete: 289..293,
                 insert: "file_id: FileId",
                 lookup: "file_id",
             },
diff --git a/crates/ra_ide/src/completion/complete_pattern.rs b/crates/ra_ide/src/completion/complete_pattern.rs
index 367e2bbce3..fdd9e928b2 100644
--- a/crates/ra_ide/src/completion/complete_pattern.rs
+++ b/crates/ra_ide/src/completion/complete_pattern.rs
@@ -63,37 +63,37 @@ mod tests {
         [
             CompletionItem {
                 label: "Bar",
-                source_range: 137..137,
-                delete: 137..137,
+                source_range: 246..246,
+                delete: 246..246,
                 insert: "Bar",
                 kind: Struct,
             },
             CompletionItem {
                 label: "E",
-                source_range: 137..137,
-                delete: 137..137,
+                source_range: 246..246,
+                delete: 246..246,
                 insert: "E",
                 kind: Enum,
             },
             CompletionItem {
                 label: "X",
-                source_range: 137..137,
-                delete: 137..137,
+                source_range: 246..246,
+                delete: 246..246,
                 insert: "X",
                 kind: EnumVariant,
                 detail: "()",
             },
             CompletionItem {
                 label: "Z",
-                source_range: 137..137,
-                delete: 137..137,
+                source_range: 246..246,
+                delete: 246..246,
                 insert: "Z",
                 kind: Const,
             },
             CompletionItem {
                 label: "m",
-                source_range: 137..137,
-                delete: 137..137,
+                source_range: 246..246,
+                delete: 246..246,
                 insert: "m",
                 kind: Module,
             },
@@ -119,15 +119,15 @@ mod tests {
         [
             CompletionItem {
                 label: "E",
-                source_range: 90..90,
-                delete: 90..90,
+                source_range: 151..151,
+                delete: 151..151,
                 insert: "E",
                 kind: Enum,
             },
             CompletionItem {
                 label: "m!(…)",
-                source_range: 90..90,
-                delete: 90..90,
+                source_range: 151..151,
+                delete: 151..151,
                 insert: "m!($0)",
                 kind: Macro,
                 detail: "macro_rules! m",
diff --git a/crates/ra_ide/src/completion/complete_postfix.rs b/crates/ra_ide/src/completion/complete_postfix.rs
index 3bd64804f4..b878aeb0ac 100644
--- a/crates/ra_ide/src/completion/complete_postfix.rs
+++ b/crates/ra_ide/src/completion/complete_postfix.rs
@@ -260,64 +260,64 @@ mod tests {
         [
             CompletionItem {
                 label: "box",
-                source_range: 40..40,
-                delete: 36..40,
+                source_range: 89..89,
+                delete: 85..89,
                 insert: "Box::new(bar)",
                 detail: "Box::new(expr)",
             },
             CompletionItem {
                 label: "call",
-                source_range: 40..40,
-                delete: 36..40,
+                source_range: 89..89,
+                delete: 85..89,
                 insert: "${1}(bar)",
                 detail: "function(expr)",
             },
             CompletionItem {
                 label: "dbg",
-                source_range: 40..40,
-                delete: 36..40,
+                source_range: 89..89,
+                delete: 85..89,
                 insert: "dbg!(bar)",
                 detail: "dbg!(expr)",
             },
             CompletionItem {
                 label: "if",
-                source_range: 40..40,
-                delete: 36..40,
+                source_range: 89..89,
+                delete: 85..89,
                 insert: "if bar {\n    $0\n}",
                 detail: "if expr {}",
             },
             CompletionItem {
                 label: "match",
-                source_range: 40..40,
-                delete: 36..40,
+                source_range: 89..89,
+                delete: 85..89,
                 insert: "match bar {\n    ${1:_} => {$0\\},\n}",
                 detail: "match expr {}",
             },
             CompletionItem {
                 label: "not",
-                source_range: 40..40,
-                delete: 36..40,
+                source_range: 89..89,
+                delete: 85..89,
                 insert: "!bar",
                 detail: "!expr",
             },
             CompletionItem {
                 label: "ref",
-                source_range: 40..40,
-                delete: 36..40,
+                source_range: 89..89,
+                delete: 85..89,
                 insert: "&bar",
                 detail: "&expr",
             },
             CompletionItem {
                 label: "refm",
-                source_range: 40..40,
-                delete: 36..40,
+                source_range: 89..89,
+                delete: 85..89,
                 insert: "&mut bar",
                 detail: "&mut expr",
             },
             CompletionItem {
                 label: "while",
-                source_range: 40..40,
-                delete: 36..40,
+                source_range: 89..89,
+                delete: 85..89,
                 insert: "while bar {\n    $0\n}",
                 detail: "while expr {}",
             },
@@ -346,64 +346,64 @@ mod tests {
         [
             CompletionItem {
                 label: "box",
-                source_range: 97..97,
-                delete: 93..97,
+                source_range: 210..210,
+                delete: 206..210,
                 insert: "Box::new(bar)",
                 detail: "Box::new(expr)",
             },
             CompletionItem {
                 label: "call",
-                source_range: 97..97,
-                delete: 93..97,
+                source_range: 210..210,
+                delete: 206..210,
                 insert: "${1}(bar)",
                 detail: "function(expr)",
             },
             CompletionItem {
                 label: "dbg",
-                source_range: 97..97,
-                delete: 93..97,
+                source_range: 210..210,
+                delete: 206..210,
                 insert: "dbg!(bar)",
                 detail: "dbg!(expr)",
             },
             CompletionItem {
                 label: "ifl",
-                source_range: 97..97,
-                delete: 93..97,
+                source_range: 210..210,
+                delete: 206..210,
                 insert: "if let Some($1) = bar {\n    $0\n}",
                 detail: "if let Some {}",
             },
             CompletionItem {
                 label: "match",
-                source_range: 97..97,
-                delete: 93..97,
+                source_range: 210..210,
+                delete: 206..210,
                 insert: "match bar {\n    Some(${1:_}) => {$2\\},\n    None => {$0\\},\n}",
                 detail: "match expr {}",
             },
             CompletionItem {
                 label: "not",
-                source_range: 97..97,
-                delete: 93..97,
+                source_range: 210..210,
+                delete: 206..210,
                 insert: "!bar",
                 detail: "!expr",
             },
             CompletionItem {
                 label: "ref",
-                source_range: 97..97,
-                delete: 93..97,
+                source_range: 210..210,
+                delete: 206..210,
                 insert: "&bar",
                 detail: "&expr",
             },
             CompletionItem {
                 label: "refm",
-                source_range: 97..97,
-                delete: 93..97,
+                source_range: 210..210,
+                delete: 206..210,
                 insert: "&mut bar",
                 detail: "&mut expr",
             },
             CompletionItem {
                 label: "while",
-                source_range: 97..97,
-                delete: 93..97,
+                source_range: 210..210,
+                delete: 206..210,
                 insert: "while let Some($1) = bar {\n    $0\n}",
                 detail: "while let Some {}",
             },
@@ -432,64 +432,64 @@ mod tests {
         [
             CompletionItem {
                 label: "box",
-                source_range: 98..98,
-                delete: 94..98,
+                source_range: 211..211,
+                delete: 207..211,
                 insert: "Box::new(bar)",
                 detail: "Box::new(expr)",
             },
             CompletionItem {
                 label: "call",
-                source_range: 98..98,
-                delete: 94..98,
+                source_range: 211..211,
+                delete: 207..211,
                 insert: "${1}(bar)",
                 detail: "function(expr)",
             },
             CompletionItem {
                 label: "dbg",
-                source_range: 98..98,
-                delete: 94..98,
+                source_range: 211..211,
+                delete: 207..211,
                 insert: "dbg!(bar)",
                 detail: "dbg!(expr)",
             },
             CompletionItem {
                 label: "ifl",
-                source_range: 98..98,
-                delete: 94..98,
+                source_range: 211..211,
+                delete: 207..211,
                 insert: "if let Ok($1) = bar {\n    $0\n}",
                 detail: "if let Ok {}",
             },
             CompletionItem {
                 label: "match",
-                source_range: 98..98,
-                delete: 94..98,
+                source_range: 211..211,
+                delete: 207..211,
                 insert: "match bar {\n    Ok(${1:_}) => {$2\\},\n    Err(${3:_}) => {$0\\},\n}",
                 detail: "match expr {}",
             },
             CompletionItem {
                 label: "not",
-                source_range: 98..98,
-                delete: 94..98,
+                source_range: 211..211,
+                delete: 207..211,
                 insert: "!bar",
                 detail: "!expr",
             },
             CompletionItem {
                 label: "ref",
-                source_range: 98..98,
-                delete: 94..98,
+                source_range: 211..211,
+                delete: 207..211,
                 insert: "&bar",
                 detail: "&expr",
             },
             CompletionItem {
                 label: "refm",
-                source_range: 98..98,
-                delete: 94..98,
+                source_range: 211..211,
+                delete: 207..211,
                 insert: "&mut bar",
                 detail: "&mut expr",
             },
             CompletionItem {
                 label: "while",
-                source_range: 98..98,
-                delete: 94..98,
+                source_range: 211..211,
+                delete: 207..211,
                 insert: "while let Ok($1) = bar {\n    $0\n}",
                 detail: "while let Ok {}",
             },
@@ -513,50 +513,50 @@ mod tests {
         [
             CompletionItem {
                 label: "box",
-                source_range: 42..42,
-                delete: 38..42,
+                source_range: 91..91,
+                delete: 87..91,
                 insert: "Box::new(bar)",
                 detail: "Box::new(expr)",
             },
             CompletionItem {
                 label: "call",
-                source_range: 42..42,
-                delete: 38..42,
+                source_range: 91..91,
+                delete: 87..91,
                 insert: "${1}(bar)",
                 detail: "function(expr)",
             },
             CompletionItem {
                 label: "dbg",
-                source_range: 42..42,
-                delete: 38..42,
+                source_range: 91..91,
+                delete: 87..91,
                 insert: "dbg!(bar)",
                 detail: "dbg!(expr)",
             },
             CompletionItem {
                 label: "match",
-                source_range: 42..42,
-                delete: 38..42,
+                source_range: 91..91,
+                delete: 87..91,
                 insert: "match bar {\n    ${1:_} => {$0\\},\n}",
                 detail: "match expr {}",
             },
             CompletionItem {
                 label: "not",
-                source_range: 42..42,
-                delete: 38..42,
+                source_range: 91..91,
+                delete: 87..91,
                 insert: "!bar",
                 detail: "!expr",
             },
             CompletionItem {
                 label: "ref",
-                source_range: 42..42,
-                delete: 38..42,
+                source_range: 91..91,
+                delete: 87..91,
                 insert: "&bar",
                 detail: "&expr",
             },
             CompletionItem {
                 label: "refm",
-                source_range: 42..42,
-                delete: 38..42,
+                source_range: 91..91,
+                delete: 87..91,
                 insert: "&mut bar",
                 detail: "&mut expr",
             },
@@ -579,50 +579,50 @@ mod tests {
         [
             CompletionItem {
                 label: "box",
-                source_range: 19..19,
-                delete: 16..19,
+                source_range: 52..52,
+                delete: 49..52,
                 insert: "Box::new(42)",
                 detail: "Box::new(expr)",
             },
             CompletionItem {
                 label: "call",
-                source_range: 19..19,
-                delete: 16..19,
+                source_range: 52..52,
+                delete: 49..52,
                 insert: "${1}(42)",
                 detail: "function(expr)",
             },
             CompletionItem {
                 label: "dbg",
-                source_range: 19..19,
-                delete: 16..19,
+                source_range: 52..52,
+                delete: 49..52,
                 insert: "dbg!(42)",
                 detail: "dbg!(expr)",
             },
             CompletionItem {
                 label: "match",
-                source_range: 19..19,
-                delete: 16..19,
+                source_range: 52..52,
+                delete: 49..52,
                 insert: "match 42 {\n    ${1:_} => {$0\\},\n}",
                 detail: "match expr {}",
             },
             CompletionItem {
                 label: "not",
-                source_range: 19..19,
-                delete: 16..19,
+                source_range: 52..52,
+                delete: 49..52,
                 insert: "!42",
                 detail: "!expr",
             },
             CompletionItem {
                 label: "ref",
-                source_range: 19..19,
-                delete: 16..19,
+                source_range: 52..52,
+                delete: 49..52,
                 insert: "&42",
                 detail: "&expr",
             },
             CompletionItem {
                 label: "refm",
-                source_range: 19..19,
-                delete: 16..19,
+                source_range: 52..52,
+                delete: 49..52,
                 insert: "&mut 42",
                 detail: "&mut expr",
             },
@@ -647,50 +647,50 @@ mod tests {
         [
             CompletionItem {
                 label: "box",
-                source_range: 84..85,
-                delete: 80..85,
+                source_range: 149..150,
+                delete: 145..150,
                 insert: "Box::new(bar)",
                 detail: "Box::new(expr)",
             },
             CompletionItem {
                 label: "call",
-                source_range: 84..85,
-                delete: 80..85,
+                source_range: 149..150,
+                delete: 145..150,
                 insert: "${1}(bar)",
                 detail: "function(expr)",
             },
             CompletionItem {
                 label: "dbg",
-                source_range: 84..85,
-                delete: 80..85,
+                source_range: 149..150,
+                delete: 145..150,
                 insert: "dbg!(bar)",
                 detail: "dbg!(expr)",
             },
             CompletionItem {
                 label: "match",
-                source_range: 84..85,
-                delete: 80..85,
+                source_range: 149..150,
+                delete: 145..150,
                 insert: "match bar {\n    ${1:_} => {$0\\},\n}",
                 detail: "match expr {}",
             },
             CompletionItem {
                 label: "not",
-                source_range: 84..85,
-                delete: 80..85,
+                source_range: 149..150,
+                delete: 145..150,
                 insert: "!bar",
                 detail: "!expr",
             },
             CompletionItem {
                 label: "ref",
-                source_range: 84..85,
-                delete: 80..85,
+                source_range: 149..150,
+                delete: 145..150,
                 insert: "&bar",
                 detail: "&expr",
             },
             CompletionItem {
                 label: "refm",
-                source_range: 84..85,
-                delete: 80..85,
+                source_range: 149..150,
+                delete: 145..150,
                 insert: "&mut bar",
                 detail: "&mut expr",
             },
@@ -713,50 +713,50 @@ mod tests {
         [
             CompletionItem {
                 label: "box",
-                source_range: 23..23,
-                delete: 16..23,
+                source_range: 56..56,
+                delete: 49..56,
                 insert: "Box::new(&&&&42)",
                 detail: "Box::new(expr)",
             },
             CompletionItem {
                 label: "call",
-                source_range: 23..23,
-                delete: 16..23,
+                source_range: 56..56,
+                delete: 49..56,
                 insert: "${1}(&&&&42)",
                 detail: "function(expr)",
             },
             CompletionItem {
                 label: "dbg",
-                source_range: 23..23,
-                delete: 16..23,
+                source_range: 56..56,
+                delete: 49..56,
                 insert: "dbg!(&&&&42)",
                 detail: "dbg!(expr)",
             },
             CompletionItem {
                 label: "match",
-                source_range: 23..23,
-                delete: 16..23,
+                source_range: 56..56,
+                delete: 49..56,
                 insert: "match &&&&42 {\n    ${1:_} => {$0\\},\n}",
                 detail: "match expr {}",
             },
             CompletionItem {
                 label: "not",
-                source_range: 23..23,
-                delete: 20..23,
+                source_range: 56..56,
+                delete: 53..56,
                 insert: "!42",
                 detail: "!expr",
             },
             CompletionItem {
                 label: "ref",
-                source_range: 23..23,
-                delete: 20..23,
+                source_range: 56..56,
+                delete: 53..56,
                 insert: "&42",
                 detail: "&expr",
             },
             CompletionItem {
                 label: "refm",
-                source_range: 23..23,
-                delete: 20..23,
+                source_range: 56..56,
+                delete: 53..56,
                 insert: "&mut 42",
                 detail: "&mut expr",
             },
diff --git a/crates/ra_ide/src/completion/complete_qualified_path.rs b/crates/ra_ide/src/completion/complete_qualified_path.rs
index f133ce3cec..d3a1cbc1da 100644
--- a/crates/ra_ide/src/completion/complete_qualified_path.rs
+++ b/crates/ra_ide/src/completion/complete_qualified_path.rs
@@ -212,8 +212,8 @@ mod tests {
         [
             CompletionItem {
                 label: "my",
-                source_range: 10..12,
-                delete: 10..12,
+                source_range: 27..29,
+                delete: 27..29,
                 insert: "my",
                 kind: Module,
                 documentation: Documentation(
@@ -243,8 +243,8 @@ mod tests {
         [
             CompletionItem {
                 label: "Bar",
-                source_range: 14..14,
-                delete: 14..14,
+                source_range: 31..31,
+                delete: 31..31,
                 insert: "Bar",
                 kind: Struct,
             },
@@ -271,15 +271,15 @@ mod tests {
         [
             CompletionItem {
                 label: "Foo",
-                source_range: 14..14,
-                delete: 14..14,
+                source_range: 31..31,
+                delete: 31..31,
                 insert: "Foo",
                 kind: Struct,
             },
             CompletionItem {
                 label: "PublicBar",
-                source_range: 14..14,
-                delete: 14..14,
+                source_range: 31..31,
+                delete: 31..31,
                 insert: "PublicBar",
                 kind: Struct,
             },
@@ -304,8 +304,8 @@ mod tests {
         [
             CompletionItem {
                 label: "Bar",
-                source_range: 13..13,
-                delete: 13..13,
+                source_range: 30..30,
+                delete: 30..30,
                 insert: "Bar",
                 kind: Struct,
             },
@@ -1145,8 +1145,8 @@ mod tests {
         [
             CompletionItem {
                 label: "bar()",
-                source_range: 88..88,
-                delete: 88..88,
+                source_range: 185..185,
+                delete: 185..185,
                 insert: "bar()$0",
                 kind: Function,
                 lookup: "bar",
@@ -1154,8 +1154,8 @@ mod tests {
             },
             CompletionItem {
                 label: "foo()",
-                source_range: 88..88,
-                delete: 88..88,
+                source_range: 185..185,
+                delete: 185..185,
                 insert: "foo()$0",
                 kind: Function,
                 lookup: "foo",
@@ -1185,16 +1185,16 @@ mod tests {
         [
             CompletionItem {
                 label: "foo!(…)",
-                source_range: 82..82,
-                delete: 82..82,
+                source_range: 179..179,
+                delete: 179..179,
                 insert: "foo!($0)",
                 kind: Macro,
                 detail: "#[macro_export]\nmacro_rules! foo",
             },
             CompletionItem {
                 label: "main()",
-                source_range: 82..82,
-                delete: 82..82,
+                source_range: 179..179,
+                delete: 179..179,
                 insert: "main()$0",
                 kind: Function,
                 lookup: "main",
@@ -1230,22 +1230,22 @@ mod tests {
         [
             CompletionItem {
                 label: "RIGHT_CONST",
-                source_range: 24..24,
-                delete: 24..24,
+                source_range: 57..57,
+                delete: 57..57,
                 insert: "RIGHT_CONST",
                 kind: Const,
             },
             CompletionItem {
                 label: "RightType",
-                source_range: 24..24,
-                delete: 24..24,
+                source_range: 57..57,
+                delete: 57..57,
                 insert: "RightType",
                 kind: Struct,
             },
             CompletionItem {
                 label: "right_fn()",
-                source_range: 24..24,
-                delete: 24..24,
+                source_range: 57..57,
+                delete: 57..57,
                 insert: "right_fn()$0",
                 kind: Function,
                 lookup: "right_fn",
@@ -1269,8 +1269,8 @@ mod tests {
         [
             CompletionItem {
                 label: "foo()",
-                source_range: 60..61,
-                delete: 60..61,
+                source_range: 93..94,
+                delete: 93..94,
                 insert: "foo()$0",
                 kind: Function,
                 lookup: "foo",
@@ -1278,8 +1278,8 @@ mod tests {
             },
             CompletionItem {
                 label: "main()",
-                source_range: 60..61,
-                delete: 60..61,
+                source_range: 93..94,
+                delete: 93..94,
                 insert: "main()$0",
                 kind: Function,
                 lookup: "main",
@@ -1308,15 +1308,15 @@ mod tests {
         [
             CompletionItem {
                 label: "z",
-                source_range: 24..24,
-                delete: 24..24,
+                source_range: 57..57,
+                delete: 57..57,
                 insert: "z",
                 kind: Module,
             },
             CompletionItem {
                 label: "z()",
-                source_range: 24..24,
-                delete: 24..24,
+                source_range: 57..57,
+                delete: 57..57,
                 insert: "z()$0",
                 kind: Function,
                 lookup: "z",
@@ -1347,8 +1347,8 @@ mod tests {
         [
             CompletionItem {
                 label: "new()",
-                source_range: 179..179,
-                delete: 179..179,
+                source_range: 292..292,
+                delete: 292..292,
                 insert: "new()$0",
                 kind: Function,
                 lookup: "new",
diff --git a/crates/ra_ide/src/completion/complete_record.rs b/crates/ra_ide/src/completion/complete_record.rs
index 13eb2f79fa..b7ab654c52 100644
--- a/crates/ra_ide/src/completion/complete_record.rs
+++ b/crates/ra_ide/src/completion/complete_record.rs
@@ -41,17 +41,17 @@ mod tests {
             ",
             );
             assert_debug_snapshot!(completions, @r###"
-            [
-                CompletionItem {
-                    label: "foo",
-                    source_range: 68..69,
-                    delete: 68..69,
-                    insert: "foo",
-                    kind: Field,
-                    detail: "u32",
-                },
-            ]
-            "###);
+        [
+            CompletionItem {
+                label: "foo",
+                source_range: 117..118,
+                delete: 117..118,
+                insert: "foo",
+                kind: Field,
+                detail: "u32",
+            },
+        ]
+        "###);
         }
 
         #[test]
@@ -70,25 +70,25 @@ mod tests {
             ",
             );
             assert_debug_snapshot!(completions, @r###"
-            [
-                CompletionItem {
-                    label: "bar",
-                    source_range: 88..88,
-                    delete: 88..88,
-                    insert: "bar",
-                    kind: Field,
-                    detail: "()",
-                },
-                CompletionItem {
-                    label: "foo",
-                    source_range: 88..88,
-                    delete: 88..88,
-                    insert: "foo",
-                    kind: Field,
-                    detail: "u32",
-                },
-            ]
-            "###);
+        [
+            CompletionItem {
+                label: "bar",
+                source_range: 161..161,
+                delete: 161..161,
+                insert: "bar",
+                kind: Field,
+                detail: "()",
+            },
+            CompletionItem {
+                label: "foo",
+                source_range: 161..161,
+                delete: 161..161,
+                insert: "foo",
+                kind: Field,
+                detail: "u32",
+            },
+        ]
+        "###);
         }
 
         #[test]
@@ -106,17 +106,17 @@ mod tests {
             ",
             );
             assert_debug_snapshot!(completions, @r###"
-            [
-                CompletionItem {
-                    label: "foo",
-                    source_range: 110..111,
-                    delete: 110..111,
-                    insert: "foo",
-                    kind: Field,
-                    detail: "u32",
-                },
-            ]
-            "###);
+        [
+            CompletionItem {
+                label: "foo",
+                source_range: 171..172,
+                delete: 171..172,
+                insert: "foo",
+                kind: Field,
+                detail: "u32",
+            },
+        ]
+        "###);
         }
 
         #[test]
@@ -142,25 +142,25 @@ mod tests {
             ",
             );
             assert_debug_snapshot!(completions, @r###"
-            [
-                CompletionItem {
-                    label: "bar",
-                    source_range: 203..203,
-                    delete: 203..203,
-                    insert: "bar",
-                    kind: Field,
-                    detail: "u32",
-                },
-                CompletionItem {
-                    label: "baz",
-                    source_range: 203..203,
-                    delete: 203..203,
-                    insert: "baz",
-                    kind: Field,
-                    detail: "u32",
-                },
-            ]
-            "###);
+        [
+            CompletionItem {
+                label: "bar",
+                source_range: 372..372,
+                delete: 372..372,
+                insert: "bar",
+                kind: Field,
+                detail: "u32",
+            },
+            CompletionItem {
+                label: "baz",
+                source_range: 372..372,
+                delete: 372..372,
+                insert: "baz",
+                kind: Field,
+                detail: "u32",
+            },
+        ]
+        "###);
         }
     }
 
@@ -187,18 +187,18 @@ mod tests {
             ",
             );
             assert_debug_snapshot!(completions, @r###"
-            [
-                CompletionItem {
-                    label: "the_field",
-                    source_range: 69..72,
-                    delete: 69..72,
-                    insert: "the_field",
-                    kind: Field,
-                    detail: "u32",
-                    deprecated: true,
-                },
-            ]
-            "###);
+        [
+            CompletionItem {
+                label: "the_field",
+                source_range: 142..145,
+                delete: 142..145,
+                insert: "the_field",
+                kind: Field,
+                detail: "u32",
+                deprecated: true,
+            },
+        ]
+        "###);
         }
 
         #[test]
@@ -212,17 +212,17 @@ mod tests {
             ",
             );
             assert_debug_snapshot!(completions, @r###"
-            [
-                CompletionItem {
-                    label: "the_field",
-                    source_range: 46..49,
-                    delete: 46..49,
-                    insert: "the_field",
-                    kind: Field,
-                    detail: "u32",
-                },
-            ]
-            "###);
+        [
+            CompletionItem {
+                label: "the_field",
+                source_range: 83..86,
+                delete: 83..86,
+                insert: "the_field",
+                kind: Field,
+                detail: "u32",
+            },
+        ]
+        "###);
         }
 
         #[test]
@@ -238,17 +238,17 @@ mod tests {
             ",
             );
             assert_debug_snapshot!(completions, @r###"
-            [
-                CompletionItem {
-                    label: "a",
-                    source_range: 58..58,
-                    delete: 58..58,
-                    insert: "a",
-                    kind: Field,
-                    detail: "u32",
-                },
-            ]
-            "###);
+        [
+            CompletionItem {
+                label: "a",
+                source_range: 119..119,
+                delete: 119..119,
+                insert: "a",
+                kind: Field,
+                detail: "u32",
+            },
+        ]
+        "###);
         }
 
         #[test]
@@ -264,17 +264,17 @@ mod tests {
             ",
             );
             assert_debug_snapshot!(completions, @r###"
-            [
-                CompletionItem {
-                    label: "b",
-                    source_range: 70..70,
-                    delete: 70..70,
-                    insert: "b",
-                    kind: Field,
-                    detail: "u32",
-                },
-            ]
-            "###);
+        [
+            CompletionItem {
+                label: "b",
+                source_range: 119..119,
+                delete: 119..119,
+                insert: "b",
+                kind: Field,
+                detail: "u32",
+            },
+        ]
+        "###);
         }
 
         #[test]
@@ -289,17 +289,17 @@ mod tests {
             ",
             );
             assert_debug_snapshot!(completions, @r###"
-            [
-                CompletionItem {
-                    label: "a",
-                    source_range: 56..56,
-                    delete: 56..56,
-                    insert: "a",
-                    kind: Field,
-                    detail: "u32",
-                },
-            ]
-            "###);
+        [
+            CompletionItem {
+                label: "a",
+                source_range: 93..93,
+                delete: 93..93,
+                insert: "a",
+                kind: Field,
+                detail: "u32",
+            },
+        ]
+        "###);
         }
 
         #[test]
@@ -314,17 +314,17 @@ mod tests {
             ",
             );
             assert_debug_snapshot!(completions, @r###"
-            [
-                CompletionItem {
-                    label: "the_field",
-                    source_range: 88..91,
-                    delete: 88..91,
-                    insert: "the_field",
-                    kind: Field,
-                    detail: "u32",
-                },
-            ]
-            "###);
+        [
+            CompletionItem {
+                label: "the_field",
+                source_range: 137..140,
+                delete: 137..140,
+                insert: "the_field",
+                kind: Field,
+                detail: "u32",
+            },
+        ]
+        "###);
         }
 
         #[test]
@@ -349,25 +349,25 @@ mod tests {
             ",
             );
             assert_debug_snapshot!(completions, @r###"
-            [
-                CompletionItem {
-                    label: "bar",
-                    source_range: 157..157,
-                    delete: 157..157,
-                    insert: "bar",
-                    kind: Field,
-                    detail: "u32",
-                },
-                CompletionItem {
-                    label: "baz",
-                    source_range: 157..157,
-                    delete: 157..157,
-                    insert: "baz",
-                    kind: Field,
-                    detail: "u32",
-                },
-            ]
-            "###);
+        [
+            CompletionItem {
+                label: "bar",
+                source_range: 302..302,
+                delete: 302..302,
+                insert: "bar",
+                kind: Field,
+                detail: "u32",
+            },
+            CompletionItem {
+                label: "baz",
+                source_range: 302..302,
+                delete: 302..302,
+                insert: "baz",
+                kind: Field,
+                detail: "u32",
+            },
+        ]
+        "###);
         }
 
         #[test]
@@ -390,17 +390,17 @@ mod tests {
             ",
             );
             assert_debug_snapshot!(completions, @r###"
-            [
-                CompletionItem {
-                    label: "foo2",
-                    source_range: 112..112,
-                    delete: 112..112,
-                    insert: "foo2",
-                    kind: Field,
-                    detail: "u32",
-                },
-            ]
-            "###);
+        [
+            CompletionItem {
+                label: "foo2",
+                source_range: 221..221,
+                delete: 221..221,
+                insert: "foo2",
+                kind: Field,
+                detail: "u32",
+            },
+        ]
+        "###);
         }
     }
 }
diff --git a/crates/ra_ide/src/completion/complete_snippet.rs b/crates/ra_ide/src/completion/complete_snippet.rs
index 52aaa70f06..0568d9ccf3 100644
--- a/crates/ra_ide/src/completion/complete_snippet.rs
+++ b/crates/ra_ide/src/completion/complete_snippet.rs
@@ -129,31 +129,31 @@ mod tests {
         [
             CompletionItem {
                 label: "Test function",
-                source_range: 29..29,
-                delete: 29..29,
+                source_range: 78..78,
+                delete: 78..78,
                 insert: "#[test]\nfn ${1:feature}() {\n    $0\n}",
                 kind: Snippet,
                 lookup: "tfn",
             },
             CompletionItem {
                 label: "Test module",
-                source_range: 29..29,
-                delete: 29..29,
+                source_range: 78..78,
+                delete: 78..78,
                 insert: "#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn ${1:test_name}() {\n        $0\n    }\n}",
                 kind: Snippet,
                 lookup: "tmod",
             },
             CompletionItem {
                 label: "macro_rules",
-                source_range: 29..29,
-                delete: 29..29,
+                source_range: 78..78,
+                delete: 78..78,
                 insert: "macro_rules! $1 {\n\t($2) => {\n\t\t$0\n\t};\n}",
                 kind: Snippet,
             },
             CompletionItem {
                 label: "pub(crate)",
-                source_range: 29..29,
-                delete: 29..29,
+                source_range: 78..78,
+                delete: 78..78,
                 insert: "pub(crate) $0",
                 kind: Snippet,
             },
diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs
index 23e42928dd..21c9316e66 100644
--- a/crates/ra_ide/src/completion/complete_trait_impl.rs
+++ b/crates/ra_ide/src/completion/complete_trait_impl.rs
@@ -256,24 +256,24 @@ mod tests {
         [
             CompletionItem {
                 label: "const TEST_CONST: u16 = ",
-                source_range: 112..113,
-                delete: 112..113,
+                source_range: 209..210,
+                delete: 209..210,
                 insert: "const TEST_CONST: u16 = ",
                 kind: Const,
                 lookup: "TEST_CONST",
             },
             CompletionItem {
                 label: "fn test()",
-                source_range: 112..113,
-                delete: 112..113,
+                source_range: 209..210,
+                delete: 209..210,
                 insert: "fn test() {\n    $0\n}",
                 kind: Function,
                 lookup: "test",
             },
             CompletionItem {
                 label: "type TestType = ",
-                source_range: 112..113,
-                delete: 112..113,
+                source_range: 209..210,
+                delete: 209..210,
                 insert: "type TestType = ",
                 kind: TypeAlias,
                 lookup: "TestType",
@@ -322,8 +322,8 @@ mod tests {
         [
             CompletionItem {
                 label: "fn test()",
-                source_range: 66..67,
-                delete: 66..67,
+                source_range: 139..140,
+                delete: 139..140,
                 insert: "fn test() {\n    $0\n}",
                 kind: Function,
                 lookup: "test",
@@ -351,8 +351,8 @@ mod tests {
         [
             CompletionItem {
                 label: "fn foo()",
-                source_range: 68..69,
-                delete: 65..69,
+                source_range: 141..142,
+                delete: 138..142,
                 insert: "fn foo() {\n    $0\n}",
                 kind: Function,
                 lookup: "foo",
@@ -383,8 +383,8 @@ mod tests {
         [
             CompletionItem {
                 label: "fn foo_bar()",
-                source_range: 103..104,
-                delete: 100..104,
+                source_range: 200..201,
+                delete: 197..201,
                 insert: "fn foo_bar() {\n    $0\n}",
                 kind: Function,
                 lookup: "foo_bar",
@@ -434,8 +434,8 @@ mod tests {
         [
             CompletionItem {
                 label: "fn foo()",
-                source_range: 71..72,
-                delete: 68..72,
+                source_range: 144..145,
+                delete: 141..145,
                 insert: "fn foo<T>() {\n    $0\n}",
                 kind: Function,
                 lookup: "foo",
@@ -463,8 +463,8 @@ mod tests {
         [
             CompletionItem {
                 label: "fn foo()",
-                source_range: 93..94,
-                delete: 90..94,
+                source_range: 166..167,
+                delete: 163..167,
                 insert: "fn foo<T>()\nwhere T: Into<String> {\n    $0\n}",
                 kind: Function,
                 lookup: "foo",
@@ -490,8 +490,8 @@ mod tests {
         [
             CompletionItem {
                 label: "type SomeType = ",
-                source_range: 63..64,
-                delete: 58..64,
+                source_range: 124..125,
+                delete: 119..125,
                 insert: "type SomeType = ",
                 kind: TypeAlias,
                 lookup: "SomeType",
@@ -517,8 +517,8 @@ mod tests {
         [
             CompletionItem {
                 label: "const SOME_CONST: u16 = ",
-                source_range: 72..73,
-                delete: 66..73,
+                source_range: 133..134,
+                delete: 127..134,
                 insert: "const SOME_CONST: u16 = ",
                 kind: Const,
                 lookup: "SOME_CONST",
@@ -544,8 +544,8 @@ mod tests {
         [
             CompletionItem {
                 label: "const SOME_CONST: u16 = ",
-                source_range: 77..78,
-                delete: 71..78,
+                source_range: 138..139,
+                delete: 132..139,
                 insert: "const SOME_CONST: u16 = ",
                 kind: Const,
                 lookup: "SOME_CONST",
diff --git a/crates/ra_ide/src/completion/complete_unqualified_path.rs b/crates/ra_ide/src/completion/complete_unqualified_path.rs
index a0a04bb580..aa2b07a2f1 100644
--- a/crates/ra_ide/src/completion/complete_unqualified_path.rs
+++ b/crates/ra_ide/src/completion/complete_unqualified_path.rs
@@ -85,15 +85,15 @@ mod tests {
                 "#,
             ),
             @r###"
-        [
-            CompletionItem {
-                label: "collections",
-                source_range: 4..7,
-                delete: 4..7,
-                insert: "collections",
-            },
-        ]
-        "###
+            [
+                CompletionItem {
+                    label: "collections",
+                    source_range: 21..24,
+                    delete: 21..24,
+                    insert: "collections",
+                },
+            ]
+            "###
         );
     }
 
@@ -157,16 +157,16 @@ mod tests {
                 "
             ),
             @r###"
-        [
-            CompletionItem {
-                label: "Enum",
-                source_range: 102..104,
-                delete: 102..104,
-                insert: "Enum",
-                kind: Enum,
-            },
-        ]
-        "###
+            [
+                CompletionItem {
+                    label: "Enum",
+                    source_range: 231..233,
+                    delete: 231..233,
+                    insert: "Enum",
+                    kind: Enum,
+                },
+            ]
+            "###
         );
     }
 
@@ -186,8 +186,8 @@ mod tests {
         [
             CompletionItem {
                 label: "quux(…)",
-                source_range: 42..42,
-                delete: 42..42,
+                source_range: 91..91,
+                delete: 91..91,
                 insert: "quux(${1:x})$0",
                 kind: Function,
                 lookup: "quux",
@@ -196,16 +196,16 @@ mod tests {
             },
             CompletionItem {
                 label: "x",
-                source_range: 42..42,
-                delete: 42..42,
+                source_range: 91..91,
+                delete: 91..91,
                 insert: "x",
                 kind: Binding,
                 detail: "i32",
             },
             CompletionItem {
                 label: "y",
-                source_range: 42..42,
-                delete: 42..42,
+                source_range: 91..91,
+                delete: 91..91,
                 insert: "y",
                 kind: Binding,
                 detail: "i32",
@@ -235,23 +235,23 @@ mod tests {
         [
             CompletionItem {
                 label: "a",
-                source_range: 129..129,
-                delete: 129..129,
+                source_range: 242..242,
+                delete: 242..242,
                 insert: "a",
                 kind: Binding,
             },
             CompletionItem {
                 label: "b",
-                source_range: 129..129,
-                delete: 129..129,
+                source_range: 242..242,
+                delete: 242..242,
                 insert: "b",
                 kind: Binding,
                 detail: "i32",
             },
             CompletionItem {
                 label: "quux()",
-                source_range: 129..129,
-                delete: 129..129,
+                source_range: 242..242,
+                delete: 242..242,
                 insert: "quux()$0",
                 kind: Function,
                 lookup: "quux",
@@ -278,8 +278,8 @@ mod tests {
         [
             CompletionItem {
                 label: "quux()",
-                source_range: 46..46,
-                delete: 46..46,
+                source_range: 95..95,
+                delete: 95..95,
                 insert: "quux()$0",
                 kind: Function,
                 lookup: "quux",
@@ -287,8 +287,8 @@ mod tests {
             },
             CompletionItem {
                 label: "x",
-                source_range: 46..46,
-                delete: 46..46,
+                source_range: 95..95,
+                delete: 95..95,
                 insert: "x",
                 kind: Binding,
             },
@@ -314,15 +314,15 @@ mod tests {
         [
             CompletionItem {
                 label: "index",
-                source_range: 58..58,
-                delete: 58..58,
+                source_range: 107..107,
+                delete: 107..107,
                 insert: "index",
                 kind: Binding,
             },
             CompletionItem {
                 label: "test()",
-                source_range: 58..58,
-                delete: 58..58,
+                source_range: 107..107,
+                delete: 107..107,
                 insert: "test()$0",
                 kind: Function,
                 lookup: "test",
@@ -347,15 +347,15 @@ mod tests {
         [
             CompletionItem {
                 label: "T",
-                source_range: 19..19,
-                delete: 19..19,
+                source_range: 52..52,
+                delete: 52..52,
                 insert: "T",
                 kind: TypeParam,
             },
             CompletionItem {
                 label: "quux()",
-                source_range: 19..19,
-                delete: 19..19,
+                source_range: 52..52,
+                delete: 52..52,
                 insert: "quux()$0",
                 kind: Function,
                 lookup: "quux",
@@ -380,22 +380,22 @@ mod tests {
         [
             CompletionItem {
                 label: "Self",
-                source_range: 21..21,
-                delete: 21..21,
+                source_range: 54..54,
+                delete: 54..54,
                 insert: "Self",
                 kind: TypeParam,
             },
             CompletionItem {
                 label: "T",
-                source_range: 21..21,
-                delete: 21..21,
+                source_range: 54..54,
+                delete: 54..54,
                 insert: "T",
                 kind: TypeParam,
             },
             CompletionItem {
                 label: "X<…>",
-                source_range: 21..21,
-                delete: 21..21,
+                source_range: 54..54,
+                delete: 54..54,
                 insert: "X<$0>",
                 kind: Struct,
                 lookup: "X",
@@ -419,15 +419,15 @@ mod tests {
         [
             CompletionItem {
                 label: "Self",
-                source_range: 15..15,
-                delete: 15..15,
+                source_range: 48..48,
+                delete: 48..48,
                 insert: "Self",
                 kind: TypeParam,
             },
             CompletionItem {
                 label: "X",
-                source_range: 15..15,
-                delete: 15..15,
+                source_range: 48..48,
+                delete: 48..48,
                 insert: "X",
                 kind: Enum,
             },
@@ -452,22 +452,22 @@ mod tests {
         [
             CompletionItem {
                 label: "Baz",
-                source_range: 40..40,
-                delete: 40..40,
+                source_range: 105..105,
+                delete: 105..105,
                 insert: "Baz",
                 kind: Enum,
             },
             CompletionItem {
                 label: "Foo",
-                source_range: 40..40,
-                delete: 40..40,
+                source_range: 105..105,
+                delete: 105..105,
                 insert: "Foo",
                 kind: Struct,
             },
             CompletionItem {
                 label: "quux()",
-                source_range: 40..40,
-                delete: 40..40,
+                source_range: 105..105,
+                delete: 105..105,
                 insert: "quux()$0",
                 kind: Function,
                 lookup: "quux",
@@ -520,15 +520,15 @@ mod tests {
         [
             CompletionItem {
                 label: "Bar",
-                source_range: 52..52,
-                delete: 52..52,
+                source_range: 117..117,
+                delete: 117..117,
                 insert: "Bar",
                 kind: Struct,
             },
             CompletionItem {
                 label: "quux()",
-                source_range: 52..52,
-                delete: 52..52,
+                source_range: 117..117,
+                delete: 117..117,
                 insert: "quux()$0",
                 kind: Function,
                 lookup: "quux",
@@ -552,15 +552,15 @@ mod tests {
         [
             CompletionItem {
                 label: "Foo",
-                source_range: 22..22,
-                delete: 22..22,
+                source_range: 55..55,
+                delete: 55..55,
                 insert: "Foo",
                 kind: Struct,
             },
             CompletionItem {
                 label: "x()",
-                source_range: 22..22,
-                delete: 22..22,
+                source_range: 55..55,
+                delete: 55..55,
                 insert: "x()$0",
                 kind: Function,
                 lookup: "x",
@@ -589,16 +589,16 @@ mod tests {
         [
             CompletionItem {
                 label: "bar",
-                source_range: 65..65,
-                delete: 65..65,
+                source_range: 146..146,
+                delete: 146..146,
                 insert: "bar",
                 kind: Binding,
                 detail: "i32",
             },
             CompletionItem {
                 label: "foo()",
-                source_range: 65..65,
-                delete: 65..65,
+                source_range: 146..146,
+                delete: 146..146,
                 insert: "foo()$0",
                 kind: Function,
                 lookup: "foo",
@@ -1001,16 +1001,16 @@ mod tests {
         [
             CompletionItem {
                 label: "m!(…)",
-                source_range: 80..80,
-                delete: 80..80,
+                source_range: 145..145,
+                delete: 145..145,
                 insert: "m!($0)",
                 kind: Macro,
                 detail: "macro_rules! m",
             },
             CompletionItem {
                 label: "quux(…)",
-                source_range: 80..80,
-                delete: 80..80,
+                source_range: 145..145,
+                delete: 145..145,
                 insert: "quux(${1:x})$0",
                 kind: Function,
                 lookup: "quux",
@@ -1019,16 +1019,16 @@ mod tests {
             },
             CompletionItem {
                 label: "x",
-                source_range: 80..80,
-                delete: 80..80,
+                source_range: 145..145,
+                delete: 145..145,
                 insert: "x",
                 kind: Binding,
                 detail: "i32",
             },
             CompletionItem {
                 label: "y",
-                source_range: 80..80,
-                delete: 80..80,
+                source_range: 145..145,
+                delete: 145..145,
                 insert: "y",
                 kind: Binding,
                 detail: "i32",
@@ -1054,16 +1054,16 @@ mod tests {
         [
             CompletionItem {
                 label: "m!(…)",
-                source_range: 80..81,
-                delete: 80..81,
+                source_range: 145..146,
+                delete: 145..146,
                 insert: "m!($0)",
                 kind: Macro,
                 detail: "macro_rules! m",
             },
             CompletionItem {
                 label: "quux(…)",
-                source_range: 80..81,
-                delete: 80..81,
+                source_range: 145..146,
+                delete: 145..146,
                 insert: "quux(${1:x})$0",
                 kind: Function,
                 lookup: "quux",
@@ -1072,16 +1072,16 @@ mod tests {
             },
             CompletionItem {
                 label: "x",
-                source_range: 80..81,
-                delete: 80..81,
+                source_range: 145..146,
+                delete: 145..146,
                 insert: "x",
                 kind: Binding,
                 detail: "i32",
             },
             CompletionItem {
                 label: "y",
-                source_range: 80..81,
-                delete: 80..81,
+                source_range: 145..146,
+                delete: 145..146,
                 insert: "y",
                 kind: Binding,
                 detail: "i32",
@@ -1107,16 +1107,16 @@ mod tests {
         [
             CompletionItem {
                 label: "m!(…)",
-                source_range: 80..81,
-                delete: 80..81,
+                source_range: 145..146,
+                delete: 145..146,
                 insert: "m!($0)",
                 kind: Macro,
                 detail: "macro_rules! m",
             },
             CompletionItem {
                 label: "quux(…)",
-                source_range: 80..81,
-                delete: 80..81,
+                source_range: 145..146,
+                delete: 145..146,
                 insert: "quux(${1:x})$0",
                 kind: Function,
                 lookup: "quux",
@@ -1125,16 +1125,16 @@ mod tests {
             },
             CompletionItem {
                 label: "x",
-                source_range: 80..81,
-                delete: 80..81,
+                source_range: 145..146,
+                delete: 145..146,
                 insert: "x",
                 kind: Binding,
                 detail: "i32",
             },
             CompletionItem {
                 label: "y",
-                source_range: 80..81,
-                delete: 80..81,
+                source_range: 145..146,
+                delete: 145..146,
                 insert: "y",
                 kind: Binding,
                 detail: "i32",
@@ -1160,14 +1160,14 @@ mod tests {
         [
             CompletionItem {
                 label: "Quux",
-                source_range: 33..33,
-                delete: 33..33,
+                source_range: 82..82,
+                delete: 82..82,
                 insert: "Quux",
             },
             CompletionItem {
                 label: "main()",
-                source_range: 33..33,
-                delete: 33..33,
+                source_range: 82..82,
+                delete: 82..82,
                 insert: "main()$0",
                 kind: Function,
                 lookup: "main",
@@ -1201,15 +1201,15 @@ mod tests {
         [
             CompletionItem {
                 label: "Foo",
-                source_range: 103..105,
-                delete: 103..105,
+                source_range: 248..250,
+                delete: 248..250,
                 insert: "Foo",
                 kind: Enum,
             },
             CompletionItem {
                 label: "Foo::Bar",
-                source_range: 103..105,
-                delete: 103..105,
+                source_range: 248..250,
+                delete: 248..250,
                 insert: "Foo::Bar",
                 kind: EnumVariant,
                 lookup: "Bar",
@@ -1217,8 +1217,8 @@ mod tests {
             },
             CompletionItem {
                 label: "Foo::Baz",
-                source_range: 103..105,
-                delete: 103..105,
+                source_range: 248..250,
+                delete: 248..250,
                 insert: "Foo::Baz",
                 kind: EnumVariant,
                 lookup: "Baz",
@@ -1226,8 +1226,8 @@ mod tests {
             },
             CompletionItem {
                 label: "Foo::Quux",
-                source_range: 103..105,
-                delete: 103..105,
+                source_range: 248..250,
+                delete: 248..250,
                 insert: "Foo::Quux",
                 kind: EnumVariant,
                 lookup: "Quux",
@@ -1262,15 +1262,15 @@ mod tests {
         [
             CompletionItem {
                 label: "Foo",
-                source_range: 90..92,
-                delete: 90..92,
+                source_range: 219..221,
+                delete: 219..221,
                 insert: "Foo",
                 kind: Enum,
             },
             CompletionItem {
                 label: "Foo::Bar",
-                source_range: 90..92,
-                delete: 90..92,
+                source_range: 219..221,
+                delete: 219..221,
                 insert: "Foo::Bar",
                 kind: EnumVariant,
                 lookup: "Bar",
@@ -1278,8 +1278,8 @@ mod tests {
             },
             CompletionItem {
                 label: "Foo::Baz",
-                source_range: 90..92,
-                delete: 90..92,
+                source_range: 219..221,
+                delete: 219..221,
                 insert: "Foo::Baz",
                 kind: EnumVariant,
                 lookup: "Baz",
@@ -1287,8 +1287,8 @@ mod tests {
             },
             CompletionItem {
                 label: "Foo::Quux",
-                source_range: 90..92,
-                delete: 90..92,
+                source_range: 219..221,
+                delete: 219..221,
                 insert: "Foo::Quux",
                 kind: EnumVariant,
                 lookup: "Quux",
@@ -1319,15 +1319,15 @@ mod tests {
         [
             CompletionItem {
                 label: "Foo",
-                source_range: 72..73,
-                delete: 72..73,
+                source_range: 185..186,
+                delete: 185..186,
                 insert: "Foo",
                 kind: Enum,
             },
             CompletionItem {
                 label: "Foo::Bar",
-                source_range: 72..73,
-                delete: 72..73,
+                source_range: 185..186,
+                delete: 185..186,
                 insert: "Foo::Bar",
                 kind: EnumVariant,
                 lookup: "Bar",
@@ -1335,8 +1335,8 @@ mod tests {
             },
             CompletionItem {
                 label: "Foo::Baz",
-                source_range: 72..73,
-                delete: 72..73,
+                source_range: 185..186,
+                delete: 185..186,
                 insert: "Foo::Baz",
                 kind: EnumVariant,
                 lookup: "Baz",
@@ -1344,8 +1344,8 @@ mod tests {
             },
             CompletionItem {
                 label: "Foo::Quux",
-                source_range: 72..73,
-                delete: 72..73,
+                source_range: 185..186,
+                delete: 185..186,
                 insert: "Foo::Quux",
                 kind: EnumVariant,
                 lookup: "Quux",
@@ -1353,8 +1353,8 @@ mod tests {
             },
             CompletionItem {
                 label: "main()",
-                source_range: 72..73,
-                delete: 72..73,
+                source_range: 185..186,
+                delete: 185..186,
                 insert: "main()$0",
                 kind: Function,
                 lookup: "main",
@@ -1381,8 +1381,8 @@ mod tests {
         [
             CompletionItem {
                 label: "f()",
-                source_range: 49..50,
-                delete: 49..50,
+                source_range: 98..99,
+                delete: 98..99,
                 insert: "f()$0",
                 kind: Function,
                 lookup: "f",
@@ -1390,15 +1390,15 @@ mod tests {
             },
             CompletionItem {
                 label: "m",
-                source_range: 49..50,
-                delete: 49..50,
+                source_range: 98..99,
+                delete: 98..99,
                 insert: "m",
                 kind: Module,
             },
             CompletionItem {
                 label: "m::E::V",
-                source_range: 49..50,
-                delete: 49..50,
+                source_range: 98..99,
+                delete: 98..99,
                 insert: "m::E::V",
                 kind: EnumVariant,
                 lookup: "V",
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs
index 4fdc2f0bbc..61565c84fe 100644
--- a/crates/ra_ide/src/completion/presentation.rs
+++ b/crates/ra_ide/src/completion/presentation.rs
@@ -491,14 +491,13 @@ mod tests {
         [
             CompletionItem {
                 label: "Foo",
-                source_range: 56..58,
-                delete: 56..58,
+                source_range: 121..123,
+                delete: 121..123,
                 insert: "Foo",
                 kind: EnumVariant,
                 detail: "{ x: i32, y: i32 }",
             },
-        ]
-        "###
+        ]"###
         );
     }
 
@@ -518,16 +517,15 @@ mod tests {
         [
             CompletionItem {
                 label: "Foo(…)",
-                source_range: 50..52,
-                delete: 50..52,
+                source_range: 115..117,
+                delete: 115..117,
                 insert: "Foo($0)",
                 kind: EnumVariant,
                 lookup: "Foo",
                 detail: "(i32, i32)",
                 trigger_call_info: true,
             },
-        ]
-        "###
+        ]"###
         );
     }
 
@@ -547,14 +545,13 @@ mod tests {
         [
             CompletionItem {
                 label: "Foo",
-                source_range: 39..41,
-                delete: 39..41,
+                source_range: 104..106,
+                delete: 104..106,
                 insert: "Foo",
                 kind: EnumVariant,
                 detail: "()",
             },
-        ]
-        "###
+        ]"###
         );
     }
 
@@ -576,8 +573,8 @@ mod tests {
         [
             CompletionItem {
                 label: "main()",
-                source_range: 122..125,
-                delete: 122..125,
+                source_range: 203..206,
+                delete: 203..206,
                 insert: "main()$0",
                 kind: Function,
                 lookup: "main",
@@ -585,8 +582,8 @@ mod tests {
             },
             CompletionItem {
                 label: "something_deprecated()",
-                source_range: 122..125,
-                delete: 122..125,
+                source_range: 203..206,
+                delete: 203..206,
                 insert: "something_deprecated()$0",
                 kind: Function,
                 lookup: "something_deprecated",
@@ -595,8 +592,8 @@ mod tests {
             },
             CompletionItem {
                 label: "something_else_deprecated()",
-                source_range: 122..125,
-                delete: 122..125,
+                source_range: 203..206,
+                delete: 203..206,
                 insert: "something_else_deprecated()$0",
                 kind: Function,
                 lookup: "something_else_deprecated",
@@ -622,8 +619,8 @@ mod tests {
         [
             CompletionItem {
                 label: "main()",
-                source_range: 28..31,
-                delete: 28..31,
+                source_range: 61..64,
+                delete: 61..64,
                 insert: "main()$0",
                 kind: Function,
                 lookup: "main",
@@ -631,8 +628,8 @@ mod tests {
             },
             CompletionItem {
                 label: "no_args()",
-                source_range: 28..31,
-                delete: 28..31,
+                source_range: 61..64,
+                delete: 61..64,
                 insert: "no_args()$0",
                 kind: Function,
                 lookup: "no_args",
@@ -652,8 +649,8 @@ mod tests {
         [
             CompletionItem {
                 label: "main()",
-                source_range: 47..52,
-                delete: 47..52,
+                source_range: 80..85,
+                delete: 80..85,
                 insert: "main()$0",
                 kind: Function,
                 lookup: "main",
@@ -661,8 +658,8 @@ mod tests {
             },
             CompletionItem {
                 label: "with_args(…)",
-                source_range: 47..52,
-                delete: 47..52,
+                source_range: 80..85,
+                delete: 80..85,
                 insert: "with_args(${1:x}, ${2:y})$0",
                 kind: Function,
                 lookup: "with_args",
@@ -683,8 +680,8 @@ mod tests {
         [
             CompletionItem {
                 label: "main()",
-                source_range: 77..82,
-                delete: 77..82,
+                source_range: 110..115,
+                delete: 110..115,
                 insert: "main()$0",
                 kind: Function,
                 lookup: "main",
@@ -692,8 +689,8 @@ mod tests {
             },
             CompletionItem {
                 label: "with_ignored_args(…)",
-                source_range: 77..82,
-                delete: 77..82,
+                source_range: 110..115,
+                delete: 110..115,
                 insert: "with_ignored_args(${1:foo}, ${2:bar}, ${3:ho_ge_})$0",
                 kind: Function,
                 lookup: "with_ignored_args",
@@ -719,8 +716,8 @@ mod tests {
         [
             CompletionItem {
                 label: "foo()",
-                source_range: 66..67,
-                delete: 66..67,
+                source_range: 163..164,
+                delete: 163..164,
                 insert: "foo()$0",
                 kind: Method,
                 lookup: "foo",
@@ -745,8 +742,8 @@ mod tests {
         [
             CompletionItem {
                 label: "foo_ignored_args(…)",
-                source_range: 97..98,
-                delete: 97..98,
+                source_range: 194..195,
+                delete: 194..195,
                 insert: "foo_ignored_args(${1:a}, ${2:b})$0",
                 kind: Method,
                 lookup: "foo_ignored_args",
@@ -774,23 +771,23 @@ mod tests {
         [
             CompletionItem {
                 label: "None",
-                source_range: 79..82,
-                delete: 79..82,
+                source_range: 144..147,
+                delete: 144..147,
                 insert: "None",
                 kind: EnumVariant,
                 detail: "()",
             },
             CompletionItem {
                 label: "Option",
-                source_range: 79..82,
-                delete: 79..82,
+                source_range: 144..147,
+                delete: 144..147,
                 insert: "Option",
                 kind: Enum,
             },
             CompletionItem {
                 label: "Some(…)",
-                source_range: 79..82,
-                delete: 79..82,
+                source_range: 144..147,
+                delete: 144..147,
                 insert: "Some($0)",
                 kind: EnumVariant,
                 lookup: "Some",
@@ -799,8 +796,8 @@ mod tests {
             },
             CompletionItem {
                 label: "main()",
-                source_range: 79..82,
-                delete: 79..82,
+                source_range: 144..147,
+                delete: 144..147,
                 insert: "main()$0",
                 kind: Function,
                 lookup: "main",
@@ -825,23 +822,23 @@ mod tests {
         [
             CompletionItem {
                 label: "None",
-                source_range: 104..107,
-                delete: 104..107,
+                source_range: 185..188,
+                delete: 185..188,
                 insert: "None",
                 kind: EnumVariant,
                 detail: "()",
             },
             CompletionItem {
                 label: "Option",
-                source_range: 104..107,
-                delete: 104..107,
+                source_range: 185..188,
+                delete: 185..188,
                 insert: "Option",
                 kind: Enum,
             },
             CompletionItem {
                 label: "Some(…)",
-                source_range: 104..107,
-                delete: 104..107,
+                source_range: 185..188,
+                delete: 185..188,
                 insert: "Some($0)",
                 kind: EnumVariant,
                 lookup: "Some",
@@ -875,23 +872,23 @@ mod tests {
         [
             CompletionItem {
                 label: "ManualVtable",
-                source_range: 182..186,
-                delete: 182..186,
+                source_range: 295..299,
+                delete: 295..299,
                 insert: "ManualVtable",
                 kind: Struct,
             },
             CompletionItem {
                 label: "main",
-                source_range: 182..186,
-                delete: 182..186,
+                source_range: 295..299,
+                delete: 295..299,
                 insert: "main",
                 kind: Function,
                 detail: "fn main() -> ManualVtable",
             },
             CompletionItem {
                 label: "somefn",
-                source_range: 182..186,
-                delete: 182..186,
+                source_range: 295..299,
+                delete: 295..299,
                 insert: "somefn",
                 kind: Function,
                 detail: "fn somefn(with: u8, a: u8, lot: u8, of: u8, args: u8)",
@@ -919,8 +916,8 @@ mod tests {
         [
             CompletionItem {
                 label: "foo(…)",
-                source_range: 74..75,
-                delete: 74..75,
+                source_range: 171..172,
+                delete: 171..172,
                 insert: "foo(${1:x})$0",
                 kind: Method,
                 lookup: "foo",
@@ -954,8 +951,8 @@ mod tests {
         [
             CompletionItem {
                 label: "foo(…)",
-                source_range: 74..75,
-                delete: 74..75,
+                source_range: 171..172,
+                delete: 171..172,
                 insert: "foo($0)",
                 kind: Method,
                 lookup: "foo",
@@ -1065,16 +1062,16 @@ mod tests {
         [
             CompletionItem {
                 label: "Vec<…>",
-                source_range: 28..30,
-                delete: 28..30,
+                source_range: 61..63,
+                delete: 61..63,
                 insert: "Vec<$0>",
                 kind: Struct,
                 lookup: "Vec",
             },
             CompletionItem {
                 label: "foo(…)",
-                source_range: 28..30,
-                delete: 28..30,
+                source_range: 61..63,
+                delete: 61..63,
                 insert: "foo(${1:xs})$0",
                 kind: Function,
                 lookup: "foo",
@@ -1095,16 +1092,16 @@ mod tests {
         [
             CompletionItem {
                 label: "Vec<…>",
-                source_range: 31..33,
-                delete: 31..33,
+                source_range: 64..66,
+                delete: 64..66,
                 insert: "Vec<$0>",
                 kind: TypeAlias,
                 lookup: "Vec",
             },
             CompletionItem {
                 label: "foo(…)",
-                source_range: 31..33,
-                delete: 31..33,
+                source_range: 64..66,
+                delete: 64..66,
                 insert: "foo(${1:xs})$0",
                 kind: Function,
                 lookup: "foo",
@@ -1125,15 +1122,15 @@ mod tests {
         [
             CompletionItem {
                 label: "Vec",
-                source_range: 35..37,
-                delete: 35..37,
+                source_range: 68..70,
+                delete: 68..70,
                 insert: "Vec",
                 kind: Struct,
             },
             CompletionItem {
                 label: "foo(…)",
-                source_range: 35..37,
-                delete: 35..37,
+                source_range: 68..70,
+                delete: 68..70,
                 insert: "foo(${1:xs})$0",
                 kind: Function,
                 lookup: "foo",
@@ -1154,15 +1151,15 @@ mod tests {
         [
             CompletionItem {
                 label: "Vec",
-                source_range: 28..30,
-                delete: 28..30,
+                source_range: 61..63,
+                delete: 61..63,
                 insert: "Vec",
                 kind: Struct,
             },
             CompletionItem {
                 label: "foo(…)",
-                source_range: 28..30,
-                delete: 28..30,
+                source_range: 61..63,
+                delete: 61..63,
                 insert: "foo(${1:xs})$0",
                 kind: Function,
                 lookup: "foo",
@@ -1257,24 +1254,24 @@ mod tests {
         [
             CompletionItem {
                 label: "another_field",
-                source_range: 136..136,
-                delete: 136..136,
+                source_range: 201..201,
+                delete: 201..201,
                 insert: "another_field",
                 kind: Field,
                 detail: "i64",
             },
             CompletionItem {
                 label: "my_string",
-                source_range: 136..136,
-                delete: 136..136,
+                source_range: 201..201,
+                delete: 201..201,
                 insert: "my_string",
                 kind: Field,
                 detail: "{unknown}",
             },
             CompletionItem {
                 label: "the_field",
-                source_range: 136..136,
-                delete: 136..136,
+                source_range: 201..201,
+                delete: 201..201,
                 insert: "the_field",
                 kind: Field,
                 detail: "u32",
@@ -1301,16 +1298,16 @@ mod tests {
         [
             CompletionItem {
                 label: "another_field",
-                source_range: 143..143,
-                delete: 143..143,
+                source_range: 208..208,
+                delete: 208..208,
                 insert: "another_field",
                 kind: Field,
                 detail: "i64",
             },
             CompletionItem {
                 label: "another_good_type",
-                source_range: 143..143,
-                delete: 143..143,
+                source_range: 208..208,
+                delete: 208..208,
                 insert: "another_good_type",
                 kind: Field,
                 detail: "u32",
@@ -1318,8 +1315,8 @@ mod tests {
             },
             CompletionItem {
                 label: "the_field",
-                source_range: 143..143,
-                delete: 143..143,
+                source_range: 208..208,
+                delete: 208..208,
                 insert: "the_field",
                 kind: Field,
                 detail: "u32",
@@ -1349,16 +1346,16 @@ mod tests {
         [
             CompletionItem {
                 label: "another_field",
-                source_range: 189..189,
-                delete: 189..189,
+                source_range: 270..270,
+                delete: 270..270,
                 insert: "another_field",
                 kind: Field,
                 detail: "i64",
             },
             CompletionItem {
                 label: "another_good_type",
-                source_range: 189..189,
-                delete: 189..189,
+                source_range: 270..270,
+                delete: 270..270,
                 insert: "another_good_type",
                 kind: Field,
                 detail: "u32",
@@ -1366,8 +1363,8 @@ mod tests {
             },
             CompletionItem {
                 label: "the_field",
-                source_range: 189..189,
-                delete: 189..189,
+                source_range: 270..270,
+                delete: 270..270,
                 insert: "the_field",
                 kind: Field,
                 detail: "u32",
@@ -1397,8 +1394,8 @@ mod tests {
         [
             CompletionItem {
                 label: "another_field",
-                source_range: 239..239,
-                delete: 239..239,
+                source_range: 336..336,
+                delete: 336..336,
                 insert: "another_field",
                 kind: Field,
                 detail: "i64",
@@ -1406,16 +1403,16 @@ mod tests {
             },
             CompletionItem {
                 label: "another_good_type",
-                source_range: 239..239,
-                delete: 239..239,
+                source_range: 336..336,
+                delete: 336..336,
                 insert: "another_good_type",
                 kind: Field,
                 detail: "u32",
             },
             CompletionItem {
                 label: "the_field",
-                source_range: 239..239,
-                delete: 239..239,
+                source_range: 336..336,
+                delete: 336..336,
                 insert: "the_field",
                 kind: Field,
                 detail: "u32",
@@ -1444,16 +1441,16 @@ mod tests {
         [
             CompletionItem {
                 label: "another_field",
-                source_range: 231..231,
-                delete: 231..231,
+                source_range: 328..328,
+                delete: 328..328,
                 insert: "another_field",
                 kind: Field,
                 detail: "i64",
             },
             CompletionItem {
                 label: "another_good_type",
-                source_range: 231..231,
-                delete: 231..231,
+                source_range: 328..328,
+                delete: 328..328,
                 insert: "another_good_type",
                 kind: Field,
                 detail: "u32",
@@ -1461,8 +1458,8 @@ mod tests {
             },
             CompletionItem {
                 label: "the_field",
-                source_range: 231..231,
-                delete: 231..231,
+                source_range: 328..328,
+                delete: 328..328,
                 insert: "the_field",
                 kind: Field,
                 detail: "u32",
@@ -1488,15 +1485,15 @@ mod tests {
         [
             CompletionItem {
                 label: "WorldSnapshot",
-                source_range: 71..72,
-                delete: 71..72,
+                source_range: 132..133,
+                delete: 132..133,
                 insert: "WorldSnapshot",
                 kind: Struct,
             },
             CompletionItem {
                 label: "go(…)",
-                source_range: 71..72,
-                delete: 71..72,
+                source_range: 132..133,
+                delete: 132..133,
                 insert: "go(${1:world})$0",
                 kind: Function,
                 lookup: "go",
@@ -1505,8 +1502,8 @@ mod tests {
             },
             CompletionItem {
                 label: "world",
-                source_range: 71..72,
-                delete: 71..72,
+                source_range: 132..133,
+                delete: 132..133,
                 insert: "world",
                 kind: Binding,
                 detail: "&WorldSnapshot",
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs
index 8a18bc18c7..8cb0700b94 100644
--- a/crates/ra_ide/src/diagnostics.rs
+++ b/crates/ra_ide/src/diagnostics.rs
@@ -348,10 +348,8 @@ mod tests {
         );
     }
 
-    fn check_apply_diagnostic_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
-        let ra_fixture_after = &trim_indent(ra_fixture_after);
-        let (analysis, file_id) = single_file(ra_fixture_before);
-        let before = analysis.file_text(file_id).unwrap();
+    fn check_apply_diagnostic_fix(before: &str, after: &str) {
+        let (analysis, file_id) = single_file(before);
         let diagnostic = analysis.diagnostics(file_id).unwrap().pop().unwrap();
         let mut fix = diagnostic.fix.unwrap();
         let edit = fix.source_change.source_file_edits.pop().unwrap().edit;
@@ -360,7 +358,7 @@ mod tests {
             edit.apply(&mut actual);
             actual
         };
-        assert_eq_text!(ra_fixture_after, &actual);
+        assert_eq_text!(after, &actual);
     }
 
     /// Takes a multi-file input fixture with annotated cursor position and checks that no diagnostics
@@ -711,7 +709,7 @@ mod tests {
         [
             Diagnostic {
                 message: "Missing structure fields:\n- b\n",
-                range: 127..136,
+                range: 224..233,
                 severity: Error,
                 fix: Some(
                     Fix {
@@ -857,22 +855,22 @@ fn main() {
     fn test_add_field_from_usage() {
         check_apply_diagnostic_fix(
             r"
-fn main() {
-    Foo { bar: 3, baz: false};
-}
-struct Foo {
-    bar: i32
-}
-",
+            fn main() {
+                Foo { bar: 3, baz: false};
+            }
+            struct Foo {
+                bar: i32
+            }
+            ",
             r"
-fn main() {
-    Foo { bar: 3, baz: false};
-}
-struct Foo {
-    bar: i32,
-    baz: bool
-}
-",
+            fn main() {
+                Foo { bar: 3, baz: false};
+            }
+            struct Foo {
+                bar: i32,
+                baz: bool
+            }
+            ",
         )
     }
 }
diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs
index 8a6b3ea990..a4bc93cdba 100644
--- a/crates/ra_ide/src/extend_selection.rs
+++ b/crates/ra_ide/src/extend_selection.rs
@@ -315,15 +315,17 @@ fn adj_comments(comment: &ast::Comment, dir: Direction) -> ast::Comment {
 
 #[cfg(test)]
 mod tests {
-    use crate::mock_analysis::analysis_and_position;
+    use test_utils::extract_offset;
+
+    use crate::mock_analysis::single_file;
 
     use super::*;
 
     fn do_check(before: &str, afters: &[&str]) {
-        let (analysis, position) = analysis_and_position(&before);
-        let before = analysis.file_text(position.file_id).unwrap();
-        let range = TextRange::empty(position.offset);
-        let mut frange = FileRange { file_id: position.file_id, range };
+        let (cursor, before) = extract_offset(before);
+        let (analysis, file_id) = single_file(&before);
+        let range = TextRange::empty(cursor);
+        let mut frange = FileRange { file_id, range };
 
         for &after in afters {
             frange.range = analysis.extend_selection(frange).unwrap();
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index c3e36a387a..a898f2e4a0 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -399,7 +399,7 @@ mod tests {
     use ra_db::FileLoader;
     use ra_syntax::TextRange;
 
-    use crate::mock_analysis::analysis_and_position;
+    use crate::mock_analysis::{analysis_and_position, single_file_with_position};
 
     fn trim_markup(s: &str) -> &str {
         s.trim_start_matches("```rust\n").trim_end_matches("\n```")
@@ -442,17 +442,17 @@ mod tests {
 
     #[test]
     fn hover_shows_type_of_an_expression() {
-        let (analysis, position) = analysis_and_position(
-            r#"
-pub fn foo() -> u32 { 1 }
+        let (analysis, position) = single_file_with_position(
+            "
+            pub fn foo() -> u32 { 1 }
 
-fn main() {
-    let foo_test = foo()<|>;
-}
-"#,
+            fn main() {
+                let foo_test = foo()<|>;
+            }
+            ",
         );
         let hover = analysis.hover(position).unwrap().unwrap();
-        assert_eq!(hover.range, TextRange::new(58.into(), 63.into()));
+        assert_eq!(hover.range, TextRange::new(95.into(), 100.into()));
         assert_eq!(trim_markup_opt(hover.info.first()), Some("u32"));
     }
 
@@ -641,7 +641,7 @@ fn main() {
 
     #[test]
     fn hover_some() {
-        let (analysis, position) = analysis_and_position(
+        let (analysis, position) = single_file_with_position(
             "
             enum Option<T> { Some(T) }
             use Option::Some;
@@ -654,7 +654,7 @@ fn main() {
         let hover = analysis.hover(position).unwrap().unwrap();
         assert_eq!(trim_markup_opt(hover.info.first()), Some("Option\n```\n\n```rust\nSome"));
 
-        let (analysis, position) = analysis_and_position(
+        let (analysis, position) = single_file_with_position(
             "
             enum Option<T> { Some(T) }
             use Option::Some;
@@ -720,21 +720,21 @@ The Some variant
 
     #[test]
     fn hover_for_local_variable() {
-        let (analysis, position) = analysis_and_position("fn func(foo: i32) { fo<|>o; }");
+        let (analysis, position) = single_file_with_position("fn func(foo: i32) { fo<|>o; }");
         let hover = analysis.hover(position).unwrap().unwrap();
         assert_eq!(trim_markup_opt(hover.info.first()), Some("i32"));
     }
 
     #[test]
     fn hover_for_local_variable_pat() {
-        let (analysis, position) = analysis_and_position("fn func(fo<|>o: i32) {}");
+        let (analysis, position) = single_file_with_position("fn func(fo<|>o: i32) {}");
         let hover = analysis.hover(position).unwrap().unwrap();
         assert_eq!(trim_markup_opt(hover.info.first()), Some("i32"));
     }
 
     #[test]
     fn hover_local_var_edge() {
-        let (analysis, position) = analysis_and_position(
+        let (analysis, position) = single_file_with_position(
             "
 fn func(foo: i32) { if true { <|>foo; }; }
 ",
@@ -745,14 +745,14 @@ fn func(foo: i32) { if true { <|>foo; }; }
 
     #[test]
     fn hover_for_param_edge() {
-        let (analysis, position) = analysis_and_position("fn func(<|>foo: i32) {}");
+        let (analysis, position) = single_file_with_position("fn func(<|>foo: i32) {}");
         let hover = analysis.hover(position).unwrap().unwrap();
         assert_eq!(trim_markup_opt(hover.info.first()), Some("i32"));
     }
 
     #[test]
     fn test_hover_infer_associated_method_result() {
-        let (analysis, position) = analysis_and_position(
+        let (analysis, position) = single_file_with_position(
             "
             struct Thing { x: u32 }
 
@@ -773,7 +773,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
 
     #[test]
     fn test_hover_infer_associated_method_exact() {
-        let (analysis, position) = analysis_and_position(
+        let (analysis, position) = single_file_with_position(
             "
             mod wrapper {
                 struct Thing { x: u32 }
@@ -799,7 +799,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
 
     #[test]
     fn test_hover_infer_associated_const_in_pattern() {
-        let (analysis, position) = analysis_and_position(
+        let (analysis, position) = single_file_with_position(
             "
             struct X;
             impl X {
@@ -821,7 +821,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
 
     #[test]
     fn test_hover_self() {
-        let (analysis, position) = analysis_and_position(
+        let (analysis, position) = single_file_with_position(
             "
             struct Thing { x: u32 }
             impl Thing {
@@ -835,7 +835,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
         assert_eq!(trim_markup_opt(hover.info.first()), Some("Thing"));
 
         /* FIXME: revive these tests
-                let (analysis, position) = analysis_and_position(
+                let (analysis, position) = single_file_with_position(
                     "
                     struct Thing { x: u32 }
                     impl Thing {
@@ -849,7 +849,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
                 let hover = analysis.hover(position).unwrap().unwrap();
                 assert_eq!(trim_markup_opt(hover.info.first()), Some("Thing"));
 
-                let (analysis, position) = analysis_and_position(
+                let (analysis, position) = single_file_with_position(
                     "
                     enum Thing { A }
                     impl Thing {
@@ -862,7 +862,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
                 let hover = analysis.hover(position).unwrap().unwrap();
                 assert_eq!(trim_markup_opt(hover.info.first()), Some("enum Thing"));
 
-                let (analysis, position) = analysis_and_position(
+                let (analysis, position) = single_file_with_position(
                     "
                     enum Thing { A }
                     impl Thing {
@@ -878,7 +878,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
 
     #[test]
     fn test_hover_shadowing_pat() {
-        let (analysis, position) = analysis_and_position(
+        let (analysis, position) = single_file_with_position(
             "
             fn x() {}
 
@@ -894,7 +894,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
 
     #[test]
     fn test_hover_macro_invocation() {
-        let (analysis, position) = analysis_and_position(
+        let (analysis, position) = single_file_with_position(
             "
             macro_rules! foo {
                 () => {}
@@ -911,7 +911,7 @@ fn func(foo: i32) { if true { <|>foo; }; }
 
     #[test]
     fn test_hover_tuple_field() {
-        let (analysis, position) = analysis_and_position(
+        let (analysis, position) = single_file_with_position(
             "
             struct TS(String, i32<|>);
             ",
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 3fd08b1e80..7eb2cef735 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -363,17 +363,16 @@ mod tests {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: true, type_hints: false, chaining_hints: false, max_length: None}).unwrap(), @r###"
         [
             InlayHint {
-                range: 69..70,
+                range: 106..107,
                 kind: ParameterHint,
                 label: "a",
             },
             InlayHint {
-                range: 72..73,
+                range: 109..110,
                 kind: ParameterHint,
                 label: "b",
             },
-        ]
-        "###);
+        ]"###);
     }
 
     #[test]
@@ -400,12 +399,11 @@ mod tests {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ type_hints: true, parameter_hints: false, chaining_hints: false, max_length: None}).unwrap(), @r###"
         [
             InlayHint {
-                range: 60..62,
+                range: 97..99,
                 kind: TypeHint,
                 label: "i32",
             },
-        ]
-        "###);
+        ]"###);
     }
     #[test]
     fn default_generic_types_should_not_be_displayed() {
@@ -425,12 +423,12 @@ fn main() {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
         [
             InlayHint {
-                range: 68..70,
+                range: 69..71,
                 kind: TypeHint,
                 label: "Test<i32>",
             },
             InlayHint {
-                range: 106..112,
+                range: 107..113,
                 kind: TypeHint,
                 label: "&Test<i32>",
             },
@@ -482,57 +480,57 @@ fn main() {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
         [
             InlayHint {
-                range: 192..196,
+                range: 193..197,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 235..243,
+                range: 236..244,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 274..278,
+                range: 275..279,
                 kind: TypeHint,
                 label: "&str",
             },
             InlayHint {
-                range: 538..542,
+                range: 539..543,
                 kind: TypeHint,
                 label: "(i32, char)",
             },
             InlayHint {
-                range: 565..566,
+                range: 566..567,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 569..570,
+                range: 570..571,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 572..573,
+                range: 573..574,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 576..577,
+                range: 577..578,
                 kind: TypeHint,
                 label: "f64",
             },
             InlayHint {
-                range: 579..580,
+                range: 580..581,
                 kind: TypeHint,
                 label: "f64",
             },
             InlayHint {
-                range: 583..584,
+                range: 584..585,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 626..627,
+                range: 627..628,
                 kind: TypeHint,
                 label: "i32",
             },
@@ -562,47 +560,47 @@ fn main() {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
         [
             InlayHint {
-                range: 20..29,
+                range: 21..30,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 56..65,
+                range: 57..66,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 114..122,
+                range: 115..123,
                 kind: TypeHint,
                 label: "|…| -> i32",
             },
             InlayHint {
-                range: 126..127,
+                range: 127..128,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 129..130,
+                range: 130..131,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 132..133,
+                range: 133..134,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 135..136,
+                range: 136..137,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 200..212,
+                range: 201..213,
                 kind: TypeHint,
                 label: "&|…| -> i32",
             },
             InlayHint {
-                range: 235..244,
+                range: 236..245,
                 kind: TypeHint,
                 label: "|| -> i32",
             },
@@ -626,12 +624,12 @@ fn main() {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
         [
             InlayHint {
-                range: 20..29,
+                range: 21..30,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 43..52,
+                range: 44..53,
                 kind: TypeHint,
                 label: "i32",
             },
@@ -676,57 +674,57 @@ fn main() {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
         [
             InlayHint {
-                range: 187..191,
+                range: 188..192,
                 kind: TypeHint,
                 label: "CustomOption<Test>",
             },
             InlayHint {
-                range: 266..270,
+                range: 267..271,
                 kind: TypeHint,
                 label: "&CustomOption<Test>",
             },
             InlayHint {
-                range: 299..303,
+                range: 300..304,
                 kind: TypeHint,
                 label: "&Test",
             },
             InlayHint {
-                range: 340..341,
+                range: 341..342,
                 kind: TypeHint,
                 label: "&CustomOption<u32>",
             },
             InlayHint {
-                range: 343..344,
+                range: 344..345,
                 kind: TypeHint,
                 label: "&u8",
             },
             InlayHint {
-                range: 386..387,
+                range: 387..388,
                 kind: TypeHint,
                 label: "&CustomOption<u32>",
             },
             InlayHint {
-                range: 392..393,
+                range: 393..394,
                 kind: TypeHint,
                 label: "&u8",
             },
             InlayHint {
-                range: 440..441,
+                range: 441..442,
                 kind: TypeHint,
                 label: "&u32",
             },
             InlayHint {
-                range: 447..448,
+                range: 448..449,
                 kind: TypeHint,
                 label: "&u8",
             },
             InlayHint {
-                range: 499..500,
+                range: 500..501,
                 kind: TypeHint,
                 label: "&u8",
             },
             InlayHint {
-                range: 542..543,
+                range: 543..544,
                 kind: TypeHint,
                 label: "&u8",
             },
@@ -771,57 +769,57 @@ fn main() {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
         [
             InlayHint {
-                range: 187..191,
+                range: 188..192,
                 kind: TypeHint,
                 label: "CustomOption<Test>",
             },
             InlayHint {
-                range: 272..276,
+                range: 273..277,
                 kind: TypeHint,
                 label: "&CustomOption<Test>",
             },
             InlayHint {
-                range: 308..312,
+                range: 309..313,
                 kind: TypeHint,
                 label: "&Test",
             },
             InlayHint {
-                range: 352..353,
+                range: 353..354,
                 kind: TypeHint,
                 label: "&CustomOption<u32>",
             },
             InlayHint {
-                range: 355..356,
+                range: 356..357,
                 kind: TypeHint,
                 label: "&u8",
             },
             InlayHint {
-                range: 401..402,
+                range: 402..403,
                 kind: TypeHint,
                 label: "&CustomOption<u32>",
             },
             InlayHint {
-                range: 407..408,
+                range: 408..409,
                 kind: TypeHint,
                 label: "&u8",
             },
             InlayHint {
-                range: 458..459,
+                range: 459..460,
                 kind: TypeHint,
                 label: "&u32",
             },
             InlayHint {
-                range: 465..466,
+                range: 466..467,
                 kind: TypeHint,
                 label: "&u8",
             },
             InlayHint {
-                range: 520..521,
+                range: 521..522,
                 kind: TypeHint,
                 label: "&u8",
             },
             InlayHint {
-                range: 566..567,
+                range: 567..568,
                 kind: TypeHint,
                 label: "&u8",
             },
@@ -866,52 +864,52 @@ fn main() {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
         [
             InlayHint {
-                range: 251..255,
+                range: 252..256,
                 kind: TypeHint,
                 label: "CustomOption<Test>",
             },
             InlayHint {
-                range: 276..280,
+                range: 277..281,
                 kind: TypeHint,
                 label: "Test",
             },
             InlayHint {
-                range: 309..310,
+                range: 310..311,
                 kind: TypeHint,
                 label: "CustomOption<u32>",
             },
             InlayHint {
-                range: 312..313,
+                range: 313..314,
                 kind: TypeHint,
                 label: "u8",
             },
             InlayHint {
-                range: 347..348,
+                range: 348..349,
                 kind: TypeHint,
                 label: "CustomOption<u32>",
             },
             InlayHint {
-                range: 353..354,
+                range: 354..355,
                 kind: TypeHint,
                 label: "u8",
             },
             InlayHint {
-                range: 393..394,
+                range: 394..395,
                 kind: TypeHint,
                 label: "u32",
             },
             InlayHint {
-                range: 400..401,
+                range: 401..402,
                 kind: TypeHint,
                 label: "u8",
             },
             InlayHint {
-                range: 444..445,
+                range: 445..446,
                 kind: TypeHint,
                 label: "u8",
             },
             InlayHint {
-                range: 479..480,
+                range: 480..481,
                 kind: TypeHint,
                 label: "u8",
             },
@@ -938,17 +936,17 @@ fn main() {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###"
         [
             InlayHint {
-                range: 73..74,
+                range: 74..75,
                 kind: TypeHint,
                 label: "Smol<u32>",
             },
             InlayHint {
-                range: 97..98,
+                range: 98..99,
                 kind: TypeHint,
                 label: "VeryLongOuterName<…>",
             },
             InlayHint {
-                range: 136..137,
+                range: 137..138,
                 kind: TypeHint,
                 label: "Smol<Smol<…>>",
             },
@@ -1026,77 +1024,77 @@ fn main() {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
         [
             InlayHint {
-                range: 797..808,
+                range: 798..809,
                 kind: TypeHint,
                 label: "i32",
             },
             InlayHint {
-                range: 841..842,
+                range: 842..843,
                 kind: ParameterHint,
                 label: "foo",
             },
             InlayHint {
-                range: 844..845,
+                range: 845..846,
                 kind: ParameterHint,
                 label: "bar",
             },
             InlayHint {
-                range: 847..854,
+                range: 848..855,
                 kind: ParameterHint,
                 label: "msg",
             },
             InlayHint {
-                range: 859..870,
+                range: 860..871,
                 kind: ParameterHint,
                 label: "last",
             },
             InlayHint {
-                range: 913..916,
+                range: 914..917,
                 kind: ParameterHint,
                 label: "param",
             },
             InlayHint {
-                range: 936..938,
+                range: 937..939,
                 kind: ParameterHint,
                 label: "&self",
             },
             InlayHint {
-                range: 940..944,
+                range: 941..945,
                 kind: ParameterHint,
                 label: "param",
             },
             InlayHint {
-                range: 979..988,
+                range: 980..989,
                 kind: ParameterHint,
                 label: "file_id",
             },
             InlayHint {
-                range: 998..1011,
+                range: 999..1012,
                 kind: ParameterHint,
                 label: "name",
             },
             InlayHint {
-                range: 1021..1025,
+                range: 1022..1026,
                 kind: ParameterHint,
                 label: "focus_range",
             },
             InlayHint {
-                range: 1035..1047,
+                range: 1036..1048,
                 kind: ParameterHint,
                 label: "full_range",
             },
             InlayHint {
-                range: 1057..1070,
+                range: 1058..1071,
                 kind: ParameterHint,
                 label: "kind",
             },
             InlayHint {
-                range: 1080..1084,
+                range: 1081..1085,
                 kind: ParameterHint,
                 label: "docs",
             },
             InlayHint {
-                range: 1094..1098,
+                range: 1095..1099,
                 kind: ParameterHint,
                 label: "description",
             },
@@ -1241,17 +1239,16 @@ fn main() {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###"
         [
             InlayHint {
-                range: 147..172,
+                range: 232..269,
                 kind: ChainingHint,
                 label: "B",
             },
             InlayHint {
-                range: 147..154,
+                range: 232..239,
                 kind: ChainingHint,
                 label: "A",
             },
-        ]
-        "###);
+        ]"###);
     }
 
     #[test]
@@ -1296,12 +1293,12 @@ fn main() {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###"
         [
             InlayHint {
-                range: 143..190,
+                range: 252..323,
                 kind: ChainingHint,
                 label: "C",
             },
             InlayHint {
-                range: 143..179,
+                range: 252..300,
                 kind: ChainingHint,
                 label: "B",
             },
@@ -1334,16 +1331,15 @@ fn main() {
         assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###"
         [
             InlayHint {
-                range: 246..283,
+                range: 403..452,
                 kind: ChainingHint,
                 label: "B<X<i32, bool>>",
             },
             InlayHint {
-                range: 246..265,
+                range: 403..422,
                 kind: ChainingHint,
                 label: "A<X<i32, bool>>",
             },
-        ]
-        "###);
+        ]"###);
     }
 }
diff --git a/crates/ra_ide/src/mock_analysis.rs b/crates/ra_ide/src/mock_analysis.rs
index b7325bfc3c..981bdf924d 100644
--- a/crates/ra_ide/src/mock_analysis.rs
+++ b/crates/ra_ide/src/mock_analysis.rs
@@ -79,6 +79,9 @@ pub struct MockAnalysis {
 }
 
 impl MockAnalysis {
+    pub fn new() -> MockAnalysis {
+        MockAnalysis::default()
+    }
     /// Creates `MockAnalysis` using a fixture data in the following format:
     ///
     /// ```not_rust
@@ -90,7 +93,7 @@ impl MockAnalysis {
     /// struct Baz;
     /// ```
     pub fn with_files(fixture: &str) -> MockAnalysis {
-        let mut res = MockAnalysis::default();
+        let mut res = MockAnalysis::new();
         for entry in Fixture::parse(fixture) {
             res.add_file_fixture(entry);
         }
@@ -101,14 +104,11 @@ impl MockAnalysis {
     /// whose position is also returned.
     pub fn with_files_and_position(fixture: &str) -> (MockAnalysis, FilePosition) {
         let mut position = None;
-        let mut res = MockAnalysis::default();
-        for mut entry in Fixture::parse(fixture) {
+        let mut res = MockAnalysis::new();
+        for entry in Fixture::parse(fixture) {
             if entry.text.contains(CURSOR_MARKER) {
                 assert!(position.is_none(), "only one marker (<|>) per fixture is allowed");
-                let (offset, text) = extract_offset(&entry.text);
-                entry.text = text;
-                let file_id = res.add_file_fixture(entry);
-                position = Some(FilePosition { file_id, offset });
+                position = Some(res.add_file_fixture_with_position(entry));
             } else {
                 res.add_file_fixture(entry);
             }
@@ -117,13 +117,32 @@ impl MockAnalysis {
         (res, position)
     }
 
-    fn add_file_fixture(&mut self, fixture: Fixture) -> FileId {
+    pub fn add_file_fixture(&mut self, fixture: Fixture) -> FileId {
         let file_id = self.next_id();
         self.files.push(MockFileData::from(fixture));
         file_id
     }
 
-    fn add_file_with_range(&mut self, path: &str, text: &str) -> FileRange {
+    pub fn add_file_fixture_with_position(&mut self, mut fixture: Fixture) -> FilePosition {
+        let (offset, text) = extract_offset(&fixture.text);
+        fixture.text = text;
+        let file_id = self.next_id();
+        self.files.push(MockFileData::from(fixture));
+        FilePosition { file_id, offset }
+    }
+
+    pub fn add_file(&mut self, path: &str, text: &str) -> FileId {
+        let file_id = self.next_id();
+        self.files.push(MockFileData::new(path.to_string(), text.to_string()));
+        file_id
+    }
+    pub fn add_file_with_position(&mut self, path: &str, text: &str) -> FilePosition {
+        let (offset, text) = extract_offset(text);
+        let file_id = self.next_id();
+        self.files.push(MockFileData::new(path.to_string(), text));
+        FilePosition { file_id, offset }
+    }
+    pub fn add_file_with_range(&mut self, path: &str, text: &str) -> FileRange {
         let (range, text) = extract_range(text);
         let file_id = self.next_id();
         self.files.push(MockFileData::new(path.to_string(), text));
@@ -203,14 +222,21 @@ pub fn analysis_and_position(ra_fixture: &str) -> (Analysis, FilePosition) {
 
 /// Creates analysis for a single file.
 pub fn single_file(ra_fixture: &str) -> (Analysis, FileId) {
-    let mock = MockAnalysis::with_files(ra_fixture);
-    let file_id = mock.id_of("/main.rs");
+    let mut mock = MockAnalysis::new();
+    let file_id = mock.add_file("/main.rs", ra_fixture);
     (mock.analysis(), file_id)
 }
 
+/// Creates analysis for a single file, returns position marked with <|>.
+pub fn single_file_with_position(ra_fixture: &str) -> (Analysis, FilePosition) {
+    let mut mock = MockAnalysis::new();
+    let pos = mock.add_file_with_position("/main.rs", ra_fixture);
+    (mock.analysis(), pos)
+}
+
 /// Creates analysis for a single file, returns range marked with a pair of <|>.
 pub fn single_file_with_range(ra_fixture: &str) -> (Analysis, FileRange) {
-    let mut mock = MockAnalysis::default();
+    let mut mock = MockAnalysis::new();
     let pos = mock.add_file_with_range("/main.rs", ra_fixture);
     (mock.analysis(), pos)
 }
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs
index 3433fdae39..4a96d65056 100644
--- a/crates/ra_ide/src/references.rs
+++ b/crates/ra_ide/src/references.rs
@@ -191,244 +191,239 @@ fn get_struct_def_name_for_struct_literal_search(
 #[cfg(test)]
 mod tests {
     use crate::{
-        mock_analysis::{analysis_and_position, MockAnalysis},
+        mock_analysis::{analysis_and_position, single_file_with_position, MockAnalysis},
         Declaration, Reference, ReferenceSearchResult, SearchScope,
     };
 
     #[test]
     fn test_struct_literal_after_space() {
-        let refs = get_all_refs(
-            r#"
-struct Foo <|>{
-    a: i32,
-}
-impl Foo {
-    fn f() -> i32 { 42 }
-}
-fn main() {
-    let f: Foo;
-    f = Foo {a: Foo::f()};
-}
-"#,
-        );
+        let code = r#"
+    struct Foo <|>{
+        a: i32,
+    }
+    impl Foo {
+        fn f() -> i32 { 42 }
+    }
+    fn main() {
+        let f: Foo;
+        f = Foo {a: Foo::f()};
+    }"#;
+
+        let refs = get_all_refs(code);
         check_result(
             refs,
-            "Foo STRUCT_DEF FileId(1) 0..26 7..10 Other",
-            &["FileId(1) 101..104 StructLiteral"],
+            "Foo STRUCT_DEF FileId(1) 5..39 12..15 Other",
+            &["FileId(1) 138..141 StructLiteral"],
         );
     }
 
     #[test]
-    fn test_struct_literal_before_space() {
-        let refs = get_all_refs(
-            r#"
-struct Foo<|> {}
-    fn main() {
-    let f: Foo;
-    f = Foo {};
-}
-"#,
-        );
+    fn test_struct_literal_befor_space() {
+        let code = r#"
+    struct Foo<|> {}
+        fn main() {
+        let f: Foo;
+        f = Foo {};
+    }"#;
+
+        let refs = get_all_refs(code);
         check_result(
             refs,
-            "Foo STRUCT_DEF FileId(1) 0..13 7..10 Other",
-            &["FileId(1) 41..44 Other", "FileId(1) 54..57 StructLiteral"],
+            "Foo STRUCT_DEF FileId(1) 5..18 12..15 Other",
+            &["FileId(1) 54..57 Other", "FileId(1) 71..74 StructLiteral"],
         );
     }
 
     #[test]
     fn test_struct_literal_with_generic_type() {
-        let refs = get_all_refs(
-            r#"
-struct Foo<T> <|>{}
-    fn main() {
-    let f: Foo::<i32>;
-    f = Foo {};
-}
-"#,
-        );
+        let code = r#"
+    struct Foo<T> <|>{}
+        fn main() {
+        let f: Foo::<i32>;
+        f = Foo {};
+    }"#;
+
+        let refs = get_all_refs(code);
         check_result(
             refs,
-            "Foo STRUCT_DEF FileId(1) 0..16 7..10 Other",
-            &["FileId(1) 64..67 StructLiteral"],
+            "Foo STRUCT_DEF FileId(1) 5..21 12..15 Other",
+            &["FileId(1) 81..84 StructLiteral"],
         );
     }
 
     #[test]
     fn test_struct_literal_for_tuple() {
-        let refs = get_all_refs(
-            r#"
-struct Foo<|>(i32);
+        let code = r#"
+    struct Foo<|>(i32);
 
-fn main() {
-    let f: Foo;
-    f = Foo(1);
-}
-"#,
-        );
+    fn main() {
+        let f: Foo;
+        f = Foo(1);
+    }"#;
+
+        let refs = get_all_refs(code);
         check_result(
             refs,
-            "Foo STRUCT_DEF FileId(1) 0..16 7..10 Other",
-            &["FileId(1) 54..57 StructLiteral"],
+            "Foo STRUCT_DEF FileId(1) 5..21 12..15 Other",
+            &["FileId(1) 71..74 StructLiteral"],
         );
     }
 
     #[test]
     fn test_find_all_refs_for_local() {
-        let refs = get_all_refs(
-            r#"
-fn main() {
-    let mut i = 1;
-    let j = 1;
-    i = i<|> + j;
+        let code = r#"
+    fn main() {
+        let mut i = 1;
+        let j = 1;
+        i = i<|> + j;
 
-    {
-        i = 0;
-    }
+        {
+            i = 0;
+        }
 
-    i = 5;
-}"#,
-        );
+        i = 5;
+    }"#;
+
+        let refs = get_all_refs(code);
         check_result(
             refs,
-            "i BIND_PAT FileId(1) 24..25 Other Write",
+            "i BIND_PAT FileId(1) 33..34 Other Write",
             &[
-                "FileId(1) 50..51 Other Write",
-                "FileId(1) 54..55 Other Read",
-                "FileId(1) 76..77 Other Write",
-                "FileId(1) 94..95 Other Write",
+                "FileId(1) 67..68 Other Write",
+                "FileId(1) 71..72 Other Read",
+                "FileId(1) 101..102 Other Write",
+                "FileId(1) 127..128 Other Write",
             ],
         );
     }
 
     #[test]
     fn search_filters_by_range() {
-        let refs = get_all_refs(
-            r#"
-fn foo() {
-    let spam<|> = 92;
-    spam + spam
-}
-fn bar() {
-    let spam = 92;
-    spam + spam
-}
-"#,
-        );
+        let code = r#"
+            fn foo() {
+                let spam<|> = 92;
+                spam + spam
+            }
+            fn bar() {
+                let spam = 92;
+                spam + spam
+            }
+        "#;
+        let refs = get_all_refs(code);
         check_result(
             refs,
-            "spam BIND_PAT FileId(1) 19..23 Other",
-            &["FileId(1) 34..38 Other Read", "FileId(1) 41..45 Other Read"],
+            "spam BIND_PAT FileId(1) 44..48 Other",
+            &["FileId(1) 71..75 Other Read", "FileId(1) 78..82 Other Read"],
         );
     }
 
     #[test]
     fn test_find_all_refs_for_param_inside() {
-        let refs = get_all_refs(
-            r#"
-fn foo(i : u32) -> u32 {
-    i<|>
-}
-"#,
-        );
-        check_result(refs, "i BIND_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]);
+        let code = r#"
+    fn foo(i : u32) -> u32 {
+        i<|>
+    }"#;
+
+        let refs = get_all_refs(code);
+        check_result(refs, "i BIND_PAT FileId(1) 12..13 Other", &["FileId(1) 38..39 Other Read"]);
     }
 
     #[test]
     fn test_find_all_refs_for_fn_param() {
-        let refs = get_all_refs(
-            r#"
-fn foo(i<|> : u32) -> u32 {
-    i
-}
-"#,
-        );
-        check_result(refs, "i BIND_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]);
+        let code = r#"
+    fn foo(i<|> : u32) -> u32 {
+        i
+    }"#;
+
+        let refs = get_all_refs(code);
+        check_result(refs, "i BIND_PAT FileId(1) 12..13 Other", &["FileId(1) 38..39 Other Read"]);
     }
 
     #[test]
     fn test_find_all_refs_field_name() {
-        let refs = get_all_refs(
-            r#"
-//- /lib.rs
-struct Foo {
-    pub spam<|>: u32,
-}
+        let code = r#"
+            //- /lib.rs
+            struct Foo {
+                pub spam<|>: u32,
+            }
 
-fn main(s: Foo) {
-    let f = s.spam;
-}
-"#,
-        );
+            fn main(s: Foo) {
+                let f = s.spam;
+            }
+        "#;
+
+        let refs = get_all_refs(code);
         check_result(
             refs,
-            "spam RECORD_FIELD_DEF FileId(1) 17..30 21..25 Other",
-            &["FileId(1) 67..71 Other Read"],
+            "spam RECORD_FIELD_DEF FileId(1) 66..79 70..74 Other",
+            &["FileId(1) 152..156 Other Read"],
         );
     }
 
     #[test]
     fn test_find_all_refs_impl_item_name() {
-        let refs = get_all_refs(
-            r#"
-struct Foo;
-impl Foo {
-    fn f<|>(&self) {  }
-}
-"#,
-        );
-        check_result(refs, "f FN_DEF FileId(1) 27..43 30..31 Other", &[]);
+        let code = r#"
+            //- /lib.rs
+            struct Foo;
+            impl Foo {
+                fn f<|>(&self) {  }
+            }
+        "#;
+
+        let refs = get_all_refs(code);
+        check_result(refs, "f FN_DEF FileId(1) 88..104 91..92 Other", &[]);
     }
 
     #[test]
     fn test_find_all_refs_enum_var_name() {
-        let refs = get_all_refs(
-            r#"
-enum Foo {
-    A,
-    B<|>,
-    C,
-}
-"#,
-        );
-        check_result(refs, "B ENUM_VARIANT FileId(1) 22..23 22..23 Other", &[]);
+        let code = r#"
+            //- /lib.rs
+            enum Foo {
+                A,
+                B<|>,
+                C,
+            }
+        "#;
+
+        let refs = get_all_refs(code);
+        check_result(refs, "B ENUM_VARIANT FileId(1) 83..84 83..84 Other", &[]);
     }
 
     #[test]
     fn test_find_all_refs_two_modules() {
-        let (analysis, pos) = analysis_and_position(
-            r#"
-//- /lib.rs
-pub mod foo;
-pub mod bar;
-
-fn f() {
-    let i = foo::Foo { n: 5 };
-}
+        let code = r#"
+            //- /lib.rs
+            pub mod foo;
+            pub mod bar;
 
-//- /foo.rs
-use crate::bar;
+            fn f() {
+                let i = foo::Foo { n: 5 };
+            }
 
-pub struct Foo {
-    pub n: u32,
-}
+            //- /foo.rs
+            use crate::bar;
 
-fn f() {
-    let i = bar::Bar { n: 5 };
-}
+            pub struct Foo {
+                pub n: u32,
+            }
 
-//- /bar.rs
-use crate::foo;
+            fn f() {
+                let i = bar::Bar { n: 5 };
+            }
 
-pub struct Bar {
-    pub n: u32,
-}
+            //- /bar.rs
+            use crate::foo;
 
-fn f() {
-    let i = foo::Foo<|> { n: 5 };
-}
-"#,
-        );
+            pub struct Bar {
+                pub n: u32,
+            }
+
+            fn f() {
+                let i = foo::Foo<|> { n: 5 };
+            }
+        "#;
+
+        let (analysis, pos) = analysis_and_position(code);
         let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
         check_result(
             refs,
@@ -442,48 +437,48 @@ fn f() {
     // which is the whole `foo.rs`, and the second one is in `use foo::Foo`.
     #[test]
     fn test_find_all_refs_decl_module() {
-        let (analysis, pos) = analysis_and_position(
-            r#"
-//- /lib.rs
-mod foo<|>;
+        let code = r#"
+            //- /lib.rs
+            mod foo<|>;
 
-use foo::Foo;
+            use foo::Foo;
 
-fn f() {
-    let i = Foo { n: 5 };
-}
+            fn f() {
+                let i = Foo { n: 5 };
+            }
 
-//- /foo.rs
-pub struct Foo {
-    pub n: u32,
-}
-"#,
-        );
+            //- /foo.rs
+            pub struct Foo {
+                pub n: u32,
+            }
+        "#;
+
+        let (analysis, pos) = analysis_and_position(code);
         let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
         check_result(refs, "foo SOURCE_FILE FileId(2) 0..35 Other", &["FileId(1) 14..17 Other"]);
     }
 
     #[test]
     fn test_find_all_refs_super_mod_vis() {
-        let (analysis, pos) = analysis_and_position(
-            r#"
-//- /lib.rs
-mod foo;
+        let code = r#"
+            //- /lib.rs
+            mod foo;
+
+            //- /foo.rs
+            mod some;
+            use some::Foo;
 
-//- /foo.rs
-mod some;
-use some::Foo;
+            fn f() {
+                let i = Foo { n: 5 };
+            }
 
-fn f() {
-    let i = Foo { n: 5 };
-}
+            //- /foo/some.rs
+            pub(super) struct Foo<|> {
+                pub n: u32,
+            }
+        "#;
 
-//- /foo/some.rs
-pub(super) struct Foo<|> {
-    pub n: u32,
-}
-"#,
-        );
+        let (analysis, pos) = analysis_and_position(code);
         let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
         check_result(
             refs,
@@ -530,98 +525,93 @@ pub(super) struct Foo<|> {
 
     #[test]
     fn test_find_all_refs_macro_def() {
-        let refs = get_all_refs(
-            r#"
-#[macro_export]
-macro_rules! m1<|> { () => (()) }
-
-fn foo() {
-    m1();
-    m1();
-}
-"#,
-        );
+        let code = r#"
+        #[macro_export]
+        macro_rules! m1<|> { () => (()) }
+
+        fn foo() {
+            m1();
+            m1();
+        }"#;
+
+        let refs = get_all_refs(code);
         check_result(
             refs,
-            "m1 MACRO_CALL FileId(1) 0..46 29..31 Other",
-            &["FileId(1) 63..65 StructLiteral", "FileId(1) 73..75 StructLiteral"],
+            "m1 MACRO_CALL FileId(1) 9..63 46..48 Other",
+            &["FileId(1) 96..98 StructLiteral", "FileId(1) 114..116 StructLiteral"],
         );
     }
 
     #[test]
     fn test_basic_highlight_read_write() {
-        let refs = get_all_refs(
-            r#"
-fn foo() {
-    let mut i<|> = 0;
-    i = i + 1;
-}
-"#,
-        );
+        let code = r#"
+        fn foo() {
+            let mut i<|> = 0;
+            i = i + 1;
+        }"#;
+
+        let refs = get_all_refs(code);
         check_result(
             refs,
-            "i BIND_PAT FileId(1) 23..24 Other Write",
-            &["FileId(1) 34..35 Other Write", "FileId(1) 38..39 Other Read"],
+            "i BIND_PAT FileId(1) 40..41 Other Write",
+            &["FileId(1) 59..60 Other Write", "FileId(1) 63..64 Other Read"],
         );
     }
 
     #[test]
     fn test_basic_highlight_field_read_write() {
-        let refs = get_all_refs(
-            r#"
-struct S {
-    f: u32,
-}
+        let code = r#"
+        struct S {
+            f: u32,
+        }
 
-fn foo() {
-    let mut s = S{f: 0};
-    s.f<|> = 0;
-}
-"#,
-        );
+        fn foo() {
+            let mut s = S{f: 0};
+            s.f<|> = 0;
+        }"#;
+
+        let refs = get_all_refs(code);
         check_result(
             refs,
-            "f RECORD_FIELD_DEF FileId(1) 15..21 15..16 Other",
-            &["FileId(1) 55..56 Other Read", "FileId(1) 68..69 Other Write"],
+            "f RECORD_FIELD_DEF FileId(1) 32..38 32..33 Other",
+            &["FileId(1) 96..97 Other Read", "FileId(1) 117..118 Other Write"],
         );
     }
 
     #[test]
     fn test_basic_highlight_decl_no_write() {
-        let refs = get_all_refs(
-            r#"
-fn foo() {
-    let i<|>;
-    i = 1;
-}
-"#,
-        );
-        check_result(refs, "i BIND_PAT FileId(1) 19..20 Other", &["FileId(1) 26..27 Other Write"]);
+        let code = r#"
+        fn foo() {
+            let i<|>;
+            i = 1;
+        }"#;
+
+        let refs = get_all_refs(code);
+        check_result(refs, "i BIND_PAT FileId(1) 36..37 Other", &["FileId(1) 51..52 Other Write"]);
     }
 
     #[test]
     fn test_find_struct_function_refs_outside_module() {
-        let refs = get_all_refs(
-            r#"
-mod foo {
-    pub struct Foo;
+        let code = r#"
+        mod foo {
+            pub struct Foo;
 
-    impl Foo {
-        pub fn new<|>() -> Foo {
-            Foo
+            impl Foo {
+                pub fn new<|>() -> Foo {
+                    Foo
+                }
+            }
         }
-    }
-}
 
-fn main() {
-    let _f = foo::Foo::new();
-}
-"#,
-        );
+        fn main() {
+            let _f = foo::Foo::new();
+        }"#;
+
+        let refs = get_all_refs(code);
         check_result(
             refs,
-            "new FN_DEF FileId(1) 54..101 61..64 Other",
-            &["FileId(1) 146..149 StructLiteral"],
+            "new FN_DEF FileId(1) 87..150 94..97 Other",
+            &["FileId(1) 227..230 StructLiteral"],
         );
     }
 
@@ -652,8 +642,8 @@ fn main() {
         );
     }
 
-    fn get_all_refs(ra_fixture: &str) -> ReferenceSearchResult {
-        let (analysis, position) = analysis_and_position(ra_fixture);
+    fn get_all_refs(text: &str) -> ReferenceSearchResult {
+        let (analysis, position) = single_file_with_position(text);
         analysis.find_all_refs(position, None).unwrap().unwrap()
     }
 
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs
index 7ebc0adcf9..6edf565b53 100644
--- a/crates/ra_ide/src/references/rename.rs
+++ b/crates/ra_ide/src/references/rename.rs
@@ -271,10 +271,11 @@ fn rename_reference(
 mod tests {
     use insta::assert_debug_snapshot;
     use ra_text_edit::TextEditBuilder;
-    use stdx::trim_indent;
     use test_utils::{assert_eq_text, mark};
 
-    use crate::{mock_analysis::analysis_and_position, FileId};
+    use crate::{
+        mock_analysis::analysis_and_position, mock_analysis::single_file_with_position, FileId,
+    };
 
     #[test]
     fn test_rename_to_underscore() {
@@ -308,7 +309,7 @@ mod tests {
 
     #[test]
     fn test_rename_to_invalid_identifier() {
-        let (analysis, position) = analysis_and_position(
+        let (analysis, position) = single_file_with_position(
             "
     fn main() {
         let i<|> = 1;
@@ -1052,9 +1053,8 @@ pub mod foo<|>;
         );
     }
 
-    fn test_rename(ra_fixture_before: &str, new_name: &str, ra_fixture_after: &str) {
-        let ra_fixture_after = &trim_indent(ra_fixture_after);
-        let (analysis, position) = analysis_and_position(ra_fixture_before);
+    fn test_rename(text: &str, new_name: &str, expected: &str) {
+        let (analysis, position) = single_file_with_position(text);
         let source_change = analysis.rename(position, new_name).unwrap();
         let mut text_edit_builder = TextEditBuilder::default();
         let mut file_id: Option<FileId> = None;
@@ -1068,6 +1068,6 @@ pub mod foo<|>;
         }
         let mut result = analysis.file_text(file_id.unwrap()).unwrap().to_string();
         text_edit_builder.finish().apply(&mut result);
-        assert_eq_text!(ra_fixture_after, &*result);
+        assert_eq_text!(expected, &*result);
     }
 }
diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs
index 2faaa8ff07..a40d8af9c4 100644
--- a/crates/ra_ide/src/typing/on_enter.rs
+++ b/crates/ra_ide/src/typing/on_enter.rs
@@ -75,22 +75,23 @@ fn node_indent(file: &SourceFile, token: &SyntaxToken) -> Option<SmolStr> {
 
 #[cfg(test)]
 mod tests {
-    use test_utils::assert_eq_text;
+    use test_utils::{assert_eq_text, extract_offset};
 
-    use crate::mock_analysis::analysis_and_position;
-    use stdx::trim_indent;
+    use crate::mock_analysis::single_file;
+
+    use super::*;
 
     fn apply_on_enter(before: &str) -> Option<String> {
-        let (analysis, position) = analysis_and_position(&before);
-        let result = analysis.on_enter(position).unwrap()?;
+        let (offset, before) = extract_offset(before);
+        let (analysis, file_id) = single_file(&before);
+        let result = analysis.on_enter(FilePosition { offset, file_id }).unwrap()?;
 
-        let mut actual = analysis.file_text(position.file_id).unwrap().to_string();
+        let mut actual = before.to_string();
         result.apply(&mut actual);
         Some(actual)
     }
 
     fn do_check(ra_fixture_before: &str, ra_fixture_after: &str) {
-        let ra_fixture_after = &trim_indent(ra_fixture_after);
         let actual = apply_on_enter(ra_fixture_before).unwrap();
         assert_eq_text!(ra_fixture_after, &actual);
     }


Test patch:
diff --git a/crates/ra_ide/src/completion/test_utils.rs b/crates/ra_ide/src/completion/test_utils.rs
index a1b7c11934..1e16a43cab 100644
--- a/crates/ra_ide/src/completion/test_utils.rs
+++ b/crates/ra_ide/src/completion/test_utils.rs
@@ -2,7 +2,7 @@
 
 use crate::{
     completion::{completion_item::CompletionKind, CompletionConfig},
-    mock_analysis::analysis_and_position,
+    mock_analysis::{analysis_and_position, single_file_with_position},
     CompletionItem,
 };
 use hir::Semantics;
@@ -33,7 +33,7 @@ fn get_all_completion_items(code: &str, options: &CompletionConfig) -> Vec<Compl
     let (analysis, position) = if code.contains("//-") {
         analysis_and_position(code)
     } else {
-        analysis_and_position(code)
+        single_file_with_position(code)
     };
     analysis.completions(options, position).unwrap().unwrap().into()
 }
@@ -55,7 +55,7 @@ pub(crate) fn completion_list_with_options(
 }
 
 pub(crate) fn check_pattern_is_applicable(code: &str, check: fn(SyntaxElement) -> bool) {
-    let (analysis, pos) = analysis_and_position(code);
+    let (analysis, pos) = single_file_with_position(code);
     analysis
         .with_db(|db| {
             let sema = Semantics::new(db);
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs
index b7fad97197..b1f48f03bc 100644
--- a/crates/ra_ide/src/syntax_highlighting/tests.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tests.rs
@@ -2,7 +2,10 @@ use std::fs;
 
 use test_utils::{assert_eq_text, project_dir, read_text};
 
-use crate::{mock_analysis::single_file, FileRange, TextRange};
+use crate::{
+    mock_analysis::{single_file, MockAnalysis},
+    FileRange, TextRange,
+};
 
 #[test]
 fn test_highlighting() {
@@ -124,10 +127,12 @@ fn accidentally_quadratic() {
     let file = project_dir().join("crates/ra_syntax/test_data/accidentally_quadratic");
     let src = fs::read_to_string(file).unwrap();
 
-    let (analysis, file_id) = single_file(&src);
+    let mut mock = MockAnalysis::new();
+    let file_id = mock.add_file("/main.rs", &src);
+    let host = mock.analysis_host();
 
     // let t = std::time::Instant::now();
-    let _ = analysis.highlight(file_id).unwrap();
+    let _ = host.analysis().highlight(file_id).unwrap();
     // eprintln!("elapsed: {:?}", t.elapsed());
 }
 
@@ -135,17 +140,16 @@ fn accidentally_quadratic() {
 fn test_ranges() {
     let (analysis, file_id) = single_file(
         r#"
-#[derive(Clone, Debug)]
-struct Foo {
-    pub x: i32,
-    pub y: i32,
-}
-"#,
+            #[derive(Clone, Debug)]
+            struct Foo {
+                pub x: i32,
+                pub y: i32,
+            }"#,
     );
 
     // The "x"
     let highlights = &analysis
-        .highlight_range(FileRange { file_id, range: TextRange::at(45.into(), 1.into()) })
+        .highlight_range(FileRange { file_id, range: TextRange::at(82.into(), 1.into()) })
         .unwrap();
 
     assert_eq!(&highlights[0].highlight.to_string(), "field.declaration");
diff --git a/crates/rust-analyzer/tests/heavy_tests/support.rs b/crates/rust-analyzer/tests/heavy_tests/support.rs
index 001a2a1045..8d88f992dd 100644
--- a/crates/rust-analyzer/tests/heavy_tests/support.rs
+++ b/crates/rust-analyzer/tests/heavy_tests/support.rs
@@ -19,7 +19,7 @@ use test_utils::{find_mismatch, Fixture};
 
 use ra_project_model::ProjectManifest;
 use rust_analyzer::{
-    config::{ClientCapsConfig, Config, LinkedProject},
+    config::{ClientCapsConfig, Config, FilesConfig, FilesWatcher, LinkedProject},
     main_loop,
 };
 
@@ -90,9 +90,9 @@ impl<'a> Project<'a> {
             },
             with_sysroot: self.with_sysroot,
             linked_projects,
+            files: FilesConfig { watcher: FilesWatcher::Client, exclude: Vec::new() },
             ..Config::default()
         };
-
         if let Some(f) = &self.config {
             f(&mut config)
         }
@@ -173,8 +173,14 @@ impl Server {
         self.client.sender.send(r.into()).unwrap();
         while let Some(msg) = self.recv() {
             match msg {
-                Message::Request(req) if req.method == "window/workDoneProgress/create" => (),
-                Message::Request(req) => panic!("unexpected request: {:?}", req),
+                Message::Request(req) => {
+                    if req.method != "window/workDoneProgress/create"
+                        && !(req.method == "client/registerCapability"
+                            && req.params.to_string().contains("workspace/didChangeWatchedFiles"))
+                    {
+                        panic!("unexpected request: {:?}", req)
+                    }
+                }
                 Message::Notification(_) => (),
                 Message::Response(res) => {
                     assert_eq!(res.id, id);
diff --git a/crates/test_utils/src/fixture.rs b/crates/test_utils/src/fixture.rs
index fad8f7e2cc..7e93fbcd64 100644
--- a/crates/test_utils/src/fixture.rs
+++ b/crates/test_utils/src/fixture.rs
@@ -8,7 +8,7 @@ use stdx::{lines_with_ends, split_delim, trim_indent};
 pub struct Fixture {
     pub path: String,
     pub text: String,
-    pub krate: Option<String>,
+    pub crate_name: Option<String>,
     pub deps: Vec<String>,
     pub cfg_atoms: Vec<String>,
     pub cfg_key_values: Vec<(String, String)>,
@@ -56,7 +56,7 @@ impl Fixture {
     }
 
     //- /lib.rs crate:foo deps:bar,baz cfg:foo=a,bar=b env:OUTDIR=path/to,OTHER=foo
-    fn parse_meta_line(meta: &str) -> Fixture {
+    pub fn parse_meta_line(meta: &str) -> Fixture {
         assert!(meta.starts_with("//-"));
         let meta = meta["//-".len()..].trim();
         let components = meta.split_ascii_whitespace().collect::<Vec<_>>();
@@ -98,7 +98,7 @@ impl Fixture {
         Fixture {
             path,
             text: String::new(),
-            krate: krate,
+            crate_name: krate,
             deps,
             cfg_atoms,
             cfg_key_values,
@@ -136,7 +136,7 @@ fn parse_fixture_gets_full_meta() {
     let meta = &parsed[0];
     assert_eq!("mod m;\n", meta.text);
 
-    assert_eq!("foo", meta.krate.as_ref().unwrap());
+    assert_eq!("foo", meta.crate_name.as_ref().unwrap());
     assert_eq!("/lib.rs", meta.path);
     assert_eq!(2, meta.env.len());
 }