From 2050812cad7905c33870c36362593360f7216310 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 1 Nov 2018 13:15:11 +0300 Subject: remove SyntaxPtrDatabase --- crates/ra_analysis/src/db.rs | 14 +++++++++----- crates/ra_analysis/src/descriptors/mod.rs | 4 ++-- crates/ra_analysis/src/imp.rs | 1 - crates/ra_analysis/src/syntax_ptr.rs | 12 +----------- 4 files changed, 12 insertions(+), 19 deletions(-) (limited to 'crates') 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 @@ use std::sync::Arc; use ra_editor::LineIndex; -use ra_syntax::File; +use ra_syntax::{File, SyntaxNode}; use salsa; use crate::{ @@ -11,7 +11,7 @@ use crate::{ SubmodulesQuery, }, symbol_index::SymbolIndex, - syntax_ptr::{ResolveSyntaxPtrQuery, SyntaxPtrDatabase}, + syntax_ptr::SyntaxPtr, Cancelable, Canceled, FileId, }; @@ -62,6 +62,7 @@ salsa::database_storage! { fn file_syntax() for FileSyntaxQuery; fn file_lines() for FileLinesQuery; fn file_symbols() for FileSymbolsQuery; + fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery; } impl DescriptorDatabase { fn module_tree() for ModuleTreeQuery; @@ -70,9 +71,6 @@ salsa::database_storage! { fn fn_syntax() for FnSyntaxQuery; fn fn_scopes() for FnScopesQuery; } - impl SyntaxPtrDatabase { - fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery; - } } } @@ -87,6 +85,12 @@ salsa::query_group! { fn file_symbols(file_id: FileId) -> Cancelable> { type FileSymbolsQuery; } + fn resolve_syntax_ptr(ptr: SyntaxPtr) -> SyntaxNode { + type ResolveSyntaxPtrQuery; + // Don't retain syntax trees in memory + storage volatile; + use fn crate::syntax_ptr::resolve_syntax_ptr; + } } } 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::{ descriptors::function::{resolve_local_name, FnId, FnScopes}, descriptors::module::{ModuleId, ModuleScope, ModuleTree}, input::SourceRootId, - syntax_ptr::{LocalSyntaxPtr, SyntaxPtrDatabase}, + syntax_ptr::LocalSyntaxPtr, Cancelable, FileId, }; salsa::query_group! { - pub(crate) trait DescriptorDatabase: SyntaxDatabase + SyntaxPtrDatabase { + pub(crate) trait DescriptorDatabase: SyntaxDatabase { fn module_tree(source_root_id: SourceRootId) -> Cancelable> { type ModuleTreeQuery; 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::{ }, input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE}, symbol_index::SymbolIndex, - syntax_ptr::SyntaxPtrDatabase, AnalysisChange, Cancelable, CrateGraph, CrateId, Diagnostic, FileId, FileResolver, FileSystemEdit, Position, Query, SourceChange, SourceFileEdit, }; 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}; use crate::db::SyntaxDatabase; use crate::FileId; -salsa::query_group! { - pub(crate) trait SyntaxPtrDatabase: SyntaxDatabase { - fn resolve_syntax_ptr(ptr: SyntaxPtr) -> SyntaxNode { - type ResolveSyntaxPtrQuery; - // Don't retain syntax trees in memory - storage volatile; - } - } -} - -fn resolve_syntax_ptr(db: &impl SyntaxDatabase, ptr: SyntaxPtr) -> SyntaxNode { +pub(crate) fn resolve_syntax_ptr(db: &impl SyntaxDatabase, ptr: SyntaxPtr) -> SyntaxNode { let syntax = db.file_syntax(ptr.file_id); ptr.local.resolve(&syntax) } -- cgit v1.2.3