diff --git a/docs/engine.html b/docs/engine.html index 9c8fa82a4..d2e66e53d 100644 --- a/docs/engine.html +++ b/docs/engine.html @@ -184,13 +184,14 @@
Container Managed Persistence EJBs require (in the EJB 1.1 specification) that managed fields are declared public. This will cause checkstyle to complain that the fields should be declared private. Hence checkstyle supports ignoring public that match a specified regular expression. The default is ^f[A-Z][a-zA-Z0-9]*$.
-Checks for the following use of white space:
This feature can be turned off.
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/java.g b/src/checkstyle/com/puppycrawl/tools/checkstyle/java.g index 14c099c44..d995d9d12 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/java.g +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/java.g @@ -183,14 +183,14 @@ identifier ver.reportReference(i1.getText()); sLastIdentifier = new LineText(i1.getLine(), i1.getText()); } - ( DOT^ i2:IDENT {sLastIdentifier.appendText("." + i2.getText());} )* + ( DOT^ i2:IDENT {ver.verifyDot(#DOT); sLastIdentifier.appendText("." + i2.getText());} )* ; identifierStar { int ln = 0; String str = ""; boolean star = false; } : i1:IDENT {ln = i1.getLine(); str = i1.getText();} - ( DOT^ i2:IDENT {str += "." + i2.getText();} )* - ( DOT^ i3:STAR {str += ".*"; star = true;} )? + ( DOT^ i2:IDENT {str += "." + i2.getText(); ver.verifyDot(#DOT); } )* + ( DOT^ i3:STAR {str += ".*"; star = true; ver.verifyDot(#DOT); } )? { if (star) { ver.reportStarImport(ln, str); @@ -394,7 +394,7 @@ explicitConstructorInvocation {#lp2.setType(SUPER_CTOR_CALL);} // (new Outer()).super() (create enclosing instance) - | primaryExpression DOT! "super"! lp3:LPAREN^ argList RPAREN! SEMI! + | primaryExpression DOT! {ver.verifyDot(#DOT);} "super"! lp3:LPAREN^ argList RPAREN! SEMI! {#lp3.setType(SUPER_CTOR_CALL);} ) ; @@ -884,7 +884,7 @@ postfixExpression : primaryExpression // start with a primary ( // qualified id (id.id.id.id...) -- build the name - DOT^ ( IDENT {ver.reportReference(sFirstIdent);} + DOT^ {ver.verifyDot(#DOT);} ( IDENT {ver.reportReference(sFirstIdent);} | "this" | "class" {ver.reportReference(sFirstIdent);} | newExpression @@ -895,7 +895,7 @@ postfixExpression // allow ClassName[].class | ( lbc:LBRACK^ {#lbc.setType(ARRAY_DECLARATOR);} RBRACK! )+ - DOT^ "class" + DOT^ "class" {ver.verifyDot(#DOT);} // an array indexing operation | lb:LBRACK^ {#lb.setType(INDEX_OP);} expression RBRACK! @@ -935,7 +935,7 @@ primaryExpression // look for int.class and int[].class | builtInType ( lbt:LBRACK^ {#lbt.setType(ARRAY_DECLARATOR);} RBRACK! )* - DOT^ "class" + DOT^ "class" { ver.verifyDot(#DOT); } ; /** object instantiation. @@ -1067,7 +1067,6 @@ LCURLY : '{' ; RCURLY : '}' ; COLON : ':' ; COMMA : ',' {ver.verifyWSAfter(getLine(), getColumn() - 1, MyToken.COMMA);} ; -//DOT : '.' ; ASSIGN : '=' {ver.verifyWSAroundEnd(getLine(), getColumn(), "=");} ; EQUAL : "==" {ver.verifyWSAroundEnd(getLine(), getColumn(), "==");} ; LNOT : '!' ; // check above diff --git a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java index d2fbd6dd2..809524a89 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java @@ -87,46 +87,52 @@ public class CheckerTest final String filepath = getPath("InputWhitespace.java"); assertNotNull(c); final String[] expected = { - filepath + ":11: type Javadoc comment is missing an @author tag.", - filepath + ":14: '=' is not preceeded with whitespace.", - filepath + ":14: '=' is not followed by whitespace.", + filepath + ":5: '.' is preceeded with whitespace.", + filepath + ":5: '.' is followed by whitespace.", + filepath + ":13: type Javadoc comment is missing an @author tag.", + filepath + ":16: '=' is not preceeded with whitespace.", filepath + ":16: '=' is not followed by whitespace.", - filepath + ":24: '=' is not preceeded with whitespace.", - filepath + ":25: '=' is not preceeded with whitespace.", - filepath + ":25: '=' is not followed by whitespace.", - filepath + ":26: '+=' is not preceeded with whitespace.", - filepath + ":26: '+=' is not followed by whitespace.", - filepath + ":27: '-=' is not followed by whitespace.", - filepath + ":27: '-' is followed by whitespace.", - filepath + ":27: '+' is followed by whitespace.", - filepath + ":28: '++' is preceeded with whitespace.", - filepath + ":28: '--' is preceeded with whitespace.", - filepath + ":29: '++' is followed by whitespace.", - filepath + ":29: '--' is followed by whitespace.", - filepath + ":35: 'synchronized' is not followed by whitespace.", - filepath + ":37: 'try' is not followed by whitespace.", - filepath + ":39: 'catch' is not followed by whitespace.", - filepath + ":56: 'if' is not followed by whitespace.", - filepath + ":74: 'return' is not followed by whitespace.", - filepath + ":86: cast needs to be followed by whitespace.", - filepath + ":95: '?' is not preceeded with whitespace.", - filepath + ":95: '?' is not followed by whitespace.", - filepath + ":95: ':' is not preceeded with whitespace.", - filepath + ":95: ':' is not followed by whitespace.", - filepath + ":96: '==' is not preceeded with whitespace.", - filepath + ":96: '==' is not followed by whitespace.", - filepath + ":102: '*' is not followed by whitespace.", - filepath + ":102: '*' is not preceeded with whitespace.", - filepath + ":109: '!' is followed by whitespace.", - filepath + ":110: '~' is followed by whitespace.", - filepath + ":117: '%' is not preceeded with whitespace.", - filepath + ":118: '%' is not followed by whitespace.", + filepath + ":18: '=' is not followed by whitespace.", + filepath + ":26: '=' is not preceeded with whitespace.", + filepath + ":27: '=' is not preceeded with whitespace.", + filepath + ":27: '=' is not followed by whitespace.", + filepath + ":28: '+=' is not preceeded with whitespace.", + filepath + ":28: '+=' is not followed by whitespace.", + filepath + ":29: '-=' is not followed by whitespace.", + filepath + ":29: '-' is followed by whitespace.", + filepath + ":29: '+' is followed by whitespace.", + filepath + ":30: '++' is preceeded with whitespace.", + filepath + ":30: '--' is preceeded with whitespace.", + filepath + ":31: '++' is followed by whitespace.", + filepath + ":31: '--' is followed by whitespace.", + filepath + ":37: 'synchronized' is not followed by whitespace.", + filepath + ":39: 'try' is not followed by whitespace.", + filepath + ":41: 'catch' is not followed by whitespace.", + filepath + ":58: 'if' is not followed by whitespace.", + filepath + ":76: 'return' is not followed by whitespace.", + filepath + ":88: cast needs to be followed by whitespace.", + filepath + ":97: '?' is not preceeded with whitespace.", + filepath + ":97: '?' is not followed by whitespace.", + filepath + ":97: ':' is not preceeded with whitespace.", + filepath + ":97: ':' is not followed by whitespace.", + filepath + ":98: '==' is not preceeded with whitespace.", + filepath + ":98: '==' is not followed by whitespace.", + filepath + ":104: '*' is not followed by whitespace.", + filepath + ":104: '*' is not preceeded with whitespace.", + filepath + ":111: '!' is followed by whitespace.", + filepath + ":112: '~' is followed by whitespace.", filepath + ":119: '%' is not preceeded with whitespace.", - filepath + ":119: '%' is not followed by whitespace.", - filepath + ":121: '/' is not preceeded with whitespace.", - filepath + ":122: '/' is not followed by whitespace.", + filepath + ":120: '%' is not followed by whitespace.", + filepath + ":121: '%' is not preceeded with whitespace.", + filepath + ":121: '%' is not followed by whitespace.", filepath + ":123: '/' is not preceeded with whitespace.", - filepath + ":123: '/' is not followed by whitespace.", + filepath + ":124: '/' is not followed by whitespace.", + filepath + ":125: '/' is not preceeded with whitespace.", + filepath + ":125: '/' is not followed by whitespace.", + filepath + ":129: '.' is preceeded with whitespace.", + filepath + ":129: '.' is followed by whitespace.", + filepath + ":136: '.' is preceeded with whitespace.", + filepath + ":136: '.' is followed by whitespace.", }; verify(c, filepath, expected); } @@ -139,45 +145,51 @@ public class CheckerTest final String filepath = getPath("InputWhitespace.java"); assertNotNull(c); final String[] expected = { - filepath + ":11: type Javadoc comment is missing an @author tag.", - filepath + ":14: '=' is not preceeded with whitespace.", - filepath + ":14: '=' is not followed by whitespace.", + filepath + ":5: '.' is preceeded with whitespace.", + filepath + ":5: '.' is followed by whitespace.", + filepath + ":13: type Javadoc comment is missing an @author tag.", + filepath + ":16: '=' is not preceeded with whitespace.", filepath + ":16: '=' is not followed by whitespace.", - filepath + ":24: '=' is not preceeded with whitespace.", - filepath + ":25: '=' is not preceeded with whitespace.", - filepath + ":25: '=' is not followed by whitespace.", - filepath + ":26: '+=' is not preceeded with whitespace.", - filepath + ":26: '+=' is not followed by whitespace.", - filepath + ":27: '-=' is not followed by whitespace.", - filepath + ":27: '-' is followed by whitespace.", - filepath + ":27: '+' is followed by whitespace.", - filepath + ":28: '++' is preceeded with whitespace.", - filepath + ":28: '--' is preceeded with whitespace.", - filepath + ":29: '++' is followed by whitespace.", - filepath + ":29: '--' is followed by whitespace.", - filepath + ":35: 'synchronized' is not followed by whitespace.", - filepath + ":37: 'try' is not followed by whitespace.", - filepath + ":39: 'catch' is not followed by whitespace.", - filepath + ":56: 'if' is not followed by whitespace.", - filepath + ":74: 'return' is not followed by whitespace.", - filepath + ":95: '?' is not preceeded with whitespace.", - filepath + ":95: '?' is not followed by whitespace.", - filepath + ":95: ':' is not preceeded with whitespace.", - filepath + ":95: ':' is not followed by whitespace.", - filepath + ":96: '==' is not preceeded with whitespace.", - filepath + ":96: '==' is not followed by whitespace.", - filepath + ":102: '*' is not followed by whitespace.", - filepath + ":102: '*' is not preceeded with whitespace.", - filepath + ":109: '!' is followed by whitespace.", - filepath + ":110: '~' is followed by whitespace.", - filepath + ":117: '%' is not preceeded with whitespace.", - filepath + ":118: '%' is not followed by whitespace.", + filepath + ":18: '=' is not followed by whitespace.", + filepath + ":26: '=' is not preceeded with whitespace.", + filepath + ":27: '=' is not preceeded with whitespace.", + filepath + ":27: '=' is not followed by whitespace.", + filepath + ":28: '+=' is not preceeded with whitespace.", + filepath + ":28: '+=' is not followed by whitespace.", + filepath + ":29: '-=' is not followed by whitespace.", + filepath + ":29: '-' is followed by whitespace.", + filepath + ":29: '+' is followed by whitespace.", + filepath + ":30: '++' is preceeded with whitespace.", + filepath + ":30: '--' is preceeded with whitespace.", + filepath + ":31: '++' is followed by whitespace.", + filepath + ":31: '--' is followed by whitespace.", + filepath + ":37: 'synchronized' is not followed by whitespace.", + filepath + ":39: 'try' is not followed by whitespace.", + filepath + ":41: 'catch' is not followed by whitespace.", + filepath + ":58: 'if' is not followed by whitespace.", + filepath + ":76: 'return' is not followed by whitespace.", + filepath + ":97: '?' is not preceeded with whitespace.", + filepath + ":97: '?' is not followed by whitespace.", + filepath + ":97: ':' is not preceeded with whitespace.", + filepath + ":97: ':' is not followed by whitespace.", + filepath + ":98: '==' is not preceeded with whitespace.", + filepath + ":98: '==' is not followed by whitespace.", + filepath + ":104: '*' is not followed by whitespace.", + filepath + ":104: '*' is not preceeded with whitespace.", + filepath + ":111: '!' is followed by whitespace.", + filepath + ":112: '~' is followed by whitespace.", filepath + ":119: '%' is not preceeded with whitespace.", - filepath + ":119: '%' is not followed by whitespace.", - filepath + ":121: '/' is not preceeded with whitespace.", - filepath + ":122: '/' is not followed by whitespace.", + filepath + ":120: '%' is not followed by whitespace.", + filepath + ":121: '%' is not preceeded with whitespace.", + filepath + ":121: '%' is not followed by whitespace.", filepath + ":123: '/' is not preceeded with whitespace.", - filepath + ":123: '/' is not followed by whitespace.", + filepath + ":124: '/' is not followed by whitespace.", + filepath + ":125: '/' is not preceeded with whitespace.", + filepath + ":125: '/' is not followed by whitespace.", + filepath + ":129: '.' is preceeded with whitespace.", + filepath + ":129: '.' is followed by whitespace.", + filepath + ":136: '.' is preceeded with whitespace.", + filepath + ":136: '.' is followed by whitespace.", }; verify(c, filepath, expected); } @@ -190,7 +202,7 @@ public class CheckerTest final String filepath = getPath("InputWhitespace.java"); assertNotNull(c); final String[] expected = { - filepath + ":11: type Javadoc comment is missing an @author tag.", + filepath + ":13: type Javadoc comment is missing an @author tag.", }; verify(c, filepath, expected); } diff --git a/src/tests/com/puppycrawl/tools/checkstyle/InputWhitespace.java b/src/tests/com/puppycrawl/tools/checkstyle/InputWhitespace.java index 9c73a005c..f3a6b3ae6 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/InputWhitespace.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/InputWhitespace.java @@ -2,7 +2,9 @@ // Test case file for checkstyle. // Created: 2001 //////////////////////////////////////////////////////////////////////////////// -package com.puppycrawl.tools.checkstyle; +package com . puppycrawl + .tools. + checkstyle; /** * Class for testing whitespace issues. @@ -122,4 +124,16 @@ class InputWhitespace int g = 4 /2; int h = 4/2; } + + /** @return dot test **/ + private java .lang. String dotTest() + { + Object o = new java.lang.Object(); + o. + toString(); + o + .toString(); + o . toString(); + return o.toString(); + } }