Skip to content

Commit

Permalink
Suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Apr 4, 2023
1 parent cc7149a commit e7b47a7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@
final class SuggestedFixRules {
private SuggestedFixRules() {}

/** 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);
}
}

/** Prefer {@link SuggestedFix#replace(Tree, String)}} over more contrived alternatives. */
static final class SuggestedFixReplaceTree {
@BeforeTemplate
Expand Down Expand Up @@ -90,17 +103,4 @@ 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 @@ -5,6 +5,10 @@
import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase;

final class SuggestFixRulesTest implements RefasterRuleCollectionTestCase {
SuggestedFix testSuggestedFixDelete() {
return SuggestedFix.builder().delete(null).build();
}

SuggestedFix testSuggestedFixReplaceTree() {
return SuggestedFix.builder().replace(null, "foo").build();
}
Expand All @@ -28,8 +32,4 @@ 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
Expand Up @@ -6,6 +6,10 @@
import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase;

final class SuggestFixRulesTest implements RefasterRuleCollectionTestCase {
SuggestedFix testSuggestedFixDelete() {
return SuggestedFix.delete(null);
}

SuggestedFix testSuggestedFixReplaceTree() {
return Suggestions.replace(null, "foo");
}
Expand All @@ -29,8 +33,4 @@ SuggestedFix testSuggestedFixPrefixWith() {
SuggestedFix testSuggestedFixPostfixWith() {
return Suggestions.postfixWith(null, "foo");
}

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

0 comments on commit e7b47a7

Please sign in to comment.