aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/syntax_highlighting/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting/tests.rs')
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tests.rs24
1 files changed, 10 insertions, 14 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs
index b1f48f03b..b7fad9719 100644
--- a/crates/ra_ide/src/syntax_highlighting/tests.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tests.rs
@@ -2,10 +2,7 @@ use std::fs;
2 2
3use test_utils::{assert_eq_text, project_dir, read_text}; 3use test_utils::{assert_eq_text, project_dir, read_text};
4 4
5use crate::{ 5use crate::{mock_analysis::single_file, FileRange, TextRange};
6 mock_analysis::{single_file, MockAnalysis},
7 FileRange, TextRange,
8};
9 6
10#[test] 7#[test]
11fn test_highlighting() { 8fn test_highlighting() {
@@ -127,12 +124,10 @@ fn accidentally_quadratic() {
127 let file = project_dir().join("crates/ra_syntax/test_data/accidentally_quadratic"); 124 let file = project_dir().join("crates/ra_syntax/test_data/accidentally_quadratic");
128 let src = fs::read_to_string(file).unwrap(); 125 let src = fs::read_to_string(file).unwrap();
129 126
130 let mut mock = MockAnalysis::new(); 127 let (analysis, file_id) = single_file(&src);
131 let file_id = mock.add_file("/main.rs", &src);
132 let host = mock.analysis_host();
133 128
134 // let t = std::time::Instant::now(); 129 // let t = std::time::Instant::now();
135 let _ = host.analysis().highlight(file_id).unwrap(); 130 let _ = analysis.highlight(file_id).unwrap();
136 // eprintln!("elapsed: {:?}", t.elapsed()); 131 // eprintln!("elapsed: {:?}", t.elapsed());
137} 132}
138 133
@@ -140,16 +135,17 @@ fn accidentally_quadratic() {
140fn test_ranges() { 135fn test_ranges() {
141 let (analysis, file_id) = single_file( 136 let (analysis, file_id) = single_file(
142 r#" 137 r#"
143 #[derive(Clone, Debug)] 138#[derive(Clone, Debug)]
144 struct Foo { 139struct Foo {
145 pub x: i32, 140 pub x: i32,
146 pub y: i32, 141 pub y: i32,
147 }"#, 142}
143"#,
148 ); 144 );
149 145
150 // The "x" 146 // The "x"
151 let highlights = &analysis 147 let highlights = &analysis
152 .highlight_range(FileRange { file_id, range: TextRange::at(82.into(), 1.into()) }) 148 .highlight_range(FileRange { file_id, range: TextRange::at(45.into(), 1.into()) })
153 .unwrap(); 149 .unwrap();
154 150
155 assert_eq!(&highlights[0].highlight.to_string(), "field.declaration"); 151 assert_eq!(&highlights[0].highlight.to_string(), "field.declaration");