rename TreePtr -> TreeArc

This is much clearer about the semantics
This commit is contained in:
Aleksey Kladov 2019-01-11 19:59:06 +03:00
parent aad1bf877e
commit 2d3940d0ab
25 changed files with 197 additions and 197 deletions

6
Cargo.lock generated
View file

@ -760,7 +760,7 @@ dependencies = [
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_text_edit 0.1.0",
"rowan 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rowan 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smol_str 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0",
"text_unit 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -975,7 +975,7 @@ dependencies = [
[[package]]
name = "rowan"
version = "0.2.0"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1573,7 +1573,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c"
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
"checksum ron 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d9cb28ade964585205aaca1f3d41a6297f72e1ad097b49c4bbde033ef86b38d7"
"checksum rowan 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9ae7dba5e703f423ceb8646d636c73e6d858a2f8c834808b4565e42ccda9e2"
"checksum rowan 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4df666a130f870e6ac76fa525b0b6d984cfeee8f4cd675f2a125f0aced79c5f7"
"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619"
"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"

View file

@ -3,7 +3,7 @@ use std::{fs, io::Read, path::Path, time::Instant};
use clap::{App, Arg, SubCommand};
use join_to_string::join;
use ra_ide_api_light::{extend_selection, file_structure, syntax_tree};
use ra_syntax::{SourceFile, TextRange, TreePtr, AstNode};
use ra_syntax::{SourceFile, TextRange, TreeArc, AstNode};
use tools::collect_tests;
type Result<T> = ::std::result::Result<T, failure::Error>;
@ -71,7 +71,7 @@ fn main() -> Result<()> {
Ok(())
}
fn file() -> Result<TreePtr<SourceFile>> {
fn file() -> Result<TreeArc<SourceFile>> {
let text = read_stdin()?;
Ok(SourceFile::parse(&text))
}

View file

@ -7,7 +7,7 @@ pub mod mock;
use std::panic;
use ra_syntax::{TextUnit, TextRange, SourceFile, TreePtr};
use ra_syntax::{TextUnit, TextRange, SourceFile, TreeArc};
pub use crate::{
cancellation::{Canceled, Cancelable},
@ -40,13 +40,13 @@ pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe {
salsa::query_group! {
pub trait SyntaxDatabase: crate::input::FilesDatabase + BaseDatabase {
fn source_file(file_id: FileId) -> TreePtr<SourceFile> {
fn source_file(file_id: FileId) -> TreeArc<SourceFile> {
type SourceFileQuery;
}
}
}
fn source_file(db: &impl SyntaxDatabase, file_id: FileId) -> TreePtr<SourceFile> {
fn source_file(db: &impl SyntaxDatabase, file_id: FileId) -> TreeArc<SourceFile> {
let text = db.file_text(file_id);
SourceFile::parse(&*text)
}

View file

@ -1,4 +1,4 @@
use ra_syntax::{AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, TreePtr};
use ra_syntax::{AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, TreeArc};
/// A pointer to a syntax node inside a file.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@ -15,7 +15,7 @@ impl LocalSyntaxPtr {
}
}
pub fn resolve(self, file: &SourceFile) -> TreePtr<SyntaxNode> {
pub fn resolve(self, file: &SourceFile) -> TreeArc<SyntaxNode> {
let mut curr = file.syntax();
loop {
if curr.range() == self.range && curr.kind() == self.kind {

View file

@ -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))
}

View file

@ -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);

View file

@ -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))

View file

@ -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;
}

View file

@ -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 {

View file

@ -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.

View file

@ -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()
}

View file

@ -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

View file

@ -1,6 +1,6 @@
use ra_db::{Cancelable, SyntaxDatabase};
use ra_syntax::{
AstNode, SyntaxNode, TreePtr,
AstNode, SyntaxNode, TreeArc,
ast::{self, NameOwner},
algo::{find_covering_node, find_node_at_offset, find_leaf_at_offset, visit::{visitor, Visitor}},
};
@ -87,7 +87,7 @@ fn doc_text_for(db: &RootDatabase, nav: NavigationTarget) -> Cancelable<Option<S
}
impl NavigationTarget {
fn node(&self, db: &RootDatabase) -> Option<TreePtr<SyntaxNode>> {
fn node(&self, db: &RootDatabase) -> Option<TreeArc<SyntaxNode>> {
let source_file = db.source_file(self.file_id());
let source_file = source_file.syntax();
let node = source_file

View file

@ -35,7 +35,7 @@ mod parent_module;
use std::{fmt, sync::Arc};
use ra_syntax::{SourceFile, TreePtr, TextRange, TextUnit};
use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit};
use ra_text_edit::TextEdit;
use ra_db::{SyntaxDatabase, FilesDatabase, BaseDatabase};
use rayon::prelude::*;
@ -303,7 +303,7 @@ impl Analysis {
}
/// Gets the syntax tree of the file.
pub fn file_syntax(&self, file_id: FileId) -> TreePtr<SourceFile> {
pub fn file_syntax(&self, file_id: FileId) -> TreeArc<SourceFile> {
self.db.source_file(file_id).clone()
}

View file

@ -27,7 +27,7 @@ use std::{
use fst::{self, Streamer};
use ra_syntax::{
SyntaxNode, SourceFile, SmolStr, TreePtr, AstNode,
SyntaxNode, SourceFile, SmolStr, TreeArc, AstNode,
algo::{visit::{visitor, Visitor}, find_covering_node},
SyntaxKind::{self, *},
ast::{self, NameOwner},
@ -141,7 +141,7 @@ impl SymbolIndex {
}
pub(crate) fn for_files(
files: impl ParallelIterator<Item = (FileId, TreePtr<SourceFile>)>,
files: impl ParallelIterator<Item = (FileId, TreeArc<SourceFile>)>,
) -> SymbolIndex {
let symbols = files
.flat_map(|(file_id, file)| {

View file

@ -13,7 +13,7 @@ unicode-xid = "0.1.0"
itertools = "0.8.0"
drop_bomb = "0.1.4"
parking_lot = "0.7.0"
rowan = "0.2.0"
rowan = "0.3.0"
# ideally, `serde` should be enabled by `ra_lsp_serder`, but we enable it here
# to reduce number of compilations

View file

@ -6,7 +6,7 @@ use itertools::Itertools;
pub use self::generated::*;
use crate::{
yellow::{SyntaxNode, SyntaxNodeChildren, TreePtr, RaTypes},
yellow::{SyntaxNode, SyntaxNodeChildren, TreeArc, RaTypes},
SmolStr,
SyntaxKind::*,
};
@ -20,7 +20,7 @@ pub trait AstNode: rowan::TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>
where
Self: Sized;
fn syntax(&self) -> &SyntaxNode;
fn to_owned(&self) -> TreePtr<Self>;
fn to_owned(&self) -> TreeArc<Self>;
}
pub trait AstToken: AstNode {

View file

@ -13,7 +13,7 @@ use rowan::TransparentNewType;
use crate::{
SyntaxNode, SyntaxKind::*,
yellow::{RaTypes, TreePtr},
yellow::{RaTypes, TreeArc},
ast::{self, AstNode},
};
@ -35,7 +35,7 @@ impl AstNode for ArgList {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ArgList> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ArgList> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -63,7 +63,7 @@ impl AstNode for ArrayExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ArrayExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ArrayExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -87,7 +87,7 @@ impl AstNode for ArrayType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ArrayType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ArrayType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -119,7 +119,7 @@ impl AstNode for Attr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Attr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Attr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -147,7 +147,7 @@ impl AstNode for BinExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<BinExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<BinExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -171,7 +171,7 @@ impl AstNode for BindPat {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<BindPat> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<BindPat> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -196,7 +196,7 @@ impl AstNode for Block {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Block> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Block> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -228,7 +228,7 @@ impl AstNode for BlockExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<BlockExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<BlockExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -256,7 +256,7 @@ impl AstNode for BreakExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<BreakExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<BreakExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -284,7 +284,7 @@ impl AstNode for Byte {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Byte> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Byte> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -309,7 +309,7 @@ impl AstNode for ByteString {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ByteString> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ByteString> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -334,7 +334,7 @@ impl AstNode for CallExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<CallExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<CallExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -363,7 +363,7 @@ impl AstNode for CastExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<CastExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<CastExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -395,7 +395,7 @@ impl AstNode for Char {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Char> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Char> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -420,7 +420,7 @@ impl AstNode for Comment {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Comment> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Comment> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -445,7 +445,7 @@ impl AstNode for Condition {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Condition> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Condition> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -477,7 +477,7 @@ impl AstNode for ConstDef {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ConstDef> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ConstDef> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -506,7 +506,7 @@ impl AstNode for ContinueExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ContinueExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ContinueExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -530,7 +530,7 @@ impl AstNode for DynTraitType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<DynTraitType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<DynTraitType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -554,7 +554,7 @@ impl AstNode for EnumDef {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<EnumDef> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<EnumDef> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -587,7 +587,7 @@ impl AstNode for EnumVariant {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<EnumVariant> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<EnumVariant> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -616,7 +616,7 @@ impl AstNode for EnumVariantList {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<EnumVariantList> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<EnumVariantList> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -701,7 +701,7 @@ impl AstNode for Expr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Expr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Expr> { TreeArc::cast(self.syntax.to_owned()) }
}
impl Expr {
@ -759,7 +759,7 @@ impl AstNode for ExprStmt {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ExprStmt> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ExprStmt> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -787,7 +787,7 @@ impl AstNode for ExternCrateItem {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ExternCrateItem> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ExternCrateItem> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -811,7 +811,7 @@ impl AstNode for FieldExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<FieldExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<FieldExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -843,7 +843,7 @@ impl AstNode for FieldPatList {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<FieldPatList> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<FieldPatList> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -867,7 +867,7 @@ impl AstNode for FnDef {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<FnDef> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<FnDef> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -908,7 +908,7 @@ impl AstNode for FnPointerType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<FnPointerType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<FnPointerType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -940,7 +940,7 @@ impl AstNode for ForExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ForExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ForExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -973,7 +973,7 @@ impl AstNode for ForType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ForType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ForType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1001,7 +1001,7 @@ impl AstNode for IfExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<IfExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<IfExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1029,7 +1029,7 @@ impl AstNode for ImplBlock {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ImplBlock> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ImplBlock> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1066,7 +1066,7 @@ impl AstNode for ImplItem {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ImplItem> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ImplItem> { TreeArc::cast(self.syntax.to_owned()) }
}
impl ImplItem {
@ -1100,7 +1100,7 @@ impl AstNode for ImplTraitType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ImplTraitType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ImplTraitType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1124,7 +1124,7 @@ impl AstNode for IndexExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<IndexExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<IndexExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1148,7 +1148,7 @@ impl AstNode for ItemList {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ItemList> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ItemList> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1178,7 +1178,7 @@ impl AstNode for Label {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Label> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Label> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1202,7 +1202,7 @@ impl AstNode for LambdaExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<LambdaExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<LambdaExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1234,7 +1234,7 @@ impl AstNode for LetStmt {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<LetStmt> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<LetStmt> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1270,7 +1270,7 @@ impl AstNode for Lifetime {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Lifetime> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Lifetime> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1295,7 +1295,7 @@ impl AstNode for LifetimeParam {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<LifetimeParam> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<LifetimeParam> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1323,7 +1323,7 @@ impl AstNode for Literal {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Literal> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Literal> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1347,7 +1347,7 @@ impl AstNode for LoopExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<LoopExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<LoopExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1372,7 +1372,7 @@ impl AstNode for MacroCall {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<MacroCall> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<MacroCall> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1404,7 +1404,7 @@ impl AstNode for MatchArm {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<MatchArm> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<MatchArm> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1440,7 +1440,7 @@ impl AstNode for MatchArmList {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<MatchArmList> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<MatchArmList> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1468,7 +1468,7 @@ impl AstNode for MatchExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<MatchExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<MatchExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1500,7 +1500,7 @@ impl AstNode for MatchGuard {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<MatchGuard> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<MatchGuard> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1524,7 +1524,7 @@ impl AstNode for MethodCallExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<MethodCallExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<MethodCallExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1557,7 +1557,7 @@ impl AstNode for Module {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Module> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Module> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1614,7 +1614,7 @@ impl AstNode for ModuleItem {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ModuleItem> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ModuleItem> { TreeArc::cast(self.syntax.to_owned()) }
}
impl ModuleItem {
@ -1656,7 +1656,7 @@ impl AstNode for Name {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Name> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Name> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1680,7 +1680,7 @@ impl AstNode for NameRef {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<NameRef> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<NameRef> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1704,7 +1704,7 @@ impl AstNode for NamedField {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<NamedField> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<NamedField> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1736,7 +1736,7 @@ impl AstNode for NamedFieldDef {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<NamedFieldDef> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<NamedFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1767,7 +1767,7 @@ impl AstNode for NamedFieldDefList {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<NamedFieldDefList> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<NamedFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1795,7 +1795,7 @@ impl AstNode for NamedFieldList {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<NamedFieldList> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<NamedFieldList> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1823,7 +1823,7 @@ impl AstNode for NeverType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<NeverType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<NeverType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1854,7 +1854,7 @@ impl AstNode for NominalDef {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<NominalDef> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<NominalDef> { TreeArc::cast(self.syntax.to_owned()) }
}
impl NominalDef {
@ -1890,7 +1890,7 @@ impl AstNode for Param {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Param> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Param> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1922,7 +1922,7 @@ impl AstNode for ParamList {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ParamList> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ParamList> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1954,7 +1954,7 @@ impl AstNode for ParenExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ParenExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ParenExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -1982,7 +1982,7 @@ impl AstNode for ParenType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ParenType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ParenType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2033,7 +2033,7 @@ impl AstNode for Pat {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Pat> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Pat> { TreeArc::cast(self.syntax.to_owned()) }
}
impl Pat {
@ -2074,7 +2074,7 @@ impl AstNode for Path {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Path> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Path> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2106,7 +2106,7 @@ impl AstNode for PathExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<PathExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<PathExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2134,7 +2134,7 @@ impl AstNode for PathPat {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<PathPat> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<PathPat> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2158,7 +2158,7 @@ impl AstNode for PathSegment {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<PathSegment> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<PathSegment> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2186,7 +2186,7 @@ impl AstNode for PathType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<PathType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<PathType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2214,7 +2214,7 @@ impl AstNode for PlaceholderPat {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<PlaceholderPat> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<PlaceholderPat> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2238,7 +2238,7 @@ impl AstNode for PlaceholderType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<PlaceholderType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<PlaceholderType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2262,7 +2262,7 @@ impl AstNode for PointerType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<PointerType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<PointerType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2290,7 +2290,7 @@ impl AstNode for PosField {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<PosField> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<PosField> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2320,7 +2320,7 @@ impl AstNode for PosFieldList {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<PosFieldList> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<PosFieldList> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2348,7 +2348,7 @@ impl AstNode for PrefixExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<PrefixExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<PrefixExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2376,7 +2376,7 @@ impl AstNode for RangeExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<RangeExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<RangeExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2400,7 +2400,7 @@ impl AstNode for RangePat {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<RangePat> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<RangePat> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2424,7 +2424,7 @@ impl AstNode for RefExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<RefExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<RefExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2452,7 +2452,7 @@ impl AstNode for RefPat {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<RefPat> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<RefPat> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2476,7 +2476,7 @@ impl AstNode for ReferenceType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ReferenceType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ReferenceType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2504,7 +2504,7 @@ impl AstNode for RetType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<RetType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<RetType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2532,7 +2532,7 @@ impl AstNode for ReturnExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<ReturnExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<ReturnExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2560,7 +2560,7 @@ impl AstNode for SelfKw {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<SelfKw> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<SelfKw> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2584,7 +2584,7 @@ impl AstNode for SelfParam {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<SelfParam> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<SelfParam> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2616,7 +2616,7 @@ impl AstNode for SlicePat {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<SlicePat> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<SlicePat> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2640,7 +2640,7 @@ impl AstNode for SliceType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<SliceType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<SliceType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2668,7 +2668,7 @@ impl AstNode for SourceFile {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<SourceFile> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<SourceFile> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2698,7 +2698,7 @@ impl AstNode for StaticDef {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<StaticDef> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<StaticDef> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2734,7 +2734,7 @@ impl AstNode for Stmt {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Stmt> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Stmt> { TreeArc::cast(self.syntax.to_owned()) }
}
impl Stmt {
@ -2767,7 +2767,7 @@ impl AstNode for String {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<String> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<String> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2792,7 +2792,7 @@ impl AstNode for StructDef {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<StructDef> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<StructDef> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2821,7 +2821,7 @@ impl AstNode for StructLit {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<StructLit> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<StructLit> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2857,7 +2857,7 @@ impl AstNode for StructPat {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<StructPat> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<StructPat> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2881,7 +2881,7 @@ impl AstNode for TokenTree {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<TokenTree> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<TokenTree> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2905,7 +2905,7 @@ impl AstNode for TraitDef {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<TraitDef> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<TraitDef> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2933,7 +2933,7 @@ impl AstNode for TryExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<TryExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<TryExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2961,7 +2961,7 @@ impl AstNode for TupleExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<TupleExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<TupleExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -2985,7 +2985,7 @@ impl AstNode for TuplePat {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<TuplePat> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<TuplePat> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -3009,7 +3009,7 @@ impl AstNode for TupleStructPat {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<TupleStructPat> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<TupleStructPat> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -3041,7 +3041,7 @@ impl AstNode for TupleType {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<TupleType> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<TupleType> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -3069,7 +3069,7 @@ impl AstNode for TypeDef {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<TypeDef> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<TypeDef> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -3098,7 +3098,7 @@ impl AstNode for TypeParam {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<TypeParam> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<TypeParam> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -3123,7 +3123,7 @@ impl AstNode for TypeParamList {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<TypeParamList> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<TypeParamList> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -3184,7 +3184,7 @@ impl AstNode for TypeRef {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<TypeRef> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<TypeRef> { TreeArc::cast(self.syntax.to_owned()) }
}
impl TypeRef {
@ -3228,7 +3228,7 @@ impl AstNode for UseItem {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<UseItem> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<UseItem> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -3256,7 +3256,7 @@ impl AstNode for UseTree {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<UseTree> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<UseTree> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -3288,7 +3288,7 @@ impl AstNode for UseTreeList {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<UseTreeList> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<UseTreeList> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -3316,7 +3316,7 @@ impl AstNode for Visibility {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Visibility> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Visibility> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -3340,7 +3340,7 @@ impl AstNode for WhereClause {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<WhereClause> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<WhereClause> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -3364,7 +3364,7 @@ impl AstNode for WhileExpr {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<WhileExpr> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) }
}
@ -3393,7 +3393,7 @@ impl AstNode for Whitespace {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<Whitespace> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<Whitespace> { TreeArc::cast(self.syntax.to_owned()) }
}

View file

@ -15,7 +15,7 @@ use rowan::TransparentNewType;
use crate::{
SyntaxNode, SyntaxKind::*,
yellow::{RaTypes, TreePtr},
yellow::{RaTypes, TreeArc},
ast::{self, AstNode},
};
{% for node, methods in ast %}
@ -48,7 +48,7 @@ impl AstNode for {{ node }} {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<{{ node }}> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<{{ node }}> { TreeArc::cast(self.syntax.to_owned()) }
}
impl {{ node }} {
@ -79,7 +79,7 @@ impl AstNode for {{ node }} {
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
fn to_owned(&self) -> TreePtr<{{ node }}> { TreePtr::cast(self.syntax.to_owned()) }
fn to_owned(&self) -> TreeArc<{{ node }}> { TreeArc::cast(self.syntax.to_owned()) }
}
{% endif %}

View file

@ -41,7 +41,7 @@ pub use crate::{
ast::AstNode,
lexer::{tokenize, Token},
syntax_kinds::SyntaxKind,
yellow::{Direction, SyntaxError, SyntaxNode, WalkEvent, Location, TreePtr},
yellow::{Direction, SyntaxError, SyntaxNode, WalkEvent, Location, TreeArc},
};
use ra_text_edit::AtomTextEdit;
@ -51,29 +51,29 @@ use crate::yellow::GreenNode;
pub use crate::ast::SourceFile;
impl SourceFile {
fn new(green: GreenNode, errors: Vec<SyntaxError>) -> TreePtr<SourceFile> {
fn new(green: GreenNode, errors: Vec<SyntaxError>) -> TreeArc<SourceFile> {
let root = SyntaxNode::new(green, errors);
if cfg!(debug_assertions) {
utils::validate_block_structure(&root);
}
assert_eq!(root.kind(), SyntaxKind::SOURCE_FILE);
TreePtr::cast(root)
TreeArc::cast(root)
}
pub fn parse(text: &str) -> TreePtr<SourceFile> {
pub fn parse(text: &str) -> TreeArc<SourceFile> {
let tokens = tokenize(&text);
let (green, errors) =
parser_impl::parse_with(yellow::GreenBuilder::new(), text, &tokens, grammar::root);
SourceFile::new(green, errors)
}
pub fn reparse(&self, edit: &AtomTextEdit) -> TreePtr<SourceFile> {
pub fn reparse(&self, edit: &AtomTextEdit) -> TreeArc<SourceFile> {
self.incremental_reparse(edit)
.unwrap_or_else(|| self.full_reparse(edit))
}
pub fn incremental_reparse(&self, edit: &AtomTextEdit) -> Option<TreePtr<SourceFile>> {
pub fn incremental_reparse(&self, edit: &AtomTextEdit) -> Option<TreeArc<SourceFile>> {
reparsing::incremental_reparse(self.syntax(), edit, self.errors())
.map(|(green_node, errors)| SourceFile::new(green_node, errors))
}
fn full_reparse(&self, edit: &AtomTextEdit) -> TreePtr<SourceFile> {
fn full_reparse(&self, edit: &AtomTextEdit) -> TreeArc<SourceFile> {
let text = edit.apply(self.syntax().text().to_string());
SourceFile::parse(&text)
}

View file

@ -106,9 +106,9 @@ fn validate_byte_code_escape(text: &str, range: TextRange, errors: &mut Vec<Synt
#[cfg(test)]
mod test {
use crate::{SourceFile, TreePtr};
use crate::{SourceFile, TreeArc};
fn build_file(literal: &str) -> TreePtr<SourceFile> {
fn build_file(literal: &str) -> TreeArc<SourceFile> {
let src = format!("const C: u8 = b'{}';", literal);
SourceFile::parse(&src)
}

View file

@ -43,9 +43,9 @@ pub(crate) fn validate_byte_string_node(node: &ast::ByteString, errors: &mut Vec
#[cfg(test)]
mod test {
use crate::{SourceFile, TreePtr};
use crate::{SourceFile, TreeArc};
fn build_file(literal: &str) -> TreePtr<SourceFile> {
fn build_file(literal: &str) -> TreeArc<SourceFile> {
let src = format!(r#"const S: &'static [u8] = b"{}";"#, literal);
println!("Source: {}", src);
SourceFile::parse(&src)

View file

@ -175,9 +175,9 @@ fn validate_unicode_escape(text: &str, range: TextRange, errors: &mut Vec<Syntax
#[cfg(test)]
mod test {
use crate::{SourceFile, TreePtr};
use crate::{SourceFile, TreeArc};
fn build_file(literal: &str) -> TreePtr<SourceFile> {
fn build_file(literal: &str) -> TreeArc<SourceFile> {
let src = format!("const C: char = '{}';", literal);
SourceFile::parse(&src)
}

View file

@ -38,9 +38,9 @@ pub(crate) fn validate_string_node(node: &ast::String, errors: &mut Vec<SyntaxEr
#[cfg(test)]
mod test {
use crate::{SourceFile, TreePtr};
use crate::{SourceFile, TreeArc};
fn build_file(literal: &str) -> TreePtr<SourceFile> {
fn build_file(literal: &str) -> TreeArc<SourceFile> {
let src = format!(r#"const S: &'static str = "{}";"#, literal);
println!("Source: {}", src);
SourceFile::parse(&src)

View file

@ -21,23 +21,23 @@ impl Types for RaTypes {
pub type GreenNode = rowan::GreenNode<RaTypes>;
#[derive(PartialEq, Eq, Hash)]
pub struct TreePtr<T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>>(
pub(crate) rowan::TreePtr<RaTypes, T>,
pub struct TreeArc<T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>>(
pub(crate) rowan::TreeArc<RaTypes, T>,
);
impl<T> TreePtr<T>
impl<T> TreeArc<T>
where
T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>,
{
pub(crate) fn cast<U>(this: TreePtr<T>) -> TreePtr<U>
pub(crate) fn cast<U>(this: TreeArc<T>) -> TreeArc<U>
where
U: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>,
{
TreePtr(rowan::TreePtr::cast(this.0))
TreeArc(rowan::TreeArc::cast(this.0))
}
}
impl<T> std::ops::Deref for TreePtr<T>
impl<T> std::ops::Deref for TreeArc<T>
where
T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>,
{
@ -47,7 +47,7 @@ where
}
}
impl<T> PartialEq<T> for TreePtr<T>
impl<T> PartialEq<T> for TreeArc<T>
where
T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>,
T: PartialEq<T>,
@ -58,16 +58,16 @@ where
}
}
impl<T> Clone for TreePtr<T>
impl<T> Clone for TreeArc<T>
where
T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>,
{
fn clone(&self) -> TreePtr<T> {
TreePtr(self.0.clone())
fn clone(&self) -> TreeArc<T> {
TreeArc(self.0.clone())
}
}
impl<T> fmt::Debug for TreePtr<T>
impl<T> fmt::Debug for TreeArc<T>
where
T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>,
T: fmt::Debug,
@ -85,9 +85,9 @@ unsafe impl TransparentNewType for SyntaxNode {
}
impl SyntaxNode {
pub(crate) fn new(green: GreenNode, errors: Vec<SyntaxError>) -> TreePtr<SyntaxNode> {
let ptr = TreePtr(rowan::SyntaxNode::new(green, errors));
TreePtr::cast(ptr)
pub(crate) fn new(green: GreenNode, errors: Vec<SyntaxError>) -> TreeArc<SyntaxNode> {
let ptr = TreeArc(rowan::SyntaxNode::new(green, errors));
TreeArc::cast(ptr)
}
}
@ -131,9 +131,9 @@ impl SyntaxNode {
pub(crate) fn replace_with(&self, replacement: GreenNode) -> GreenNode {
self.0.replace_self(replacement)
}
pub fn to_owned(&self) -> TreePtr<SyntaxNode> {
let ptr = TreePtr(self.0.to_owned());
TreePtr::cast(ptr)
pub fn to_owned(&self) -> TreeArc<SyntaxNode> {
let ptr = TreeArc(self.0.to_owned());
TreeArc::cast(ptr)
}
pub fn kind(&self) -> SyntaxKind {
self.0.kind()