From 2d3940d0ab862dbfaed4f4c844faaca6a38e31e9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 11 Jan 2019 19:59:06 +0300 Subject: rename TreePtr -> TreeArc This is much clearer about the semantics --- crates/ra_hir/src/code_model_api.rs | 18 +++++++++--------- crates/ra_hir/src/code_model_impl/function.rs | 4 ++-- crates/ra_hir/src/code_model_impl/module.rs | 6 +++--- crates/ra_hir/src/db.rs | 6 +++--- crates/ra_hir/src/ids.rs | 10 +++++----- crates/ra_hir/src/macros.rs | 6 +++--- crates/ra_hir/src/module_tree.rs | 6 +++--- crates/ra_hir/src/query_definitions.rs | 4 ++-- 8 files changed, 30 insertions(+), 30 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 8ec6b9b2b..098c7f40b 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use relative_path::RelativePathBuf; use ra_db::{CrateId, Cancelable, FileId}; -use ra_syntax::{ast, TreePtr, SyntaxNode, AstNode}; +use ra_syntax::{ast, TreeArc, SyntaxNode, AstNode}; use crate::{ Name, DefId, Path, PerNs, ScopesWithSyntaxMapping, Ty, HirFileId, @@ -55,8 +55,8 @@ pub struct Module { } pub enum ModuleSource { - SourceFile(TreePtr), - Module(TreePtr), + SourceFile(TreeArc), + Module(TreeArc), } #[derive(Clone, Debug, Hash, PartialEq, Eq)] @@ -86,7 +86,7 @@ impl Module { pub fn declaration_source( &self, db: &impl HirDatabase, - ) -> Cancelable)>> { + ) -> Cancelable)>> { self.declaration_source_impl(db) } @@ -134,7 +134,7 @@ impl Module { pub fn problems( &self, db: &impl HirDatabase, - ) -> Cancelable, Problem)>> { + ) -> Cancelable, Problem)>> { self.problems_impl(db) } } @@ -185,7 +185,7 @@ impl Struct { pub fn source( &self, db: &impl HirDatabase, - ) -> Cancelable<(HirFileId, TreePtr)> { + ) -> Cancelable<(HirFileId, TreeArc)> { let (file_id, syntax) = self.def_id.source(db); Ok(( file_id, @@ -218,7 +218,7 @@ impl Enum { Ok(db.enum_data(self.def_id)?.variants.clone()) } - pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreePtr)> { + pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc)> { let (file_id, syntax) = self.def_id.source(db); Ok(( file_id, @@ -258,7 +258,7 @@ impl EnumVariant { pub fn source( &self, db: &impl HirDatabase, - ) -> Cancelable<(HirFileId, TreePtr)> { + ) -> Cancelable<(HirFileId, TreeArc)> { let (file_id, syntax) = self.def_id.source(db); Ok(( file_id, @@ -303,7 +303,7 @@ impl Function { self.def_id } - pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreePtr)> { + pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc)> { Ok(self.source_impl(db)) } diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs index 009175bab..daf49e791 100644 --- a/crates/ra_hir/src/code_model_impl/function.rs +++ b/crates/ra_hir/src/code_model_impl/function.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use ra_db::Cancelable; use ra_syntax::{ - TreePtr, + TreeArc, ast::{self, AstNode, NameOwner}, }; @@ -22,7 +22,7 @@ impl Function { Function { def_id } } - pub(crate) fn source_impl(&self, db: &impl HirDatabase) -> (HirFileId, TreePtr) { + pub(crate) fn source_impl(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc) { let def_loc = self.def_id.loc(db); assert!(def_loc.kind == DefKind::Function); let syntax = db.file_item(def_loc.source_item_id); diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index 878dc37c8..e9ff06dc8 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs @@ -1,5 +1,5 @@ use ra_db::{Cancelable, SourceRootId, FileId}; -use ra_syntax::{ast, SyntaxNode, AstNode, TreePtr}; +use ra_syntax::{ast, SyntaxNode, AstNode, TreeArc}; use crate::{ Module, ModuleSource, Problem, @@ -57,7 +57,7 @@ impl Module { pub fn declaration_source_impl( &self, db: &impl HirDatabase, - ) -> Cancelable)>> { + ) -> Cancelable)>> { let loc = self.def_id.loc(db); let module_tree = db.module_tree(loc.source_root_id)?; let link = ctry!(loc.module_id.parent_link(&module_tree)); @@ -173,7 +173,7 @@ impl Module { pub fn problems_impl( &self, db: &impl HirDatabase, - ) -> Cancelable, Problem)>> { + ) -> Cancelable, Problem)>> { let loc = self.def_id.loc(db); let module_tree = db.module_tree(loc.source_root_id)?; Ok(loc.module_id.problems(&module_tree, db)) diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 9a6ef8083..a11c73db0 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use ra_syntax::{SyntaxNode, TreePtr, SourceFile}; +use ra_syntax::{SyntaxNode, TreeArc, SourceFile}; use ra_db::{SourceRootId, LocationIntener, SyntaxDatabase, Cancelable}; use crate::{ @@ -22,7 +22,7 @@ pub trait HirDatabase: SyntaxDatabase + AsRef> + AsRef> { - fn hir_source_file(file_id: HirFileId) -> TreePtr { + fn hir_source_file(file_id: HirFileId) -> TreeArc { type HirSourceFileQuery; use fn HirFileId::hir_source_file; } @@ -72,7 +72,7 @@ pub trait HirDatabase: SyntaxDatabase use fn query_definitions::file_items; } - fn file_item(source_item_id: SourceItemId) -> TreePtr { + fn file_item(source_item_id: SourceItemId) -> TreeArc { type FileItemQuery; use fn query_definitions::file_item; } diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index c75ef4ae7..0805fd3db 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -1,5 +1,5 @@ use ra_db::{SourceRootId, LocationIntener, Cancelable, FileId}; -use ra_syntax::{TreePtr, SyntaxKind, SyntaxNode, SourceFile, AstNode, ast}; +use ra_syntax::{TreeArc, SyntaxKind, SyntaxNode, SourceFile, AstNode, ast}; use ra_arena::{Arena, RawId, impl_arena_id}; use crate::{ @@ -61,7 +61,7 @@ impl HirFileId { pub(crate) fn hir_source_file( db: &impl HirDatabase, file_id: HirFileId, - ) -> TreePtr { + ) -> TreeArc { match file_id.0 { HirFileIdRepr::File(file_id) => db.source_file(file_id), HirFileIdRepr::Macro(m) => { @@ -179,7 +179,7 @@ impl DefId { Ok(res) } - pub(crate) fn source(self, db: &impl HirDatabase) -> (HirFileId, TreePtr) { + pub(crate) fn source(self, db: &impl HirDatabase) -> (HirFileId, TreeArc) { let loc = self.loc(db); let syntax = db.file_item(loc.source_item_id); (loc.source_item_id.file_id, syntax) @@ -244,7 +244,7 @@ pub struct SourceItemId { #[derive(Debug, PartialEq, Eq)] pub struct SourceFileItems { file_id: HirFileId, - arena: Arena>, + arena: Arena>, } impl SourceFileItems { @@ -273,7 +273,7 @@ impl SourceFileItems { }) } - fn alloc(&mut self, item: TreePtr) -> SourceFileItemId { + fn alloc(&mut self, item: TreeArc) -> SourceFileItemId { self.arena.alloc(item) } pub(crate) fn id_of(&self, file_id: HirFileId, item: &SyntaxNode) -> SourceFileItemId { diff --git a/crates/ra_hir/src/macros.rs b/crates/ra_hir/src/macros.rs index e455b2ad5..220bee94e 100644 --- a/crates/ra_hir/src/macros.rs +++ b/crates/ra_hir/src/macros.rs @@ -11,7 +11,7 @@ use std::sync::Arc; use ra_db::LocalSyntaxPtr; use ra_syntax::{ - TextRange, TextUnit, SourceFile, AstNode, SyntaxNode, TreePtr, + TextRange, TextUnit, SourceFile, AstNode, SyntaxNode, TreeArc, ast::{self, NameOwner}, }; @@ -152,11 +152,11 @@ pub struct MacroExpansion { impl MacroExpansion { // FIXME: does not really make sense, macro expansion is not neccessary a // whole file. See `MacroExpansion::ptr` as well. - pub(crate) fn file(&self) -> TreePtr { + pub(crate) fn file(&self) -> TreeArc { SourceFile::parse(&self.text) } - pub fn syntax(&self) -> TreePtr { + pub fn syntax(&self) -> TreeArc { self.ptr.resolve(&self.file()) } /// Maps range in the source code to the range in the expanded code. diff --git a/crates/ra_hir/src/module_tree.rs b/crates/ra_hir/src/module_tree.rs index 50383c6d8..67823e970 100644 --- a/crates/ra_hir/src/module_tree.rs +++ b/crates/ra_hir/src/module_tree.rs @@ -5,7 +5,7 @@ use arrayvec::ArrayVec; use relative_path::RelativePathBuf; use ra_db::{FileId, SourceRootId, Cancelable, SourceRoot}; use ra_syntax::{ - SyntaxNode, TreePtr, + SyntaxNode, TreeArc, algo::generate, ast::{self, AstNode, NameOwner}, }; @@ -170,7 +170,7 @@ impl ModuleId { self, tree: &ModuleTree, db: &impl HirDatabase, - ) -> Vec<(TreePtr, Problem)> { + ) -> Vec<(TreeArc, Problem)> { tree.mods[self] .children .iter() @@ -191,7 +191,7 @@ impl LinkId { pub(crate) fn name(self, tree: &ModuleTree) -> &Name { &tree.links[self].name } - pub(crate) fn source(self, tree: &ModuleTree, db: &impl HirDatabase) -> TreePtr { + pub(crate) fn source(self, tree: &ModuleTree, db: &impl HirDatabase) -> TreeArc { let syntax_node = db.file_item(tree.links[self].source); ast::Module::cast(&syntax_node).unwrap().to_owned() } diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index 32be23d8c..214a9d68b 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs @@ -5,7 +5,7 @@ use std::{ use rustc_hash::FxHashMap; use ra_syntax::{ - AstNode, SyntaxNode, TreePtr, + AstNode, SyntaxNode, TreeArc, ast::{self, ModuleItemOwner} }; use ra_db::{SourceRootId, Cancelable,}; @@ -33,7 +33,7 @@ pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc TreePtr { +) -> TreeArc { match source_item_id.item_id { Some(id) => db.file_items(source_item_id.file_id)[id].to_owned(), None => db -- cgit v1.2.3