[Piranha Generic]Need additional information in document for edges and creating tree sitter query
See original GitHub issueCan we add more information pertaining to the relevance of the edges file and what usually goes into it ? Also maybe add some examples so that it’s easy to understand this?
Also the documentation points to this tree sitter link to understand pattern matching with queries.
Here’s an example of the query from the example project
[[rules]]
name = "replace_isToggleEnabled_with_boolean_literal"
query = """((
(method_invocation
name : (_) @name
arguments: ((argument_list
([
(field_access field: (_)@argument)
(_) @argument
])) )
) @method_invocation
)
(#eq? @name "isActive")
(#eq? @argument "@stale_flag_name")
)"""
replace_node = "method_invocation"
replace = "@treated"
groups = [ "replace_expression_with_boolean_literal"]
holes = ["treated", "stale_flag_name"]
It would be good from an understanding perspective if we can add some additional context/documentation around each of the tags, what are the allowed values for the tags and where within the tree sitter documentation can we get more information.
For e.g., I was looking at information on how to create my own query which looks like this
"""((
(method_invocation
name : (_) @name
arguments: ((argument_list
([
(field_access field: (_)@argument)
(_) @argument
])) )
) @method_invocation
)
(#eq? @name "isActive")
(#eq? @argument "@stale_flag_name")
)"""
Also in the below sections
groups = [ "replace_expression_with_boolean_literal"]
holes = ["treated", "stale_flag_name"]
what are the other possible values for groups
apart from replace_expression_with_boolean_literal
. This will give a bit more better context around this.
So goes the case with holes
section as well.
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top GitHub Comments
I am going to steal some text from here and put it in the documentation. 😃
Please feel free to do so 👍