Coverage for src/renaissance/integrations/tree_sitter/kinds.py: 100%
2 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-15 10:34 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-15 10:34 +0000
1# Copyright (C) 2024-2026 TNO
2#
3# Licensed under the terms specified in the LICENSE file in the root directory
4# of this repository, also available at:
5# https://github.com/TNO/Renaissance.Py/blob/main/LICENSE
7"""AI: Mapping of tree-sitter node kinds to the library's semantic kinds."""
9from renaissance.syntax_tree.semantic_kind import SemanticKind
11TREE_SITTER_KIND_MAP = {
12 "module": SemanticKind.TRANSLATION_UNIT,
13 "translation_unit": SemanticKind.TRANSLATION_UNIT,
14 "function_definition": SemanticKind.FUNCTION,
15 "function_declaration": SemanticKind.FUNCTION,
16 "call": SemanticKind.CALL,
17 "call_expression": SemanticKind.CALL,
18 "identifier": SemanticKind.NAME,
19 "integer": SemanticKind.LITERAL,
20 "integer_literal": SemanticKind.LITERAL,
21 "string": SemanticKind.LITERAL,
22 "string_literal": SemanticKind.LITERAL,
23 "assignment": SemanticKind.ASSIGNMENT,
24 "assignment_expression": SemanticKind.ASSIGNMENT,
25 "binary_expression": SemanticKind.BINARY_OPERATION,
26 "unary_expression": SemanticKind.UNARY_OPERATION,
27 "if_statement": SemanticKind.CONDITIONAL,
28 "conditional_expression": SemanticKind.CONDITIONAL,
29 "for_statement": SemanticKind.LOOP,
30 "while_statement": SemanticKind.LOOP,
31 "return_statement": SemanticKind.RETURN,
32 "return": SemanticKind.RETURN,
33 "import_statement": SemanticKind.IMPORT,
34 "import": SemanticKind.IMPORT,
35 "import_declaration": SemanticKind.IMPORT,
36 "if": SemanticKind.CONDITIONAL,
37 "class_definition": SemanticKind.CLASS,
38 "class_declaration": SemanticKind.CLASS,
39 "class_specifier": SemanticKind.CLASS,
40 "for": SemanticKind.LOOP,
41 "while": SemanticKind.LOOP,
42 "expression_statement": SemanticKind.EXPRESSION,
43 "assert_statement": SemanticKind.CONDITIONAL,
44 "with_statement": SemanticKind.LOOP,
45 "async_for_statement": SemanticKind.LOOP,
46 "async_function_definition": SemanticKind.FUNCTION,
47 "async_with_statement": SemanticKind.LOOP,
48 "try_statement": SemanticKind.STATEMENT,
49 "raise_statement": SemanticKind.RETURN,
50 "break_statement": SemanticKind.RETURN,
51 "continue_statement": SemanticKind.RETURN,
52 "pass_statement": SemanticKind.STATEMENT,
53 "delete_statement": SemanticKind.STATEMENT,
54 "generator_expression": SemanticKind.EXPRESSION,
55 "formatted_string": SemanticKind.LITERAL,
56 "subscript": SemanticKind.EXPRESSION,
57 "tuple": SemanticKind.EXPRESSION,
58 "not_operator": SemanticKind.UNARY_OPERATION,
59 "list": SemanticKind.EXPRESSION,
60 "dictionary_comprehension": SemanticKind.EXPRESSION,
61 "list_comprehension": SemanticKind.EXPRESSION,
62 "set_comprehension": SemanticKind.EXPRESSION,
63 "lambda": SemanticKind.EXPRESSION,
64 "global_statement": SemanticKind.DEFINITION,
65 "dictionary": SemanticKind.EXPRESSION,
66 "set": SemanticKind.EXPRESSION,
67 "FormattedString": SemanticKind.LITERAL,
68 "yield": SemanticKind.EXPRESSION,
69 "await": SemanticKind.EXPRESSION,
70 "match_statement": SemanticKind.CONDITIONAL,
71 "augmented_assignment": SemanticKind.ASSIGNMENT,
72 "import_from_statement": SemanticKind.IMPORT,
73 "binary_operator": SemanticKind.BINARY_OPERATION,
74 "unary_operator": SemanticKind.UNARY_OPERATION,
75 "with": SemanticKind.LOOP,
76 "type_alias_statement": SemanticKind.STATEMENT,
77}