Skip to content

Adds attribute_group node to complete attributes support#130

Merged
aryx merged 1 commit intotree-sitter:masterfrom
cfroystad:attribute_group
May 27, 2022
Merged

Adds attribute_group node to complete attributes support#130
aryx merged 1 commit intotree-sitter:masterfrom
cfroystad:attribute_group

Conversation

@cfroystad
Copy link
Collaborator

@cfroystad cfroystad commented May 27, 2022

Also fixes a bug with missing support for trailing comma in attribute listings

This changes the node structure for currently unreleased code.

Example

Code:

#[
    A1,
    A2(),
    A3(0),
    A4(x: 1),
]
function a() {
}

Before:

(function_definition
    attributes: (attribute_list
        (attribute (name))
        (attribute
          (name)
          parameters: (arguments)
        )
        (attribute
          (name)
          parameters: (arguments (argument (integer)))
        )
        (attribute
          (name)
          parameters: (arguments (argument name: (name) (integer)))
        )
    )
    name: (name)
    parameters: (formal_parameters)
    body: (compound_statement)
  )

After:

(function_definition
    attributes: (attribute_list
      (attribute_group
        (attribute (name))
        (attribute
          (name)
          parameters: (arguments)
        )
        (attribute
          (name)
          parameters: (arguments (argument (integer)))
        )
        (attribute
          (name)
          parameters: (arguments (argument name: (name) (integer)))
        )
      )
    )
    name: (name)
    parameters: (formal_parameters)
    body: (compound_statement)
  )

Checklist:

  • All tests pass in CI
  • There are sufficient tests for the new fix/feature
  • Grammar rules have not been renamed unless absolutely necessary (0 rules renamed)
  • The conflicts section hasn't grown too much (0 new conflicts)
  • The parser size hasn't grown too much (master: 2330, PR: 2338)

@cfroystad cfroystad mentioned this pull request May 27, 2022
32 tasks
@aryx aryx merged commit c8955e9 into tree-sitter:master May 27, 2022
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 this pull request may close these issues.

2 participants