From 104e69edd63edb8d35b6ae63a17934fc5cf49267 Mon Sep 17 00:00:00 2001
From: Oliver Burn
Date: Sat, 17 Jun 2006 13:49:08 +0000
Subject: [PATCH] Applied patch (1505376) by Clint Stotesbery to support the
suppressLoadErrors property for AbstractTypeAwareCheck (RFE 1491630).
---
.../checks/AbstractTypeAwareCheck.java | 22 ++++++++++++++--
src/xdocs/config_coding.xml | 26 +++++++++++++++++++
src/xdocs/config_javadoc.xml | 19 +++++++++++---
src/xdocs/releasenotes.xml | 6 +++++
4 files changed, 67 insertions(+), 6 deletions(-)
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/AbstractTypeAwareCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/AbstractTypeAwareCheck.java
index fbbaf1de7..709e09173 100644
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/AbstractTypeAwareCheck.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/AbstractTypeAwareCheck.java
@@ -79,6 +79,22 @@ public abstract class AbstractTypeAwareCheck extends Check
mLogLoadErrors = aLogLoadErrors;
}
+ /**
+ * Whether to show class loading errors in the checkstyle report.
+ * Request ID 1491630
+ */
+ private boolean mSuppressLoadErrors;
+
+ /**
+ * Controls whether to show class loading errors in the checkstyle report.
+ *
+ * @param aSuppressLoadErrors true if errors shouldn't be shown
+ */
+ public final void setSuppressLoadErrors(boolean aSuppressLoadErrors)
+ {
+ mSuppressLoadErrors = aSuppressLoadErrors;
+ }
+
/**
* Called to process an AST when visiting it.
* @param aAST the AST to process. Guaranteed to not be PACKAGE_DEF or
@@ -263,7 +279,6 @@ public abstract class AbstractTypeAwareCheck extends Check
protected final void logLoadErrorImpl(int aLineNo, int aColumnNo,
String aMsgKey, Object[] aValues)
{
- System.out.println(mLogLoadErrors);
if (!mLogLoadErrors) {
LocalizedMessage msg = new LocalizedMessage(aLineNo,
aColumnNo,
@@ -275,7 +290,10 @@ public abstract class AbstractTypeAwareCheck extends Check
this.getClass());
throw new RuntimeException(msg.getMessage());
}
- log(aLineNo, aColumnNo, aMsgKey, aValues);
+
+ if (!mSuppressLoadErrors) {
+ log(aLineNo, aColumnNo, aMsgKey, aValues);
+ }
}
/**
diff --git a/src/xdocs/config_coding.xml b/src/xdocs/config_coding.xml
index 86b1f9ed6..5cfb48f9c 100755
--- a/src/xdocs/config_coding.xml
+++ b/src/xdocs/config_coding.xml
@@ -958,6 +958,32 @@ for (int i = 0; i < 1; i++) {
| boolean |
false |
+
+ | logLoadErrors |
+ This check may need to load exception classes mentioned in
+ the @throws tag to check whether they are RuntimeExceptions.
+ If loading the class fails, this property allows to control
+ checkstyle's error handling. If set to false (the default) a
+ classpath configuration problem is assumed and the TreeWalker
+ stops operating on the class completely.
+ If set to true, checkstyle assumes a typo or refactoring problem in the
+ javadoc and logs the problem in the normal checkstyle report
+ (potentially masking a configuration error). |
+ boolean |
+ false |
+
+
+ | suppressLoadErrors |
+ When logLoadErrors is set to true, the TreeWalker completely
+ processes a class and displays any problems with loading exceptions
+ as checkstyle violations.
+ When this property is set to true, the violations generated when
+ logLoadErrors is set true are suppressed from being reported as
+ violations in the checkstyle report.
+ |
+ boolean |
+ false |
+
diff --git a/src/xdocs/config_javadoc.xml b/src/xdocs/config_javadoc.xml
index 56205c145..dbd2fd717 100755
--- a/src/xdocs/config_javadoc.xml
+++ b/src/xdocs/config_javadoc.xml
@@ -209,7 +209,7 @@
declared, set property allowUndeclaredRTE to true. The scope
to verify is specified using the Scope class and
defaults to Scope.PRIVATE. To verify another
- scope, set property scope to a different
+ scope, set property scope to a different
scope.
@@ -322,10 +322,10 @@ public boolean isSomething()
| logLoadErrors |
- This check may needs to load exception classes mentioned in
+ | This check may need to load exception classes mentioned in
the @throws tag to check whether they are RuntimeExceptions.
If loading the class fails, this property allows to control
- checkstyle's error handling. If set to false (the default) a
+ checkstyle's error handling. If set to false (the default) a
classpath configuration problem is assumed and the TreeWalker
stops operating on the class completely.
If set to true, checkstyle assumes a typo or refactoring problem in the
@@ -334,7 +334,18 @@ public boolean isSomething()
| boolean |
false |
-
+
+ | suppressLoadErrors |
+ When logLoadErrors is set to true, the TreeWalker completely
+ processes a class and displays any problems with loading exceptions
+ as checkstyle violations.
+ When this property is set to true, the violations generated when
+ logLoadErrors is set true are suppressed from being reported as
+ violations in the checkstyle report.
+ |
+ boolean |
+ false |
+
| tokens |
definitions to check |
diff --git a/src/xdocs/releasenotes.xml b/src/xdocs/releasenotes.xml
index 485b723bf..707bbca7b 100755
--- a/src/xdocs/releasenotes.xml
+++ b/src/xdocs/releasenotes.xml
@@ -46,6 +46,12 @@
King. (Bug 1385095).
+
+ Applied patch (1505376) by Clint Stotesbery to support the
+ suppressLoadErrors property for AbstractTypeAwareCheck (RFE
+ 1491630).
+
+
Upgraded to ANTLR 2.7.6.