From 4711cbcace33e34d43f880d30c2778c843240f27 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 26 Jan 2019 11:20:30 +0300 Subject: rename FilesDatabase -> SourceDatabase --- crates/ra_db/src/lib.rs | 10 ++++++---- crates/ra_hir/src/db.rs | 4 ++-- crates/ra_hir/src/mock.rs | 4 ++-- crates/ra_hir/src/nameres/tests.rs | 2 +- crates/ra_hir/src/ty/tests.rs | 2 +- crates/ra_ide_api/src/call_info.rs | 2 +- crates/ra_ide_api/src/completion.rs | 2 +- crates/ra_ide_api/src/db.rs | 8 ++++---- 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 | 2 +- crates/ra_ide_api/src/imp.rs | 2 +- crates/ra_ide_api/src/lib.rs | 2 +- crates/ra_ide_api/src/rename.rs | 2 +- crates/ra_ide_api/src/runnables.rs | 2 +- crates/ra_ide_api/src/symbol_index.rs | 2 +- crates/ra_ide_api/src/syntax_highlighting.rs | 2 +- 17 files changed, 27 insertions(+), 25 deletions(-) diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index cab47dcac..2664dc69a 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs @@ -63,8 +63,10 @@ pub struct FileRange { pub range: TextRange, } -#[salsa::query_group(FilesDatabaseStorage)] -pub trait FilesDatabase: salsa::Database + CheckCanceled { +/// Database which stores all significant input facts: source code and project +/// model. Everything else in rust-analyzer is derived from these queries. +#[salsa::query_group(SourceDatabaseStorage)] +pub trait SourceDatabase: salsa::Database + CheckCanceled { /// Text of the file. #[salsa::input] fn file_text(&self, file_id: FileId) -> Arc; @@ -85,7 +87,7 @@ pub trait FilesDatabase: salsa::Database + CheckCanceled { fn crate_graph(&self) -> Arc; } -fn source_root_crates(db: &impl FilesDatabase, id: SourceRootId) -> Arc> { +fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc> { let root = db.source_root(id); let graph = db.crate_graph(); let res = root @@ -96,7 +98,7 @@ fn source_root_crates(db: &impl FilesDatabase, id: SourceRootId) -> Arc TreeArc { +fn source_file(db: &impl SourceDatabase, file_id: FileId) -> TreeArc { let text = db.file_text(file_id); SourceFile::parse(&*text) } diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 1bb9e0305..9b5b79d38 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use ra_syntax::{SyntaxNode, TreeArc, SourceFile}; -use ra_db::{FilesDatabase, CrateId, salsa}; +use ra_db::{SourceDatabase, CrateId, salsa}; use crate::{ MacroCallId, HirFileId, @@ -19,7 +19,7 @@ use crate::{ }; #[salsa::query_group(HirDatabaseStorage)] -pub trait HirDatabase: FilesDatabase + AsRef { +pub trait HirDatabase: SourceDatabase + AsRef { #[salsa::invoke(HirFileId::hir_source_file)] fn hir_source_file(&self, file_id: HirFileId) -> TreeArc; diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs index cfbe652b0..7da15eca0 100644 --- a/crates/ra_hir/src/mock.rs +++ b/crates/ra_hir/src/mock.rs @@ -2,7 +2,7 @@ use std::{sync::Arc, panic}; use parking_lot::Mutex; use ra_db::{ - CheckCanceled, FilePosition, FileId, CrateGraph, SourceRoot, SourceRootId, FilesDatabase, salsa, + CheckCanceled, FilePosition, FileId, CrateGraph, SourceRoot, SourceRootId, SourceDatabase, salsa, }; use relative_path::RelativePathBuf; use test_utils::{parse_fixture, CURSOR_MARKER, extract_offset}; @@ -11,7 +11,7 @@ use crate::{db, HirInterner}; pub const WORKSPACE: SourceRootId = SourceRootId(0); -#[salsa::database(ra_db::FilesDatabaseStorage, db::HirDatabaseStorage)] +#[salsa::database(ra_db::SourceDatabaseStorage, db::HirDatabaseStorage)] #[derive(Debug)] pub(crate) struct MockDatabase { events: Mutex>>>, diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs index 24936976c..e72781f51 100644 --- a/crates/ra_hir/src/nameres/tests.rs +++ b/crates/ra_hir/src/nameres/tests.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use ra_db::{CrateGraph, SourceRootId, FilesDatabase}; +use ra_db::{CrateGraph, SourceRootId, SourceDatabase}; use relative_path::RelativePath; use test_utils::{assert_eq_text, covers}; diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index a56783b6e..0eb4da06e 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use std::fmt::Write; -use ra_db::{FilesDatabase, salsa::Database}; +use ra_db::{SourceDatabase, salsa::Database}; use ra_syntax::ast::{self, AstNode}; use crate::{ diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs index 0eb70df16..728f2df30 100644 --- a/crates/ra_ide_api/src/call_info.rs +++ b/crates/ra_ide_api/src/call_info.rs @@ -1,4 +1,4 @@ -use ra_db::FilesDatabase; +use ra_db::SourceDatabase; use ra_syntax::{ AstNode, SyntaxNode, TextUnit, TextRange, SyntaxKind::FN_DEF, diff --git a/crates/ra_ide_api/src/completion.rs b/crates/ra_ide_api/src/completion.rs index 581ba5de8..be64f2c5a 100644 --- a/crates/ra_ide_api/src/completion.rs +++ b/crates/ra_ide_api/src/completion.rs @@ -9,7 +9,7 @@ mod complete_path; mod complete_scope; mod complete_postfix; -use ra_db::FilesDatabase; +use ra_db::SourceDatabase; use crate::{ db, diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index 119190e0a..3da93ec35 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs @@ -1,14 +1,14 @@ use std::sync::Arc; use ra_db::{ - CheckCanceled, FileId, Canceled, FilesDatabase, + CheckCanceled, FileId, Canceled, SourceDatabase, salsa, }; use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}}; #[salsa::database( - ra_db::FilesDatabaseStorage, + ra_db::SourceDatabaseStorage, LineIndexDatabaseStorage, symbol_index::SymbolsDatabaseStorage, hir::db::HirDatabaseStorage @@ -59,11 +59,11 @@ impl AsRef for RootDatabase { } #[salsa::query_group(LineIndexDatabaseStorage)] -pub(crate) trait LineIndexDatabase: ra_db::FilesDatabase + CheckCanceled { +pub(crate) trait LineIndexDatabase: ra_db::SourceDatabase + CheckCanceled { fn line_index(&self, file_id: FileId) -> Arc; } -fn line_index(db: &impl ra_db::FilesDatabase, file_id: FileId) -> Arc { +fn line_index(db: &impl ra_db::SourceDatabase, file_id: FileId) -> Arc { let text = db.file_text(file_id); Arc::new(LineIndex::new(&*text)) } diff --git a/crates/ra_ide_api/src/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs index bc19b0b9d..1cd955357 100644 --- a/crates/ra_ide_api/src/extend_selection.rs +++ b/crates/ra_ide_api/src/extend_selection.rs @@ -1,4 +1,4 @@ -use ra_db::FilesDatabase; +use ra_db::SourceDatabase; use ra_syntax::{ SyntaxNode, AstNode, SourceFile, ast, algo::find_covering_node, diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 0e40e35ce..180cc7c80 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs @@ -1,4 +1,4 @@ -use ra_db::{FileId, FilesDatabase}; +use ra_db::{FileId, SourceDatabase}; use ra_syntax::{ AstNode, ast, algo::find_node_at_offset, diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index 04f5a746e..b6d727399 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs @@ -1,4 +1,4 @@ -use ra_db::FilesDatabase; +use ra_db::SourceDatabase; use ra_syntax::{ AstNode, SyntaxNode, TreeArc, ast, algo::{find_covering_node, find_node_at_offset, find_leaf_at_offset, visit::{visitor, Visitor}}, diff --git a/crates/ra_ide_api/src/imp.rs b/crates/ra_ide_api/src/imp.rs index f2d41321d..1222fdc44 100644 --- a/crates/ra_ide_api/src/imp.rs +++ b/crates/ra_ide_api/src/imp.rs @@ -4,7 +4,7 @@ use hir::{ self, Problem, source_binder }; use ra_db::{ - FilesDatabase, SourceRoot, SourceRootId, + SourceDatabase, SourceRoot, SourceRootId, salsa::{Database, SweepStrategy}, }; use ra_ide_api_light::{self, assists, LocalEdit, Severity}; diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 8380aa6c2..62a1934f4 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs @@ -34,7 +34,7 @@ use std::{fmt, sync::Arc}; use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit}; use ra_text_edit::TextEdit; use ra_db::{ - FilesDatabase, CheckCanceled, + SourceDatabase, CheckCanceled, salsa::{self, ParallelDatabase}, }; use rayon::prelude::*; diff --git a/crates/ra_ide_api/src/rename.rs b/crates/ra_ide_api/src/rename.rs index fe81609df..81ca0537c 100644 --- a/crates/ra_ide_api/src/rename.rs +++ b/crates/ra_ide_api/src/rename.rs @@ -17,7 +17,7 @@ use crate::{ SourceChange, SourceFileEdit, }; -use ra_db::FilesDatabase; +use ra_db::SourceDatabase; use relative_path::RelativePath; pub(crate) fn rename( diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs index e21724207..0f2d00f13 100644 --- a/crates/ra_ide_api/src/runnables.rs +++ b/crates/ra_ide_api/src/runnables.rs @@ -3,7 +3,7 @@ use ra_syntax::{ TextRange, SyntaxNode, ast::{self, AstNode, NameOwner, ModuleItemOwner}, }; -use ra_db::FilesDatabase; +use ra_db::SourceDatabase; use crate::{db::RootDatabase, FileId}; diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs index 4d81d14b3..230ff410e 100644 --- a/crates/ra_ide_api/src/symbol_index.rs +++ b/crates/ra_ide_api/src/symbol_index.rs @@ -34,7 +34,7 @@ use ra_syntax::{ ast::{self, NameOwner}, }; use ra_db::{ - SourceRootId, FilesDatabase, + SourceRootId, SourceDatabase, salsa::{self, ParallelDatabase}, }; use rayon::prelude::*; diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index cfa0257dd..16d23e140 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs @@ -1,5 +1,5 @@ use ra_syntax::{ast, AstNode,}; -use ra_db::FilesDatabase; +use ra_db::SourceDatabase; use crate::{ FileId, HighlightedRange, -- cgit v1.2.3