diff --git a/docs/releasenotes.html b/docs/releasenotes.html index 01f5993fa..822a1a1ea 100644 --- a/docs/releasenotes.html +++ b/docs/releasenotes.html @@ -82,6 +82,9 @@
  • Added NPathComplexity check from Simon Harris (request 750757)
  • +
  • Added several more log() method to + AbtractViolationReporter. (request 843551)
  • +

    diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/AbstractViolationReporter.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/AbstractViolationReporter.java index fab27a9e6..aa0193f48 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/AbstractViolationReporter.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/AbstractViolationReporter.java @@ -116,6 +116,18 @@ public abstract class AbstractViolationReporter log(aLineNo, aColNo, aKey, EMPTY_OBJECT_ARRAY); } + /** + * Helper method to log a LocalizedMessage. + * + * @param aAST a node to get line and column numbers associated + * with the message + * @param aKey key to locale message format + */ + protected final void log(DetailAST aAST, String aKey) + { + log(aAST.getLineNo(), aAST.getColumnNo(), aKey); + } + /** * Helper method to log a LocalizedMessage. * @@ -130,6 +142,18 @@ public abstract class AbstractViolationReporter log(aLineNo, aColNo, aKey, new Object[] {aArg0}); } + /** + * Helper method to log a LocalizedMessage. + * + * @param aAST a node to get line and column numbers associated + * with the message + * @param aKey key to locale message format + * @param aArg0 an Object value + */ + protected final void log(DetailAST aAST, String aKey, Object aArg0) + { + log(aAST.getLineNo(), aAST.getColumnNo(), aKey, aArg0); + } /** * Helper method to log a LocalizedMessage. * @@ -145,6 +169,20 @@ public abstract class AbstractViolationReporter log(aLineNo, aColNo, aKey, new Object[] {aArg0, aArg1}); } + /** + * Helper method to log a LocalizedMessage. + * + * @param aAST a node to get line and column numbers associated + * with the message + * @param aKey key to locale message format + * @param aArg0 an Object value + * @param aArg1 an Object value + */ + protected final void log(DetailAST aAST, String aKey, + Object aArg0, Object aArg1) + { + log(aAST.getLineNo(), aAST.getColumnNo(), aKey, aArg0, aArg1); + } /** * Returns the message bundle name resourcebundle that contains the messages diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java index 393e3dca4..28ecea855 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.java @@ -185,14 +185,4 @@ public class DeclarationOrderCheck extends Check default: } } - - /** - * Our own logging method - * @param aAST The AST to log - * @param aError The type of error to log - */ - private void log(DetailAST aAST, String aError) - { - log(aAST.getLineNo(), aAST.getColumnNo(), aError); - } } diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/metrics/AbstractComplexityCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/metrics/AbstractComplexityCheck.java index d23dc983b..cef9dba78 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/metrics/AbstractComplexityCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/metrics/AbstractComplexityCheck.java @@ -194,9 +194,7 @@ public abstract class AbstractComplexityCheck private void leaveMethodDef(DetailAST aAST) { if (mCurrentValue > mMax) { - log(aAST.getLineNo(), - aAST.getColumnNo(), - getMessageID(), + log(aAST, getMessageID(), new Integer(mCurrentValue), new Integer(mMax)); }