aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-14 09:20:09 +0100
committerAleksey Kladov <[email protected]>2018-08-14 09:20:09 +0100
commit2b828c68e8acda628d6e3a36827d1ffd9c9aaec6 (patch)
treee63ec3bb469eaaf996bbc45c038e66395c04ed23 /crates/libsyntax2/src
parent49ab44102496ac8c4a05b00c584adecf583f4d87 (diff)
separete structure from symbols
Diffstat (limited to 'crates/libsyntax2/src')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs18
-rw-r--r--crates/libsyntax2/src/ast/mod.rs5
-rw-r--r--crates/libsyntax2/src/grammar.ron1
3 files changed, 22 insertions, 2 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs
index b347a05b4..13668b803 100644
--- a/crates/libsyntax2/src/ast/generated.rs
+++ b/crates/libsyntax2/src/ast/generated.rs
@@ -86,6 +86,24 @@ impl<R: TreeRoot> AstNode<R> for FnDef<R> {
86impl<R: TreeRoot> ast::NameOwner<R> for FnDef<R> {} 86impl<R: TreeRoot> ast::NameOwner<R> for FnDef<R> {}
87impl<R: TreeRoot> FnDef<R> {} 87impl<R: TreeRoot> FnDef<R> {}
88 88
89// ImplItem
90#[derive(Debug, Clone, Copy)]
91pub struct ImplItem<R: TreeRoot = Arc<SyntaxRoot>> {
92 syntax: SyntaxNode<R>,
93}
94
95impl<R: TreeRoot> AstNode<R> for ImplItem<R> {
96 fn cast(syntax: SyntaxNode<R>) -> Option<Self> {
97 match syntax.kind() {
98 IMPL_ITEM => Some(ImplItem { syntax }),
99 _ => None,
100 }
101 }
102 fn syntax(&self) -> &SyntaxNode<R> { &self.syntax }
103}
104
105impl<R: TreeRoot> ImplItem<R> {}
106
89// Module 107// Module
90#[derive(Debug, Clone, Copy)] 108#[derive(Debug, Clone, Copy)]
91pub struct Module<R: TreeRoot = Arc<SyntaxRoot>> { 109pub struct Module<R: TreeRoot = Arc<SyntaxRoot>> {
diff --git a/crates/libsyntax2/src/ast/mod.rs b/crates/libsyntax2/src/ast/mod.rs
index 18a9f5d17..f001d340e 100644
--- a/crates/libsyntax2/src/ast/mod.rs
+++ b/crates/libsyntax2/src/ast/mod.rs
@@ -10,8 +10,9 @@ use {
10}; 10};
11pub use self::generated::*; 11pub use self::generated::*;
12 12
13pub trait AstNode<R: TreeRoot>: Sized { 13pub trait AstNode<R: TreeRoot> {
14 fn cast(syntax: SyntaxNode<R>) -> Option<Self>; 14 fn cast(syntax: SyntaxNode<R>) -> Option<Self>
15 where Self: Sized;
15 fn syntax(&self) -> &SyntaxNode<R>; 16 fn syntax(&self) -> &SyntaxNode<R>;
16} 17}
17 18
diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron
index ef56761fd..ebd7d3943 100644
--- a/crates/libsyntax2/src/grammar.ron
+++ b/crates/libsyntax2/src/grammar.ron
@@ -229,6 +229,7 @@ Grammar(
229 "ConstDef": ( traits: ["NameOwner"] ), 229 "ConstDef": ( traits: ["NameOwner"] ),
230 "StaticDef": ( traits: ["NameOwner"] ), 230 "StaticDef": ( traits: ["NameOwner"] ),
231 "TypeDef": ( traits: ["NameOwner"] ), 231 "TypeDef": ( traits: ["NameOwner"] ),
232 "ImplItem": (),
232 "Name": (), 233 "Name": (),
233 "NameRef": (), 234 "NameRef": (),
234 }, 235 },