rust-code-analysis-code-split 0.0.26-cs.0

Fork of mozilla/rust-code-analysis bumped to tree-sitter 0.26 for use by code-split. Computes complexity metrics (cyclomatic, cognitive, Halstead, MI, LOC).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
// Code generated; DO NOT EDIT.

use num_derive::FromPrimitive;

#[derive(Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum Javascript {
    End = 0,
    Identifier = 1,
    HashBangLine = 2,
    Export = 3,
    STAR = 4,
    Default = 5,
    As = 6,
    LBRACE = 7,
    COMMA = 8,
    RBRACE = 9,
    Import2 = 10,
    From = 11,
    With = 12,
    Var = 13,
    Let = 14,
    Const = 15,
    Else = 16,
    If = 17,
    Switch = 18,
    For = 19,
    LPAREN = 20,
    SEMI = 21,
    RPAREN = 22,
    Await = 23,
    In = 24,
    Of = 25,
    While = 26,
    Do = 27,
    Try = 28,
    Break = 29,
    Continue = 30,
    Debugger = 31,
    Return = 32,
    Throw = 33,
    COLON = 34,
    Case = 35,
    Catch = 36,
    Finally = 37,
    Yield = 38,
    EQ = 39,
    LBRACK = 40,
    RBRACK = 41,
    HtmlCharacterReference = 42,
    LT = 43,
    GT = 44,
    Identifier2 = 45,
    DOT = 46,
    LTSLASH = 47,
    SLASHGT = 48,
    DQUOTE = 49,
    SQUOTE = 50,
    StringFragment = 51,
    StringFragment2 = 52,
    Class2 = 53,
    Extends = 54,
    Async = 55,
    Function = 56,
    EQGT = 57,
    OptionalChain = 58,
    New = 59,
    PLUSEQ = 60,
    DASHEQ = 61,
    STAREQ = 62,
    SLASHEQ = 63,
    PERCENTEQ = 64,
    CARETEQ = 65,
    AMPEQ = 66,
    PIPEEQ = 67,
    GTGTEQ = 68,
    GTGTGTEQ = 69,
    LTLTEQ = 70,
    STARSTAREQ = 71,
    AMPAMPEQ = 72,
    PIPEPIPEEQ = 73,
    QMARKQMARKEQ = 74,
    DOTDOTDOT = 75,
    AMPAMP = 76,
    PIPEPIPE = 77,
    GTGT = 78,
    GTGTGT = 79,
    LTLT = 80,
    AMP = 81,
    CARET = 82,
    PIPE = 83,
    PLUS = 84,
    DASH = 85,
    SLASH = 86,
    PERCENT = 87,
    STARSTAR = 88,
    LTEQ = 89,
    EQEQ = 90,
    EQEQEQ = 91,
    BANGEQ = 92,
    BANGEQEQ = 93,
    GTEQ = 94,
    QMARKQMARK = 95,
    Instanceof = 96,
    BANG = 97,
    TILDE = 98,
    Typeof = 99,
    Void = 100,
    Delete = 101,
    PLUSPLUS = 102,
    DASHDASH = 103,
    StringFragment3 = 104,
    StringFragment4 = 105,
    EscapeSequence = 106,
    Comment = 107,
    BQUOTE = 108,
    DOLLARLBRACE = 109,
    SLASH2 = 110,
    RegexPattern = 111,
    RegexFlags = 112,
    Number = 113,
    PrivatePropertyIdentifier = 114,
    Target = 115,
    Meta = 116,
    This = 117,
    Super = 118,
    True = 119,
    False = 120,
    Null = 121,
    Undefined = 122,
    AT = 123,
    Static = 124,
    Staticget = 125,
    Get = 126,
    Set = 127,
    AutomaticSemicolon = 128,
    StringFragment5 = 129,
    QMARK = 130,
    HtmlComment = 131,
    JsxText = 132,
    Program = 133,
    ExportStatement = 134,
    NamespaceExport = 135,
    ExportClause = 136,
    ExportSpecifier = 137,
    ModuleExportName = 138,
    Declaration = 139,
    Import = 140,
    ImportStatement = 141,
    ImportClause = 142,
    FromClause = 143,
    NamespaceImport = 144,
    NamedImports = 145,
    ImportSpecifier = 146,
    ImportAttribute = 147,
    Statement = 148,
    ExpressionStatement = 149,
    VariableDeclaration = 150,
    LexicalDeclaration = 151,
    VariableDeclarator = 152,
    StatementBlock = 153,
    ElseClause = 154,
    IfStatement = 155,
    SwitchStatement = 156,
    ForStatement = 157,
    ForInStatement = 158,
    ForHeader = 159,
    WhileStatement = 160,
    DoStatement = 161,
    TryStatement = 162,
    WithStatement = 163,
    BreakStatement = 164,
    ContinueStatement = 165,
    DebuggerStatement = 166,
    ReturnStatement = 167,
    ThrowStatement = 168,
    EmptyStatement = 169,
    LabeledStatement = 170,
    SwitchBody = 171,
    SwitchCase = 172,
    SwitchDefault = 173,
    CatchClause = 174,
    FinallyClause = 175,
    ParenthesizedExpression = 176,
    Expression = 177,
    PrimaryExpression = 178,
    YieldExpression = 179,
    Object = 180,
    ObjectPattern = 181,
    AssignmentPattern = 182,
    ObjectAssignmentPattern = 183,
    Array = 184,
    ArrayPattern = 185,
    JsxElement = 186,
    JsxExpression = 187,
    JsxOpeningElement = 188,
    MemberExpression = 189,
    JsxNamespaceName = 190,
    JsxClosingElement = 191,
    JsxSelfClosingElement = 192,
    JsxAttribute = 193,
    String = 194,
    Class = 195,
    ClassDeclaration = 196,
    ClassHeritage = 197,
    FunctionExpression = 198,
    FunctionDeclaration = 199,
    GeneratorFunction = 200,
    GeneratorFunctionDeclaration = 201,
    ArrowFunction = 202,
    CallExpression = 203,
    NewExpression = 204,
    AwaitExpression = 205,
    MemberExpression2 = 206,
    SubscriptExpression = 207,
    AssignmentExpression = 208,
    AugmentedAssignmentLhs = 209,
    AugmentedAssignmentExpression = 210,
    Initializer = 211,
    DestructuringPattern = 212,
    SpreadElement = 213,
    TernaryExpression = 214,
    BinaryExpression = 215,
    UnaryExpression = 216,
    UpdateExpression = 217,
    SequenceExpression = 218,
    String2 = 219,
    TemplateString = 220,
    TemplateSubstitution = 221,
    Regex = 222,
    MetaProperty = 223,
    Arguments = 224,
    Decorator = 225,
    MemberExpression3 = 226,
    CallExpression2 = 227,
    ClassBody = 228,
    FieldDefinition = 229,
    FormalParameters = 230,
    ClassStaticBlock = 231,
    Pattern = 232,
    RestPattern = 233,
    MethodDefinition = 234,
    Pair = 235,
    PairPattern = 236,
    PropertyName = 237,
    ComputedPropertyName = 238,
    ProgramRepeat1 = 239,
    ExportStatementRepeat1 = 240,
    ExportClauseRepeat1 = 241,
    NamedImportsRepeat1 = 242,
    VariableDeclarationRepeat1 = 243,
    SwitchBodyRepeat1 = 244,
    ObjectRepeat1 = 245,
    ObjectPatternRepeat1 = 246,
    ArrayRepeat1 = 247,
    ArrayPatternRepeat1 = 248,
    JsxElementRepeat1 = 249,
    JsxOpeningElementRepeat1 = 250,
    JsxStringRepeat1 = 251,
    JsxStringRepeat2 = 252,
    SequenceExpressionRepeat1 = 253,
    StringRepeat1 = 254,
    StringRepeat2 = 255,
    TemplateStringRepeat1 = 256,
    ClassBodyRepeat1 = 257,
    FormalParametersRepeat1 = 258,
    PropertyIdentifier = 259,
    ShorthandPropertyIdentifier = 260,
    ShorthandPropertyIdentifierPattern = 261,
    StatementIdentifier = 262,
    Error = 263,
}

impl From<Javascript> for &'static str {
    #[inline(always)]
    fn from(tok: Javascript) -> Self {
        match tok {
            Javascript::End => "end",
            Javascript::Identifier => "identifier",
            Javascript::HashBangLine => "hash_bang_line",
            Javascript::Export => "export",
            Javascript::STAR => "*",
            Javascript::Default => "default",
            Javascript::As => "as",
            Javascript::LBRACE => "{",
            Javascript::COMMA => ",",
            Javascript::RBRACE => "}",
            Javascript::Import2 => "import",
            Javascript::From => "from",
            Javascript::With => "with",
            Javascript::Var => "var",
            Javascript::Let => "let",
            Javascript::Const => "const",
            Javascript::Else => "else",
            Javascript::If => "if",
            Javascript::Switch => "switch",
            Javascript::For => "for",
            Javascript::LPAREN => "(",
            Javascript::SEMI => ";",
            Javascript::RPAREN => ")",
            Javascript::Await => "await",
            Javascript::In => "in",
            Javascript::Of => "of",
            Javascript::While => "while",
            Javascript::Do => "do",
            Javascript::Try => "try",
            Javascript::Break => "break",
            Javascript::Continue => "continue",
            Javascript::Debugger => "debugger",
            Javascript::Return => "return",
            Javascript::Throw => "throw",
            Javascript::COLON => ":",
            Javascript::Case => "case",
            Javascript::Catch => "catch",
            Javascript::Finally => "finally",
            Javascript::Yield => "yield",
            Javascript::EQ => "=",
            Javascript::LBRACK => "[",
            Javascript::RBRACK => "]",
            Javascript::HtmlCharacterReference => "html_character_reference",
            Javascript::LT => "<",
            Javascript::GT => ">",
            Javascript::Identifier2 => "identifier",
            Javascript::DOT => ".",
            Javascript::LTSLASH => "</",
            Javascript::SLASHGT => "/>",
            Javascript::DQUOTE => "\"",
            Javascript::SQUOTE => "'",
            Javascript::StringFragment => "string_fragment",
            Javascript::StringFragment2 => "string_fragment",
            Javascript::Class2 => "class",
            Javascript::Extends => "extends",
            Javascript::Async => "async",
            Javascript::Function => "function",
            Javascript::EQGT => "=>",
            Javascript::OptionalChain => "optional_chain",
            Javascript::New => "new",
            Javascript::PLUSEQ => "+=",
            Javascript::DASHEQ => "-=",
            Javascript::STAREQ => "*=",
            Javascript::SLASHEQ => "/=",
            Javascript::PERCENTEQ => "%=",
            Javascript::CARETEQ => "^=",
            Javascript::AMPEQ => "&=",
            Javascript::PIPEEQ => "|=",
            Javascript::GTGTEQ => ">>=",
            Javascript::GTGTGTEQ => ">>>=",
            Javascript::LTLTEQ => "<<=",
            Javascript::STARSTAREQ => "**=",
            Javascript::AMPAMPEQ => "&&=",
            Javascript::PIPEPIPEEQ => "||=",
            Javascript::QMARKQMARKEQ => "??=",
            Javascript::DOTDOTDOT => "...",
            Javascript::AMPAMP => "&&",
            Javascript::PIPEPIPE => "||",
            Javascript::GTGT => ">>",
            Javascript::GTGTGT => ">>>",
            Javascript::LTLT => "<<",
            Javascript::AMP => "&",
            Javascript::CARET => "^",
            Javascript::PIPE => "|",
            Javascript::PLUS => "+",
            Javascript::DASH => "-",
            Javascript::SLASH => "/",
            Javascript::PERCENT => "%",
            Javascript::STARSTAR => "**",
            Javascript::LTEQ => "<=",
            Javascript::EQEQ => "==",
            Javascript::EQEQEQ => "===",
            Javascript::BANGEQ => "!=",
            Javascript::BANGEQEQ => "!==",
            Javascript::GTEQ => ">=",
            Javascript::QMARKQMARK => "??",
            Javascript::Instanceof => "instanceof",
            Javascript::BANG => "!",
            Javascript::TILDE => "~",
            Javascript::Typeof => "typeof",
            Javascript::Void => "void",
            Javascript::Delete => "delete",
            Javascript::PLUSPLUS => "++",
            Javascript::DASHDASH => "--",
            Javascript::StringFragment3 => "string_fragment",
            Javascript::StringFragment4 => "string_fragment",
            Javascript::EscapeSequence => "escape_sequence",
            Javascript::Comment => "comment",
            Javascript::BQUOTE => "`",
            Javascript::DOLLARLBRACE => "${",
            Javascript::SLASH2 => "/",
            Javascript::RegexPattern => "regex_pattern",
            Javascript::RegexFlags => "regex_flags",
            Javascript::Number => "number",
            Javascript::PrivatePropertyIdentifier => "private_property_identifier",
            Javascript::Target => "target",
            Javascript::Meta => "meta",
            Javascript::This => "this",
            Javascript::Super => "super",
            Javascript::True => "true",
            Javascript::False => "false",
            Javascript::Null => "null",
            Javascript::Undefined => "undefined",
            Javascript::AT => "@",
            Javascript::Static => "static",
            Javascript::Staticget => "static get",
            Javascript::Get => "get",
            Javascript::Set => "set",
            Javascript::AutomaticSemicolon => "_automatic_semicolon",
            Javascript::StringFragment5 => "string_fragment",
            Javascript::QMARK => "?",
            Javascript::HtmlComment => "html_comment",
            Javascript::JsxText => "jsx_text",
            Javascript::Program => "program",
            Javascript::ExportStatement => "export_statement",
            Javascript::NamespaceExport => "namespace_export",
            Javascript::ExportClause => "export_clause",
            Javascript::ExportSpecifier => "export_specifier",
            Javascript::ModuleExportName => "_module_export_name",
            Javascript::Declaration => "declaration",
            Javascript::Import => "import",
            Javascript::ImportStatement => "import_statement",
            Javascript::ImportClause => "import_clause",
            Javascript::FromClause => "_from_clause",
            Javascript::NamespaceImport => "namespace_import",
            Javascript::NamedImports => "named_imports",
            Javascript::ImportSpecifier => "import_specifier",
            Javascript::ImportAttribute => "import_attribute",
            Javascript::Statement => "statement",
            Javascript::ExpressionStatement => "expression_statement",
            Javascript::VariableDeclaration => "variable_declaration",
            Javascript::LexicalDeclaration => "lexical_declaration",
            Javascript::VariableDeclarator => "variable_declarator",
            Javascript::StatementBlock => "statement_block",
            Javascript::ElseClause => "else_clause",
            Javascript::IfStatement => "if_statement",
            Javascript::SwitchStatement => "switch_statement",
            Javascript::ForStatement => "for_statement",
            Javascript::ForInStatement => "for_in_statement",
            Javascript::ForHeader => "_for_header",
            Javascript::WhileStatement => "while_statement",
            Javascript::DoStatement => "do_statement",
            Javascript::TryStatement => "try_statement",
            Javascript::WithStatement => "with_statement",
            Javascript::BreakStatement => "break_statement",
            Javascript::ContinueStatement => "continue_statement",
            Javascript::DebuggerStatement => "debugger_statement",
            Javascript::ReturnStatement => "return_statement",
            Javascript::ThrowStatement => "throw_statement",
            Javascript::EmptyStatement => "empty_statement",
            Javascript::LabeledStatement => "labeled_statement",
            Javascript::SwitchBody => "switch_body",
            Javascript::SwitchCase => "switch_case",
            Javascript::SwitchDefault => "switch_default",
            Javascript::CatchClause => "catch_clause",
            Javascript::FinallyClause => "finally_clause",
            Javascript::ParenthesizedExpression => "parenthesized_expression",
            Javascript::Expression => "expression",
            Javascript::PrimaryExpression => "primary_expression",
            Javascript::YieldExpression => "yield_expression",
            Javascript::Object => "object",
            Javascript::ObjectPattern => "object_pattern",
            Javascript::AssignmentPattern => "assignment_pattern",
            Javascript::ObjectAssignmentPattern => "object_assignment_pattern",
            Javascript::Array => "array",
            Javascript::ArrayPattern => "array_pattern",
            Javascript::JsxElement => "jsx_element",
            Javascript::JsxExpression => "jsx_expression",
            Javascript::JsxOpeningElement => "jsx_opening_element",
            Javascript::MemberExpression => "member_expression",
            Javascript::JsxNamespaceName => "jsx_namespace_name",
            Javascript::JsxClosingElement => "jsx_closing_element",
            Javascript::JsxSelfClosingElement => "jsx_self_closing_element",
            Javascript::JsxAttribute => "jsx_attribute",
            Javascript::String => "string",
            Javascript::Class => "class",
            Javascript::ClassDeclaration => "class_declaration",
            Javascript::ClassHeritage => "class_heritage",
            Javascript::FunctionExpression => "function_expression",
            Javascript::FunctionDeclaration => "function_declaration",
            Javascript::GeneratorFunction => "generator_function",
            Javascript::GeneratorFunctionDeclaration => "generator_function_declaration",
            Javascript::ArrowFunction => "arrow_function",
            Javascript::CallExpression => "call_expression",
            Javascript::NewExpression => "new_expression",
            Javascript::AwaitExpression => "await_expression",
            Javascript::MemberExpression2 => "member_expression",
            Javascript::SubscriptExpression => "subscript_expression",
            Javascript::AssignmentExpression => "assignment_expression",
            Javascript::AugmentedAssignmentLhs => "_augmented_assignment_lhs",
            Javascript::AugmentedAssignmentExpression => "augmented_assignment_expression",
            Javascript::Initializer => "_initializer",
            Javascript::DestructuringPattern => "_destructuring_pattern",
            Javascript::SpreadElement => "spread_element",
            Javascript::TernaryExpression => "ternary_expression",
            Javascript::BinaryExpression => "binary_expression",
            Javascript::UnaryExpression => "unary_expression",
            Javascript::UpdateExpression => "update_expression",
            Javascript::SequenceExpression => "sequence_expression",
            Javascript::String2 => "string",
            Javascript::TemplateString => "template_string",
            Javascript::TemplateSubstitution => "template_substitution",
            Javascript::Regex => "regex",
            Javascript::MetaProperty => "meta_property",
            Javascript::Arguments => "arguments",
            Javascript::Decorator => "decorator",
            Javascript::MemberExpression3 => "member_expression",
            Javascript::CallExpression2 => "call_expression",
            Javascript::ClassBody => "class_body",
            Javascript::FieldDefinition => "field_definition",
            Javascript::FormalParameters => "formal_parameters",
            Javascript::ClassStaticBlock => "class_static_block",
            Javascript::Pattern => "pattern",
            Javascript::RestPattern => "rest_pattern",
            Javascript::MethodDefinition => "method_definition",
            Javascript::Pair => "pair",
            Javascript::PairPattern => "pair_pattern",
            Javascript::PropertyName => "_property_name",
            Javascript::ComputedPropertyName => "computed_property_name",
            Javascript::ProgramRepeat1 => "program_repeat1",
            Javascript::ExportStatementRepeat1 => "export_statement_repeat1",
            Javascript::ExportClauseRepeat1 => "export_clause_repeat1",
            Javascript::NamedImportsRepeat1 => "named_imports_repeat1",
            Javascript::VariableDeclarationRepeat1 => "variable_declaration_repeat1",
            Javascript::SwitchBodyRepeat1 => "switch_body_repeat1",
            Javascript::ObjectRepeat1 => "object_repeat1",
            Javascript::ObjectPatternRepeat1 => "object_pattern_repeat1",
            Javascript::ArrayRepeat1 => "array_repeat1",
            Javascript::ArrayPatternRepeat1 => "array_pattern_repeat1",
            Javascript::JsxElementRepeat1 => "jsx_element_repeat1",
            Javascript::JsxOpeningElementRepeat1 => "jsx_opening_element_repeat1",
            Javascript::JsxStringRepeat1 => "_jsx_string_repeat1",
            Javascript::JsxStringRepeat2 => "_jsx_string_repeat2",
            Javascript::SequenceExpressionRepeat1 => "sequence_expression_repeat1",
            Javascript::StringRepeat1 => "string_repeat1",
            Javascript::StringRepeat2 => "string_repeat2",
            Javascript::TemplateStringRepeat1 => "template_string_repeat1",
            Javascript::ClassBodyRepeat1 => "class_body_repeat1",
            Javascript::FormalParametersRepeat1 => "formal_parameters_repeat1",
            Javascript::PropertyIdentifier => "property_identifier",
            Javascript::ShorthandPropertyIdentifier => "shorthand_property_identifier",
            Javascript::ShorthandPropertyIdentifierPattern => {
                "shorthand_property_identifier_pattern"
            }
            Javascript::StatementIdentifier => "statement_identifier",
            Javascript::Error => "ERROR",
        }
    }
}

impl From<u16> for Javascript {
    #[inline(always)]
    fn from(x: u16) -> Self {
        num::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
    }
}

// Javascript == u16
impl PartialEq<u16> for Javascript {
    #[inline(always)]
    fn eq(&self, x: &u16) -> bool {
        *self == Into::<Self>::into(*x)
    }
}

// u16 == Javascript
impl PartialEq<Javascript> for u16 {
    #[inline(always)]
    fn eq(&self, x: &Javascript) -> bool {
        *x == *self
    }
}