-
Notifications
You must be signed in to change notification settings - Fork 39
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
Suggest canonical modifier usage for Refaster template definitions #254
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.
Check looks good, nice improvement for open sourcing!
Tests look really clean.
@Override | ||
public Description matchClass(ClassTree tree, VisitorState state) { | ||
if (!hasMatchingMember(tree, BEFORE_TEMPLATE_METHOD, state)) { | ||
/* This is not a Refaster template class. */ |
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.
/* This is not a Refaster template class. */ | |
/* This class is not a Refaster template. */ |
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.
Hmm, not sure. But will propose something.
.orElse(Description.NO_MATCH); | ||
} | ||
|
||
private static SuggestedFix suggestFix(ClassTree tree, VisitorState state) { |
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.
suggestFix
is not ideal IMHO, simply because of the SuggestedFix
class. In some other classes we use tryFix....
. Maybe we can go for tryFixModifiers
? Although clear from context, I think it is a bit clearer about the content of the method.
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.
suggestCanonicalModifiers
maybe?
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.
"suggest" is present tense, and "suggested" is past tense. So to me it makes at least some sense that a method named suggestFix
produces a SuggestedFix
. I avoided tryFixModifiers
on purpose because I prefer to reserve try
for Optional
-returning methods (or methods with a conditional side-effect).
But suggestCanonicalModifiers
SGTM 👍
" }", | ||
"", | ||
" @BeforeTemplate", | ||
" // BUG: Diagnostic contains:", |
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.
Shouldn't beforeStatic
come before beforeSynchronized
?
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.
By that logic we should swap more stuff; will add a commit.
Added a commit. Suggested commit message looks good. We could go for |
15ecd5e
to
841b35e
Compare
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.
Rebased and added a commit. Thanks for the review!
" }", | ||
"", | ||
" @BeforeTemplate", | ||
" // BUG: Diagnostic contains:", |
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.
By that logic we should swap more stuff; will add a commit.
@Override | ||
public Description matchClass(ClassTree tree, VisitorState state) { | ||
if (!hasMatchingMember(tree, BEFORE_TEMPLATE_METHOD, state)) { | ||
/* This is not a Refaster template class. */ |
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.
Hmm, not sure. But will propose something.
.orElse(Description.NO_MATCH); | ||
} | ||
|
||
private static SuggestedFix suggestFix(ClassTree tree, VisitorState state) { |
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.
"suggest" is present tense, and "suggested" is past tense. So to me it makes at least some sense that a method named suggestFix
produces a SuggestedFix
. I avoided tryFixModifiers
on purpose because I prefer to reserve try
for Optional
-returning methods (or methods with a conditional side-effect).
But suggestCanonicalModifiers
SGTM 👍
As discussed here.
Suggested commit message: