remove syntax ptr

This commit is contained in:
Aleksey Kladov 2018-11-28 02:15:21 +03:00
parent c2abd17f57
commit 201aa7ea2a
2 changed files with 1 additions and 26 deletions

View file

@ -2,13 +2,12 @@ use std::sync::Arc;
#[cfg(test)]
use parking_lot::Mutex;
use ra_editor::LineIndex;
use ra_syntax::{SourceFileNode, SyntaxNode};
use ra_syntax::{SourceFileNode};
use salsa::{self, Database};
use crate::{
hir,
symbol_index::SymbolIndex,
syntax_ptr::SyntaxPtr,
loc2id::{IdMaps},
Cancelable, Canceled, FileId,
};
@ -122,7 +121,6 @@ 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 hir::db::HirDatabase {
fn module_tree() for hir::db::ModuleTreeQuery;
@ -148,12 +146,6 @@ salsa::query_group! {
fn file_symbols(file_id: FileId) -> Cancelable<Arc<SymbolIndex>> {
type FileSymbolsQuery;
}
fn resolve_syntax_ptr(ptr: SyntaxPtr) -> SyntaxNode {
type ResolveSyntaxPtrQuery;
// Don't retain syntax trees in memory
storage dependencies;
use fn crate::syntax_ptr::resolve_syntax_ptr;
}
}
}

View file

@ -1,22 +1,5 @@
use ra_syntax::{SourceFileNode, SyntaxKind, SyntaxNode, SyntaxNodeRef, TextRange};
use crate::db::SyntaxDatabase;
use crate::FileId;
pub(crate) fn resolve_syntax_ptr(db: &impl SyntaxDatabase, ptr: SyntaxPtr) -> SyntaxNode {
let syntax = db.file_syntax(ptr.file_id);
ptr.local.resolve(&syntax)
}
/// SyntaxPtr is a cheap `Copy` id which identifies a particular syntax node,
/// without retaining syntax tree in memory. You need to explicitly `resolve`
/// `SyntaxPtr` to get a `SyntaxNode`
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub(crate) struct SyntaxPtr {
file_id: FileId,
local: LocalSyntaxPtr,
}
/// A pionter to a syntax node inside a file.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub(crate) struct LocalSyntaxPtr {