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

Suggest canonical modifier usage for Refaster template definitions #254

Merged
merged 3 commits into from
Sep 29, 2022

Conversation

Stephan202
Copy link
Member

@Stephan202 Stephan202 commented Sep 21, 2022

As discussed here.

Suggested commit message:

Suggest canonical modifier usage for Refaster template definitions (#254)

Copy link
Member

@rickie rickie left a 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. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* This is not a Refaster template class. */
/* This class is not a Refaster template. */

Copy link
Member Author

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) {
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestCanonicalModifiers maybe?

Copy link
Member Author

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:",
Copy link
Member

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?

Copy link
Member Author

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.

@rickie
Copy link
Member

rickie commented Sep 24, 2022

Added a commit.

Suggested commit message looks good. We could go for s/suggest/enforce, but I already like this one.

@Stephan202 Stephan202 force-pushed the sschroevers/refaster-template-modifier-fixes branch from 15ecd5e to 841b35e Compare September 24, 2022 08:54
Copy link
Member Author

@Stephan202 Stephan202 left a 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:",
Copy link
Member Author

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. */
Copy link
Member Author

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) {
Copy link
Member Author

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 👍

@rickie rickie removed the request for review from EnricSala September 29, 2022 11:06
@rickie rickie merged commit 397f9c3 into master Sep 29, 2022
@rickie rickie deleted the sschroevers/refaster-template-modifier-fixes branch September 29, 2022 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants