aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-11-27 23:15:21 +0000
committerAleksey Kladov <[email protected]>2018-11-27 23:15:21 +0000
commit201aa7ea2ae75f9599dc74ad2f4d3f41c1540e73 (patch)
tree56fdc206dc7ba7b6654e53b836afae6ddc3f2acc /crates
parentc2abd17f57fa14960e8a175bdabe49eb365a585f (diff)
remove syntax ptr
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_analysis/src/db.rs10
-rw-r--r--crates/ra_analysis/src/syntax_ptr.rs17
2 files changed, 1 insertions, 26 deletions
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs
index 97f170473..4c9c84e4f 100644
--- a/crates/ra_analysis/src/db.rs
+++ b/crates/ra_analysis/src/db.rs
@@ -2,13 +2,12 @@ use std::sync::Arc;
2#[cfg(test)] 2#[cfg(test)]
3use parking_lot::Mutex; 3use parking_lot::Mutex;
4use ra_editor::LineIndex; 4use ra_editor::LineIndex;
5use ra_syntax::{SourceFileNode, SyntaxNode}; 5use ra_syntax::{SourceFileNode};
6use salsa::{self, Database}; 6use salsa::{self, Database};
7 7
8use crate::{ 8use crate::{
9 hir, 9 hir,
10 symbol_index::SymbolIndex, 10 symbol_index::SymbolIndex,
11 syntax_ptr::SyntaxPtr,
12 loc2id::{IdMaps}, 11 loc2id::{IdMaps},
13 Cancelable, Canceled, FileId, 12 Cancelable, Canceled, FileId,
14}; 13};
@@ -122,7 +121,6 @@ salsa::database_storage! {
122 fn file_syntax() for FileSyntaxQuery; 121 fn file_syntax() for FileSyntaxQuery;
123 fn file_lines() for FileLinesQuery; 122 fn file_lines() for FileLinesQuery;
124 fn file_symbols() for FileSymbolsQuery; 123 fn file_symbols() for FileSymbolsQuery;
125 fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery;
126 } 124 }
127 impl hir::db::HirDatabase { 125 impl hir::db::HirDatabase {
128 fn module_tree() for hir::db::ModuleTreeQuery; 126 fn module_tree() for hir::db::ModuleTreeQuery;
@@ -148,12 +146,6 @@ salsa::query_group! {
148 fn file_symbols(file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { 146 fn file_symbols(file_id: FileId) -> Cancelable<Arc<SymbolIndex>> {
149 type FileSymbolsQuery; 147 type FileSymbolsQuery;
150 } 148 }
151 fn resolve_syntax_ptr(ptr: SyntaxPtr) -> SyntaxNode {
152 type ResolveSyntaxPtrQuery;
153 // Don't retain syntax trees in memory
154 storage dependencies;
155 use fn crate::syntax_ptr::resolve_syntax_ptr;
156 }
157 } 149 }
158} 150}
159 151
diff --git a/crates/ra_analysis/src/syntax_ptr.rs b/crates/ra_analysis/src/syntax_ptr.rs
index 7bbf1fc33..f4b05fc19 100644
--- a/crates/ra_analysis/src/syntax_ptr.rs
+++ b/crates/ra_analysis/src/syntax_ptr.rs
@@ -1,22 +1,5 @@
1use ra_syntax::{SourceFileNode, SyntaxKind, SyntaxNode, SyntaxNodeRef, TextRange}; 1use ra_syntax::{SourceFileNode, SyntaxKind, SyntaxNode, SyntaxNodeRef, TextRange};
2 2
3use crate::db::SyntaxDatabase;
4use crate::FileId;
5
6pub(crate) fn resolve_syntax_ptr(db: &impl SyntaxDatabase, ptr: SyntaxPtr) -> SyntaxNode {
7 let syntax = db.file_syntax(ptr.file_id);
8 ptr.local.resolve(&syntax)
9}
10
11/// SyntaxPtr is a cheap `Copy` id which identifies a particular syntax node,
12/// without retaining syntax tree in memory. You need to explicitly `resolve`
13/// `SyntaxPtr` to get a `SyntaxNode`
14#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
15pub(crate) struct SyntaxPtr {
16 file_id: FileId,
17 local: LocalSyntaxPtr,
18}
19
20/// A pionter to a syntax node inside a file. 3/// A pionter to a syntax node inside a file.
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
22pub(crate) struct LocalSyntaxPtr { 5pub(crate) struct LocalSyntaxPtr {