Skip to content

Commit

Permalink
group params
Browse files Browse the repository at this point in the history
  • Loading branch information
amchiclet committed Mar 26, 2024
1 parent 68235d5 commit ea10bc4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
8 changes: 5 additions & 3 deletions lang/semgrep-grammars/src/semgrep-kotlin/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,17 @@ module.exports = grammar(standard_grammar, {
// So we just need to fix _statement.
_statement: ($, previous) => choice(
previous,
prec.left(seq(
$.partial_class_declaration,
),

partial_class_declaration: $ => prec.left(seq(
optional($.type_parameters),
seq(optional($.modifiers), "constructor"),
$._class_parameters,
optional(seq(":", $._delegation_specifiers)),
optional($.type_constraints),
optional($.class_body)
))
),
)),

class_parameter: ($, previous) => {
return choice(
Expand Down
27 changes: 14 additions & 13 deletions lang/semgrep-grammars/src/semgrep-kotlin/test/corpus/semgrep.txt
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,20 @@ constructor(arg: Int) {
(source_file
(class_declaration
(type_identifier))
(class_parameter
(simple_identifier)
(user_type
(type_identifier)))
(class_body
(property_declaration
(modifiers
(visibility_modifier))
(variable_declaration
(simple_identifier))
(string_literal
(interpolated_expression
(simple_identifier))))))
(partial_class_declaration
(class_parameter
(simple_identifier)
(user_type
(type_identifier)))
(class_body
(property_declaration
(modifiers
(visibility_modifier))
(variable_declaration
(simple_identifier))
(string_literal
(interpolated_expression
(simple_identifier)))))))

=====================================
Class in a class
Expand Down

0 comments on commit ea10bc4

Please sign in to comment.