completed port of modifier order check, removed old code

This commit is contained in:
Lars Kühne 2002-09-29 14:28:10 +00:00
parent 553a1aec9f
commit 6d191d438b
4 changed files with 30 additions and 39 deletions

View File

@ -229,9 +229,6 @@ class Verifier
**/
void verifyMethod(MethodSignature aSig)
{
// Always check that the order of modifiers follows the JLS suggestion
checkModOrder(aSig.getModSet());
// Check for to many parameters
if (aSig.getParams().size() > mConfig.getMaxParameters()) {
mMessages.add(aSig.getFirstLineNo(),
@ -287,9 +284,6 @@ class Verifier
**/
void verifyType(MyModifierSet aMods, MyCommonAST aType)
{
// Always check that the order of modifiers follows the JLS suggestion
checkModOrder(aMods);
//
// Only Javadoc testing below
//
@ -349,9 +343,6 @@ class Verifier
final Scope variableScope =
inInterfaceBlock() ? Scope.PUBLIC : declaredScope;
// Always check that the order of modifiers follows the JLS suggestion
checkModOrder(mods);
if (inCheckScope(variableScope)
&& (getJavadocBefore(aVar.getStartLineNo() - 1) == null))
{
@ -1338,21 +1329,6 @@ class Verifier
}
/**
* checks if the order of modifiers follows the suggestions
* in the JLS and logs an error message accordingly.
*
* @param aModSet the set of modifiers
*/
private void checkModOrder(MyModifierSet aModSet)
{
final MyCommonAST error = aModSet.checkOrderSuggestedByJLS();
if (error != null) {
mMessages.add(error.getLineNo(), error.getColumnNo(),
"mod.order", error.getText());
}
}
/**
* @return the class name from a fully qualified name
* @param aType the fully qualified name

View File

@ -61,7 +61,8 @@ public class ModifierCheck
if (!mods.isEmpty()) {
final DetailAST error = checkOrderSuggestedByJLS(mods);
if (error != null) {
log(error.getLineNo(), "OUT OF ORDER " + error.getText());
log(error.getLineNo(), error.getColumnNo(),
"mod.order", error.getText());
}
}
}

View File

@ -512,20 +512,6 @@ public class CheckerTest
verify(c, filepath, expected);
}
public void testModifierChecks()
throws Exception
{
final Checker c = createChecker();
final String filepath = getPath("InputModifier.java");
assertNotNull(c);
final String[] expected = {
filepath + ":14:10: 'final' modifier out of order with the JLS suggestions.",
filepath + ":18:12: 'private' modifier out of order with the JLS suggestions.",
filepath + ":24:14: 'private' modifier out of order with the JLS suggestions.",
};
verify(c, filepath, expected);
}
public void testStrictJavadoc()
throws Exception
{

View File

@ -0,0 +1,28 @@
package com.puppycrawl.tools.checkstyle;
import com.puppycrawl.tools.checkstyle.checks.ModifierCheck;
public class ModifierCheckTest
extends BaseCheckTestCase
{
public ModifierCheckTest(String aName)
{
super(aName);
}
public void testIt() throws Exception
{
final CheckConfiguration checkConfig = new CheckConfiguration();
checkConfig.setClassname(ModifierCheck.class.getName());
final Checker c = createChecker(checkConfig);
final String filepath = getPath("InputModifier.java");
assertNotNull(c);
final String[] expected = {
"14:10: 'final' modifier out of order with the JLS suggestions.",
"18:12: 'private' modifier out of order with the JLS suggestions.",
"24:14: 'private' modifier out of order with the JLS suggestions.",
};
verify(c, filepath, expected);
}
}