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

Introduce "query_name" predicate #760

Merged
merged 2 commits into from
Oct 9, 2024
Merged

Introduce "query_name" predicate #760

merged 2 commits into from
Oct 9, 2024

Conversation

nbacquey
Copy link
Member

@nbacquey nbacquey commented Oct 8, 2024

Description

This PR introduces an optional predicate #query_name!, that will be displayed in logs.

For instance, this query:

(
  (#query_name! "comma spacing")
  "," @append_space
  .
  (_)
)

will produce the following log line:

[2024-10-08T15:48:13Z INFO  topiary_core::tree_sitter] Processing match of query "comma spacing": LocalQueryMatch { pattern_index: 17, captures: [ {Node "," (1,3) - (1,4)} ] } at location (286,1)

It also triggers an error when encountering an unknown predicate, instead of silently ignoring it (which caused problems during prior developments).

Closes #681

Checklist

Checklist before merging:

  • CHANGELOG.md updated
  • README.md up-to-date

@nbacquey nbacquey marked this pull request as ready for review October 8, 2024 15:56
Copy link
Member

@Xophmeister Xophmeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

I think your comment in the example (in the README) isn't right -- see comment 👇 -- but it's been a while since I looked into this! Please could you double-check?

README.md Show resolved Hide resolved
@nbacquey nbacquey merged commit 80fafe4 into main Oct 9, 2024
9 checks passed
@nbacquey nbacquey deleted the nb/query_names branch October 9, 2024 09:11
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.

Named rules
2 participants