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_hir/src/db.rs | 4 ++-- crates/ra_hir/src/ids.rs | 9 +++------ crates/ra_hir/src/nameres/lower.rs | 2 +- crates/ra_hir/src/query_definitions.rs | 7 ++----- crates/ra_hir/src/source_binder.rs | 4 ++-- crates/ra_hir/src/ty/tests.rs | 2 +- 6 files changed, 11 insertions(+), 17 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 9b5b79d38..5df4bd4a1 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -20,8 +20,8 @@ use crate::{ #[salsa::query_group(HirDatabaseStorage)] pub trait HirDatabase: SourceDatabase + AsRef { - #[salsa::invoke(HirFileId::hir_source_file)] - fn hir_source_file(&self, file_id: HirFileId) -> TreeArc; + #[salsa::invoke(HirFileId::hir_parse)] + fn hir_parse(&self, file_id: HirFileId) -> TreeArc; #[salsa::invoke(crate::macros::expand_macro_invocation)] fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option>; diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 5272656ec..7dd4b540e 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -86,12 +86,9 @@ impl HirFileId { } } - pub(crate) fn hir_source_file( - db: &impl HirDatabase, - file_id: HirFileId, - ) -> TreeArc { + pub(crate) fn hir_parse(db: &impl HirDatabase, file_id: HirFileId) -> TreeArc { match file_id.0 { - HirFileIdRepr::File(file_id) => db.source_file(file_id), + HirFileIdRepr::File(file_id) => db.parse(file_id), HirFileIdRepr::Macro(m) => { if let Some(exp) = db.expand_macro_invocation(m) { return exp.file(); @@ -370,7 +367,7 @@ impl SourceFileItems { self.arena.iter().map(|(_id, i)| i).collect::>(), ); } - pub fn id_of_source_file(&self) -> SourceFileItemId { + pub fn id_of_parse(&self) -> SourceFileItemId { let (id, _syntax) = self.arena.iter().next().unwrap(); id } diff --git a/crates/ra_hir/src/nameres/lower.rs b/crates/ra_hir/src/nameres/lower.rs index b4fe99ea7..1d77548f3 100644 --- a/crates/ra_hir/src/nameres/lower.rs +++ b/crates/ra_hir/src/nameres/lower.rs @@ -129,7 +129,7 @@ impl LoweredModule { let id = loc.id(db); let file_id = HirFileId::from(id); //FIXME: expand recursively - for item in db.hir_source_file(file_id).items() { + for item in db.hir_parse(file_id).items() { self.add_def_id(source_map, db, module, file_id, item); } } diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index cf8c7e435..61c93a964 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs @@ -23,7 +23,7 @@ pub(super) fn fn_scopes(db: &impl HirDatabase, func: Function) -> Arc } pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc { - let source_file = db.hir_source_file(file_id); + let source_file = db.hir_parse(file_id); let res = SourceFileItems::new(file_id, &source_file); Arc::new(res) } @@ -34,10 +34,7 @@ pub(super) fn file_item( ) -> TreeArc { match source_item_id.item_id { Some(id) => db.file_items(source_item_id.file_id)[id].to_owned(), - None => db - .hir_source_file(source_item_id.file_id) - .syntax() - .to_owned(), + None => db.hir_parse(source_item_id.file_id).syntax().to_owned(), } } diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index dbe040805..c0b3f1cd4 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -43,7 +43,7 @@ pub fn module_from_declaration( /// Locates the module by position in the source code. pub fn module_from_position(db: &impl HirDatabase, position: FilePosition) -> Option { - let file = db.source_file(position.file_id); + let file = db.parse(position.file_id); match find_node_at_offset::(file.syntax(), position.offset) { Some(m) if !m.has_semi() => module_from_inline(db, position.file_id.into(), m), _ => module_from_file_id(db, position.file_id.into()), @@ -95,7 +95,7 @@ fn module_from_source(db: &impl HirDatabase, source: SourceItemId) -> Option Option { - let file = db.source_file(position.file_id); + let file = db.parse(position.file_id); let fn_def = find_node_at_offset::(file.syntax(), position.offset)?; function_from_source(db, position.file_id, fn_def) } diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 0eb4da06e..e0b0689f8 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -547,7 +547,7 @@ fn quux() { fn infer(content: &str) -> String { let (db, _, file_id) = MockDatabase::with_single_file(content); - let source_file = db.source_file(file_id); + let source_file = db.parse(file_id); let mut acc = String::new(); for fn_def in source_file .syntax() -- cgit v1.2.3