aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/syntax_kind/generated.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-04-08 23:06:30 +0100
committerAleksey Kladov <[email protected]>2019-04-09 08:26:51 +0100
commitfaf526e021e09770cae28f8d7c8ee88a54d6574d (patch)
tree9fb5bbab15472c7d5b870a65c0ec34256b13c428 /crates/ra_parser/src/syntax_kind/generated.rs
parentac6ab0758731d0555fbf1b1a918abd3e12c8169d (diff)
migrate to untyped rowan
Diffstat (limited to 'crates/ra_parser/src/syntax_kind/generated.rs')
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs
index 547af1b27..b8350266f 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs
+++ b/crates/ra_parser/src/syntax_kind/generated.rs
@@ -7,6 +7,7 @@ use super::SyntaxInfo;
7 7
8/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. 8/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`.
9#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 9#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[repr(u16)]
10pub enum SyntaxKind { 11pub enum SyntaxKind {
11 // Technical SyntaxKinds: they appear temporally during parsing, 12 // Technical SyntaxKinds: they appear temporally during parsing,
12 // but never end up in the final tree 13 // but never end up in the final tree
@@ -230,9 +231,25 @@ pub enum SyntaxKind {
230 ARG_LIST, 231 ARG_LIST,
231 TYPE_BOUND, 232 TYPE_BOUND,
232 TYPE_BOUND_LIST, 233 TYPE_BOUND_LIST,
234 // Technical kind so that we can cast from u16 safely
235 #[doc(hidden)]
236 __LAST,
233} 237}
234use self::SyntaxKind::*; 238use self::SyntaxKind::*;
235 239
240impl From<u16> for SyntaxKind {
241 fn from(d: u16) -> SyntaxKind {
242 assert!(d <= (__LAST as u16));
243 unsafe { std::mem::transmute::<u16, SyntaxKind>(d) }
244 }
245}
246
247impl From<SyntaxKind> for u16 {
248 fn from(k: SyntaxKind) -> u16 {
249 k as u16
250 }
251}
252
236impl SyntaxKind { 253impl SyntaxKind {
237 pub fn is_keyword(self) -> bool { 254 pub fn is_keyword(self) -> bool {
238 match self { 255 match self {
@@ -573,6 +590,7 @@ impl SyntaxKind {
573 TYPE_BOUND_LIST => &SyntaxInfo { name: "TYPE_BOUND_LIST" }, 590 TYPE_BOUND_LIST => &SyntaxInfo { name: "TYPE_BOUND_LIST" },
574 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, 591 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" },
575 EOF => &SyntaxInfo { name: "EOF" }, 592 EOF => &SyntaxInfo { name: "EOF" },
593 __LAST => &SyntaxInfo { name: "__LAST" },
576 } 594 }
577 } 595 }
578 pub fn from_keyword(ident: &str) -> Option<SyntaxKind> { 596 pub fn from_keyword(ident: &str) -> Option<SyntaxKind> {