diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_db/src/lib.rs | 13 | ||||
-rw-r--r-- | crates/ra_hir/src/db.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/mock.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/call_info.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/db.rs | 7 | ||||
-rw-r--r-- | crates/ra_ide_api/src/extend_selection.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/hover.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/imp.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/rename.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/runnables.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/syntax_highlighting.rs | 2 |
15 files changed, 24 insertions, 32 deletions
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 3a0aa7d24..4bfc3f9ae 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -20,7 +20,7 @@ pub use crate::{ | |||
20 | loc2id::LocationIntener, | 20 | loc2id::LocationIntener, |
21 | }; | 21 | }; |
22 | 22 | ||
23 | pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe { | 23 | pub trait CheckCanceled: salsa::Database + panic::RefUnwindSafe { |
24 | /// Aborts current query if there are pending changes. | 24 | /// Aborts current query if there are pending changes. |
25 | /// | 25 | /// |
26 | /// rust-analyzer needs to be able to answer semantic questions about the | 26 | /// rust-analyzer needs to be able to answer semantic questions about the |
@@ -64,10 +64,12 @@ pub struct FileRange { | |||
64 | } | 64 | } |
65 | 65 | ||
66 | #[salsa::query_group(FilesDatabaseStorage)] | 66 | #[salsa::query_group(FilesDatabaseStorage)] |
67 | pub trait FilesDatabase: salsa::Database { | 67 | pub trait FilesDatabase: salsa::Database + CheckCanceled { |
68 | /// Text of the file. | 68 | /// Text of the file. |
69 | #[salsa::input] | 69 | #[salsa::input] |
70 | fn file_text(&self, file_id: FileId) -> Arc<String>; | 70 | fn file_text(&self, file_id: FileId) -> Arc<String>; |
71 | // Parses the file into the syntax tree. | ||
72 | fn source_file(&self, file_id: FileId) -> TreeArc<SourceFile>; | ||
71 | /// Path to a file, relative to the root of its source root. | 73 | /// Path to a file, relative to the root of its source root. |
72 | #[salsa::input] | 74 | #[salsa::input] |
73 | fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf; | 75 | fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf; |
@@ -102,12 +104,7 @@ fn source_root_crates(db: &impl FilesDatabase, id: SourceRootId) -> Arc<Vec<Crat | |||
102 | Arc::new(res) | 104 | Arc::new(res) |
103 | } | 105 | } |
104 | 106 | ||
105 | #[salsa::query_group(SyntaxDatabaseStorage)] | 107 | fn source_file(db: &impl FilesDatabase, file_id: FileId) -> TreeArc<SourceFile> { |
106 | pub trait SyntaxDatabase: FilesDatabase + BaseDatabase { | ||
107 | fn source_file(&self, file_id: FileId) -> TreeArc<SourceFile>; | ||
108 | } | ||
109 | |||
110 | fn source_file(db: &impl SyntaxDatabase, file_id: FileId) -> TreeArc<SourceFile> { | ||
111 | let text = db.file_text(file_id); | 108 | let text = db.file_text(file_id); |
112 | SourceFile::parse(&*text) | 109 | SourceFile::parse(&*text) |
113 | } | 110 | } |
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index dfbf41bd6..1bb9e0305 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_syntax::{SyntaxNode, TreeArc, SourceFile}; | 3 | use ra_syntax::{SyntaxNode, TreeArc, SourceFile}; |
4 | use ra_db::{SyntaxDatabase, CrateId, salsa}; | 4 | use ra_db::{FilesDatabase, CrateId, salsa}; |
5 | 5 | ||
6 | use crate::{ | 6 | use crate::{ |
7 | MacroCallId, HirFileId, | 7 | MacroCallId, HirFileId, |
@@ -19,7 +19,7 @@ use crate::{ | |||
19 | }; | 19 | }; |
20 | 20 | ||
21 | #[salsa::query_group(HirDatabaseStorage)] | 21 | #[salsa::query_group(HirDatabaseStorage)] |
22 | pub trait HirDatabase: SyntaxDatabase + AsRef<HirInterner> { | 22 | pub trait HirDatabase: FilesDatabase + AsRef<HirInterner> { |
23 | #[salsa::invoke(HirFileId::hir_source_file)] | 23 | #[salsa::invoke(HirFileId::hir_source_file)] |
24 | fn hir_source_file(&self, file_id: HirFileId) -> TreeArc<SourceFile>; | 24 | fn hir_source_file(&self, file_id: HirFileId) -> TreeArc<SourceFile>; |
25 | 25 | ||
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs index 2dc252b1e..4af4dd096 100644 --- a/crates/ra_hir/src/mock.rs +++ b/crates/ra_hir/src/mock.rs | |||
@@ -2,7 +2,7 @@ use std::{sync::Arc, panic}; | |||
2 | 2 | ||
3 | use parking_lot::Mutex; | 3 | use parking_lot::Mutex; |
4 | use ra_db::{ | 4 | use ra_db::{ |
5 | BaseDatabase, FilePosition, FileId, CrateGraph, SourceRoot, SourceRootId, FilesDatabase, salsa, | 5 | CheckCanceled, FilePosition, FileId, CrateGraph, SourceRoot, SourceRootId, FilesDatabase, salsa, |
6 | }; | 6 | }; |
7 | use relative_path::RelativePathBuf; | 7 | use relative_path::RelativePathBuf; |
8 | use test_utils::{parse_fixture, CURSOR_MARKER, extract_offset}; | 8 | use test_utils::{parse_fixture, CURSOR_MARKER, extract_offset}; |
@@ -11,11 +11,7 @@ use crate::{db, HirInterner}; | |||
11 | 11 | ||
12 | pub const WORKSPACE: SourceRootId = SourceRootId(0); | 12 | pub const WORKSPACE: SourceRootId = SourceRootId(0); |
13 | 13 | ||
14 | #[salsa::database( | 14 | #[salsa::database(ra_db::FilesDatabaseStorage, db::HirDatabaseStorage)] |
15 | ra_db::FilesDatabaseStorage, | ||
16 | ra_db::SyntaxDatabaseStorage, | ||
17 | db::HirDatabaseStorage | ||
18 | )] | ||
19 | #[derive(Debug)] | 15 | #[derive(Debug)] |
20 | pub(crate) struct MockDatabase { | 16 | pub(crate) struct MockDatabase { |
21 | events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>, | 17 | events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>, |
@@ -161,7 +157,7 @@ impl salsa::ParallelDatabase for MockDatabase { | |||
161 | } | 157 | } |
162 | } | 158 | } |
163 | 159 | ||
164 | impl BaseDatabase for MockDatabase {} | 160 | impl CheckCanceled for MockDatabase {} |
165 | 161 | ||
166 | impl AsRef<HirInterner> for MockDatabase { | 162 | impl AsRef<HirInterner> for MockDatabase { |
167 | fn as_ref(&self) -> &HirInterner { | 163 | fn as_ref(&self) -> &HirInterner { |
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 389bdaf23..a56783b6e 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | use std::fmt::Write; | 2 | use std::fmt::Write; |
3 | 3 | ||
4 | use ra_db::{SyntaxDatabase, salsa::Database}; | 4 | use ra_db::{FilesDatabase, salsa::Database}; |
5 | use ra_syntax::ast::{self, AstNode}; | 5 | use ra_syntax::ast::{self, AstNode}; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs index 0449c1902..0eb70df16 100644 --- a/crates/ra_ide_api/src/call_info.rs +++ b/crates/ra_ide_api/src/call_info.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ra_db::SyntaxDatabase; | 1 | use ra_db::FilesDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | AstNode, SyntaxNode, TextUnit, TextRange, | 3 | AstNode, SyntaxNode, TextUnit, TextRange, |
4 | SyntaxKind::FN_DEF, | 4 | SyntaxKind::FN_DEF, |
diff --git a/crates/ra_ide_api/src/completion.rs b/crates/ra_ide_api/src/completion.rs index 565d57c37..581ba5de8 100644 --- a/crates/ra_ide_api/src/completion.rs +++ b/crates/ra_ide_api/src/completion.rs | |||
@@ -9,7 +9,7 @@ mod complete_path; | |||
9 | mod complete_scope; | 9 | mod complete_scope; |
10 | mod complete_postfix; | 10 | mod complete_postfix; |
11 | 11 | ||
12 | use ra_db::SyntaxDatabase; | 12 | use ra_db::FilesDatabase; |
13 | 13 | ||
14 | use crate::{ | 14 | use crate::{ |
15 | db, | 15 | db, |
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index 30891aed4..02e12437c 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_db::{ | 3 | use ra_db::{ |
4 | BaseDatabase, FileId, Canceled, | 4 | CheckCanceled, FileId, Canceled, |
5 | salsa::{self, Database}, | 5 | salsa::{self, Database}, |
6 | }; | 6 | }; |
7 | 7 | ||
@@ -9,7 +9,6 @@ use crate::{symbol_index, LineIndex}; | |||
9 | 9 | ||
10 | #[salsa::database( | 10 | #[salsa::database( |
11 | ra_db::FilesDatabaseStorage, | 11 | ra_db::FilesDatabaseStorage, |
12 | ra_db::SyntaxDatabaseStorage, | ||
13 | LineIndexDatabaseStorage, | 12 | LineIndexDatabaseStorage, |
14 | symbol_index::SymbolsDatabaseStorage, | 13 | symbol_index::SymbolsDatabaseStorage, |
15 | hir::db::HirDatabaseStorage | 14 | hir::db::HirDatabaseStorage |
@@ -54,7 +53,7 @@ impl salsa::ParallelDatabase for RootDatabase { | |||
54 | } | 53 | } |
55 | } | 54 | } |
56 | 55 | ||
57 | impl BaseDatabase for RootDatabase {} | 56 | impl CheckCanceled for RootDatabase {} |
58 | 57 | ||
59 | impl AsRef<hir::HirInterner> for RootDatabase { | 58 | impl AsRef<hir::HirInterner> for RootDatabase { |
60 | fn as_ref(&self) -> &hir::HirInterner { | 59 | fn as_ref(&self) -> &hir::HirInterner { |
@@ -63,7 +62,7 @@ impl AsRef<hir::HirInterner> for RootDatabase { | |||
63 | } | 62 | } |
64 | 63 | ||
65 | #[salsa::query_group(LineIndexDatabaseStorage)] | 64 | #[salsa::query_group(LineIndexDatabaseStorage)] |
66 | pub(crate) trait LineIndexDatabase: ra_db::FilesDatabase + BaseDatabase { | 65 | pub(crate) trait LineIndexDatabase: ra_db::FilesDatabase + CheckCanceled { |
67 | fn line_index(&self, file_id: FileId) -> Arc<LineIndex>; | 66 | fn line_index(&self, file_id: FileId) -> Arc<LineIndex>; |
68 | } | 67 | } |
69 | 68 | ||
diff --git a/crates/ra_ide_api/src/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs index 718b4def5..bc19b0b9d 100644 --- a/crates/ra_ide_api/src/extend_selection.rs +++ b/crates/ra_ide_api/src/extend_selection.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ra_db::SyntaxDatabase; | 1 | use ra_db::FilesDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | SyntaxNode, AstNode, SourceFile, | 3 | SyntaxNode, AstNode, SourceFile, |
4 | ast, algo::find_covering_node, | 4 | 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 dc0c50918..0e40e35ce 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ra_db::{FileId, SyntaxDatabase}; | 1 | use ra_db::{FileId, FilesDatabase}; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | AstNode, ast, | 3 | AstNode, ast, |
4 | algo::find_node_at_offset, | 4 | algo::find_node_at_offset, |
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index 4d4bfbc4d..04f5a746e 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ra_db::{SyntaxDatabase}; | 1 | use ra_db::FilesDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | AstNode, SyntaxNode, TreeArc, ast, | 3 | AstNode, SyntaxNode, TreeArc, ast, |
4 | algo::{find_covering_node, find_node_at_offset, find_leaf_at_offset, visit::{visitor, Visitor}}, | 4 | 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 bd9e3f1e3..f2d41321d 100644 --- a/crates/ra_ide_api/src/imp.rs +++ b/crates/ra_ide_api/src/imp.rs | |||
@@ -4,7 +4,7 @@ use hir::{ | |||
4 | self, Problem, source_binder | 4 | self, Problem, source_binder |
5 | }; | 5 | }; |
6 | use ra_db::{ | 6 | use ra_db::{ |
7 | FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase, | 7 | FilesDatabase, SourceRoot, SourceRootId, |
8 | salsa::{Database, SweepStrategy}, | 8 | salsa::{Database, SweepStrategy}, |
9 | }; | 9 | }; |
10 | use ra_ide_api_light::{self, assists, LocalEdit, Severity}; | 10 | 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 ffd026b04..8380aa6c2 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}; | |||
34 | use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit}; | 34 | use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit}; |
35 | use ra_text_edit::TextEdit; | 35 | use ra_text_edit::TextEdit; |
36 | use ra_db::{ | 36 | use ra_db::{ |
37 | SyntaxDatabase, FilesDatabase, BaseDatabase, | 37 | FilesDatabase, CheckCanceled, |
38 | salsa::{self, ParallelDatabase}, | 38 | salsa::{self, ParallelDatabase}, |
39 | }; | 39 | }; |
40 | use rayon::prelude::*; | 40 | use rayon::prelude::*; |
diff --git a/crates/ra_ide_api/src/rename.rs b/crates/ra_ide_api/src/rename.rs index 5b767addd..fe81609df 100644 --- a/crates/ra_ide_api/src/rename.rs +++ b/crates/ra_ide_api/src/rename.rs | |||
@@ -17,7 +17,7 @@ use crate::{ | |||
17 | SourceChange, | 17 | SourceChange, |
18 | SourceFileEdit, | 18 | SourceFileEdit, |
19 | }; | 19 | }; |
20 | use ra_db::{FilesDatabase, SyntaxDatabase}; | 20 | use ra_db::FilesDatabase; |
21 | use relative_path::RelativePath; | 21 | use relative_path::RelativePath; |
22 | 22 | ||
23 | pub(crate) fn rename( | 23 | pub(crate) fn rename( |
diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs index 0f9f8deb3..e21724207 100644 --- a/crates/ra_ide_api/src/runnables.rs +++ b/crates/ra_ide_api/src/runnables.rs | |||
@@ -3,7 +3,7 @@ use ra_syntax::{ | |||
3 | TextRange, SyntaxNode, | 3 | TextRange, SyntaxNode, |
4 | ast::{self, AstNode, NameOwner, ModuleItemOwner}, | 4 | ast::{self, AstNode, NameOwner, ModuleItemOwner}, |
5 | }; | 5 | }; |
6 | use ra_db::SyntaxDatabase; | 6 | use ra_db::FilesDatabase; |
7 | 7 | ||
8 | use crate::{db::RootDatabase, FileId}; | 8 | use crate::{db::RootDatabase, FileId}; |
9 | 9 | ||
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index a4d3ad005..cfa0257dd 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use ra_syntax::{ast, AstNode,}; | 1 | use ra_syntax::{ast, AstNode,}; |
2 | use ra_db::SyntaxDatabase; | 2 | use ra_db::FilesDatabase; |
3 | 3 | ||
4 | use crate::{ | 4 | use crate::{ |
5 | FileId, HighlightedRange, | 5 | FileId, HighlightedRange, |