question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Piranha Generic]Need additional information in document for edges and creating tree sitter query

See original GitHub issue

Can 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:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
ketkarameyacommented, Jun 7, 2022

I am going to steal some text from here and put it in the documentation. 😃

0reactions
krmahadevancommented, Jun 7, 2022

I am going to actually steal some text from here and put it in the documentation. 😃

Please feel free to do so 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Piranha Generic]Need additional information in document for edges ...
We are telling piranha to do the following: I am giving you Java source files. Please create 3 variables viz.,. treated with its...
Read more >
Using Parsers - Tree-sitter
This document will describe the general concepts of how to use Tree-sitter, which should be relevant regardless of what language you're using. It...
Read more >
uber/piranha: A tool for refactoring code related to ... - GitHub
Piranha is a tool to automatically refactor code related to stale flags. At a higher level, the input to the tool is the...
Read more >
Package List — Spack 0.20.0.dev0 documentation
A package universe and a request to install, remove, or upgrade packages have to be encoded in the CUDF format. Such a CUDF...
Read more >
Tips for using tree sitter queries - Bearer
Tree-sitter is a powerful library for parsing all kinds of languages, but sometimes it can be tricky. Here are our tips on making...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found