@@ -19,6 +19,7 @@ pub trait Checker {
1919 fn is_string ( node : & Node ) -> bool ;
2020 fn is_call ( node : & Node ) -> bool ;
2121 fn is_func ( node : & Node ) -> bool ;
22+ fn is_closure ( node : & Node ) -> bool ;
2223 fn is_func_space ( node : & Node ) -> bool ;
2324 fn is_non_arg ( node : & Node ) -> bool ;
2425
@@ -32,6 +33,7 @@ impl Checker for PreprocCode {
3233 mk_checker ! ( is_string, StringLiteral , RawStringLiteral ) ;
3334 mk_checker ! ( is_call, ) ;
3435 mk_checker ! ( is_func, ) ;
36+ mk_checker ! ( is_closure, ) ;
3537 mk_checker ! ( is_func_space, ) ;
3638 mk_checker ! ( is_non_arg, ) ;
3739}
@@ -41,6 +43,7 @@ impl Checker for CcommentCode {
4143 mk_checker ! ( is_string, StringLiteral , RawStringLiteral ) ;
4244 mk_checker ! ( is_call, ) ;
4345 mk_checker ! ( is_func, ) ;
46+ mk_checker ! ( is_closure, ) ;
4447 mk_checker ! ( is_func_space, ) ;
4548 mk_checker ! ( is_non_arg, ) ;
4649
@@ -68,6 +71,7 @@ impl Checker for CppCode {
6871 FunctionDefinition2 ,
6972 FunctionDefinition3
7073 ) ;
74+ mk_checker ! ( is_closure, LambdaExpression ) ;
7175 mk_checker ! (
7276 is_func_space,
7377 TranslationUnit ,
@@ -106,6 +110,7 @@ impl Checker for PythonCode {
106110 mk_checker ! ( is_string, String , ConcatenatedString ) ;
107111 mk_checker ! ( is_call, Call ) ;
108112 mk_checker ! ( is_func, FunctionDefinition ) ;
113+ mk_checker ! ( is_closure, Lambda ) ;
109114 mk_checker ! ( is_func_space, Module , FunctionDefinition , ClassDefinition ) ;
110115 mk_checker ! ( is_non_arg, LPAREN , COMMA , RPAREN ) ;
111116}
@@ -115,6 +120,7 @@ impl Checker for JavaCode {
115120 mk_checker ! ( is_string, StringLiteral ) ;
116121 mk_checker ! ( is_call, MethodInvocation ) ;
117122 mk_checker ! ( is_func, MethodDeclaration ) ;
123+ mk_checker ! ( is_closure, ) ;
118124 mk_checker ! ( is_func_space, Program , ClassDeclaration ) ;
119125 mk_checker ! ( is_non_arg, ) ;
120126}
@@ -123,13 +129,12 @@ impl Checker for MozjsCode {
123129 mk_checker ! ( is_comment, Comment ) ;
124130 mk_checker ! ( is_string, String , TemplateString ) ;
125131 mk_checker ! ( is_call, CallExpression ) ;
132+ mk_checker ! ( is_func, FunctionDeclaration , MethodDefinition ) ;
126133 mk_checker ! (
127- is_func ,
134+ is_closure ,
128135 Function ,
129136 GeneratorFunction ,
130- FunctionDeclaration ,
131137 GeneratorFunctionDeclaration ,
132- MethodDefinition ,
133138 ArrowFunction
134139 ) ;
135140 mk_checker ! (
@@ -153,13 +158,12 @@ impl Checker for JavascriptCode {
153158 mk_checker ! ( is_comment, Comment ) ;
154159 mk_checker ! ( is_string, String , TemplateString ) ;
155160 mk_checker ! ( is_call, CallExpression ) ;
161+ mk_checker ! ( is_func, FunctionDeclaration , MethodDefinition ) ;
156162 mk_checker ! (
157- is_func ,
163+ is_closure ,
158164 Function ,
159165 GeneratorFunction ,
160- FunctionDeclaration ,
161166 GeneratorFunctionDeclaration ,
162- MethodDefinition ,
163167 ArrowFunction
164168 ) ;
165169 mk_checker ! (
@@ -182,13 +186,12 @@ impl Checker for TypescriptCode {
182186 mk_checker ! ( is_comment, Comment ) ;
183187 mk_checker ! ( is_string, String , TemplateString ) ;
184188 mk_checker ! ( is_call, CallExpression ) ;
189+ mk_checker ! ( is_func, FunctionDeclaration , MethodDefinition ) ;
185190 mk_checker ! (
186- is_func ,
191+ is_closure ,
187192 Function ,
188193 GeneratorFunction ,
189- FunctionDeclaration ,
190194 GeneratorFunctionDeclaration ,
191- MethodDefinition ,
192195 ArrowFunction
193196 ) ;
194197 mk_checker ! (
@@ -211,13 +214,12 @@ impl Checker for TsxCode {
211214 mk_checker ! ( is_comment, Comment ) ;
212215 mk_checker ! ( is_string, String , TemplateString ) ;
213216 mk_checker ! ( is_call, CallExpression ) ;
217+ mk_checker ! ( is_func, FunctionDeclaration , MethodDefinition ) ;
214218 mk_checker ! (
215- is_func ,
219+ is_closure ,
216220 Function ,
217221 GeneratorFunction ,
218- FunctionDeclaration ,
219222 GeneratorFunctionDeclaration ,
220- MethodDefinition ,
221223 ArrowFunction
222224 ) ;
223225 mk_checker ! (
@@ -254,7 +256,8 @@ impl Checker for RustCode {
254256 mk_else_if ! ( IfExpression ) ;
255257 mk_checker ! ( is_string, StringLiteral , RawStringLiteral ) ;
256258 mk_checker ! ( is_call, CallExpression ) ;
257- mk_checker ! ( is_func, FunctionItem , ClosureExpression ) ;
259+ mk_checker ! ( is_func, FunctionItem ) ;
260+ mk_checker ! ( is_closure, ClosureExpression ) ;
258261 mk_checker ! (
259262 is_func_space,
260263 SourceFile ,
@@ -263,5 +266,5 @@ impl Checker for RustCode {
263266 TraitItem ,
264267 ClosureExpression
265268 ) ;
266- mk_checker ! ( is_non_arg, LPAREN , COMMA , RPAREN , AttributeItem ) ;
269+ mk_checker ! ( is_non_arg, LPAREN , COMMA , RPAREN , PIPE , AttributeItem ) ;
267270}
0 commit comments