mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
rename TreePtr -> TreeArc
This is much clearer about the semantics
This commit is contained in:
parent
aad1bf877e
commit
2d3940d0ab
25 changed files with 197 additions and 197 deletions
|
@ -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<ast::SourceFile>),
|
||||
Module(TreePtr<ast::Module>),
|
||||
SourceFile(TreeArc<ast::SourceFile>),
|
||||
Module(TreeArc<ast::Module>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
||||
|
@ -86,7 +86,7 @@ impl Module {
|
|||
pub fn declaration_source(
|
||||
&self,
|
||||
db: &impl HirDatabase,
|
||||
) -> Cancelable<Option<(FileId, TreePtr<ast::Module>)>> {
|
||||
) -> Cancelable<Option<(FileId, TreeArc<ast::Module>)>> {
|
||||
self.declaration_source_impl(db)
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ impl Module {
|
|||
pub fn problems(
|
||||
&self,
|
||||
db: &impl HirDatabase,
|
||||
) -> Cancelable<Vec<(TreePtr<SyntaxNode>, Problem)>> {
|
||||
) -> Cancelable<Vec<(TreeArc<SyntaxNode>, Problem)>> {
|
||||
self.problems_impl(db)
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ impl Struct {
|
|||
pub fn source(
|
||||
&self,
|
||||
db: &impl HirDatabase,
|
||||
) -> Cancelable<(HirFileId, TreePtr<ast::StructDef>)> {
|
||||
) -> Cancelable<(HirFileId, TreeArc<ast::StructDef>)> {
|
||||
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<ast::EnumDef>)> {
|
||||
pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::EnumDef>)> {
|
||||
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<ast::EnumVariant>)> {
|
||||
) -> Cancelable<(HirFileId, TreeArc<ast::EnumVariant>)> {
|
||||
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<ast::FnDef>)> {
|
||||
pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::FnDef>)> {
|
||||
Ok(self.source_impl(db))
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ast::FnDef>) {
|
||||
pub(crate) fn source_impl(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::FnDef>) {
|
||||
let def_loc = self.def_id.loc(db);
|
||||
assert!(def_loc.kind == DefKind::Function);
|
||||
let syntax = db.file_item(def_loc.source_item_id);
|
||||
|
|
|
@ -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<Option<(FileId, TreePtr<ast::Module>)>> {
|
||||
) -> Cancelable<Option<(FileId, TreeArc<ast::Module>)>> {
|
||||
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<Vec<(TreePtr<SyntaxNode>, Problem)>> {
|
||||
) -> Cancelable<Vec<(TreeArc<SyntaxNode>, 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))
|
||||
|
|
|
@ -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<LocationIntener<DefLoc, DefId>>
|
||||
+ AsRef<LocationIntener<MacroCallLoc, MacroCallId>>
|
||||
{
|
||||
fn hir_source_file(file_id: HirFileId) -> TreePtr<SourceFile> {
|
||||
fn hir_source_file(file_id: HirFileId) -> TreeArc<SourceFile> {
|
||||
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<SyntaxNode> {
|
||||
fn file_item(source_item_id: SourceItemId) -> TreeArc<SyntaxNode> {
|
||||
type FileItemQuery;
|
||||
use fn query_definitions::file_item;
|
||||
}
|
||||
|
|
|
@ -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<SourceFile> {
|
||||
) -> TreeArc<SourceFile> {
|
||||
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<SyntaxNode>) {
|
||||
pub(crate) fn source(self, db: &impl HirDatabase) -> (HirFileId, TreeArc<SyntaxNode>) {
|
||||
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<SourceFileItemId, TreePtr<SyntaxNode>>,
|
||||
arena: Arena<SourceFileItemId, TreeArc<SyntaxNode>>,
|
||||
}
|
||||
|
||||
impl SourceFileItems {
|
||||
|
@ -273,7 +273,7 @@ impl SourceFileItems {
|
|||
})
|
||||
}
|
||||
|
||||
fn alloc(&mut self, item: TreePtr<SyntaxNode>) -> SourceFileItemId {
|
||||
fn alloc(&mut self, item: TreeArc<SyntaxNode>) -> SourceFileItemId {
|
||||
self.arena.alloc(item)
|
||||
}
|
||||
pub(crate) fn id_of(&self, file_id: HirFileId, item: &SyntaxNode) -> SourceFileItemId {
|
||||
|
|
|
@ -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<SourceFile> {
|
||||
pub(crate) fn file(&self) -> TreeArc<SourceFile> {
|
||||
SourceFile::parse(&self.text)
|
||||
}
|
||||
|
||||
pub fn syntax(&self) -> TreePtr<SyntaxNode> {
|
||||
pub fn syntax(&self) -> TreeArc<SyntaxNode> {
|
||||
self.ptr.resolve(&self.file())
|
||||
}
|
||||
/// Maps range in the source code to the range in the expanded code.
|
||||
|
|
|
@ -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<SyntaxNode>, Problem)> {
|
||||
) -> Vec<(TreeArc<SyntaxNode>, 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<ast::Module> {
|
||||
pub(crate) fn source(self, tree: &ModuleTree, db: &impl HirDatabase) -> TreeArc<ast::Module> {
|
||||
let syntax_node = db.file_item(tree.links[self].source);
|
||||
ast::Module::cast(&syntax_node).unwrap().to_owned()
|
||||
}
|
||||
|
|
|
@ -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<Sourc
|
|||
pub(super) fn file_item(
|
||||
db: &impl HirDatabase,
|
||||
source_item_id: SourceItemId,
|
||||
) -> TreePtr<SyntaxNode> {
|
||||
) -> TreeArc<SyntaxNode> {
|
||||
match source_item_id.item_id {
|
||||
Some(id) => db.file_items(source_item_id.file_id)[id].to_owned(),
|
||||
None => db
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue