Fixed bug in parameter name check. did not handle catch blocks.

This commit is contained in:
Oliver Burn 2002-11-22 13:35:49 +00:00
parent 303352fe2d
commit d83cf71c6b
2 changed files with 22 additions and 0 deletions

View File

@ -18,6 +18,7 @@
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.checks;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
/**
@ -46,4 +47,12 @@ public class ParameterNameCheck
{
return new int[] {TokenTypes.PARAMETER_DEF};
}
/** @see com.puppycrawl.tools.checkstyle.checks.AbstractNameCheck */
protected boolean mustCheckName(DetailAST aAST)
{
return !(
(aAST.getParent() != null)
&& (aAST.getParent().getType() == TokenTypes.LITERAL_CATCH));
}
}

View File

@ -5,6 +5,19 @@ import com.puppycrawl.tools.checkstyle.checks.ParameterNameCheck;
public class ParameterNameCheckTest
extends BaseCheckTestCase
{
public void testCatch()
throws Exception
{
final CheckConfiguration checkConfig = new CheckConfiguration();
checkConfig.setClassname(ParameterNameCheck.class.getName());
checkConfig.addProperty("format", "^NO_WAY_MATEY$");
final Checker c = createChecker(checkConfig);
final String fname = getPath("InputLeftCurlyOther.java");
final String[] expected = {
};
verify(c, fname, expected);
}
public void testSpecified()
throws Exception
{