-
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
Introduce SuggestedFixRules
Refaster rule collection
#559
Conversation
Looks good. No mutations were possible for these changes. |
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 commit and added a Refaster rule and some questions. Besides that, LGTM!
static final class SuggestedFixReplaceTree { | ||
@BeforeTemplate | ||
SuggestedFix before(Tree tree, String replaceWith) { | ||
return SuggestedFix.builder().replace(tree, replaceWith).build(); |
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'm curious why the replaceWith
part is left out in all titles 👀.
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.
Because I started out with a name that didn't include it, I think.
} | ||
|
||
/** Prefer {@link SuggestedFix#swap(Tree, Tree)} over more contrived alternatives. */ | ||
static final class SuggestedFixSwap { |
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.
What order do we use here? Should we use the same order as the methods are listed in SuggestedFix
?
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.
Long-term I guess lexicographical order makes most sense. Here I went with "likelihood of being used".
} | ||
|
||
/** Prefer {@link SuggestedFix#swap(Tree, Tree)} over more contrived alternatives. */ | ||
static final class SuggestedFixSwap { |
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.
What order do we use here? Should we use the same order as the methods are listed in SuggestedFix
?
SuggestedFix after(Tree tree, String postfix) { | ||
return SuggestedFix.postfixWith(tree, postfix); | ||
} | ||
} |
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.
Any reason for omitting SuggestedFix#delete(Tree)
? I added it :).
Looks good. No mutations were possible for these changes. |
cacc84b
to
e7b47a7
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 :)
} | ||
|
||
SuggestedFix testSuggestedFixDelete() { | ||
return SuggestedFix.builder().delete((Tree) null).build(); |
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.
No need to cast here. (Another thing we could try to auto-fix.)
static final class SuggestedFixReplaceTree { | ||
@BeforeTemplate | ||
SuggestedFix before(Tree tree, String replaceWith) { | ||
return SuggestedFix.builder().replace(tree, replaceWith).build(); |
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.
Because I started out with a name that didn't include it, I think.
} | ||
|
||
/** Prefer {@link SuggestedFix#swap(Tree, Tree)} over more contrived alternatives. */ | ||
static final class SuggestedFixSwap { |
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.
Long-term I guess lexicographical order makes most sense. Here I went with "likelihood of being used".
Looks good. No mutations were possible for these changes. |
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 stuff 🚀 !
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, will merge once 🟢. |
Looks good. No mutations were possible for these changes. |
Suggested commit message:
This PR was written with the aid of GitHub Copilot. It simplifies expressions suggested by Copilot while working on another PR.