tree-sitter-kotlin
tree-sitter-kotlin copied to clipboard
Annotations with commas cause errors
Example test case that fails:
==================
Comma in annotation property
==================
class EnvironmentSpec {
@Option(
names = ["--environment", "--env"],
arity = "0..1",
description = [
"Which environment to use",
],
)
var environment: Environment
}
---
(source_file
(class_declaration
(type_identifier)
(class_body
(property_declaration
(modifiers
(annotation
(constructor_invocation
(user_type
(type_identifier))
(value_arguments
(value_argument
(simple_identifier)
(collection_literal
(string_literal (string_content))
(string_literal (string_content))))
(value_argument
(simple_identifier)
(string_literal (string_content)))
(value_argument
(simple_identifier)
(collection_literal
(string_literal (string_content))
))))))
(binding_pattern_kind)
(variable_declaration
(simple_identifier)
(user_type
(type_identifier)))
))))
Something like this might fix it:
// https://kotlinlang.org/spec/syntax-and-grammar.html#grammar-rule-collectionLiteral
collection_literal: $ => seq(
"[",
$._expression,
repeat(seq(",", $._expression)),
optional(","),
"]"),