Enhanced WriteTag to support empty tags, and constructor declarations. Thanks to Rolf Wojtech for patch #2724894.
This commit is contained in:
parent
eeee00819b
commit
1017cb35e4
|
|
@ -89,7 +89,7 @@ public class WriteTagCheck
|
|||
{
|
||||
try {
|
||||
mTag = aTag;
|
||||
mTagRE = Utils.getPattern(aTag + "\\s+(.*$)");
|
||||
mTagRE = Utils.getPattern(aTag + "\\s*(.*$)");
|
||||
}
|
||||
catch (final PatternSyntaxException e) {
|
||||
throw new ConversionException("unable to parse " + aTag, e);
|
||||
|
|
@ -143,6 +143,7 @@ public class WriteTagCheck
|
|||
TokenTypes.ENUM_DEF,
|
||||
TokenTypes.ANNOTATION_DEF,
|
||||
TokenTypes.METHOD_DEF,
|
||||
TokenTypes.CTOR_DEF,
|
||||
TokenTypes.ENUM_CONSTANT_DEF,
|
||||
TokenTypes.ANNOTATION_FIELD_DEF,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,9 +11,17 @@ package com.puppycrawl.tools.checkstyle;
|
|||
* @incomplete This class needs more code...
|
||||
* @doubletag first text
|
||||
* @doubletag second text
|
||||
* @emptytag
|
||||
*/
|
||||
class InputWriteTag
|
||||
{
|
||||
/**
|
||||
* @todo Add a constructor comment
|
||||
*/
|
||||
public InputWriteTag()
|
||||
{
|
||||
}
|
||||
|
||||
public void method()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,18 @@ public class WriteTagCheckTest extends BaseCheckTestSupport
|
|||
};
|
||||
verify(mCheckConfig, getPath("InputWriteTag.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyTag() throws Exception
|
||||
{
|
||||
mCheckConfig.addAttribute("tag", "@emptytag");
|
||||
mCheckConfig.addAttribute("tagFormat", "");
|
||||
final String[] expected =
|
||||
{
|
||||
"14: @emptytag=",
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputWriteTag.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
|
|
@ -92,7 +104,7 @@ public class WriteTagCheckTest extends BaseCheckTestSupport
|
|||
mCheckConfig.addAttribute("tag", "@missingtag");
|
||||
final String[] expected =
|
||||
{
|
||||
"15: Type Javadoc comment is missing an @missingtag tag.",
|
||||
"16: Type Javadoc comment is missing an @missingtag tag.",
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputWriteTag.java"), expected);
|
||||
}
|
||||
|
|
@ -103,11 +115,12 @@ public class WriteTagCheckTest extends BaseCheckTestSupport
|
|||
mCheckConfig.addAttribute("tag", "@todo");
|
||||
mCheckConfig.addAttribute("tagFormat", "\\S");
|
||||
mCheckConfig.addAttribute("tokens",
|
||||
"INTERFACE_DEF, CLASS_DEF, METHOD_DEF");
|
||||
"INTERFACE_DEF, CLASS_DEF, METHOD_DEF, CTOR_DEF");
|
||||
mCheckConfig.addAttribute("severity", "ignore");
|
||||
final String[] expected =
|
||||
{
|
||||
"22: @todo=Add a comment",
|
||||
"19: @todo=Add a constructor comment",
|
||||
"30: @todo=Add a comment",
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputWriteTag.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,11 @@
|
|||
to support properties to ignore constructors, methods and modifiers.
|
||||
Thanks to Steve McKay for patch #2953941.
|
||||
</li>
|
||||
<li>
|
||||
Enhanced <a href="config_javadoc.html#WriteTag">WriteTag</a>
|
||||
to support empty tags, and constructor declarations.
|
||||
Thanks to Rolf Wojtech for patch #2724894.
|
||||
</li>
|
||||
</ul>
|
||||
<p>Bug fixes:</p>
|
||||
<ul>
|
||||
|
|
|
|||
Loading…
Reference in New Issue