Skip to content

Commit

Permalink
Suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
rickie committed Apr 4, 2023
1 parent c627149 commit cacc84b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,17 @@ SuggestedFix after(Tree tree, String postfix) {
return SuggestedFix.postfixWith(tree, postfix);
}
}

/** Prefer {@link SuggestedFix#delete(Tree)} over more contrived alternatives. */
static final class SuggestedFixDelete {
@BeforeTemplate
SuggestedFix before(Tree tree) {
return SuggestedFix.builder().delete(tree).build();
}

@AfterTemplate
SuggestedFix after(Tree tree) {
return SuggestedFix.delete(tree);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ SuggestedFix testSuggestedFixPrefixWith() {
SuggestedFix testSuggestedFixPostfixWith() {
return SuggestedFix.builder().postfixWith(null, "foo").build();
}

SuggestedFix testSuggestedFixDelete() {
return SuggestedFix.builder().delete((Tree) null).build();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tech.picnic.errorprone.refasterrules;

import com.google.errorprone.fixes.SuggestedFix;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.Tree;
import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase;
Expand Down Expand Up @@ -28,4 +29,8 @@ SuggestedFix testSuggestedFixPrefixWith() {
SuggestedFix testSuggestedFixPostfixWith() {
return Suggestions.postfixWith(null, "foo");
}

SuggestedFix testSuggestedFixDelete() {
return SuggestedFix.delete((Tree) null);
}
}

0 comments on commit cacc84b

Please sign in to comment.