1(comment)+ @comment.around
2
3(function_declaration
4 body: (_
5 "{"
6 (_)* @function.inside
7 "}")) @function.around
8
9(method_definition
10 body: (_
11 "{"
12 (_)* @function.inside
13 "}")) @function.around
14
15(function_expression
16 body: (_
17 "{"
18 (_)* @function.inside
19 "}")) @function.around
20
21((arrow_function
22 body: (statement_block
23 "{"
24 (_)* @function.inside
25 "}")) @function.around
26 (#not-has-parent? @function.around variable_declarator))
27
28; Arrow function in variable declaration - capture the full declaration
29([
30 (lexical_declaration
31 (variable_declarator
32 value: (arrow_function
33 body: (statement_block
34 "{"
35 (_)* @function.inside
36 "}"))))
37 (variable_declaration
38 (variable_declarator
39 value: (arrow_function
40 body: (statement_block
41 "{"
42 (_)* @function.inside
43 "}"))))
44]) @function.around
45
46; Arrow function in variable declaration - capture body as @function.inside
47; (for statement blocks, the more specific pattern above captures just the contents)
48([
49 (lexical_declaration
50 (variable_declarator
51 value: (arrow_function
52 body: (_) @function.inside)))
53 (variable_declaration
54 (variable_declarator
55 value: (arrow_function
56 body: (_) @function.inside)))
57]) @function.around
58
59; Catch-all for arrow functions in other contexts (callbacks, etc.)
60((arrow_function
61 body: (_) @function.inside) @function.around
62 (#not-has-parent? @function.around variable_declarator))
63(function_signature) @function.around
64
65(generator_function
66 body: (_
67 "{"
68 (_)* @function.inside
69 "}")) @function.around
70
71(generator_function_declaration
72 body: (_
73 "{"
74 (_)* @function.inside
75 "}")) @function.around
76
77(class_declaration
78 body: (_
79 "{"
80 [(_) ";"?]* @class.inside
81 "}" )) @class.around
82
83(class
84 body: (_
85 "{"
86 (_)* @class.inside
87 "}" )) @class.around
88
89(interface_declaration
90 body: (_
91 "{"
92 [(_) ";"?]* @class.inside
93 "}" )) @class.around
94
95(enum_declaration
96 body: (_
97 "{"
98 [(_) ","?]* @class.inside
99 "}" )) @class.around
100
101(ambient_declaration
102 (module
103 body: (_
104 "{"
105 [(_) ";"?]* @class.inside
106 "}" ))) @class.around
107
108(internal_module
109 body: (_
110 "{"
111 [(_) ";"?]* @class.inside
112 "}" )) @class.around
113
114(type_alias_declaration) @class.around