From 6d191d438b5a23efd62dacca2a33a3a3bdedecc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20K=C3=BChne?= Date: Sun, 29 Sep 2002 14:28:10 +0000 Subject: [PATCH] completed port of modifier order check, removed old code --- .../puppycrawl/tools/checkstyle/Verifier.java | 24 ---------------- .../checkstyle/checks/ModifierCheck.java | 3 +- .../tools/checkstyle/CheckerTest.java | 14 ---------- .../tools/checkstyle/ModifierCheckTest.java | 28 +++++++++++++++++++ 4 files changed, 30 insertions(+), 39 deletions(-) create mode 100644 src/tests/com/puppycrawl/tools/checkstyle/ModifierCheckTest.java diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/Verifier.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/Verifier.java index 15d8f6fad..ef49a07af 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/Verifier.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/Verifier.java @@ -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 diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/ModifierCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/ModifierCheck.java index 6360184a2..7ebed25dd 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/ModifierCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/ModifierCheck.java @@ -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()); } } } diff --git a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java index 7211c59fa..2975781be 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java @@ -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 { diff --git a/src/tests/com/puppycrawl/tools/checkstyle/ModifierCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/ModifierCheckTest.java new file mode 100644 index 000000000..6cecc5df8 --- /dev/null +++ b/src/tests/com/puppycrawl/tools/checkstyle/ModifierCheckTest.java @@ -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); + + } +}