aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast.rs')
-rw-r--r--crates/ra_syntax/src/ast.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 26fafb469..ab0f44dd2 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -30,7 +30,7 @@ pub use self::{
30/// conversion itself has zero runtime cost: ast and syntax nodes have exactly 30/// conversion itself has zero runtime cost: ast and syntax nodes have exactly
31/// the same representation: a pointer to the tree root and a pointer to the 31/// the same representation: a pointer to the tree root and a pointer to the
32/// node itself. 32/// node itself.
33pub trait AstNode: std::fmt::Display { 33pub trait AstNode {
34 fn can_cast(kind: SyntaxKind) -> bool 34 fn can_cast(kind: SyntaxKind) -> bool
35 where 35 where
36 Self: Sized; 36 Self: Sized;
@@ -49,10 +49,16 @@ fn assert_ast_is_object_safe() {
49 49
50/// Like `AstNode`, but wraps tokens rather than interior nodes. 50/// Like `AstNode`, but wraps tokens rather than interior nodes.
51pub trait AstToken { 51pub trait AstToken {
52 fn cast(token: SyntaxToken) -> Option<Self> 52 fn can_cast(token: SyntaxKind) -> bool
53 where 53 where
54 Self: Sized; 54 Self: Sized;
55
56 fn cast(syntax: SyntaxToken) -> Option<Self>
57 where
58 Self: Sized;
59
55 fn syntax(&self) -> &SyntaxToken; 60 fn syntax(&self) -> &SyntaxToken;
61
56 fn text(&self) -> &SmolStr { 62 fn text(&self) -> &SmolStr {
57 self.syntax().text() 63 self.syntax().text()
58 } 64 }