From 5e7f4202cf4d64f565d6d035cd2e854acfc336ab Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 28 Nov 2018 01:45:36 +0300 Subject: Move FileItems up --- crates/ra_analysis/src/hir/module/nameres.rs | 36 ++-------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) (limited to 'crates/ra_analysis/src/hir/module') diff --git a/crates/ra_analysis/src/hir/module/nameres.rs b/crates/ra_analysis/src/hir/module/nameres.rs index d38940085..f7d8c8e8c 100644 --- a/crates/ra_analysis/src/hir/module/nameres.rs +++ b/crates/ra_analysis/src/hir/module/nameres.rs @@ -16,13 +16,12 @@ //! structure itself is modified. use std::{ sync::Arc, - ops::Index, }; use rustc_hash::FxHashMap; use ra_syntax::{ - SyntaxNode, SyntaxNodeRef, TextRange, + TextRange, SmolStr, SyntaxKind::{self, *}, ast::{self, AstNode} }; @@ -31,45 +30,14 @@ use crate::{ Cancelable, FileId, loc2id::{DefId, DefLoc}, hir::{ + FileItemId, FileItems, Path, PathKind, HirDatabase, module::{ModuleId, ModuleTree}, }, input::SourceRootId, - arena::{Arena, Id} }; -/// Identifier of item within a specific file. This is stable over reparses, so -/// it's OK to use it as a salsa key/value. -pub(crate) type FileItemId = Id; - -/// Maps item's `SyntaxNode`s to `FileItemId` and back. -#[derive(Debug, PartialEq, Eq, Default)] -pub(crate) struct FileItems { - arena: Arena, -} - -impl FileItems { - pub(crate) fn alloc(&mut self, item: SyntaxNode) -> FileItemId { - self.arena.alloc(item) - } - fn id_of(&self, item: SyntaxNodeRef) -> FileItemId { - let (id, _item) = self - .arena - .iter() - .find(|(_id, i)| i.borrowed() == item) - .unwrap(); - id - } -} - -impl Index for FileItems { - type Output = SyntaxNode; - fn index(&self, idx: FileItemId) -> &SyntaxNode { - &self.arena[idx] - } -} - /// Item map is the result of the name resolution. Item map contains, for each /// module, the set of visible items. #[derive(Default, Debug, PartialEq, Eq)] -- cgit v1.2.3