Skip to content

Commit

Permalink
Handle methods without parameters in ParameterComment
Browse files Browse the repository at this point in the history
Fixes #707

MOE_MIGRATED_REVID=165665554
  • Loading branch information
cushon committed Aug 21, 2017
1 parent 7eb9837 commit 7edbf8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public class ParameterComment extends BugChecker implements MethodInvocationTree
@Override
public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) {
MethodSymbol symbol = ASTHelpers.getSymbol(tree);
if (symbol.getParameters().isEmpty()) {
return NO_MATCH;
}
SuggestedFix.Builder fix = SuggestedFix.builder();
forEachPair(
Comments.findCommentsForArguments(tree, state).stream(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,19 @@ public void varargs() throws IOException {
"}")
.doTest(TestMode.TEXT_MATCH);
}

@Test
public void noParams() throws IOException {
testHelper
.addInputLines(
"in/Test.java", //
"class Test {",
" void f() {}",
" {",
" f();",
" }",
"}")
.expectUnchanged()
.doTest();
}
}

0 comments on commit 7edbf8d

Please sign in to comment.