aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast/generated.rs.tera
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-11-06 19:47:38 +0000
committerAleksey Kladov <[email protected]>2018-11-06 20:26:26 +0000
commit8eaf7952ae4ba510d448a7e310a3e2dcfd09f6d3 (patch)
tree263aed65ed9a8aa30b37674d01f8a82aee66d2f1 /crates/ra_syntax/src/ast/generated.rs.tera
parent7196286ec5de7a545654ca94878230fc31d4a8db (diff)
ra_syntax::File is just RootNode
Diffstat (limited to 'crates/ra_syntax/src/ast/generated.rs.tera')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs.tera16
1 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera
index d4fc6b5bd..131ee09ec 100644
--- a/crates/ra_syntax/src/ast/generated.rs.tera
+++ b/crates/ra_syntax/src/ast/generated.rs.tera
@@ -11,6 +11,8 @@ the below applies to the result of this template
11 11
12#![cfg_attr(rustfmt, rustfmt_skip)] 12#![cfg_attr(rustfmt, rustfmt_skip)]
13 13
14use std::hash::{Hash, Hasher};
15
14use crate::{ 16use crate::{
15 ast, 17 ast,
16 SyntaxNode, SyntaxNodeRef, AstNode, 18 SyntaxNode, SyntaxNodeRef, AstNode,
@@ -21,7 +23,7 @@ use crate::{
21// {{ node }} 23// {{ node }}
22 24
23{%- if methods.enum %} 25{%- if methods.enum %}
24#[derive(Debug, Clone, Copy)] 26#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25pub enum {{ node }}<'a> { 27pub enum {{ node }}<'a> {
26{%- for kind in methods.enum %} 28{%- for kind in methods.enum %}
27 {{ kind }}({{ kind }}<'a>), 29 {{ kind }}({{ kind }}<'a>),
@@ -46,12 +48,20 @@ impl<'a> AstNode<'a> for {{ node }}<'a> {
46 } 48 }
47} 49}
48{% else %} 50{% else %}
49#[derive(Debug, Clone, Copy)] 51#[derive(Debug, Clone, Copy,)]
50pub struct {{ node }}Node<R: TreeRoot<RaTypes> = OwnedRoot> { 52pub struct {{ node }}Node<R: TreeRoot<RaTypes> = OwnedRoot> {
51 syntax: SyntaxNode<R>, 53 pub(crate) syntax: SyntaxNode<R>,
52} 54}
53pub type {{ node }}<'a> = {{ node }}Node<RefRoot<'a>>; 55pub type {{ node }}<'a> = {{ node }}Node<RefRoot<'a>>;
54 56
57impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<{{node}}Node<R1>> for {{node}}Node<R2> {
58 fn eq(&self, other: &{{node}}Node<R1>) -> bool { self.syntax == other.syntax }
59}
60impl<R: TreeRoot<RaTypes>> Eq for {{node}}Node<R> {}
61impl<R: TreeRoot<RaTypes>> Hash for {{node}}Node<R> {
62 fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
63}
64
55impl<'a> AstNode<'a> for {{ node }}<'a> { 65impl<'a> AstNode<'a> for {{ node }}<'a> {
56 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 66 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
57 match syntax.kind() { 67 match syntax.kind() {