aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs86
1 files changed, 43 insertions, 43 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 8cf3222f7..5b5f71ee7 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -3016,49 +3016,6 @@ impl<R: TreeRoot<RaTypes>> ReturnExprNode<R> {
3016 3016
3017impl<'a> ReturnExpr<'a> {} 3017impl<'a> ReturnExpr<'a> {}
3018 3018
3019// Root
3020#[derive(Debug, Clone, Copy,)]
3021pub struct RootNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3022 pub(crate) syntax: SyntaxNode<R>,
3023}
3024pub type Root<'a> = RootNode<RefRoot<'a>>;
3025
3026impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RootNode<R1>> for RootNode<R2> {
3027 fn eq(&self, other: &RootNode<R1>) -> bool { self.syntax == other.syntax }
3028}
3029impl<R: TreeRoot<RaTypes>> Eq for RootNode<R> {}
3030impl<R: TreeRoot<RaTypes>> Hash for RootNode<R> {
3031 fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
3032}
3033
3034impl<'a> AstNode<'a> for Root<'a> {
3035 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
3036 match syntax.kind() {
3037 ROOT => Some(Root { syntax }),
3038 _ => None,
3039 }
3040 }
3041 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3042}
3043
3044impl<R: TreeRoot<RaTypes>> RootNode<R> {
3045 pub fn borrowed(&self) -> Root {
3046 RootNode { syntax: self.syntax.borrowed() }
3047 }
3048 pub fn owned(&self) -> RootNode {
3049 RootNode { syntax: self.syntax.owned() }
3050 }
3051}
3052
3053
3054impl<'a> ast::ModuleItemOwner<'a> for Root<'a> {}
3055impl<'a> ast::FnDefOwner<'a> for Root<'a> {}
3056impl<'a> Root<'a> {
3057 pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a {
3058 super::children(self)
3059 }
3060}
3061
3062// SelfParam 3019// SelfParam
3063#[derive(Debug, Clone, Copy,)] 3020#[derive(Debug, Clone, Copy,)]
3064pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { 3021pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
@@ -3170,6 +3127,49 @@ impl<R: TreeRoot<RaTypes>> SliceTypeNode<R> {
3170 3127
3171impl<'a> SliceType<'a> {} 3128impl<'a> SliceType<'a> {}
3172 3129
3130// SourceFile
3131#[derive(Debug, Clone, Copy,)]
3132pub struct SourceFileNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3133 pub(crate) syntax: SyntaxNode<R>,
3134}
3135pub type SourceFile<'a> = SourceFileNode<RefRoot<'a>>;
3136
3137impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SourceFileNode<R1>> for SourceFileNode<R2> {
3138 fn eq(&self, other: &SourceFileNode<R1>) -> bool { self.syntax == other.syntax }
3139}
3140impl<R: TreeRoot<RaTypes>> Eq for SourceFileNode<R> {}
3141impl<R: TreeRoot<RaTypes>> Hash for SourceFileNode<R> {
3142 fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
3143}
3144
3145impl<'a> AstNode<'a> for SourceFile<'a> {
3146 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
3147 match syntax.kind() {
3148 SOURCE_FILE => Some(SourceFile { syntax }),
3149 _ => None,
3150 }
3151 }
3152 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3153}
3154
3155impl<R: TreeRoot<RaTypes>> SourceFileNode<R> {
3156 pub fn borrowed(&self) -> SourceFile {
3157 SourceFileNode { syntax: self.syntax.borrowed() }
3158 }
3159 pub fn owned(&self) -> SourceFileNode {
3160 SourceFileNode { syntax: self.syntax.owned() }
3161 }
3162}
3163
3164
3165impl<'a> ast::ModuleItemOwner<'a> for SourceFile<'a> {}
3166impl<'a> ast::FnDefOwner<'a> for SourceFile<'a> {}
3167impl<'a> SourceFile<'a> {
3168 pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a {
3169 super::children(self)
3170 }
3171}
3172
3173// StaticDef 3173// StaticDef
3174#[derive(Debug, Clone, Copy,)] 3174#[derive(Debug, Clone, Copy,)]
3175pub struct StaticDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { 3175pub struct StaticDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {