From 9457b1f0e64d38e7dc24d8c66a52ffef759d4dbf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 26 Jan 2019 11:51:36 +0300 Subject: rename source_file -> parse --- crates/ra_ide_api/src/call_info.rs | 4 ++-- crates/ra_ide_api/src/completion.rs | 2 +- crates/ra_ide_api/src/extend_selection.rs | 2 +- crates/ra_ide_api/src/goto_definition.rs | 2 +- crates/ra_ide_api/src/hover.rs | 6 +++--- crates/ra_ide_api/src/imp.rs | 10 +++++----- crates/ra_ide_api/src/lib.rs | 18 +++++++++--------- crates/ra_ide_api/src/rename.rs | 2 +- crates/ra_ide_api/src/runnables.rs | 2 +- crates/ra_ide_api/src/status.rs | 4 ++-- crates/ra_ide_api/src/symbol_index.rs | 2 +- crates/ra_ide_api/src/syntax_highlighting.rs | 2 +- 12 files changed, 28 insertions(+), 28 deletions(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs index 728f2df30..3267fff96 100644 --- a/crates/ra_ide_api/src/call_info.rs +++ b/crates/ra_ide_api/src/call_info.rs @@ -10,7 +10,7 @@ use crate::{FilePosition, CallInfo, db::RootDatabase}; /// Computes parameter information for the given call expression. pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option { - let file = db.source_file(position.file_id); + let file = db.parse(position.file_id); let syntax = file.syntax(); // Find the calling expression and it's NameRef @@ -22,7 +22,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option Option { - let original_file = db.source_file(position.file_id); + let original_file = db.parse(position.file_id); let ctx = CompletionContext::new(db, &original_file, position)?; let mut acc = Completions::default(); diff --git a/crates/ra_ide_api/src/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs index 1cd955357..cd2ebe471 100644 --- a/crates/ra_ide_api/src/extend_selection.rs +++ b/crates/ra_ide_api/src/extend_selection.rs @@ -10,7 +10,7 @@ use crate::{ }; pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange { - let source_file = db.source_file(frange.file_id); + let source_file = db.parse(frange.file_id); if let Some(range) = extend_selection_in_macro(db, &source_file, frange) { return range; } diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 180cc7c80..2a20c20ee 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs @@ -11,7 +11,7 @@ pub(crate) fn goto_definition( db: &RootDatabase, position: FilePosition, ) -> Option>> { - let file = db.source_file(position.file_id); + let file = db.parse(position.file_id); let syntax = file.syntax(); if let Some(name_ref) = find_node_at_offset::(syntax, position.offset) { let navs = reference_definition(db, position.file_id, name_ref).to_vec(); diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index b6d727399..ff9ae2d9c 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs @@ -7,7 +7,7 @@ use ra_syntax::{ use crate::{db::RootDatabase, RangeInfo, FilePosition, FileRange, NavigationTarget}; pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option> { - let file = db.source_file(position.file_id); + let file = db.parse(position.file_id); let mut res = Vec::new(); let mut range = None; @@ -53,7 +53,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option Option { - let file = db.source_file(frange.file_id); + let file = db.parse(frange.file_id); let syntax = file.syntax(); let leaf_node = find_covering_node(syntax, frange.range); // if we picked identifier, expand to pattern/expression @@ -88,7 +88,7 @@ fn doc_text_for(db: &RootDatabase, nav: NavigationTarget) -> Option { impl NavigationTarget { fn node(&self, db: &RootDatabase) -> Option> { - let source_file = db.source_file(self.file_id()); + let source_file = db.parse(self.file_id()); let source_file = source_file.syntax(); let node = source_file .descendants() diff --git a/crates/ra_ide_api/src/imp.rs b/crates/ra_ide_api/src/imp.rs index 1222fdc44..399433a01 100644 --- a/crates/ra_ide_api/src/imp.rs +++ b/crates/ra_ide_api/src/imp.rs @@ -76,9 +76,9 @@ impl db::RootDatabase { /// syntax trees. However, if we actually do that, everything is recomputed /// for some reason. Needs investigation. pub(crate) fn collect_garbage(&mut self) { - self.query(ra_db::SourceFileQuery) + self.query(ra_db::ParseQuery) .sweep(SweepStrategy::default().discard_values()); - self.query(hir::db::HirSourceFileQuery) + self.query(hir::db::HirParseQuery) .sweep(SweepStrategy::default().discard_values()); self.query(hir::db::FileItemsQuery) .sweep(SweepStrategy::default().discard_values()); @@ -102,7 +102,7 @@ impl db::RootDatabase { } pub(crate) fn find_all_refs(&self, position: FilePosition) -> Vec<(FileId, TextRange)> { - let file = self.source_file(position.file_id); + let file = self.parse(position.file_id); // Find the binding associated with the offset let (binding, descr) = match find_binding(self, &file, position) { None => return Vec::new(), @@ -150,7 +150,7 @@ impl db::RootDatabase { } pub(crate) fn diagnostics(&self, file_id: FileId) -> Vec { - let syntax = self.source_file(file_id); + let syntax = self.parse(file_id); let mut res = ra_ide_api_light::diagnostics(&syntax) .into_iter() @@ -214,7 +214,7 @@ impl db::RootDatabase { } pub(crate) fn assists(&self, frange: FileRange) -> Vec { - let file = self.source_file(frange.file_id); + let file = self.parse(frange.file_id); assists::assists(&file, frange.range) .into_iter() .map(|local_edit| SourceChange::from_local_edit(frange.file_id, local_edit)) diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 62a1934f4..43c8bea71 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs @@ -313,7 +313,7 @@ impl Analysis { /// Gets the syntax tree of the file. pub fn parse(&self, file_id: FileId) -> TreeArc { - self.db.source_file(file_id).clone() + self.db.parse(file_id).clone() } /// Gets the file's `LineIndex`: data structure to convert between absolute @@ -330,21 +330,21 @@ impl Analysis { /// Returns position of the mathcing brace (all types of braces are /// supported). pub fn matching_brace(&self, position: FilePosition) -> Option { - let file = self.db.source_file(position.file_id); + let file = self.db.parse(position.file_id); ra_ide_api_light::matching_brace(&file, position.offset) } /// Returns a syntax tree represented as `String`, for debug purposes. // FIXME: use a better name here. pub fn syntax_tree(&self, file_id: FileId) -> String { - let file = self.db.source_file(file_id); + let file = self.db.parse(file_id); ra_ide_api_light::syntax_tree(&file) } /// Returns an edit to remove all newlines in the range, cleaning up minor /// stuff like trailing commas. pub fn join_lines(&self, frange: FileRange) -> SourceChange { - let file = self.db.source_file(frange.file_id); + let file = self.db.parse(frange.file_id); SourceChange::from_local_edit( frange.file_id, ra_ide_api_light::join_lines(&file, frange.range), @@ -354,7 +354,7 @@ impl Analysis { /// Returns an edit which should be applied when opening a new line, fixing /// up minor stuff like continuing the comment. pub fn on_enter(&self, position: FilePosition) -> Option { - let file = self.db.source_file(position.file_id); + let file = self.db.parse(position.file_id); let edit = ra_ide_api_light::on_enter(&file, position.offset)?; Some(SourceChange::from_local_edit(position.file_id, edit)) } @@ -363,14 +363,14 @@ impl Analysis { /// this works when adding `let =`. // FIXME: use a snippet completion instead of this hack here. pub fn on_eq_typed(&self, position: FilePosition) -> Option { - let file = self.db.source_file(position.file_id); + let file = self.db.parse(position.file_id); let edit = ra_ide_api_light::on_eq_typed(&file, position.offset)?; Some(SourceChange::from_local_edit(position.file_id, edit)) } /// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately. pub fn on_dot_typed(&self, position: FilePosition) -> Option { - let file = self.db.source_file(position.file_id); + let file = self.db.parse(position.file_id); let edit = ra_ide_api_light::on_dot_typed(&file, position.offset)?; Some(SourceChange::from_local_edit(position.file_id, edit)) } @@ -378,13 +378,13 @@ impl Analysis { /// Returns a tree representation of symbols in the file. Useful to draw a /// file outline. pub fn file_structure(&self, file_id: FileId) -> Vec { - let file = self.db.source_file(file_id); + let file = self.db.parse(file_id); ra_ide_api_light::file_structure(&file) } /// Returns the set of folding ranges. pub fn folding_ranges(&self, file_id: FileId) -> Vec { - let file = self.db.source_file(file_id); + let file = self.db.parse(file_id); ra_ide_api_light::folding_ranges(&file) } diff --git a/crates/ra_ide_api/src/rename.rs b/crates/ra_ide_api/src/rename.rs index 81ca0537c..db5ccf969 100644 --- a/crates/ra_ide_api/src/rename.rs +++ b/crates/ra_ide_api/src/rename.rs @@ -25,7 +25,7 @@ pub(crate) fn rename( position: FilePosition, new_name: &str, ) -> Option { - let source_file = db.source_file(position.file_id); + let source_file = db.parse(position.file_id); let syntax = source_file.syntax(); if let Some((ast_name, ast_module)) = find_name_and_module_at_offset(syntax, position) { diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs index 0f2d00f13..dc8c40ea6 100644 --- a/crates/ra_ide_api/src/runnables.rs +++ b/crates/ra_ide_api/src/runnables.rs @@ -22,7 +22,7 @@ pub enum RunnableKind { } pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec { - let source_file = db.source_file(file_id); + let source_file = db.parse(file_id); source_file .syntax() .descendants() diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs index 59159df98..e11eed223 100644 --- a/crates/ra_ide_api/src/status.rs +++ b/crates/ra_ide_api/src/status.rs @@ -6,7 +6,7 @@ use std::{ use ra_syntax::{AstNode, TreeArc, SourceFile}; use ra_db::{ - SourceFileQuery, FileTextQuery, SourceRootId, + ParseQuery, FileTextQuery, SourceRootId, salsa::{Database, debug::{DebugQueryTable, TableEntry}}, }; @@ -17,7 +17,7 @@ use crate::{ pub(crate) fn status(db: &RootDatabase) -> String { let files_stats = db.query(FileTextQuery).entries::(); - let syntax_tree_stats = db.query(SourceFileQuery).entries::(); + let syntax_tree_stats = db.query(ParseQuery).entries::(); let symbols_stats = db .query(LibrarySymbolsQuery) .entries::(); diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs index 230ff410e..72c93f530 100644 --- a/crates/ra_ide_api/src/symbol_index.rs +++ b/crates/ra_ide_api/src/symbol_index.rs @@ -61,7 +61,7 @@ pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc { db.check_canceled(); - let source_file = db.source_file(file_id); + let source_file = db.parse(file_id); let mut symbols = source_file .syntax() .descendants() diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index 16d23e140..26bde495b 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs @@ -7,7 +7,7 @@ use crate::{ }; pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec { - let source_file = db.source_file(file_id); + let source_file = db.parse(file_id); let mut res = ra_ide_api_light::highlight(source_file.syntax()); for macro_call in source_file .syntax() -- cgit v1.2.3