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

Document comment patterns #571

Open
joelburget opened this issue Nov 3, 2024 · 3 comments
Open

Document comment patterns #571

joelburget opened this issue Nov 3, 2024 · 3 comments

Comments

@joelburget
Copy link

The docs don't cover matching comments. It seems like there is support and I was able to reverse-engineer a bit of it, but wasn't able to figure out how to match comments with a specific format (e.g. TODO\((.*)\) where the capture group is a bug identifier).

  • `// TODO` matches only comments whose text is exactly "TODO"
  • `// TODO$_` matches all comments whose prefix is "TODO"
  • `// r"TODO"`, `// r"TODO.*"`, `r"// TODO"`, `r"// TODO.*"`, `// TODO.*`, and `// TODO*` don't match anything
@joelburget
Copy link
Author

`/* TODO$_ */` finds different locations from `// TODO$_` -- both only match that specific type of comment 👎🏻

@joelburget
Copy link
Author

While we're here I also tried the AST node example from the docs but wasn't able to make it work

Screenshot 2024-11-03 at 7 41 24 AM Screenshot 2024-11-03 at 7 41 40 AM Screenshot 2024-11-03 at 7 42 16 AM

@morgante
Copy link
Contributor

morgante commented Nov 4, 2024

By default, Grit treats block comments as different from line comments - since sometimes you want to transform one into the other. We can consider adding an equivalence class, but if you use the AST node it works well.

This should do what you want:

engine marzano(0.1)
language js

string(fragment="str")

I'm unable to replicate your concern with AST nodes:
image

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

2 participants