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.rs34
-rw-r--r--crates/ra_syntax/src/ast/mod.rs6
2 files changed, 40 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index f77795d05..75769a4e9 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -409,6 +409,40 @@ impl<'a> AstNode<'a> for CastExpr<'a> {
409 409
410impl<'a> CastExpr<'a> {} 410impl<'a> CastExpr<'a> {}
411 411
412// Char
413
414#[derive(Debug, Clone)]
415pub struct CharNode(SyntaxNode);
416
417impl CharNode {
418 pub fn ast(&self) -> Char {
419 Char::cast(self.0.borrowed()).unwrap()
420 }
421}
422
423impl<'a> From<Char<'a>> for CharNode {
424 fn from(ast: Char<'a>) -> CharNode {
425 let syntax = ast.syntax().owned();
426 CharNode(syntax)
427 }
428}
429#[derive(Debug, Clone, Copy)]
430pub struct Char<'a> {
431 syntax: SyntaxNodeRef<'a>,
432}
433
434impl<'a> AstNode<'a> for Char<'a> {
435 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
436 match syntax.kind() {
437 CHAR => Some(Char { syntax }),
438 _ => None,
439 }
440 }
441 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
442}
443
444impl<'a> Char<'a> {}
445
412// Comment 446// Comment
413 447
414#[derive(Debug, Clone)] 448#[derive(Debug, Clone)]
diff --git a/crates/ra_syntax/src/ast/mod.rs b/crates/ra_syntax/src/ast/mod.rs
index 688ffff47..4355531d0 100644
--- a/crates/ra_syntax/src/ast/mod.rs
+++ b/crates/ra_syntax/src/ast/mod.rs
@@ -123,6 +123,12 @@ impl<'a> Lifetime<'a> {
123 } 123 }
124} 124}
125 125
126impl<'a> Char<'a> {
127 pub fn text(&self) -> &SmolStr {
128 &self.syntax().leaf_text().unwrap()
129 }
130}
131
126impl<'a> Comment<'a> { 132impl<'a> Comment<'a> {
127 pub fn text(&self) -> &SmolStr { 133 pub fn text(&self) -> &SmolStr {
128 self.syntax().leaf_text().unwrap() 134 self.syntax().leaf_text().unwrap()