diff options
author | Aleksey Kladov <[email protected]> | 2018-12-28 15:15:19 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-12-28 15:17:43 +0000 |
commit | fd33c89207f6dc621ef6e8c26ea288089448d811 (patch) | |
tree | 7933988832041d364a0bab6a82061d5e33cc65e6 /crates/ra_analysis | |
parent | 02924174bb084d73cab67af6665ddf00e91983f6 (diff) |
switch to FileRange
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r-- | crates/ra_analysis/src/extend_selection.rs | 11 | ||||
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 8 |
2 files changed, 16 insertions, 3 deletions
diff --git a/crates/ra_analysis/src/extend_selection.rs b/crates/ra_analysis/src/extend_selection.rs new file mode 100644 index 000000000..5e1fbee18 --- /dev/null +++ b/crates/ra_analysis/src/extend_selection.rs | |||
@@ -0,0 +1,11 @@ | |||
1 | use ra_db::SyntaxDatabase; | ||
2 | |||
3 | use crate::{ | ||
4 | TextRange, FileRange, | ||
5 | db::RootDatabase, | ||
6 | }; | ||
7 | |||
8 | pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange { | ||
9 | let file = db.source_file(frange.file_id); | ||
10 | ra_editor::extend_selection(&file, frange.range).unwrap_or(frange.range) | ||
11 | } | ||
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 3fa4189ce..98abe8523 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -14,9 +14,11 @@ mod db; | |||
14 | mod imp; | 14 | mod imp; |
15 | mod completion; | 15 | mod completion; |
16 | mod symbol_index; | 16 | mod symbol_index; |
17 | mod syntax_highlighting; | ||
18 | pub mod mock_analysis; | 17 | pub mod mock_analysis; |
19 | 18 | ||
19 | mod extend_selection; | ||
20 | mod syntax_highlighting; | ||
21 | |||
20 | use std::{fmt, sync::Arc}; | 22 | use std::{fmt, sync::Arc}; |
21 | 23 | ||
22 | use rustc_hash::FxHashMap; | 24 | use rustc_hash::FxHashMap; |
@@ -277,8 +279,8 @@ impl Analysis { | |||
277 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { | 279 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { |
278 | self.imp.file_line_index(file_id) | 280 | self.imp.file_line_index(file_id) |
279 | } | 281 | } |
280 | pub fn extend_selection(&self, file: &SourceFileNode, range: TextRange) -> TextRange { | 282 | pub fn extend_selection(&self, frange: FileRange) -> TextRange { |
281 | ra_editor::extend_selection(file, range).unwrap_or(range) | 283 | extend_selection::extend_selection(&self.imp.db, frange) |
282 | } | 284 | } |
283 | pub fn matching_brace(&self, file: &SourceFileNode, offset: TextUnit) -> Option<TextUnit> { | 285 | pub fn matching_brace(&self, file: &SourceFileNode, offset: TextUnit) -> Option<TextUnit> { |
284 | ra_editor::matching_brace(file, offset) | 286 | ra_editor::matching_brace(file, offset) |