aboutsummaryrefslogtreecommitdiff
path: root/crates/libanalysis/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-30 14:27:09 +0100
committerAleksey Kladov <[email protected]>2018-08-30 14:27:09 +0100
commit9fcebbc51284408203c05219a0ee92519f51ea74 (patch)
tree5fd3f53769e3fe5b8f6a0d2a5eaa86167b7a3b10 /crates/libanalysis/src
parent7570d85869da7e2d35958047f8d1a90e3b6e2212 (diff)
subscriptions
Diffstat (limited to 'crates/libanalysis/src')
-rw-r--r--crates/libanalysis/src/imp.rs20
-rw-r--r--crates/libanalysis/src/lib.rs8
2 files changed, 14 insertions, 14 deletions
diff --git a/crates/libanalysis/src/imp.rs b/crates/libanalysis/src/imp.rs
index 004942e72..97802bd50 100644
--- a/crates/libanalysis/src/imp.rs
+++ b/crates/libanalysis/src/imp.rs
@@ -39,11 +39,11 @@ impl AnalysisHostImpl {
39 39
40 pub fn analysis( 40 pub fn analysis(
41 &self, 41 &self,
42 file_resolver: impl FileResolver, 42 file_resolver: Arc<dyn FileResolver>,
43 ) -> AnalysisImpl { 43 ) -> AnalysisImpl {
44 AnalysisImpl { 44 AnalysisImpl {
45 needs_reindex: AtomicBool::new(false), 45 needs_reindex: AtomicBool::new(false),
46 file_resolver: Arc::new(file_resolver), 46 file_resolver,
47 data: self.data.clone(), 47 data: self.data.clone(),
48 } 48 }
49 } 49 }
@@ -78,7 +78,7 @@ impl AnalysisHostImpl {
78 78
79pub(crate) struct AnalysisImpl { 79pub(crate) struct AnalysisImpl {
80 needs_reindex: AtomicBool, 80 needs_reindex: AtomicBool,
81 file_resolver: Arc<FileResolver>, 81 file_resolver: Arc<dyn FileResolver>,
82 data: Arc<WorldData>, 82 data: Arc<WorldData>,
83} 83}
84 84
@@ -236,15 +236,13 @@ impl AnalysisImpl {
236 ("add `#[derive]`", libeditor::add_derive(&file, offset).map(|f| f())), 236 ("add `#[derive]`", libeditor::add_derive(&file, offset).map(|f| f())),
237 ("add impl", libeditor::add_impl(&file, offset).map(|f| f())), 237 ("add impl", libeditor::add_impl(&file, offset).map(|f| f())),
238 ]; 238 ];
239 let mut res = Vec::new(); 239 actions.into_iter()
240 for (name, local_edit) in actions { 240 .filter_map(|(name, local_edit)| {
241 if let Some(local_edit) = local_edit { 241 Some(SourceChange::from_local_edit(
242 res.push(SourceChange::from_local_edit( 242 file_id, name, local_edit?,
243 file_id, name, local_edit
244 )) 243 ))
245 } 244 })
246 } 245 .collect()
247 res
248 } 246 }
249 247
250 fn index_resolve(&self, name_ref: ast::NameRef) -> Vec<(FileId, FileSymbol)> { 248 fn index_resolve(&self, name_ref: ast::NameRef) -> Vec<(FileId, FileSymbol)> {
diff --git a/crates/libanalysis/src/lib.rs b/crates/libanalysis/src/lib.rs
index 810228632..c25d31f4b 100644
--- a/crates/libanalysis/src/lib.rs
+++ b/crates/libanalysis/src/lib.rs
@@ -12,6 +12,8 @@ mod symbol_index;
12mod module_map; 12mod module_map;
13mod imp; 13mod imp;
14 14
15use std::sync::Arc;
16
15use relative_path::{RelativePath, RelativePathBuf}; 17use relative_path::{RelativePath, RelativePathBuf};
16use libsyntax2::{File, TextRange, TextUnit, AtomEdit}; 18use libsyntax2::{File, TextRange, TextUnit, AtomEdit};
17use imp::{AnalysisImpl, AnalysisHostImpl}; 19use imp::{AnalysisImpl, AnalysisHostImpl};
@@ -31,7 +33,7 @@ pub trait FileResolver: Send + Sync + 'static {
31 33
32#[derive(Debug)] 34#[derive(Debug)]
33pub struct AnalysisHost { 35pub struct AnalysisHost {
34 pub(crate) imp: AnalysisHostImpl 36 imp: AnalysisHostImpl
35} 37}
36 38
37impl AnalysisHost { 39impl AnalysisHost {
@@ -39,7 +41,7 @@ impl AnalysisHost {
39 AnalysisHost { imp: AnalysisHostImpl::new() } 41 AnalysisHost { imp: AnalysisHostImpl::new() }
40 } 42 }
41 pub fn analysis(&self, file_resolver: impl FileResolver) -> Analysis { 43 pub fn analysis(&self, file_resolver: impl FileResolver) -> Analysis {
42 Analysis { imp: self.imp.analysis(file_resolver) } 44 Analysis { imp: self.imp.analysis(Arc::new(file_resolver)) }
43 } 45 }
44 pub fn change_file(&mut self, file_id: FileId, text: Option<String>) { 46 pub fn change_file(&mut self, file_id: FileId, text: Option<String>) {
45 self.change_files(::std::iter::once((file_id, text))); 47 self.change_files(::std::iter::once((file_id, text)));
@@ -121,7 +123,7 @@ impl Query {
121 123
122#[derive(Clone, Debug)] 124#[derive(Clone, Debug)]
123pub struct Analysis { 125pub struct Analysis {
124 pub(crate) imp: AnalysisImpl 126 imp: AnalysisImpl
125} 127}
126 128
127impl Analysis { 129impl Analysis {