Skip to content

Commit

Permalink
Issue checkstyle#3891: reorganized astprinter package inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach committed Sep 10, 2017
1 parent 3cc6495 commit 8080262
Show file tree
Hide file tree
Showing 32 changed files with 59 additions and 57 deletions.
4 changes: 2 additions & 2 deletions config/checkstyle_non_main_files_suppressions.xml
Expand Up @@ -11,7 +11,7 @@

<!-- Intentional no new line at the end. -->
<suppress checks="NewlineAtEndOfFile" files="[\\/]test[\\/].*[\\/]grammars[\\/]comments[\\/]InputFullOfSinglelineComments\.java"/>
<suppress checks="NewlineAtEndOfFile" files="[\\/]test[\\/].*[\\/]astprinter[\\/]InputFullOfSinglelineComments\.java"/>
<suppress checks="NewlineAtEndOfFile" files="[\\/]test[\\/].*[\\/]asttreestringprinter[\\/]InputAstTreeStringPrinterFullOfSinglelineComments\.java"/>

<!-- Grammar specific input file, should have exact structure to reproduce the case. -->
<suppress checks="NewlineAtEndOfFile" files="[\\/]test[\\/].*[\\/]grammars[\\/]InputEmbeddedNullChar\.java"/>
Expand All @@ -24,7 +24,7 @@
<suppress checks="NewlineAtEndOfFile" files="[\\/]test[\\/].*[\\/]grammars[\\/]InputRegressionEmptyAst\.txt"/>

<!-- File with CR line separators used for testing -->
<suppress checks="NewlineAtEndOfFile" files="[\\/]test[\\/].*[\\/]astprinter[\\/]InputFullOfBlockCommentsCR\.java"/>
<suppress checks="NewlineAtEndOfFile" files="[\\/]test[\\/].*[\\/]asttreestringprinter[\\/]InputAstTreeStringPrinterFullOfBlockCommentsCR\.java"/>

<!-- For the testing purposes -->
<suppress checks="NewlineAtEndOfFile" files="[\\/]test[\\/].*[\\/]checks[\\/]misc[\\/]uniqueproperties[\\/]InputUniquePropertiesWithDuplicates\.properties"/>
Expand Down
Expand Up @@ -37,7 +37,7 @@ public class AstTreeStringPrinterTest extends AbstractTreeTestSupport {

@Override
protected String getPackageLocation() {
return "com/puppycrawl/tools/checkstyle/astprinter";
return "com/puppycrawl/tools/checkstyle/asttreestringprinter";
}

@Test
Expand All @@ -64,7 +64,7 @@ public void testParseFileThrowable() throws Exception {

@Test
public void testParseFile() throws Exception {
verifyAst(getPath("expectedInputAstTreeStringPrinter.txt"),
verifyAst(getPath("ExpectedAstTreeStringPrinter.txt"),
getPath("InputAstTreeStringPrinterComments.java"),
AstTreeStringPrinter.PrintOptions.WITHOUT_COMMENTS);
}
Expand All @@ -77,62 +77,62 @@ public void testPrintAst() throws Exception {
final String actual = AstTreeStringPrinter.printAst(text,
AstTreeStringPrinter.PrintOptions.WITHOUT_COMMENTS);
final String expected = new String(Files.readAllBytes(Paths.get(
getPath("expectedInputAstTreeStringPrinter.txt"))), StandardCharsets.UTF_8);
getPath("ExpectedAstTreeStringPrinter.txt"))), StandardCharsets.UTF_8);

Assert.assertEquals("Print AST output is invalid", expected, actual);
}

@Test
public void testParseFileWithComments() throws Exception {
verifyAst(getPath("expectedInputAstTreeStringPrinterComments.txt"),
verifyAst(getPath("ExpectedAstTreeStringPrinterComments.txt"),
getPath("InputAstTreeStringPrinterComments.java"),
AstTreeStringPrinter.PrintOptions.WITH_COMMENTS);
}

@Test
public void testParseFileWithJavadoc1() throws Exception {
verifyJavaAndJavadocAst(getPath("expectedInputAstTreeStringPrinterJavadoc.txt"),
verifyJavaAndJavadocAst(getPath("ExpectedAstTreeStringPrinterJavadoc.txt"),
getPath("InputAstTreeStringPrinterJavadoc.java"));
}

@Test
public void testParseFileWithJavadoc2() throws Exception {
verifyJavaAndJavadocAst(getPath("expectedInputAstTreeStringPrinterJavaAndJavadoc.txt"),
verifyJavaAndJavadocAst(getPath("ExpectedAstTreeStringPrinterJavaAndJavadoc.txt"),
getPath("InputAstTreeStringPrinterJavaAndJavadoc.java"));
}

@Test
public void testParseFileWithJavadoc3() throws Exception {
verifyJavaAndJavadocAst(
getPath("expectedInputAstTreeStringPrinterAttributesAndMethodsJavadoc.txt"),
getPath("ExpectedAstTreeStringPrinterAttributesAndMethodsJavadoc.txt"),
getPath("InputAstTreeStringPrinterAttributesAndMethodsJavadoc.java")
);
}

@Test
public void testJavadocPosition() throws Exception {
verifyJavaAndJavadocAst(getPath("expectedJavadocPosition.txt"),
getPath("InputJavadocPosition.java"));
verifyJavaAndJavadocAst(getPath("ExpectedAstTreeStringPrinterJavadocPosition.txt"),
getPath("InputAstTreeStringPrinterJavadocPosition.java"));
}

@Test
public void testAstTreeBlockComments() throws Exception {
verifyAst(getPath("InputFullOfBlockCommentsAst.txt"),
getPath("InputFullOfBlockComments.java"),
verifyAst(getPath("ExpectedAstTreeStringPrinterFullOfBlockComments.txt"),
getPath("InputAstTreeStringPrinterFullOfBlockComments.java"),
AstTreeStringPrinter.PrintOptions.WITH_COMMENTS);
}

@Test
public void testAstTreeBlockCommentsCarriageReturn() throws Exception {
verifyAst(getPath("InputFullOfBlockCommentsAstCR.txt"),
getPath("InputFullOfBlockCommentsCR.java"),
verifyAst(getPath("ExpectedAstTreeStringPrinterFullOfBlockCommentsCR.txt"),
getPath("InputAstTreeStringPrinterFullOfBlockCommentsCR.java"),
AstTreeStringPrinter.PrintOptions.WITH_COMMENTS);
}

@Test
public void testAstTreeSingleLineComments() throws Exception {
verifyAst(getPath("InputFullOfSinglelineCommentsAst.txt"),
getPath("InputFullOfSinglelineComments.java"),
verifyAst(getPath("ExpectedAstTreeStringPrinterFullOfSinglelineComments.txt"),
getPath("InputAstTreeStringPrinterFullOfSinglelineComments.java"),
AstTreeStringPrinter.PrintOptions.WITH_COMMENTS);
}

Expand Down
Expand Up @@ -47,7 +47,7 @@ public class DetailNodeTreeStringPrinterTest extends AbstractTreeTestSupport {

@Override
protected String getPackageLocation() {
return "com/puppycrawl/tools/checkstyle/astprinter";
return "com/puppycrawl/tools/checkstyle/detailnodetreestringprinter";
}

@Test
Expand All @@ -57,15 +57,15 @@ public void testIsProperUtilsClass() throws ReflectiveOperationException {

@Test
public void testParseFile() throws Exception {
verifyJavadocTree(getPath("expectedInputJavadocComment.txt"),
getPath("InputJavadocComment.javadoc"));
verifyJavadocTree(getPath("ExpectedDetailNodeTreeStringPrinterJavadocComment.txt"),
getPath("InputDetailNodeTreeStringPrinterJavadocComment.javadoc"));
}

@Test
public void testParseFileWithError() throws Exception {
try {
DetailNodeTreeStringPrinter.printFileAst(
new File(getPath("InputJavadocWithError.javadoc")));
new File(getPath("InputDetailNodeTreeStringPrinterJavadocWithError.javadoc")));
Assert.fail("Javadoc parser didn't fail on missing end tag");
}
catch (IllegalArgumentException ex) {
Expand Down Expand Up @@ -103,8 +103,9 @@ public void testCreationOfFakeCommentBlock() throws Exception {

@Test
public void testNoUnnecessaryTextinJavadocAst() throws Exception {
verifyJavadocTree(getPath("expectedNoUnnecessaryTextInJavadocAst.txt"),
getPath("InputNoUnnecessaryTextInJavadocAst.javadoc"));
verifyJavadocTree(
getPath("ExpectedDetailNodeTreeStringPrinterNoUnnecessaryTextInJavadocAst.txt"),
getPath("InputDetailNodeTreeStringPrinterNoUnnecessaryTextInJavadocAst.javadoc"));
}

@Test
Expand Down Expand Up @@ -162,8 +163,9 @@ public void testWrongSingletonParseErrorMessage() throws Exception {
@Test
public void testUnescapedJavaCodeWithGenericsInJavadoc() throws Exception {
try {
DetailNodeTreeStringPrinter.printFileAst(new File(getPath(
"InputUnescapedJavaCodeWithGenericsInJavadoc.javadoc")));
DetailNodeTreeStringPrinter.printFileAst(new File(
getPath("InputDetailNodeTreeStringPrinter"
+ "UnescapedJavaCodeWithGenericsInJavadoc.javadoc")));
}
catch (IllegalArgumentException ex) {
final String expected = (String) GET_PARSE_ERROR_MESSAGE.invoke(null,
Expand All @@ -177,7 +179,7 @@ public void testUnescapedJavaCodeWithGenericsInJavadoc() throws Exception {
public void testNoViableAltException() throws Exception {
try {
DetailNodeTreeStringPrinter.printFileAst(new File(getPath(
"InputNoViableAltException.javadoc")));
"InputDetailNodeTreeStringPrinterNoViableAltException.javadoc")));
}
catch (IllegalArgumentException ex) {
final String expected = (String) GET_PARSE_ERROR_MESSAGE.invoke(null,
Expand All @@ -192,7 +194,7 @@ public void testNoViableAltException() throws Exception {
public void testHtmlTagCloseBeforeTagOpen() throws Exception {
try {
DetailNodeTreeStringPrinter.printFileAst(new File(getPath(
"InputHtmlTagCloseBeforeTagOpen.javadoc"
"InputDetailNodeTreeStringPrinterHtmlTagCloseBeforeTagOpen.javadoc"
)));
}
catch (IllegalArgumentException ex) {
Expand All @@ -208,7 +210,7 @@ public void testHtmlTagCloseBeforeTagOpen() throws Exception {
public void testWrongHtmlTagOrder() throws Exception {
try {
DetailNodeTreeStringPrinter.printFileAst(new File(getPath(
"InputWrongHtmlTagOrder.javadoc"
"InputDetailNodeTreeStringPrinterWrongHtmlTagOrder.javadoc"
)));
}
catch (IllegalArgumentException ex) {
Expand All @@ -223,7 +225,7 @@ public void testWrongHtmlTagOrder() throws Exception {
public void testOmittedStartTagForHtmlElement() throws Exception {
try {
DetailNodeTreeStringPrinter.printFileAst(new File(getPath(
"InputOmittedStartTagForHtmlElement.javadoc"
"InputDetailNodeTreeStringPrinterOmittedStartTagForHtmlElement.javadoc"
)));
}
catch (IllegalArgumentException ex) {
Expand Down

This file was deleted.

Expand Up @@ -65,17 +65,17 @@ CLASS_DEF -> CLASS_DEF [3:6]
|--BLOCK_COMMENT_BEGIN -> /* [3:25]
| |--COMMENT_CONTENT -> 16 [3:27]
| `--BLOCK_COMMENT_END -> */ [3:28]
|--IDENT -> InputFullOfBlockComments [3:31]
`--OBJBLOCK -> OBJBLOCK [3:62]
|--BLOCK_COMMENT_BEGIN -> /* [3:56]
| |--COMMENT_CONTENT -> 49 [3:58]
| `--BLOCK_COMMENT_END -> */ [3:59]
|--LCURLY -> { [3:62]
|--IDENT -> InputAstTreeStringPrinterFullOfBlockComments [3:31]
`--OBJBLOCK -> OBJBLOCK [3:82]
|--BLOCK_COMMENT_BEGIN -> /* [3:76]
| |--COMMENT_CONTENT -> 49 [3:78]
| `--BLOCK_COMMENT_END -> */ [3:79]
|--LCURLY -> { [3:82]
|--METHOD_DEF -> METHOD_DEF [5:7]
| |--MODIFIERS -> MODIFIERS [5:7]
| | |--BLOCK_COMMENT_BEGIN -> /* [3:63]
| | | |--COMMENT_CONTENT -> 17 [3:65]
| | | `--BLOCK_COMMENT_END -> */ [3:66]
| | |--BLOCK_COMMENT_BEGIN -> /* [3:83]
| | | |--COMMENT_CONTENT -> 17 [3:85]
| | | `--BLOCK_COMMENT_END -> */ [3:86]
| | |--BLOCK_COMMENT_BEGIN -> /* [4:1]
| | | |--COMMENT_CONTENT -> 18 [4:3]
| | | `--BLOCK_COMMENT_END -> */ [4:4]
Expand Down
Expand Up @@ -26,13 +26,13 @@ CLASS_DEF -> CLASS_DEF [3:0]
|--BLOCK_COMMENT_BEGIN -> /* [3:17]
| |--COMMENT_CONTENT -> 16 [3:19]
| `--BLOCK_COMMENT_END -> */ [3:20]
|--IDENT -> InputFullOfBlockCommentsCR [3:23]
`--OBJBLOCK -> OBJBLOCK [3:55]
|--BLOCK_COMMENT_BEGIN -> /* [3:49]
| |--COMMENT_CONTENT -> 49 [3:51]
| `--BLOCK_COMMENT_END -> */ [3:52]
|--LCURLY -> { [3:55]
|--BLOCK_COMMENT_BEGIN -> /* [3:56]
| |--COMMENT_CONTENT -> \r21\r [3:58]
|--IDENT -> InputAstTreeStringPrinterFullOfBlockCommentsCR [3:23]
`--OBJBLOCK -> OBJBLOCK [3:75]
|--BLOCK_COMMENT_BEGIN -> /* [3:69]
| |--COMMENT_CONTENT -> 49 [3:71]
| `--BLOCK_COMMENT_END -> */ [3:72]
|--LCURLY -> { [3:75]
|--BLOCK_COMMENT_BEGIN -> /* [3:76]
| |--COMMENT_CONTENT -> \r21\r [3:78]
| `--BLOCK_COMMENT_END -> */ [5:0]
`--RCURLY -> } [5:2]
Expand Up @@ -48,10 +48,10 @@ CLASS_DEF -> CLASS_DEF [16:0]
|--LITERAL_CLASS -> class [17:0]
|--SINGLE_LINE_COMMENT -> // [17:5]
| `--COMMENT_CONTENT -> 16\n [17:7]
|--IDENT -> InputFullOfSinglelineComments [18:0]
|--IDENT -> InputAstTreeStringPrinterFullOfSinglelineComments [18:0]
`--OBJBLOCK -> OBJBLOCK [19:0]
|--SINGLE_LINE_COMMENT -> // [18:29]
| `--COMMENT_CONTENT -> 17\n [18:31]
|--SINGLE_LINE_COMMENT -> // [18:49]
| `--COMMENT_CONTENT -> 17\n [18:51]
|--LCURLY -> { [19:0]
|--METHOD_DEF -> METHOD_DEF [20:0]
| |--MODIFIERS -> MODIFIERS [20:0]
Expand Down
Expand Up @@ -2,9 +2,9 @@ CLASS_DEF -> CLASS_DEF [1:0]
|--MODIFIERS -> MODIFIERS [1:0]
| `--LITERAL_PUBLIC -> public [1:0]
|--LITERAL_CLASS -> class [1:7]
|--IDENT -> InputJavadocPosition [1:13]
`--OBJBLOCK -> OBJBLOCK [1:34]
|--LCURLY -> { [1:34]
|--IDENT -> InputAstTreeStringPrinterJavadocPosition [1:13]
`--OBJBLOCK -> OBJBLOCK [1:54]
|--LCURLY -> { [1:54]
|--METHOD_DEF -> METHOD_DEF [2:4]
| |--MODIFIERS -> MODIFIERS [2:4]
| |--TYPE -> TYPE [2:4]
Expand All @@ -15,7 +15,7 @@ CLASS_DEF -> CLASS_DEF [1:0]
| |--RPAREN -> ) [2:16]
| `--SLIST -> { [2:18]
| |--BLOCK_COMMENT_BEGIN -> /* [3:1]
| | |--COMMENT_CONTENT -> *\r\n\tThis is a method\r\n\t@return void\r\n\t<html\r\n\t [3:3]
| | |--COMMENT_CONTENT -> *\n\tThis is a method\n\t@return void\n\t<html\n\t [3:3]
| | `--BLOCK_COMMENT_END -> */ [7:1]
| `--RCURLY -> } [8:4]
`--RCURLY -> } [9:0]
@@ -1,6 +1,6 @@
/*0*//*1*/package/*2*/ com/*3*/./*4*/puppycrawl/*5*/./*6*/tools/*7*/./*8*/checkstyle/*9*/./*10*/astprinter/*11*/;/*12*/
/*13*/
/*14*/public/*15*/ class /*16*/InputFullOfBlockComments /*49*/{/*17*/
/*14*/public/*15*/ class /*16*/InputAstTreeStringPrinterFullOfBlockComments /*49*/{/*17*/
/*18*/
/*19*/public/*20*/ static/*
21
Expand Down
@@ -0,0 +1 @@
package/*2*/com.puppycrawl.tools.checkstyle.astprinter;/*13*/public/*15*/class/*16*/InputAstTreeStringPrinterFullOfBlockCommentsCR/*49*/{/*21*/}
Expand Down
Expand Up @@ -15,7 +15,7 @@
//14
public//15
class//16
InputFullOfSinglelineComments//17
InputAstTreeStringPrinterFullOfSinglelineComments//17
{//18
public//19
static//20
Expand Down
@@ -1,4 +1,4 @@
public class InputJavadocPosition {
public class InputAstTreeStringPrinterJavadocPosition {
void method() {
/**
This is a method
Expand Down

0 comments on commit 8080262

Please sign in to comment.