Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotations with commas cause errors #151

Open
reddaly opened this issue Oct 8, 2024 · 1 comment · May be fixed by #152
Open

Annotations with commas cause errors #151

reddaly opened this issue Oct 8, 2024 · 1 comment · May be fixed by #152

Comments

@reddaly
Copy link
Contributor

reddaly commented Oct 8, 2024

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)))
      ))))
@reddaly
Copy link
Contributor Author

reddaly commented Oct 8, 2024

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(","),
      "]"),

reddaly added a commit to reddaly/tree-sitter-kotlin that referenced this issue Oct 8, 2024
reddaly added a commit to reddaly/tree-sitter-kotlin that referenced this issue Oct 8, 2024
@reddaly reddaly linked a pull request Oct 8, 2024 that will close this issue
reddaly added a commit to reddaly/go-tree-sitter that referenced this issue Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant