aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r--crates/ra_analysis/src/extend_selection.rs11
-rw-r--r--crates/ra_analysis/src/lib.rs8
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 @@
1use ra_db::SyntaxDatabase;
2
3use crate::{
4 TextRange, FileRange,
5 db::RootDatabase,
6};
7
8pub(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;
14mod imp; 14mod imp;
15mod completion; 15mod completion;
16mod symbol_index; 16mod symbol_index;
17mod syntax_highlighting;
18pub mod mock_analysis; 17pub mod mock_analysis;
19 18
19mod extend_selection;
20mod syntax_highlighting;
21
20use std::{fmt, sync::Arc}; 22use std::{fmt, sync::Arc};
21 23
22use rustc_hash::FxHashMap; 24use 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)