From fcfda94664b454f60be2dbc1b564ed63aa4c3ec5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 7 Sep 2018 22:03:39 +0300 Subject: Separete API from IMPL Looks like there's a rule of thumb: don't call API functions from an implementation! In this case, following this rule of thumb saves us an Arc-bump! --- crates/libanalysis/src/lib.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'crates') diff --git a/crates/libanalysis/src/lib.rs b/crates/libanalysis/src/lib.rs index 4e63813f9..ff4fc709b 100644 --- a/crates/libanalysis/src/lib.rs +++ b/crates/libanalysis/src/lib.rs @@ -167,20 +167,20 @@ impl Analysis { libeditor::matching_brace(file, offset) } pub fn syntax_tree(&self, file_id: FileId) -> String { - let file = self.file_syntax(file_id); - libeditor::syntax_tree(&file) + let file = self.imp.file_syntax(file_id); + libeditor::syntax_tree(file) } pub fn join_lines(&self, file_id: FileId, range: TextRange) -> SourceChange { - let file = self.file_syntax(file_id); - SourceChange::from_local_edit(file_id, "join lines", libeditor::join_lines(&file, range)) + let file = self.imp.file_syntax(file_id); + SourceChange::from_local_edit(file_id, "join lines", libeditor::join_lines(file, range)) } pub fn on_eq_typed(&self, file_id: FileId, offset: TextUnit) -> Option { - let file = self.file_syntax(file_id); - Some(SourceChange::from_local_edit(file_id, "add semicolon", libeditor::on_eq_typed(&file, offset)?)) + let file = self.imp.file_syntax(file_id); + Some(SourceChange::from_local_edit(file_id, "add semicolon", libeditor::on_eq_typed(file, offset)?)) } pub fn file_structure(&self, file_id: FileId) -> Vec { - let file = self.file_syntax(file_id); - libeditor::file_structure(&file) + let file = self.imp.file_syntax(file_id); + libeditor::file_structure(file) } pub fn symbol_search(&self, query: Query, token: &JobToken) -> Vec<(FileId, FileSymbol)> { self.imp.world_symbols(query, token) @@ -198,16 +198,16 @@ impl Analysis { self.imp.crate_root(crate_id) } pub fn runnables(&self, file_id: FileId) -> Vec { - let file = self.file_syntax(file_id); - libeditor::runnables(&file) + let file = self.imp.file_syntax(file_id); + libeditor::runnables(file) } pub fn highlight(&self, file_id: FileId) -> Vec { - let file = self.file_syntax(file_id); - libeditor::highlight(&file) + let file = self.imp.file_syntax(file_id); + libeditor::highlight(file) } pub fn completions(&self, file_id: FileId, offset: TextUnit) -> Option> { - let file = self.file_syntax(file_id); - libeditor::scope_completion(&file, offset) + let file = self.imp.file_syntax(file_id); + libeditor::scope_completion(file, offset) } pub fn assists(&self, file_id: FileId, range: TextRange) -> Vec { self.imp.assists(file_id, range) -- cgit v1.2.3