diff options
Diffstat (limited to 'crates/libeditor')
-rw-r--r-- | crates/libeditor/src/code_actions.rs | 8 | ||||
-rw-r--r-- | crates/libeditor/src/extend_selection.rs | 4 | ||||
-rw-r--r-- | crates/libeditor/src/lib.rs | 16 | ||||
-rw-r--r-- | crates/libeditor/src/symbols.rs | 6 | ||||
-rw-r--r-- | crates/libeditor/src/typing.rs | 4 | ||||
-rw-r--r-- | crates/libeditor/tests/test.rs | 8 |
6 files changed, 23 insertions, 23 deletions
diff --git a/crates/libeditor/src/code_actions.rs b/crates/libeditor/src/code_actions.rs index c7c043b39..b3305be2a 100644 --- a/crates/libeditor/src/code_actions.rs +++ b/crates/libeditor/src/code_actions.rs | |||
@@ -3,7 +3,7 @@ use std::{ | |||
3 | }; | 3 | }; |
4 | 4 | ||
5 | use libsyntax2::{ | 5 | use libsyntax2::{ |
6 | ParsedFile, | 6 | File, |
7 | ast::{self, AstNode, AttrsOwner, TypeParamsOwner, NameOwner}, | 7 | ast::{self, AstNode, AttrsOwner, TypeParamsOwner, NameOwner}, |
8 | SyntaxKind::COMMA, | 8 | SyntaxKind::COMMA, |
9 | SyntaxNodeRef, | 9 | SyntaxNodeRef, |
@@ -21,7 +21,7 @@ pub struct ActionResult { | |||
21 | pub cursor_position: Option<TextUnit>, | 21 | pub cursor_position: Option<TextUnit>, |
22 | } | 22 | } |
23 | 23 | ||
24 | pub fn flip_comma<'a>(file: &'a ParsedFile, offset: TextUnit) -> Option<impl FnOnce() -> ActionResult + 'a> { | 24 | pub fn flip_comma<'a>(file: &'a File, offset: TextUnit) -> Option<impl FnOnce() -> ActionResult + 'a> { |
25 | let syntax = file.syntax(); | 25 | let syntax = file.syntax(); |
26 | 26 | ||
27 | let comma = find_leaf_at_offset(syntax, offset).find(|leaf| leaf.kind() == COMMA)?; | 27 | let comma = find_leaf_at_offset(syntax, offset).find(|leaf| leaf.kind() == COMMA)?; |
@@ -38,7 +38,7 @@ pub fn flip_comma<'a>(file: &'a ParsedFile, offset: TextUnit) -> Option<impl FnO | |||
38 | }) | 38 | }) |
39 | } | 39 | } |
40 | 40 | ||
41 | pub fn add_derive<'a>(file: &'a ParsedFile, offset: TextUnit) -> Option<impl FnOnce() -> ActionResult + 'a> { | 41 | pub fn add_derive<'a>(file: &'a File, offset: TextUnit) -> Option<impl FnOnce() -> ActionResult + 'a> { |
42 | let nominal = find_node::<ast::NominalDef>(file.syntax(), offset)?; | 42 | let nominal = find_node::<ast::NominalDef>(file.syntax(), offset)?; |
43 | Some(move || { | 43 | Some(move || { |
44 | let derive_attr = nominal | 44 | let derive_attr = nominal |
@@ -65,7 +65,7 @@ pub fn add_derive<'a>(file: &'a ParsedFile, offset: TextUnit) -> Option<impl FnO | |||
65 | }) | 65 | }) |
66 | } | 66 | } |
67 | 67 | ||
68 | pub fn add_impl<'a>(file: &'a ParsedFile, offset: TextUnit) -> Option<impl FnOnce() -> ActionResult + 'a> { | 68 | pub fn add_impl<'a>(file: &'a File, offset: TextUnit) -> Option<impl FnOnce() -> ActionResult + 'a> { |
69 | let nominal = find_node::<ast::NominalDef>(file.syntax(), offset)?; | 69 | let nominal = find_node::<ast::NominalDef>(file.syntax(), offset)?; |
70 | let name = nominal.name()?; | 70 | let name = nominal.name()?; |
71 | 71 | ||
diff --git a/crates/libeditor/src/extend_selection.rs b/crates/libeditor/src/extend_selection.rs index 32873f491..d1724b528 100644 --- a/crates/libeditor/src/extend_selection.rs +++ b/crates/libeditor/src/extend_selection.rs | |||
@@ -1,10 +1,10 @@ | |||
1 | use libsyntax2::{ | 1 | use libsyntax2::{ |
2 | ParsedFile, TextRange, SyntaxNodeRef, | 2 | File, TextRange, SyntaxNodeRef, |
3 | SyntaxKind::WHITESPACE, | 3 | SyntaxKind::WHITESPACE, |
4 | algo::{find_leaf_at_offset, find_covering_node, ancestors}, | 4 | algo::{find_leaf_at_offset, find_covering_node, ancestors}, |
5 | }; | 5 | }; |
6 | 6 | ||
7 | pub fn extend_selection(file: &ParsedFile, range: TextRange) -> Option<TextRange> { | 7 | pub fn extend_selection(file: &File, range: TextRange) -> Option<TextRange> { |
8 | let syntax = file.syntax(); | 8 | let syntax = file.syntax(); |
9 | extend(syntax.borrowed(), range) | 9 | extend(syntax.borrowed(), range) |
10 | } | 10 | } |
diff --git a/crates/libeditor/src/lib.rs b/crates/libeditor/src/lib.rs index 681cca81d..a6e6deba7 100644 --- a/crates/libeditor/src/lib.rs +++ b/crates/libeditor/src/lib.rs | |||
@@ -14,7 +14,7 @@ use libsyntax2::{ | |||
14 | algo::{walk, find_leaf_at_offset}, | 14 | algo::{walk, find_leaf_at_offset}, |
15 | SyntaxKind::{self, *}, | 15 | SyntaxKind::{self, *}, |
16 | }; | 16 | }; |
17 | pub use libsyntax2::{ParsedFile, TextRange, TextUnit}; | 17 | pub use libsyntax2::{File, TextRange, TextUnit}; |
18 | pub use self::{ | 18 | pub use self::{ |
19 | line_index::{LineIndex, LineCol}, | 19 | line_index::{LineIndex, LineCol}, |
20 | extend_selection::extend_selection, | 20 | extend_selection::extend_selection, |
@@ -51,11 +51,11 @@ pub enum RunnableKind { | |||
51 | Bin, | 51 | Bin, |
52 | } | 52 | } |
53 | 53 | ||
54 | pub fn parse(text: &str) -> ParsedFile { | 54 | pub fn parse(text: &str) -> File { |
55 | ParsedFile::parse(text) | 55 | File::parse(text) |
56 | } | 56 | } |
57 | 57 | ||
58 | pub fn matching_brace(file: &ParsedFile, offset: TextUnit) -> Option<TextUnit> { | 58 | pub fn matching_brace(file: &File, offset: TextUnit) -> Option<TextUnit> { |
59 | const BRACES: &[SyntaxKind] = &[ | 59 | const BRACES: &[SyntaxKind] = &[ |
60 | L_CURLY, R_CURLY, | 60 | L_CURLY, R_CURLY, |
61 | L_BRACK, R_BRACK, | 61 | L_BRACK, R_BRACK, |
@@ -75,7 +75,7 @@ pub fn matching_brace(file: &ParsedFile, offset: TextUnit) -> Option<TextUnit> { | |||
75 | Some(matching_node.range().start()) | 75 | Some(matching_node.range().start()) |
76 | } | 76 | } |
77 | 77 | ||
78 | pub fn highlight(file: &ParsedFile) -> Vec<HighlightedRange> { | 78 | pub fn highlight(file: &File) -> Vec<HighlightedRange> { |
79 | let mut res = Vec::new(); | 79 | let mut res = Vec::new(); |
80 | for node in walk::preorder(file.syntax()) { | 80 | for node in walk::preorder(file.syntax()) { |
81 | let tag = match node.kind() { | 81 | let tag = match node.kind() { |
@@ -98,7 +98,7 @@ pub fn highlight(file: &ParsedFile) -> Vec<HighlightedRange> { | |||
98 | res | 98 | res |
99 | } | 99 | } |
100 | 100 | ||
101 | pub fn diagnostics(file: &ParsedFile) -> Vec<Diagnostic> { | 101 | pub fn diagnostics(file: &File) -> Vec<Diagnostic> { |
102 | let mut res = Vec::new(); | 102 | let mut res = Vec::new(); |
103 | 103 | ||
104 | for node in walk::preorder(file.syntax()) { | 104 | for node in walk::preorder(file.syntax()) { |
@@ -116,11 +116,11 @@ pub fn diagnostics(file: &ParsedFile) -> Vec<Diagnostic> { | |||
116 | res | 116 | res |
117 | } | 117 | } |
118 | 118 | ||
119 | pub fn syntax_tree(file: &ParsedFile) -> String { | 119 | pub fn syntax_tree(file: &File) -> String { |
120 | ::libsyntax2::utils::dump_tree(file.syntax()) | 120 | ::libsyntax2::utils::dump_tree(file.syntax()) |
121 | } | 121 | } |
122 | 122 | ||
123 | pub fn runnables(file: &ParsedFile) -> Vec<Runnable> { | 123 | pub fn runnables(file: &File) -> Vec<Runnable> { |
124 | file.ast() | 124 | file.ast() |
125 | .functions() | 125 | .functions() |
126 | .filter_map(|f| { | 126 | .filter_map(|f| { |
diff --git a/crates/libeditor/src/symbols.rs b/crates/libeditor/src/symbols.rs index 37cef6389..98a35dcdf 100644 --- a/crates/libeditor/src/symbols.rs +++ b/crates/libeditor/src/symbols.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use libsyntax2::{ | 1 | use libsyntax2::{ |
2 | SyntaxKind, SyntaxNodeRef, AstNode, ParsedFile, SmolStr, | 2 | SyntaxKind, SyntaxNodeRef, AstNode, File, SmolStr, |
3 | ast::{self, NameOwner}, | 3 | ast::{self, NameOwner}, |
4 | algo::{ | 4 | algo::{ |
5 | visit::{visitor, Visitor}, | 5 | visit::{visitor, Visitor}, |
@@ -24,7 +24,7 @@ pub struct FileSymbol { | |||
24 | pub kind: SyntaxKind, | 24 | pub kind: SyntaxKind, |
25 | } | 25 | } |
26 | 26 | ||
27 | pub fn file_symbols(file: &ParsedFile) -> Vec<FileSymbol> { | 27 | pub fn file_symbols(file: &File) -> Vec<FileSymbol> { |
28 | preorder(file.syntax()) | 28 | preorder(file.syntax()) |
29 | .filter_map(to_symbol) | 29 | .filter_map(to_symbol) |
30 | .collect() | 30 | .collect() |
@@ -52,7 +52,7 @@ fn to_symbol(node: SyntaxNodeRef) -> Option<FileSymbol> { | |||
52 | } | 52 | } |
53 | 53 | ||
54 | 54 | ||
55 | pub fn file_structure(file: &ParsedFile) -> Vec<StructureNode> { | 55 | pub fn file_structure(file: &File) -> Vec<StructureNode> { |
56 | let mut res = Vec::new(); | 56 | let mut res = Vec::new(); |
57 | let mut stack = Vec::new(); | 57 | let mut stack = Vec::new(); |
58 | 58 | ||
diff --git a/crates/libeditor/src/typing.rs b/crates/libeditor/src/typing.rs index ebc7c77d2..e7eba671f 100644 --- a/crates/libeditor/src/typing.rs +++ b/crates/libeditor/src/typing.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use libsyntax2::{ | 1 | use libsyntax2::{ |
2 | TextUnit, TextRange, SyntaxNodeRef, ParsedFile, | 2 | TextUnit, TextRange, SyntaxNodeRef, File, |
3 | algo::{ | 3 | algo::{ |
4 | walk::preorder, | 4 | walk::preorder, |
5 | find_covering_node, | 5 | find_covering_node, |
@@ -10,7 +10,7 @@ use libsyntax2::{ | |||
10 | 10 | ||
11 | use {ActionResult, EditBuilder}; | 11 | use {ActionResult, EditBuilder}; |
12 | 12 | ||
13 | pub fn join_lines(file: &ParsedFile, range: TextRange) -> ActionResult { | 13 | pub fn join_lines(file: &File, range: TextRange) -> ActionResult { |
14 | let range = if range.is_empty() { | 14 | let range = if range.is_empty() { |
15 | let text = file.syntax().text(); | 15 | let text = file.syntax().text(); |
16 | let text = &text[TextRange::from_to(range.start(), TextUnit::of_str(&text))]; | 16 | let text = &text[TextRange::from_to(range.start(), TextUnit::of_str(&text))]; |
diff --git a/crates/libeditor/tests/test.rs b/crates/libeditor/tests/test.rs index 4f7c2e07a..3114a128e 100644 --- a/crates/libeditor/tests/test.rs +++ b/crates/libeditor/tests/test.rs | |||
@@ -5,7 +5,7 @@ extern crate assert_eq_text; | |||
5 | 5 | ||
6 | use assert_eq_text::{assert_eq_dbg}; | 6 | use assert_eq_text::{assert_eq_dbg}; |
7 | use libeditor::{ | 7 | use libeditor::{ |
8 | ParsedFile, TextUnit, TextRange, ActionResult, | 8 | File, TextUnit, TextRange, ActionResult, |
9 | highlight, runnables, extend_selection, file_structure, | 9 | highlight, runnables, extend_selection, file_structure, |
10 | flip_comma, add_derive, add_impl, matching_brace, | 10 | flip_comma, add_derive, add_impl, matching_brace, |
11 | join_lines, | 11 | join_lines, |
@@ -234,11 +234,11 @@ struct Foo { f: u32 } | |||
234 | "); | 234 | "); |
235 | } | 235 | } |
236 | 236 | ||
237 | fn file(text: &str) -> ParsedFile { | 237 | fn file(text: &str) -> File { |
238 | ParsedFile::parse(text) | 238 | File::parse(text) |
239 | } | 239 | } |
240 | 240 | ||
241 | fn check_action<F: Fn(&ParsedFile, TextUnit) -> Option<ActionResult>>( | 241 | fn check_action<F: Fn(&File, TextUnit) -> Option<ActionResult>>( |
242 | before: &str, | 242 | before: &str, |
243 | after: &str, | 243 | after: &str, |
244 | f: F, | 244 | f: F, |