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
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
// Code generated; DO NOT EDIT.

use num_derive::FromPrimitive;

#[derive(Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum Python {
    End = 0,
    Identifier = 1,
    SEMI = 2,
    Import = 3,
    DOT = 4,
    From = 5,
    Future = 6,
    LPAREN = 7,
    RPAREN = 8,
    COMMA = 9,
    As = 10,
    STAR = 11,
    Print = 12,
    GTGT = 13,
    Assert = 14,
    COLONEQ = 15,
    Return = 16,
    Del = 17,
    Raise = 18,
    Pass = 19,
    Break = 20,
    Continue = 21,
    If = 22,
    COLON = 23,
    Elif = 24,
    Else = 25,
    Match = 26,
    Case = 27,
    Async = 28,
    For = 29,
    In = 30,
    While = 31,
    Try = 32,
    Except = 33,
    ExceptSTAR = 34,
    Finally = 35,
    With = 36,
    Def = 37,
    DASHGT = 38,
    STARSTAR = 39,
    Global = 40,
    Nonlocal = 41,
    Exec = 42,
    Type2 = 43,
    EQ = 44,
    Class = 45,
    LBRACK = 46,
    RBRACK = 47,
    AT = 48,
    DASH = 49,
    UNDERSCORE = 50,
    PIPE = 51,
    LBRACE = 52,
    RBRACE = 53,
    PLUS = 54,
    Not = 55,
    And = 56,
    Or = 57,
    SLASH = 58,
    PERCENT = 59,
    SLASHSLASH = 60,
    AMP = 61,
    CARET = 62,
    LTLT = 63,
    TILDE = 64,
    Is = 65,
    LT = 66,
    LTEQ = 67,
    EQEQ = 68,
    BANGEQ = 69,
    GTEQ = 70,
    GT = 71,
    LTGT = 72,
    Lambda3 = 73,
    PLUSEQ = 74,
    DASHEQ = 75,
    STAREQ = 76,
    SLASHEQ = 77,
    ATEQ = 78,
    SLASHSLASHEQ = 79,
    PERCENTEQ = 80,
    STARSTAREQ = 81,
    GTGTEQ = 82,
    LTLTEQ = 83,
    AMPEQ = 84,
    CARETEQ = 85,
    PIPEEQ = 86,
    Yield2 = 87,
    Ellipsis = 88,
    EscapeSequence = 89,
    BSLASH = 90,
    FormatSpecifierToken1 = 91,
    TypeConversion = 92,
    Integer = 93,
    Float = 94,
    Await2 = 95,
    True = 96,
    False = 97,
    None = 98,
    Comment = 99,
    LineContinuation = 100,
    Newline = 101,
    Indent = 102,
    Dedent = 103,
    StringStart = 104,
    StringContent2 = 105,
    EscapeInterpolation = 106,
    StringEnd = 107,
    Module = 108,
    Statement = 109,
    SimpleStatements = 110,
    ImportStatement = 111,
    ImportPrefix = 112,
    RelativeImport = 113,
    FutureImportStatement = 114,
    ImportFromStatement = 115,
    ImportList = 116,
    AliasedImport = 117,
    WildcardImport = 118,
    PrintStatement = 119,
    Chevron = 120,
    AssertStatement = 121,
    ExpressionStatement = 122,
    NamedExpression = 123,
    NamedExpressionLhs = 124,
    ReturnStatement = 125,
    DeleteStatement = 126,
    RaiseStatement = 127,
    PassStatement = 128,
    BreakStatement = 129,
    ContinueStatement = 130,
    IfStatement = 131,
    ElifClause = 132,
    ElseClause = 133,
    MatchStatement = 134,
    Block = 135,
    CaseClause = 136,
    ForStatement = 137,
    WhileStatement = 138,
    TryStatement = 139,
    ExceptClause = 140,
    ExceptGroupClause = 141,
    FinallyClause = 142,
    WithStatement = 143,
    WithClause = 144,
    WithItem = 145,
    FunctionDefinition = 146,
    Parameters = 147,
    LambdaParameters = 148,
    ListSplat = 149,
    DictionarySplat = 150,
    GlobalStatement = 151,
    NonlocalStatement = 152,
    ExecStatement = 153,
    TypeAliasStatement = 154,
    ClassDefinition = 155,
    TypeParameter = 156,
    ParenthesizedListSplat = 157,
    ArgumentList = 158,
    DecoratedDefinition = 159,
    Decorator = 160,
    Block2 = 161,
    ExpressionList = 162,
    DottedName = 163,
    CasePattern = 164,
    SimplePattern = 165,
    AsPattern = 166,
    UnionPattern = 167,
    ListPattern = 168,
    TuplePattern = 169,
    DictPattern = 170,
    KeyValuePattern = 171,
    KeywordPattern = 172,
    SplatPattern = 173,
    ClassPattern = 174,
    ComplexPattern = 175,
    Parameters2 = 176,
    Patterns = 177,
    Parameter = 178,
    Pattern = 179,
    TuplePattern2 = 180,
    ListPattern2 = 181,
    DefaultParameter = 182,
    TypedDefaultParameter = 183,
    ListSplatPattern = 184,
    DictionarySplatPattern = 185,
    AsPattern2 = 186,
    ExpressionWithinForInClause = 187,
    Expression = 188,
    PrimaryExpression = 189,
    NotOperator = 190,
    BooleanOperator = 191,
    BinaryOperator = 192,
    UnaryOperator = 193,
    Notin = 194,
    Isnot = 195,
    ComparisonOperator = 196,
    Lambda = 197,
    Lambda2 = 198,
    Assignment = 199,
    AugmentedAssignment = 200,
    PatternList = 201,
    RightHandSide = 202,
    Yield = 203,
    Attribute = 204,
    Subscript = 205,
    Slice = 206,
    Call = 207,
    TypedParameter = 208,
    Type = 209,
    SplatType = 210,
    GenericType = 211,
    UnionType = 212,
    ConstrainedType = 213,
    MemberType = 214,
    KeywordArgument = 215,
    List = 216,
    Set = 217,
    Tuple = 218,
    Dictionary = 219,
    Pair = 220,
    ListComprehension = 221,
    DictionaryComprehension = 222,
    SetComprehension = 223,
    GeneratorExpression = 224,
    ComprehensionClauses = 225,
    ParenthesizedExpression = 226,
    CollectionElements = 227,
    ForInClause = 228,
    IfClause = 229,
    ConditionalExpression = 230,
    ConcatenatedString = 231,
    String = 232,
    StringContent = 233,
    Interpolation = 234,
    FExpression = 235,
    NotEscapeSequence = 236,
    FormatSpecifier = 237,
    Await = 238,
    PositionalSeparator = 239,
    KeywordSeparator = 240,
    ModuleRepeat1 = 241,
    SimpleStatementsRepeat1 = 242,
    ImportPrefixRepeat1 = 243,
    ImportListRepeat1 = 244,
    PrintStatementRepeat1 = 245,
    AssertStatementRepeat1 = 246,
    IfStatementRepeat1 = 247,
    MatchStatementRepeat1 = 248,
    MatchBlockRepeat1 = 249,
    CaseClauseRepeat1 = 250,
    TryStatementRepeat1 = 251,
    TryStatementRepeat2 = 252,
    WithClauseRepeat1 = 253,
    GlobalStatementRepeat1 = 254,
    TypeParameterRepeat1 = 255,
    ArgumentListRepeat1 = 256,
    DecoratedDefinitionRepeat1 = 257,
    DottedNameRepeat1 = 258,
    UnionPatternRepeat1 = 259,
    DictPatternRepeat1 = 260,
    ParametersRepeat1 = 261,
    PatternsRepeat1 = 262,
    ComparisonOperatorRepeat1 = 263,
    SubscriptRepeat1 = 264,
    DictionaryRepeat1 = 265,
    ComprehensionClausesRepeat1 = 266,
    CollectionElementsRepeat1 = 267,
    ForInClauseRepeat1 = 268,
    ConcatenatedStringRepeat1 = 269,
    StringRepeat1 = 270,
    StringContentRepeat1 = 271,
    FormatSpecifierRepeat1 = 272,
    AsPatternTarget = 273,
    FormatExpression = 274,
    Error = 275,
}

impl From<Python> for &'static str {
    #[inline(always)]
    fn from(tok: Python) -> Self {
        match tok {
            Python::End => "end",
            Python::Identifier => "identifier",
            Python::SEMI => ";",
            Python::Import => "import",
            Python::DOT => ".",
            Python::From => "from",
            Python::Future => "__future__",
            Python::LPAREN => "(",
            Python::RPAREN => ")",
            Python::COMMA => ",",
            Python::As => "as",
            Python::STAR => "*",
            Python::Print => "print",
            Python::GTGT => ">>",
            Python::Assert => "assert",
            Python::COLONEQ => ":=",
            Python::Return => "return",
            Python::Del => "del",
            Python::Raise => "raise",
            Python::Pass => "pass",
            Python::Break => "break",
            Python::Continue => "continue",
            Python::If => "if",
            Python::COLON => ":",
            Python::Elif => "elif",
            Python::Else => "else",
            Python::Match => "match",
            Python::Case => "case",
            Python::Async => "async",
            Python::For => "for",
            Python::In => "in",
            Python::While => "while",
            Python::Try => "try",
            Python::Except => "except",
            Python::ExceptSTAR => "except*",
            Python::Finally => "finally",
            Python::With => "with",
            Python::Def => "def",
            Python::DASHGT => "->",
            Python::STARSTAR => "**",
            Python::Global => "global",
            Python::Nonlocal => "nonlocal",
            Python::Exec => "exec",
            Python::Type2 => "type",
            Python::EQ => "=",
            Python::Class => "class",
            Python::LBRACK => "[",
            Python::RBRACK => "]",
            Python::AT => "@",
            Python::DASH => "-",
            Python::UNDERSCORE => "_",
            Python::PIPE => "|",
            Python::LBRACE => "{",
            Python::RBRACE => "}",
            Python::PLUS => "+",
            Python::Not => "not",
            Python::And => "and",
            Python::Or => "or",
            Python::SLASH => "/",
            Python::PERCENT => "%",
            Python::SLASHSLASH => "//",
            Python::AMP => "&",
            Python::CARET => "^",
            Python::LTLT => "<<",
            Python::TILDE => "~",
            Python::Is => "is",
            Python::LT => "<",
            Python::LTEQ => "<=",
            Python::EQEQ => "==",
            Python::BANGEQ => "!=",
            Python::GTEQ => ">=",
            Python::GT => ">",
            Python::LTGT => "<>",
            Python::Lambda3 => "lambda",
            Python::PLUSEQ => "+=",
            Python::DASHEQ => "-=",
            Python::STAREQ => "*=",
            Python::SLASHEQ => "/=",
            Python::ATEQ => "@=",
            Python::SLASHSLASHEQ => "//=",
            Python::PERCENTEQ => "%=",
            Python::STARSTAREQ => "**=",
            Python::GTGTEQ => ">>=",
            Python::LTLTEQ => "<<=",
            Python::AMPEQ => "&=",
            Python::CARETEQ => "^=",
            Python::PIPEEQ => "|=",
            Python::Yield2 => "yield",
            Python::Ellipsis => "ellipsis",
            Python::EscapeSequence => "escape_sequence",
            Python::BSLASH => "\\",
            Python::FormatSpecifierToken1 => "format_specifier_token1",
            Python::TypeConversion => "type_conversion",
            Python::Integer => "integer",
            Python::Float => "float",
            Python::Await2 => "await",
            Python::True => "true",
            Python::False => "false",
            Python::None => "none",
            Python::Comment => "comment",
            Python::LineContinuation => "line_continuation",
            Python::Newline => "_newline",
            Python::Indent => "_indent",
            Python::Dedent => "_dedent",
            Python::StringStart => "string_start",
            Python::StringContent2 => "_string_content",
            Python::EscapeInterpolation => "escape_interpolation",
            Python::StringEnd => "string_end",
            Python::Module => "module",
            Python::Statement => "_statement",
            Python::SimpleStatements => "_simple_statements",
            Python::ImportStatement => "import_statement",
            Python::ImportPrefix => "import_prefix",
            Python::RelativeImport => "relative_import",
            Python::FutureImportStatement => "future_import_statement",
            Python::ImportFromStatement => "import_from_statement",
            Python::ImportList => "_import_list",
            Python::AliasedImport => "aliased_import",
            Python::WildcardImport => "wildcard_import",
            Python::PrintStatement => "print_statement",
            Python::Chevron => "chevron",
            Python::AssertStatement => "assert_statement",
            Python::ExpressionStatement => "expression_statement",
            Python::NamedExpression => "named_expression",
            Python::NamedExpressionLhs => "_named_expression_lhs",
            Python::ReturnStatement => "return_statement",
            Python::DeleteStatement => "delete_statement",
            Python::RaiseStatement => "raise_statement",
            Python::PassStatement => "pass_statement",
            Python::BreakStatement => "break_statement",
            Python::ContinueStatement => "continue_statement",
            Python::IfStatement => "if_statement",
            Python::ElifClause => "elif_clause",
            Python::ElseClause => "else_clause",
            Python::MatchStatement => "match_statement",
            Python::Block => "block",
            Python::CaseClause => "case_clause",
            Python::ForStatement => "for_statement",
            Python::WhileStatement => "while_statement",
            Python::TryStatement => "try_statement",
            Python::ExceptClause => "except_clause",
            Python::ExceptGroupClause => "except_group_clause",
            Python::FinallyClause => "finally_clause",
            Python::WithStatement => "with_statement",
            Python::WithClause => "with_clause",
            Python::WithItem => "with_item",
            Python::FunctionDefinition => "function_definition",
            Python::Parameters => "parameters",
            Python::LambdaParameters => "lambda_parameters",
            Python::ListSplat => "list_splat",
            Python::DictionarySplat => "dictionary_splat",
            Python::GlobalStatement => "global_statement",
            Python::NonlocalStatement => "nonlocal_statement",
            Python::ExecStatement => "exec_statement",
            Python::TypeAliasStatement => "type_alias_statement",
            Python::ClassDefinition => "class_definition",
            Python::TypeParameter => "type_parameter",
            Python::ParenthesizedListSplat => "parenthesized_list_splat",
            Python::ArgumentList => "argument_list",
            Python::DecoratedDefinition => "decorated_definition",
            Python::Decorator => "decorator",
            Python::Block2 => "block",
            Python::ExpressionList => "expression_list",
            Python::DottedName => "dotted_name",
            Python::CasePattern => "case_pattern",
            Python::SimplePattern => "_simple_pattern",
            Python::AsPattern => "as_pattern",
            Python::UnionPattern => "union_pattern",
            Python::ListPattern => "list_pattern",
            Python::TuplePattern => "tuple_pattern",
            Python::DictPattern => "dict_pattern",
            Python::KeyValuePattern => "_key_value_pattern",
            Python::KeywordPattern => "keyword_pattern",
            Python::SplatPattern => "splat_pattern",
            Python::ClassPattern => "class_pattern",
            Python::ComplexPattern => "complex_pattern",
            Python::Parameters2 => "_parameters",
            Python::Patterns => "_patterns",
            Python::Parameter => "parameter",
            Python::Pattern => "pattern",
            Python::TuplePattern2 => "tuple_pattern",
            Python::ListPattern2 => "list_pattern",
            Python::DefaultParameter => "default_parameter",
            Python::TypedDefaultParameter => "typed_default_parameter",
            Python::ListSplatPattern => "list_splat_pattern",
            Python::DictionarySplatPattern => "dictionary_splat_pattern",
            Python::AsPattern2 => "as_pattern",
            Python::ExpressionWithinForInClause => "_expression_within_for_in_clause",
            Python::Expression => "expression",
            Python::PrimaryExpression => "primary_expression",
            Python::NotOperator => "not_operator",
            Python::BooleanOperator => "boolean_operator",
            Python::BinaryOperator => "binary_operator",
            Python::UnaryOperator => "unary_operator",
            Python::Notin => "not in",
            Python::Isnot => "is not",
            Python::ComparisonOperator => "comparison_operator",
            Python::Lambda => "lambda",
            Python::Lambda2 => "lambda",
            Python::Assignment => "assignment",
            Python::AugmentedAssignment => "augmented_assignment",
            Python::PatternList => "pattern_list",
            Python::RightHandSide => "_right_hand_side",
            Python::Yield => "yield",
            Python::Attribute => "attribute",
            Python::Subscript => "subscript",
            Python::Slice => "slice",
            Python::Call => "call",
            Python::TypedParameter => "typed_parameter",
            Python::Type => "type",
            Python::SplatType => "splat_type",
            Python::GenericType => "generic_type",
            Python::UnionType => "union_type",
            Python::ConstrainedType => "constrained_type",
            Python::MemberType => "member_type",
            Python::KeywordArgument => "keyword_argument",
            Python::List => "list",
            Python::Set => "set",
            Python::Tuple => "tuple",
            Python::Dictionary => "dictionary",
            Python::Pair => "pair",
            Python::ListComprehension => "list_comprehension",
            Python::DictionaryComprehension => "dictionary_comprehension",
            Python::SetComprehension => "set_comprehension",
            Python::GeneratorExpression => "generator_expression",
            Python::ComprehensionClauses => "_comprehension_clauses",
            Python::ParenthesizedExpression => "parenthesized_expression",
            Python::CollectionElements => "_collection_elements",
            Python::ForInClause => "for_in_clause",
            Python::IfClause => "if_clause",
            Python::ConditionalExpression => "conditional_expression",
            Python::ConcatenatedString => "concatenated_string",
            Python::String => "string",
            Python::StringContent => "string_content",
            Python::Interpolation => "interpolation",
            Python::FExpression => "_f_expression",
            Python::NotEscapeSequence => "_not_escape_sequence",
            Python::FormatSpecifier => "format_specifier",
            Python::Await => "await",
            Python::PositionalSeparator => "positional_separator",
            Python::KeywordSeparator => "keyword_separator",
            Python::ModuleRepeat1 => "module_repeat1",
            Python::SimpleStatementsRepeat1 => "_simple_statements_repeat1",
            Python::ImportPrefixRepeat1 => "import_prefix_repeat1",
            Python::ImportListRepeat1 => "_import_list_repeat1",
            Python::PrintStatementRepeat1 => "print_statement_repeat1",
            Python::AssertStatementRepeat1 => "assert_statement_repeat1",
            Python::IfStatementRepeat1 => "if_statement_repeat1",
            Python::MatchStatementRepeat1 => "match_statement_repeat1",
            Python::MatchBlockRepeat1 => "_match_block_repeat1",
            Python::CaseClauseRepeat1 => "case_clause_repeat1",
            Python::TryStatementRepeat1 => "try_statement_repeat1",
            Python::TryStatementRepeat2 => "try_statement_repeat2",
            Python::WithClauseRepeat1 => "with_clause_repeat1",
            Python::GlobalStatementRepeat1 => "global_statement_repeat1",
            Python::TypeParameterRepeat1 => "type_parameter_repeat1",
            Python::ArgumentListRepeat1 => "argument_list_repeat1",
            Python::DecoratedDefinitionRepeat1 => "decorated_definition_repeat1",
            Python::DottedNameRepeat1 => "dotted_name_repeat1",
            Python::UnionPatternRepeat1 => "union_pattern_repeat1",
            Python::DictPatternRepeat1 => "dict_pattern_repeat1",
            Python::ParametersRepeat1 => "_parameters_repeat1",
            Python::PatternsRepeat1 => "_patterns_repeat1",
            Python::ComparisonOperatorRepeat1 => "comparison_operator_repeat1",
            Python::SubscriptRepeat1 => "subscript_repeat1",
            Python::DictionaryRepeat1 => "dictionary_repeat1",
            Python::ComprehensionClausesRepeat1 => "_comprehension_clauses_repeat1",
            Python::CollectionElementsRepeat1 => "_collection_elements_repeat1",
            Python::ForInClauseRepeat1 => "for_in_clause_repeat1",
            Python::ConcatenatedStringRepeat1 => "concatenated_string_repeat1",
            Python::StringRepeat1 => "string_repeat1",
            Python::StringContentRepeat1 => "string_content_repeat1",
            Python::FormatSpecifierRepeat1 => "format_specifier_repeat1",
            Python::AsPatternTarget => "as_pattern_target",
            Python::FormatExpression => "format_expression",
            Python::Error => "ERROR",
        }
    }
}

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

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

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