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

Named rules #681

Open
Xophmeister opened this issue Feb 20, 2024 · 1 comment
Open

Named rules #681

Xophmeister opened this issue Feb 20, 2024 · 1 comment

Comments

@Xophmeister
Copy link
Member

Xophmeister commented Feb 20, 2024

Is your feature request related to a problem? Please describe.
When debugging the formatting queries, it is very difficult to understand which rules are being applied to some subtree. If rules could be given names, which are spewed out in the debug output, that should make things a lot easier.

Describe the solution you'd like
Perhaps using predicates, something like:

(
   (#name! "space_between_things")

   (some_node)
   .
   (some_sibling) @prepend_space
)

Using names should be encouraged, but not mandatory. If no name is given for a rule, then one could be generated (e.g., queries/my-language.scm:L20-25).

Additional context
Given names must be unique and query parsing should probably fail when this isn't true.

@Xophmeister
Copy link
Member Author

In the debug output there are pattern_index values when there's a match. Presumably these are 0-based in the order in which they appear in the query file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant