-
Notifications
You must be signed in to change notification settings - Fork 624
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
semgrep.dev Java Cannot match annotation to partial class #1877
Comments
That table is so useful, thank you! @aryx since you made the two relevant fixes I assume you'll have a look at this issue as well? |
This will help semgrep/semgrep#1877 test plan: make make test
Fixes #1877 test plan: test file included
@aryx it might be a PEBKAC issue, but I think this fix only partially works. I can see the test case you added in #1883 works and can verify that in the live editor, but if I try to run @ben-elttam's example it fails. After some attempts at debugging where/why it fails, I've noticed that it seems to be due to the EDIT: actually, on further review, maybe the behavior above is expected and it was PEBKAC after all... I see if you edit the test case by specifying the fully qualified class name for the annotation, then it will match as expected and not fail due to the import statement: https://semgrep.dev/s/kWEA/?stepByStep=1 @aryx can you confirm which is the intended behavior? If it's the latter, I might submit a PR with a documentation update and clarifying example so others don't have the some confusion as I had |
What I’ve found is that if you import the full symbol, then the pattern I write these rules with pattern-either to handle it. |
We used to force to use the fully qualified name in the pattern, but I think it's confusing for people, so maybe we should |
I've created another task to track the name resolution issue. |
See #2029 |
Now that Support for partial class header and method header for java #1830 has been merged I expected this to rule definition to work.
https://semgrep.dev/s/l01j?stepByStep=1
I expect:
To match:
But it needs the ellipse on the class, which match/output the whole class, when I just want the class name.
Works but too verbose:
Summarised as a table:
Detailed Explanation:
I can match:
But I cannot match the annotation to the (partial) class.
The text was updated successfully, but these errors were encountered: