mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-11 12:48:47 +00:00
9bd11459ba
This reverts commitcc9ae2b89e
, reversing changes made to7dfd1cb572
.
390 lines
13 KiB
Rust
390 lines
13 KiB
Rust
//! Generated by `sourcegen_ast`, do not edit by hand.
|
|
|
|
#![allow(bad_style, missing_docs, unreachable_pub)]
|
|
#[doc = r" The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT`."]
|
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
|
#[repr(u16)]
|
|
pub enum SyntaxKind {
|
|
#[doc(hidden)]
|
|
TOMBSTONE,
|
|
#[doc(hidden)]
|
|
EOF,
|
|
SEMICOLON,
|
|
COMMA,
|
|
L_PAREN,
|
|
R_PAREN,
|
|
L_CURLY,
|
|
R_CURLY,
|
|
L_BRACK,
|
|
R_BRACK,
|
|
L_ANGLE,
|
|
R_ANGLE,
|
|
AT,
|
|
POUND,
|
|
TILDE,
|
|
QUESTION,
|
|
DOLLAR,
|
|
AMP,
|
|
PIPE,
|
|
PLUS,
|
|
STAR,
|
|
SLASH,
|
|
CARET,
|
|
PERCENT,
|
|
UNDERSCORE,
|
|
DOT,
|
|
DOT2,
|
|
DOT3,
|
|
DOT2EQ,
|
|
COLON,
|
|
COLON2,
|
|
EQ,
|
|
EQ2,
|
|
FAT_ARROW,
|
|
BANG,
|
|
NEQ,
|
|
MINUS,
|
|
THIN_ARROW,
|
|
LTEQ,
|
|
GTEQ,
|
|
PLUSEQ,
|
|
MINUSEQ,
|
|
PIPEEQ,
|
|
AMPEQ,
|
|
CARETEQ,
|
|
SLASHEQ,
|
|
STAREQ,
|
|
PERCENTEQ,
|
|
AMP2,
|
|
PIPE2,
|
|
SHL,
|
|
SHR,
|
|
SHLEQ,
|
|
SHREQ,
|
|
AS_KW,
|
|
ASYNC_KW,
|
|
AWAIT_KW,
|
|
BOX_KW,
|
|
BREAK_KW,
|
|
CONST_KW,
|
|
CONTINUE_K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IST,
|
|
RECORD_FIELD,
|
|
TUPLE_FIELD_LIST,
|
|
TUPLE_FIELD,
|
|
VARIANT_LIST,
|
|
ITEM_LIST,
|
|
ASSOC_ITEM_LIST,
|
|
ATTR,
|
|
META,
|
|
USE_TREE,
|
|
USE_TREE_LIST,
|
|
PATH,
|
|
PATH_SEGMENT,
|
|
LITERAL,
|
|
RENAME,
|
|
VISIBILITY,
|
|
WHERE_CLAUSE,
|
|
WHERE_PRED,
|
|
ABI,
|
|
NAME,
|
|
NAME_REF,
|
|
LET_STMT,
|
|
LET_ELSE,
|
|
EXPR_STMT,
|
|
GENERIC_PARAM_LIST,
|
|
GENERIC_PARAM,
|
|
LIFETIME_PARAM,
|
|
TYPE_PARAM,
|
|
CONST_PARAM,
|
|
GENERIC_ARG_LIST,
|
|
LIFETIME,
|
|
LIFETIME_ARG,
|
|
TYPE_ARG,
|
|
ASSOC_TYPE_ARG,
|
|
CONST_ARG,
|
|
PARAM_LIST,
|
|
PARAM,
|
|
SELF_PARAM,
|
|
ARG_LIST,
|
|
TYPE_BOUND,
|
|
TYPE_BOUND_LIST,
|
|
MACRO_ITEMS,
|
|
MACRO_STMTS,
|
|
#[doc(hidden)]
|
|
__LAST,
|
|
}
|
|
use self::SyntaxKind::*;
|
|
impl SyntaxKind {
|
|
pub fn is_keyword(self) -> bool {
|
|
match self {
|
|
AS_KW | ASYNC_KW | AWAIT_KW | BOX_KW | BREAK_KW | CONST_KW | CONTINUE_KW | CRATE_KW
|
|
| DYN_KW | ELSE_KW | ENUM_KW | EXTERN_KW | FALSE_KW | FN_KW | FOR_KW | IF_KW
|
|
| IMPL_KW | IN_KW | LET_KW | LOOP_KW | MACRO_KW | MATCH_KW | MOD_KW | MOVE_KW
|
|
| MUT_KW | PUB_KW | REF_KW | RETURN_KW | SELF_KW | SELF_TYPE_KW | STATIC_KW
|
|
| STRUCT_KW | SUPER_KW | TRAIT_KW | TRUE_KW | TRY_KW | TYPE_KW | UNSAFE_KW | USE_KW
|
|
| WHERE_KW | WHILE_KW | YIELD_KW | AUTO_KW | DEFAULT_KW | EXISTENTIAL_KW | UNION_KW
|
|
| RAW_KW | MACRO_RULES_KW => true,
|
|
_ => false,
|
|
}
|
|
}
|
|
pub fn is_punct(self) -> bool {
|
|
match self {
|
|
SEMICOLON | COMMA | L_PAREN | R_PAREN | L_CURLY | R_CURLY | L_BRACK | R_BRACK
|
|
| L_ANGLE | R_ANGLE | AT | POUND | TILDE | QUESTION | DOLLAR | AMP | PIPE | PLUS
|
|
| STAR | SLASH | CARET | PERCENT | UNDERSCORE | DOT | DOT2 | DOT3 | DOT2EQ | COLON
|
|
| COLON2 | EQ | EQ2 | FAT_ARROW | BANG | NEQ | MINUS | THIN_ARROW | LTEQ | GTEQ
|
|
| PLUSEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ | SLASHEQ | STAREQ | PERCENTEQ | AMP2
|
|
| PIPE2 | SHL | SHR | SHLEQ | SHREQ => true,
|
|
_ => false,
|
|
}
|
|
}
|
|
pub fn is_literal(self) -> bool {
|
|
match self {
|
|
INT_NUMBER | FLOAT_NUMBER | CHAR | BYTE | STRING | BYTE_STRING => true,
|
|
_ => false,
|
|
}
|
|
}
|
|
pub fn from_keyword(ident: &str) -> Option<SyntaxKind> {
|
|
let kw = match ident {
|
|
"as" => AS_KW,
|
|
"async" => ASYNC_KW,
|
|
"await" => AWAIT_KW,
|
|
"box" => BOX_KW,
|
|
"break" => BREAK_KW,
|
|
"const" => CONST_KW,
|
|
"continue" => CONTINUE_KW,
|
|
"crate" => CRATE_KW,
|
|
"dyn" => DYN_KW,
|
|
"else" => ELSE_KW,
|
|
"enum" => ENUM_KW,
|
|
"extern" => EXTERN_KW,
|
|
"false" => FALSE_KW,
|
|
"fn" => FN_KW,
|
|
"for" => FOR_KW,
|
|
"if" => IF_KW,
|
|
"impl" => IMPL_KW,
|
|
"in" => IN_KW,
|
|
"let" => LET_KW,
|
|
"loop" => LOOP_KW,
|
|
"macro" => MACRO_KW,
|
|
"match" => MATCH_KW,
|
|
"mod" => MOD_KW,
|
|
"move" => MOVE_KW,
|
|
"mut" => MUT_KW,
|
|
"pub" => PUB_KW,
|
|
"ref" => REF_KW,
|
|
"return" => RETURN_KW,
|
|
"self" => SELF_KW,
|
|
"Self" => SELF_TYPE_KW,
|
|
"static" => STATIC_KW,
|
|
"struct" => STRUCT_KW,
|
|
"super" => SUPER_KW,
|
|
"trait" => TRAIT_KW,
|
|
"true" => TRUE_KW,
|
|
"try" => TRY_KW,
|
|
"type" => TYPE_KW,
|
|
"unsafe" => UNSAFE_KW,
|
|
"use" => USE_KW,
|
|
"where" => WHERE_KW,
|
|
"while" => WHILE_KW,
|
|
"yield" => YIELD_KW,
|
|
_ => return None,
|
|
};
|
|
Some(kw)
|
|
}
|
|
pub fn from_contextual_keyword(ident: &str) -> Option<SyntaxKind> {
|
|
let kw = match ident {
|
|
"auto" => AUTO_KW,
|
|
"default" => DEFAULT_KW,
|
|
"existential" => EXISTENTIAL_KW,
|
|
"union" => UNION_KW,
|
|
"raw" => RAW_KW,
|
|
"macro_rules" => MACRO_RULES_KW,
|
|
_ => return None,
|
|
};
|
|
Some(kw)
|
|
}
|
|
pub fn from_char(c: char) -> Option<SyntaxKind> {
|
|
let tok = match c {
|
|
';' => SEMICOLON,
|
|
',' => COMMA,
|
|
'(' => L_PAREN,
|
|
')' => R_PAREN,
|
|
'{' => L_CURLY,
|
|
'}' => R_CURLY,
|
|
'[' => L_BRACK,
|
|
']' => R_BRACK,
|
|
'<' => L_ANGLE,
|
|
'>' => R_ANGLE,
|
|
'@' => AT,
|
|
'#' => POUND,
|
|
'~' => TILDE,
|
|
'?' => QUESTION,
|
|
'$' => DOLLAR,
|
|
'&' => AMP,
|
|
'|' => PIPE,
|
|
'+' => PLUS,
|
|
'*' => STAR,
|
|
'/' => SLASH,
|
|
'^' => CARET,
|
|
'%' => PERCENT,
|
|
'_' => UNDERSCORE,
|
|
'.' => DOT,
|
|
':' => COLON,
|
|
'=' => EQ,
|
|
'!' => BANG,
|
|
'-' => MINUS,
|
|
_ => return None,
|
|
};
|
|
Some(tok)
|
|
}
|
|
}
|
|
#[macro_export]
|
|
macro_rules ! T { [;] => { $ crate :: SyntaxKind :: SEMICOLON } ; [,] => { $ crate :: SyntaxKind :: COMMA } ; ['('] => { $ crate :: SyntaxKind :: L_PAREN } ; [')'] => { $ crate :: SyntaxKind :: R_PAREN } ; ['{'] => { $ crate :: SyntaxKind :: L_CURLY } ; ['}'] => { $ crate :: SyntaxKind :: R_CURLY } ; ['['] => { $ crate :: SyntaxKind :: L_BRACK } ; [']'] => { $ crate :: SyntaxKind :: R_BRACK } ; [<] => { $ crate :: SyntaxKind :: L_ANGLE } ; [>] => { $ crate :: SyntaxKind :: R_ANGLE } ; [@] => { $ crate :: SyntaxKind :: AT } ; [#] => { $ crate :: SyntaxKind :: POUND } ; [~] => { $ crate :: SyntaxKind :: TILDE } ; [?] => { $ crate :: SyntaxKind :: QUESTION } ; [$] => { $ crate :: SyntaxKind :: DOLLAR } ; [&] => { $ crate :: SyntaxKind :: AMP } ; [|] => { $ crate :: SyntaxKind :: PIPE } ; [+] => { $ crate :: SyntaxKind :: PLUS } ; [*] => { $ crate :: SyntaxKind :: STAR } ; [/] => { $ crate :: SyntaxKind :: SLASH } ; [^] => { $ crate :: SyntaxKind :: CARET } ; [%] => { $ crate :: SyntaxKind :: PERCENT } ; [_] => { $ crate :: SyntaxKind :: UNDERSCORE } ; [.] => { $ crate :: SyntaxKind :: DOT } ; [..] => { $ crate :: SyntaxKind :: DOT2 } ; [...] => { $ crate :: SyntaxKind :: DOT3 } ; [..=] => { $ crate :: SyntaxKind :: DOT2EQ } ; [:] => { $ crate :: SyntaxKind :: COLON } ; [::] => { $ crate :: SyntaxKind :: COLON2 } ; [=] => { $ crate :: SyntaxKind :: EQ } ; [==] => { $ crate :: SyntaxKind :: EQ2 } ; [=>] => { $ crate :: SyntaxKind :: FAT_ARROW } ; [!] => { $ crate :: SyntaxKind :: BANG } ; [!=] => { $ crate :: SyntaxKind :: NEQ } ; [-] => { $ crate :: SyntaxKind :: MINUS } ; [->] => { $ crate :: SyntaxKind :: THIN_ARROW } ; [<=] => { $ crate :: SyntaxKind :: LTEQ } ; [>=] => { $ crate :: SyntaxKind :: GTEQ } ; [+=] => { $ crate :: SyntaxKind :: PLUSEQ } ; [-=] => { $ crate :: SyntaxKind :: MINUSEQ } ; [|=] => { $ crate :: SyntaxKind :: PIPEEQ } ; [&=] => { $ crate :: SyntaxKind :: AMPEQ } ; [^=] => { $ crate :: SyntaxKind :: CARETEQ } ; [/=] => { $ crate :: SyntaxKind :: SLASHEQ } ; [*=] => { $ crate :: SyntaxKind :: STAREQ } ; [%=] => { $ crate :: SyntaxKind :: PERCENTEQ } ; [&&] => { $ crate :: SyntaxKind :: AMP2 } ; [||] => { $ crate :: SyntaxKind :: PIPE2 } ; [<<] => { $ crate :: SyntaxKind :: SHL } ; [>>] => { $ crate :: SyntaxKind :: SHR } ; [<<=] => { $ crate :: SyntaxKind :: SHLEQ } ; [>>=] => { $ crate :: SyntaxKind :: SHREQ } ; [as] => { $ crate :: SyntaxKind :: AS_KW } ; [async] => { $ crate :: SyntaxKind :: ASYNC_KW } ; [await] => { $ crate :: SyntaxKind :: AWAIT_KW } ; [box] => { $ crate :: SyntaxKind :: BOX_KW } ; [break] => { $ crate :: SyntaxKind :: BREAK_KW } ; [const] => { $ crate :: SyntaxKind :: CONST_KW } ; [continue] => { $ crate :: SyntaxKind :: CONTINUE_KW } ; [crate] => { $ crate :: SyntaxKind :: CRATE_KW } ; [dyn] => { $ crate :: SyntaxKind :: DYN_KW } ; [else] => { $ crate :: SyntaxKind :: ELSE_KW } ; [enum] => { $ crate :: SyntaxKind :: ENUM_KW } ; [extern] => { $ crate :: SyntaxKind :: EXTERN_KW } ; [false] => { $ crate :: SyntaxKind :: FALSE_KW } ; [fn] => { $ crate :: SyntaxKind :: FN_KW } ; [for] => { $ crate :: SyntaxKind :: FOR_KW } ; [if] => { $ crate :: SyntaxKind :: IF_KW } ; [impl] => { $ crate :: SyntaxKind :: IMPL_KW } ; [in] => { $ crate :: SyntaxKind :: IN_KW } ; [let] => { $ crate :: SyntaxKind :: LET_KW } ; [loop] => { $ crate :: SyntaxKind :: LOOP_KW } ; [macro] => { $ crate :: SyntaxKind :: MACRO_KW } ; [match] => { $ crate :: SyntaxKind :: MATCH_KW } ; [mod] => { $ crate :: SyntaxKind :: MOD_KW } ; [move] => { $ crate :: SyntaxKind :: MOVE_KW } ; [mut] => { $ crate :: SyntaxKind :: MUT_KW } ; [pub] => { $ crate :: SyntaxKind :: PUB_KW } ; [ref] => { $ crate :: SyntaxKind :: REF_KW } ; [return] => { $ crate :: SyntaxKind :: RETURN_KW } ; [self] => { $ crate :: SyntaxKind :: SELF_KW } ; [Self] => { $ crate :: SyntaxKind :: SELF_TYPE_KW } ; [static] => { $ crate :: SyntaxKind :: STATIC_KW } ; [struct] => { $ crate :: SyntaxKind :: STRUCT_KW } ; [super] => { $ crate :: SyntaxKind :: SUPER_KW } ; [trait] => { $ crate :: SyntaxKind :: TRAIT_KW } ; [true] => { $ crate :: SyntaxKind :: TRUE_KW } ; [try] => { $ crate :: SyntaxKind :: TRY_KW } ; [type] => { $ crate :: SyntaxKind :: TYPE_KW } ; [unsafe] => { $ crate :: SyntaxKind :: UNSAFE_KW } ; [use] => { $ crate :: SyntaxKind :: USE_KW } ; [where] => { $ crate :: SyntaxKind :: WHERE_KW } ; [while] => { $ crate :: SyntaxKind :: WHILE_KW } ; [yield] => { $ crate :: SyntaxKind :: YIELD_KW } ; [auto] => { $ crate :: SyntaxKind :: AUTO_KW } ; [default] => { $ crate :: SyntaxKind :: DEFAULT_KW } ; [existential] => { $ crate :: SyntaxKind :: EXISTENTIAL_KW } ; [union] => { $ crate :: SyntaxKind :: UNION_KW } ; [raw] => { $ crate :: SyntaxKind :: RAW_KW } ; [macro_rules] => { $ crate :: SyntaxKind :: MACRO_RULES_KW } ; [lifetime_ident] => { $ crate :: SyntaxKind :: LIFETIME_IDENT } ; [ident] => { $ crate :: SyntaxKind :: IDENT } ; [shebang] => { $ crate :: SyntaxKind :: SHEBANG } ; }
|
|
pub use T;
|