Fix for issue #119 "HTML comments break the Javadoc style HTML check" error in TagParser

This commit is contained in:
theqaguy 2014-03-24 08:55:18 +01:00 committed by Roman Ivanov
parent 208e0208ca
commit 2ed89e1e58
3 changed files with 91 additions and 1 deletions

View File

@ -209,7 +209,7 @@ class TagParser
to = findChar(aText, '>', to);
while ((to.getLineNo() < aText.length)
&& !aText[to.getLineNo()]
.substring(0, to.getColumnNo()).endsWith("-->"))
.substring(0, to.getColumnNo() + 1).endsWith("-->"))
{
to = findChar(aText, '>', getNextCharPos(aText, to));
}

View File

@ -128,6 +128,19 @@ public class JavadocStyleCheckTest
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
}
@Test
public void testHtmlComment() throws Exception
{
final DefaultConfiguration checkConfig = createCheckConfig(JavadocStyleCheck.class);
checkConfig.addAttribute("checkFirstSentence", "false");
checkConfig.addAttribute("checkHtml", "true");
final String[] expected =
{
};
verify(checkConfig, getPath("InputJavadocStyleCheckHtmlComment.java"), expected);
}
@Test
public void testScopePublic()
throws Exception

View File

@ -0,0 +1,77 @@
////////////////////////////////////////////////////////////////////////////////
// Test case file for checkstyle.
// Created: 2014
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle;
/**
* Test input for the JavadocStyleCheck. This check is used to perform
* some additional Javadoc validations.
*
* @author Tobias Geyer
* @version 1.0
*/
public class InputJavadocStyleCheckHtmlComment
{
/**
* sometimes a tag starts
* <pre>
* somewhere and has a comment in the middle
* <!-- ignore this -->
* and ends afterwards
* </pre>
*/
private void method1()
{ // JavadocStyle should not report any error for this method
}
/**
* sometimes a tag starts
* <pre>
* somewhere and has a multiline comment in the middle
* <!-- ignore this
* spanning
* multiple lines -->
* and ends afterwards
* </pre>
*/
private void method2()
{ // JavadocStyle should not report any error for this method
}
/**
* sometimes a tag starts
* <pre>
* somewhere and has a multiline comment in the middle
* <!-- ignore this
* spanning
* multiple lines --></pre>
* and ends on the same line
*/
private void method3()
{ // JavadocStyle should not report any error for this method
}
/**
* sometimes a tag starts
* <pre>
* somewhere and has a comment in the middle
* <!-- ignore this --> with text following
* and ends afterwards
* </pre>
*/
private void method4()
{ // JavadocStyle should not report any error for this method
}
/**
* sometimes a tag starts
* <pre><!-- ignore this --></pre>
* and ends with a comment in the middle
*/
private void method5()
{ // JavadocStyle should not report any error for this method
}
}