From 966e9db2b83802dfb55d55bd3a26e69dced1bbd7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 1 Aug 2018 10:40:07 +0300 Subject: Extract libeditor --- src/syntax_kinds/generated.rs | 41 ++++++++++++++++++++++++++++++++++++++ src/syntax_kinds/generated.rs.tera | 10 ++++++++++ 2 files changed, 51 insertions(+) (limited to 'src/syntax_kinds') diff --git a/src/syntax_kinds/generated.rs b/src/syntax_kinds/generated.rs index 435be781c..cbcd0c4e1 100644 --- a/src/syntax_kinds/generated.rs +++ b/src/syntax_kinds/generated.rs @@ -169,6 +169,47 @@ pub enum SyntaxKind { use self::SyntaxKind::*; impl SyntaxKind { + pub fn is_keyword(self) -> bool { + match self { + | USE_KW + | FN_KW + | STRUCT_KW + | ENUM_KW + | TRAIT_KW + | IMPL_KW + | TRUE_KW + | FALSE_KW + | AS_KW + | EXTERN_KW + | CRATE_KW + | MOD_KW + | PUB_KW + | SELF_KW + | SUPER_KW + | IN_KW + | WHERE_KW + | FOR_KW + | LOOP_KW + | WHILE_KW + | IF_KW + | ELSE_KW + | MATCH_KW + | CONST_KW + | STATIC_KW + | MUT_KW + | UNSAFE_KW + | TYPE_KW + | REF_KW + | LET_KW + | MOVE_KW + | AUTO_KW + | DEFAULT_KW + | UNION_KW + => true, + _ => false + } + } + pub(crate) fn info(self) -> &'static SyntaxInfo { match self { SEMI => &SyntaxInfo { name: "SEMI" }, diff --git a/src/syntax_kinds/generated.rs.tera b/src/syntax_kinds/generated.rs.tera index d719c8312..4e2ee56c3 100644 --- a/src/syntax_kinds/generated.rs.tera +++ b/src/syntax_kinds/generated.rs.tera @@ -24,6 +24,16 @@ pub enum SyntaxKind { use self::SyntaxKind::*; impl SyntaxKind { + pub fn is_keyword(self) -> bool { + match self { +{%- for kw in concat(a=keywords, b=contextual_keywords) %} + | {{kw | upper}}_KW +{%- endfor %} + => true, + _ => false + } + } + pub(crate) fn info(self) -> &'static SyntaxInfo { match self { {%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %} -- cgit v1.2.3