aboutsummaryrefslogtreecommitdiff
path: root/libeditor
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-10 15:49:45 +0100
committerAleksey Kladov <[email protected]>2018-08-10 15:49:45 +0100
commit2e165ae82eed1dc62f1f4c68e45440c143c7c8ef (patch)
tree4148d68878bbd05a0c7b7f4ace803083f23293fd /libeditor
parentd7c5a6f3081c2e7266620779d3c32067f947b959 (diff)
logging
Diffstat (limited to 'libeditor')
-rw-r--r--libeditor/src/lib.rs3
-rw-r--r--libeditor/tests/test.rs14
2 files changed, 8 insertions, 9 deletions
diff --git a/libeditor/src/lib.rs b/libeditor/src/lib.rs
index 817a2d15b..4e9631a8b 100644
--- a/libeditor/src/lib.rs
+++ b/libeditor/src/lib.rs
@@ -6,9 +6,8 @@ use libsyntax2::{
6 SyntaxNodeRef, AstNode, 6 SyntaxNodeRef, AstNode,
7 algo::walk, 7 algo::walk,
8 SyntaxKind::*, 8 SyntaxKind::*,
9 ast,
10}; 9};
11pub use libsyntax2::{TextRange, TextUnit}; 10pub use libsyntax2::{TextRange, TextUnit, ast};
12 11
13#[derive(Debug)] 12#[derive(Debug)]
14pub struct HighlightedRange { 13pub struct HighlightedRange {
diff --git a/libeditor/tests/test.rs b/libeditor/tests/test.rs
index ab8254d16..2a84c5080 100644
--- a/libeditor/tests/test.rs
+++ b/libeditor/tests/test.rs
@@ -3,7 +3,7 @@ extern crate itertools;
3 3
4use std::fmt; 4use std::fmt;
5use itertools::Itertools; 5use itertools::Itertools;
6use libeditor::{File, TextRange}; 6use libeditor::{ast, highlight, runnables, extend_selection, TextRange};
7 7
8#[test] 8#[test]
9fn test_extend_selection() { 9fn test_extend_selection() {
@@ -12,9 +12,9 @@ fn test_extend_selection() {
12} 12}
13"#); 13"#);
14 let range = TextRange::offset_len(18.into(), 0.into()); 14 let range = TextRange::offset_len(18.into(), 0.into());
15 let range = file.extend_selection(range).unwrap(); 15 let range = extend_selection(&file, range).unwrap();
16 assert_eq!(range, TextRange::from_to(17.into(), 18.into())); 16 assert_eq!(range, TextRange::from_to(17.into(), 18.into()));
17 let range = file.extend_selection(range).unwrap(); 17 let range = extend_selection(&file, range).unwrap();
18 assert_eq!(range, TextRange::from_to(15.into(), 20.into())); 18 assert_eq!(range, TextRange::from_to(15.into(), 20.into()));
19} 19}
20 20
@@ -25,7 +25,7 @@ fn test_highlighting() {
25fn main() {} 25fn main() {}
26 println!("Hello, {}!", 92); 26 println!("Hello, {}!", 92);
27"#); 27"#);
28 let hls = file.highlight(); 28 let hls = highlight(&file);
29 dbg_eq( 29 dbg_eq(
30 &hls, 30 &hls,
31 r#"[HighlightedRange { range: [1; 11), tag: "comment" }, 31 r#"[HighlightedRange { range: [1; 11), tag: "comment" },
@@ -49,7 +49,7 @@ fn test_foo() {}
49#[ignore] 49#[ignore]
50fn test_foo() {} 50fn test_foo() {}
51"#); 51"#);
52 let runnables = file.runnables(); 52 let runnables = runnables(&file);
53 dbg_eq( 53 dbg_eq(
54 &runnables, 54 &runnables,
55 r#"[Runnable { range: [1; 13), kind: Bin }, 55 r#"[Runnable { range: [1; 13), kind: Bin },
@@ -58,8 +58,8 @@ fn test_foo() {}
58 ) 58 )
59} 59}
60 60
61fn file(text: &str) -> File { 61fn file(text: &str) -> ast::File {
62 File::new(text) 62 ast::File::parse(text)
63} 63}
64 64
65fn dbg_eq(actual: &impl fmt::Debug, expected: &str) { 65fn dbg_eq(actual: &impl fmt::Debug, expected: &str) {