-
Notifications
You must be signed in to change notification settings - Fork 591
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
[Go] Fix compiler directive syntax patterns #3242
Conversation
6199955
to
6c8f18e
Compare
This adds line and export directive syntax patterns and generalises the //go:name pattern for use in other contexts such as linter directives. It also fixes //go:name matching to avoid matching invalid directive comments.
6c8f18e
to
b9d5740
Compare
In general, capturing regex groups should not be part of variables in the syntax. This is mainly for readability reasons. Instead use the variables within a capturing group of the match in the contexts. |
Edit: I somehow didn't see the negative tests for |
These are included. |
In this case (line directive) this either declarifies the use site or breaks the rationale for the pattern, but I will change it. |
|
Looking at golang/go#43776, and noting the existence of |
Co-authored-by: deathaxe <[email protected]>
Prevent stacking `meta.annotation meta.annotation.parameters`.
I'd vote to avoid stacking |
Please revert c41f4ea, it was better before that, or alternatively (preferably) have a punctuation for the space (I looked for whether there would be an obvious way to specify a space as punctuation, but I could not see a label that fit). Pattern like so |
We could scope whitespace as |
The reason I think it should be like that is if people are using background to separately mark the function from the parameters, that will bleed into the space. I don't use background, but I do mark the function differently to the parameters. |
Sorry, clobbered your commit. The naming of the space can be changed to suit. |
@deathaxe Thank you for your help and patience with this. |
This adds line and export directive syntax patterns and generalises the
//go:name
pattern for use in other contexts such as linter directives. It also fixes//go:name
matching to avoid matching invalid directive comments.It's not completely clear to me how to express the expectation in the tests (and some current tests expectation are incorrect;//go
and//go:
are invalid directives — so I expect tests to fail), so please let me know what I should add.These should be marked as valid directives:
These should not be marked:
Please take a look.