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
Various fixes for generating @SuppressWarnings #271
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
@lazaroclapp want to take another look? I made some further fixes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but see the few questions/nits added.
&& ((ClassTree) tree).getSimpleName().length() != 0) | ||
|| tree instanceof VariableTree) | ||
.findFirst() | ||
.orElse(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this iterate over the full path even if the suppressible node is close? Or is it a lazy iterator / generator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. From what I can see it bottoms out in an iterator and goes one by one checking the predicate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry by "I think so" I meant that I think it's lazy
" @SuppressWarnings(\"NullAway\")", | ||
" int x = foo + 1;", | ||
" };", | ||
"}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you assign a lambda within a method, where does this put the suppression? And, does that suppression work?
e.g.
public void foo() {
this.f = () -> { ... };
Object o = () -> { ... };
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test case. For the this.f
assignment the suppression goes on the method, whereas for the Object o
case it goes on the assignment itself (you can suppress on variable declarations).
" }", | ||
" void m2() {", | ||
" @SuppressWarnings(\"NullAway\")", | ||
" java.util.function.Function<Object,Integer> g = (x) -> { return foo + 1; };", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Fixes #266
Fixes some issues with generating suppressions for method reference and lambda issues (see new tests).
Also refactors the code a bit to be more consistent in using the
TreePath
to find the right place to suppress