Skip to content

Commit

Permalink
Issue checkstyle#4934: Enforced WS in appropriate places for block ja…
Browse files Browse the repository at this point in the history
…vadoc tags
  • Loading branch information
voidfist committed Aug 21, 2017
1 parent 30aa3ef commit f8e4bb5
Show file tree
Hide file tree
Showing 9 changed files with 586 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -857,32 +857,36 @@ reference:
;
parameters: LEFT_BRACE (ARGUMENT | COMMA | WS | NEWLINE | LEADING_ASTERISK)* RIGHT_BRACE;

javadocTag: AUTHOR_LITERAL (WS | NEWLINE)* description?
javadocTag: AUTHOR_LITERAL (WS | NEWLINE)* ((WS | NEWLINE) description)?

| DEPRECATED_LITERAL (WS | NEWLINE)* description?
| DEPRECATED_LITERAL (WS | NEWLINE)* ((WS | NEWLINE) description)?

| EXCEPTION_LITERAL (WS | NEWLINE)* CLASS_NAME? (WS | NEWLINE)* description?
| EXCEPTION_LITERAL (WS | NEWLINE)* ((WS | NEWLINE) CLASS_NAME)? (WS | NEWLINE)*
((WS | NEWLINE) description)?

| PARAM_LITERAL (WS | NEWLINE)* PARAMETER_NAME? (WS | NEWLINE)* description?
| PARAM_LITERAL (WS | NEWLINE)* ((WS | NEWLINE) PARAMETER_NAME)? (WS | NEWLINE)*
((WS | NEWLINE) description)?

| RETURN_LITERAL (WS | NEWLINE)* description?
| RETURN_LITERAL (WS | NEWLINE)* ((WS | NEWLINE) description)?

| SEE_LITERAL (WS | NEWLINE)* reference? (STRING | htmlElement)* (WS | NEWLINE)* description?

| SERIAL_LITERAL (WS | NEWLINE)* (LITERAL_INCLUDE | LITERAL_EXCLUDE)? description?
| SERIAL_LITERAL (WS | NEWLINE)*
((WS | NEWLINE) description | LITERAL_INCLUDE | LITERAL_EXCLUDE)? (WS | NEWLINE)*

| SERIAL_DATA_LITERAL (WS | NEWLINE)* description?
| SERIAL_DATA_LITERAL (WS | NEWLINE)* ((WS | NEWLINE) description)?

| SERIAL_FIELD_LITERAL (WS | NEWLINE)* FIELD_NAME? (WS | NEWLINE)* FIELD_TYPE?
(WS | NEWLINE)* description?
| SERIAL_FIELD_LITERAL (WS | NEWLINE)* ((WS | NEWLINE) FIELD_NAME)? (WS | NEWLINE)*
((WS | NEWLINE) FIELD_TYPE)? (WS | NEWLINE)* ((WS | NEWLINE) description)?

| SINCE_LITERAL (WS | NEWLINE)* description?
| SINCE_LITERAL (WS | NEWLINE)* ((WS | NEWLINE) description)?

| THROWS_LITERAL (WS | NEWLINE)* CLASS_NAME? (WS | NEWLINE)* description?
| THROWS_LITERAL (WS | NEWLINE)* ((WS | NEWLINE) CLASS_NAME)? (WS | NEWLINE)*
((WS | NEWLINE) description)?

| VERSION_LITERAL (WS | NEWLINE)* description?
| VERSION_LITERAL (WS | NEWLINE)* ((WS | NEWLINE) description)?

| CUSTOM_NAME (WS | NEWLINE)* description?
| CUSTOM_NAME (WS | NEWLINE)* ((WS | NEWLINE) description)?
;
//////////////////////////////////////////////////////////////////////////////////////
////////////////////////// JAVADOC INLINE TAGS /////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,12 @@ public void testAstTreeSingleLineComments() throws Exception {
getPath("InputFullOfSinglelineComments.java"),
AstTreeStringPrinter.PrintOptions.WITH_COMMENTS);
}

@Test
public void testJavadocTagsWithoutArgs() throws Exception {
verifyJavaAndJavadocAst(
getPath("expectedAstTreeStringPrinterJavadocTagsWithoutArgsAst.txt"),
getPath("InputAstTreeStringPrinterJavadocTagsWithoutArgs.java")
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,10 @@ public void testNestingWithSingletonElement() throws Exception {
verifyJavadocTree(getHtmlPath("expectedNestingWithSingletonElementAst.txt"),
getHtmlPath("InputNestingWithSingletonElement.javadoc"));
}

@Test
public void testSpaceBeforeDescriptionInBlockJavadocTags() throws Exception {
verifyJavadocTree(getDocPath("expectedSpaceBeforeDescriptionInBlockJavadocTagsAst.txt"),
getDocPath("InputSpaceBeforeDescriptionInBlockJavadocTags.javadoc"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.puppycrawl.tools.checkstyle.astprinter;

import java.io.Serializable;

/**@author*/
public class InputAstTreeStringPrinterJavadocTagsWithoutArgs implements Serializable{
/**@serial*/
private static final long serialVersionUID = 7556448691029650757L;

/**@see*/
private static int field2;

/**@since*/
private static String field3;

/**@version*/
private static Object field4;

/**serialField*/
private static Object field5;

/**@exception*/
public static void method1() {

}

/**@throws*/
public static void method2() {

}

/**@return*/
public static int method3() {
return -1;
}

/**@param*/
public static void method4(int a) {

}

/**@customTag*/
public static void method5(int a) {

}

/**@deprecated*/
public static void method6(int a) {

}

/**@serialData*/
private void readObject(java.io.ObjectInputStream inputStream) {

}

private void writeObject(java.io.ObjectOutputStream outputStream) {

}
}
Loading

0 comments on commit f8e4bb5

Please sign in to comment.