File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed
check_api/src/main/java/com/google/errorprone/matchers
core/src/main/java/com/google/errorprone/bugpatterns Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 29
29
import static com .google .errorprone .matchers .Matchers .hasMethod ;
30
30
import static com .google .errorprone .matchers .Matchers .hasModifier ;
31
31
import static com .google .errorprone .matchers .Matchers .isSubtypeOf ;
32
- import static com .google .errorprone .matchers .Matchers .methodHasParameters ;
32
+ import static com .google .errorprone .matchers .Matchers .methodHasNoParameters ;
33
33
import static com .google .errorprone .matchers .Matchers .methodHasVisibility ;
34
34
import static com .google .errorprone .matchers .Matchers .methodIsNamed ;
35
35
import static com .google .errorprone .matchers .Matchers .methodNameStartsWith ;
@@ -144,14 +144,14 @@ private static boolean hasJUnitAttr(MethodSymbol methodSym) {
144
144
public static final Matcher <MethodTree > isJunit3TestCase =
145
145
allOf (
146
146
methodNameStartsWith ("test" ),
147
- methodHasParameters (),
147
+ methodHasNoParameters (),
148
148
Matchers .<MethodTree >hasModifier (Modifier .PUBLIC ),
149
149
methodReturns (VOID_TYPE ));
150
150
151
151
/** Common matcher for possible JUnit setUp/tearDown methods. */
152
152
private static final Matcher <MethodTree > looksLikeJUnitSetUpOrTearDown =
153
153
allOf (
154
- methodHasParameters (),
154
+ methodHasNoParameters (),
155
155
anyOf (
156
156
methodHasVisibility (MethodVisibility .Visibility .PUBLIC ),
157
157
methodHasVisibility (MethodVisibility .Visibility .PROTECTED )),
Original file line number Diff line number Diff line change @@ -887,6 +887,11 @@ public static Matcher<MethodTree> methodHasParameters(Matcher<VariableTree>... v
887
887
return methodHasParameters (ImmutableList .copyOf (variableMatcher ));
888
888
}
889
889
890
+ /** Matches an AST node that represents a method declaration with no parameters. */
891
+ public static Matcher <MethodTree > methodHasNoParameters () {
892
+ return methodHasParameters (ImmutableList .of ());
893
+ }
894
+
890
895
/**
891
896
* Matches an AST node that represents a method declaration, based on the list of
892
897
* variableMatchers. Applies the variableMatcher at index n to the parameter at index n and
@@ -1482,7 +1487,7 @@ public static Matcher<MethodTree> equalsMethodDeclaration() {
1482
1487
allOf (
1483
1488
methodIsNamed ("toString" ),
1484
1489
methodHasVisibility (Visibility .PUBLIC ),
1485
- methodHasParameters (),
1490
+ methodHasNoParameters (),
1486
1491
methodReturns (STRING_TYPE ));
1487
1492
1488
1493
/** Matches {@link Object#toString} method declaration. */
@@ -1494,7 +1499,7 @@ public static Matcher<MethodTree> toStringMethodDeclaration() {
1494
1499
allOf (
1495
1500
methodIsNamed ("hashCode" ),
1496
1501
methodHasVisibility (Visibility .PUBLIC ),
1497
- methodHasParameters (),
1502
+ methodHasNoParameters (),
1498
1503
methodReturns (INT_TYPE ));
1499
1504
1500
1505
/** Matches {@code hashCode} method declaration. */
Original file line number Diff line number Diff line change 27
27
import static com .google .errorprone .matchers .JUnitMatchers .wouldRunInJUnit4 ;
28
28
import static com .google .errorprone .matchers .Matchers .allOf ;
29
29
import static com .google .errorprone .matchers .Matchers .enclosingClass ;
30
- import static com .google .errorprone .matchers .Matchers .methodHasParameters ;
30
+ import static com .google .errorprone .matchers .Matchers .methodHasNoParameters ;
31
31
import static com .google .errorprone .matchers .Matchers .methodReturns ;
32
32
import static com .google .errorprone .matchers .Matchers .not ;
33
33
import static com .google .errorprone .suppliers .Suppliers .VOID_TYPE ;
@@ -77,7 +77,7 @@ public final class JUnit3TestNotRun extends BugChecker implements MethodTreeMatc
77
77
enclosingClass (isJUnit3TestClass ),
78
78
not (isJunit3TestCase ),
79
79
methodReturns (VOID_TYPE ),
80
- methodHasParameters ());
80
+ methodHasNoParameters ());
81
81
82
82
/**
83
83
* Matches iff:
You can’t perform that action at this time.
0 commit comments