aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_analysis/src/db.rs14
-rw-r--r--crates/ra_analysis/src/descriptors/mod.rs4
-rw-r--r--crates/ra_analysis/src/imp.rs1
-rw-r--r--crates/ra_analysis/src/syntax_ptr.rs12
4 files changed, 12 insertions, 19 deletions
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs
index 9ab273ad7..94fdd36a4 100644
--- a/crates/ra_analysis/src/db.rs
+++ b/crates/ra_analysis/src/db.rs
@@ -1,7 +1,7 @@
1use std::sync::Arc; 1use std::sync::Arc;
2 2
3use ra_editor::LineIndex; 3use ra_editor::LineIndex;
4use ra_syntax::File; 4use ra_syntax::{File, SyntaxNode};
5use salsa; 5use salsa;
6 6
7use crate::{ 7use crate::{
@@ -11,7 +11,7 @@ use crate::{
11 SubmodulesQuery, 11 SubmodulesQuery,
12 }, 12 },
13 symbol_index::SymbolIndex, 13 symbol_index::SymbolIndex,
14 syntax_ptr::{ResolveSyntaxPtrQuery, SyntaxPtrDatabase}, 14 syntax_ptr::SyntaxPtr,
15 Cancelable, Canceled, FileId, 15 Cancelable, Canceled, FileId,
16}; 16};
17 17
@@ -62,6 +62,7 @@ salsa::database_storage! {
62 fn file_syntax() for FileSyntaxQuery; 62 fn file_syntax() for FileSyntaxQuery;
63 fn file_lines() for FileLinesQuery; 63 fn file_lines() for FileLinesQuery;
64 fn file_symbols() for FileSymbolsQuery; 64 fn file_symbols() for FileSymbolsQuery;
65 fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery;
65 } 66 }
66 impl DescriptorDatabase { 67 impl DescriptorDatabase {
67 fn module_tree() for ModuleTreeQuery; 68 fn module_tree() for ModuleTreeQuery;
@@ -70,9 +71,6 @@ salsa::database_storage! {
70 fn fn_syntax() for FnSyntaxQuery; 71 fn fn_syntax() for FnSyntaxQuery;
71 fn fn_scopes() for FnScopesQuery; 72 fn fn_scopes() for FnScopesQuery;
72 } 73 }
73 impl SyntaxPtrDatabase {
74 fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery;
75 }
76 } 74 }
77} 75}
78 76
@@ -87,6 +85,12 @@ salsa::query_group! {
87 fn file_symbols(file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { 85 fn file_symbols(file_id: FileId) -> Cancelable<Arc<SymbolIndex>> {
88 type FileSymbolsQuery; 86 type FileSymbolsQuery;
89 } 87 }
88 fn resolve_syntax_ptr(ptr: SyntaxPtr) -> SyntaxNode {
89 type ResolveSyntaxPtrQuery;
90 // Don't retain syntax trees in memory
91 storage volatile;
92 use fn crate::syntax_ptr::resolve_syntax_ptr;
93 }
90 } 94 }
91} 95}
92 96
diff --git a/crates/ra_analysis/src/descriptors/mod.rs b/crates/ra_analysis/src/descriptors/mod.rs
index c28764336..eaeef54c1 100644
--- a/crates/ra_analysis/src/descriptors/mod.rs
+++ b/crates/ra_analysis/src/descriptors/mod.rs
@@ -13,12 +13,12 @@ use crate::{
13 descriptors::function::{resolve_local_name, FnId, FnScopes}, 13 descriptors::function::{resolve_local_name, FnId, FnScopes},
14 descriptors::module::{ModuleId, ModuleScope, ModuleTree}, 14 descriptors::module::{ModuleId, ModuleScope, ModuleTree},
15 input::SourceRootId, 15 input::SourceRootId,
16 syntax_ptr::{LocalSyntaxPtr, SyntaxPtrDatabase}, 16 syntax_ptr::LocalSyntaxPtr,
17 Cancelable, FileId, 17 Cancelable, FileId,
18}; 18};
19 19
20salsa::query_group! { 20salsa::query_group! {
21 pub(crate) trait DescriptorDatabase: SyntaxDatabase + SyntaxPtrDatabase { 21 pub(crate) trait DescriptorDatabase: SyntaxDatabase {
22 fn module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> { 22 fn module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> {
23 type ModuleTreeQuery; 23 type ModuleTreeQuery;
24 use fn module::imp::module_tree; 24 use fn module::imp::module_tree;
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index 44077b507..0744ea9c8 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -25,7 +25,6 @@ use crate::{
25 }, 25 },
26 input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE}, 26 input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE},
27 symbol_index::SymbolIndex, 27 symbol_index::SymbolIndex,
28 syntax_ptr::SyntaxPtrDatabase,
29 AnalysisChange, Cancelable, CrateGraph, CrateId, Diagnostic, FileId, FileResolver, 28 AnalysisChange, Cancelable, CrateGraph, CrateId, Diagnostic, FileId, FileResolver,
30 FileSystemEdit, Position, Query, SourceChange, SourceFileEdit, 29 FileSystemEdit, Position, Query, SourceChange, SourceFileEdit,
31}; 30};
diff --git a/crates/ra_analysis/src/syntax_ptr.rs b/crates/ra_analysis/src/syntax_ptr.rs
index 7b89ecbc8..4db1529c2 100644
--- a/crates/ra_analysis/src/syntax_ptr.rs
+++ b/crates/ra_analysis/src/syntax_ptr.rs
@@ -3,17 +3,7 @@ use ra_syntax::{File, SyntaxKind, SyntaxNode, SyntaxNodeRef, TextRange};
3use crate::db::SyntaxDatabase; 3use crate::db::SyntaxDatabase;
4use crate::FileId; 4use crate::FileId;
5 5
6salsa::query_group! { 6pub(crate) fn resolve_syntax_ptr(db: &impl SyntaxDatabase, ptr: SyntaxPtr) -> SyntaxNode {
7 pub(crate) trait SyntaxPtrDatabase: SyntaxDatabase {
8 fn resolve_syntax_ptr(ptr: SyntaxPtr) -> SyntaxNode {
9 type ResolveSyntaxPtrQuery;
10 // Don't retain syntax trees in memory
11 storage volatile;
12 }
13 }
14}
15
16fn resolve_syntax_ptr(db: &impl SyntaxDatabase, ptr: SyntaxPtr) -> SyntaxNode {
17 let syntax = db.file_syntax(ptr.file_id); 7 let syntax = db.file_syntax(ptr.file_id);
18 ptr.local.resolve(&syntax) 8 ptr.local.resolve(&syntax)
19} 9}