diff --git a/docs/releasenotes.html b/docs/releasenotes.html index 180374ad7..08163f755 100644 --- a/docs/releasenotes.html +++ b/docs/releasenotes.html @@ -26,6 +26,7 @@
Checkstyle 2
+ New features: +
+ Resolved bugs: +
+ API changes (only relevant for IDE plugin authors): +
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/Verifier.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/Verifier.java index 9f9243c1b..db581fe6d 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/Verifier.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/Verifier.java @@ -49,6 +49,16 @@ class Verifier /** compiled regexp to match Javadoc tags that take an argument **/ private static final RE MATCH_JAVADOC_ARG = createRE(MATCH_JAVADOC_ARG_PAT); + /** + * the pattern to match a single line comment containing only the comment + * itself -- no code. + **/ + private static final String MATCH_SINGLELINE_COMMENT_PAT + = "^\\s*//.*$"; + /** compiled regexp to match a single-line comment line **/ + private static final RE MATCH_SINGLELINE_COMMENT = + createRE(MATCH_SINGLELINE_COMMENT_PAT); + /** * the pattern to match the first line of a multi-line Javadoc * tag that takes an argument. Javadoc with no arguments isn't @@ -1157,7 +1167,7 @@ class Verifier int lineNo = aLineNo - 1; // skip blank lines - while ((lineNo > 0) && lineIsBlank(lineNo)) { + while ((lineNo > 0) && (lineIsBlank(lineNo) || lineIsComment(lineNo))) { lineNo--; } @@ -1175,6 +1185,17 @@ class Verifier return "".equals(mLines[aLineNo].trim()); } + /** + * Checks if the specified line is a single-line comment without code. + * @param aLineNo the line number to check + * @return if the specified line consists of only a single line comment + * without code. + **/ + private boolean lineIsComment(int aLineNo) + { + return MATCH_SINGLELINE_COMMENT.match(mLines[aLineNo]); + } + /** * Returns the tags in a javadoc comment. Only finds throws, exception, * param, return and see tags. diff --git a/src/tests/com/puppycrawl/tools/checkstyle/InputTags.java b/src/tests/com/puppycrawl/tools/checkstyle/InputTags.java index 28640674e..d9aee888a 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/InputTags.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/InputTags.java @@ -160,4 +160,16 @@ class InputTags /** getting code coverage up **/ static final int serialVersionUID = 666; + + //**********************************************************************/ + // Method Name: method16 + /** + * handle the case of an elaborate header surrounding javadoc comments + * + * @param aOne valid parameter content + */ + //**********************************************************************/ + void method16(int aOne) + { + } }