#626 Remove doubled blank lines on Windows

This commit is contained in:
Andreas Gudian 2015-08-17 17:20:22 +02:00
parent 9ccc9726ff
commit 2c2f69b0d3
2 changed files with 21 additions and 16 deletions

View File

@ -71,7 +71,7 @@ class IndentationCorrectingWriter extends Writer {
State newState = currentState.handleCharacter( c, context );
if ( newState != currentState ) {
currentState.onExit( context );
currentState.onExit( context, newState );
newState.onEntry( context );
currentState = newState;
}
@ -89,7 +89,7 @@ class IndentationCorrectingWriter extends Writer {
@Override
public void close() throws IOException {
currentState.onExit( context );
currentState.onExit( context, null );
context.writer.close();
}
@ -150,7 +150,7 @@ class IndentationCorrectingWriter extends Writer {
* Writes out the current text.
*/
@Override
void onExit(StateContext context) throws IOException {
void onExit(StateContext context, State nextState) throws IOException {
flush( context );
}
@ -194,7 +194,7 @@ class IndentationCorrectingWriter extends Writer {
* Writes out the current text.
*/
@Override
void onExit(StateContext context) throws IOException {
void onExit(StateContext context, State nextState) throws IOException {
flush( context );
}
@ -229,7 +229,7 @@ class IndentationCorrectingWriter extends Writer {
* Writes out the current text.
*/
@Override
void onExit(StateContext context) throws IOException {
void onExit(StateContext context, State nextState) throws IOException {
flush( context );
}
@ -259,7 +259,7 @@ class IndentationCorrectingWriter extends Writer {
* Writes out the current text.
*/
@Override
void onExit(StateContext context) throws IOException {
void onExit(StateContext context, State nextState) throws IOException {
flush( context );
}
@ -320,8 +320,9 @@ class IndentationCorrectingWriter extends Writer {
* Writes out the current line-breaks, avoiding more than one consecutive empty line
*/
@Override
void onExit(StateContext context) throws IOException {
void onExit(StateContext context, State nextState) throws IOException {
context.consecutiveLineBreaks++;
if ( nextState != IN_LINE_BREAK ) {
int lineBreaks = Math.min( context.consecutiveLineBreaks, 2 );
for ( int i = 0; i < lineBreaks; i++ ) {
@ -334,6 +335,7 @@ class IndentationCorrectingWriter extends Writer {
context.consecutiveLineBreaks = 0;
}
}
};
final State handleCharacter(char c, StateContext context) throws IOException {
@ -352,7 +354,7 @@ class IndentationCorrectingWriter extends Writer {
void doOnEntry(StateContext context) throws IOException {
}
void onExit(StateContext context) throws IOException {
void onExit(StateContext context, State nextState) throws IOException {
}
void onBufferFinished(StateContext context) throws IOException {

View File

@ -39,6 +39,10 @@
<property name="format" value="\S\z" />
<property name="message" value="There is no new line at the end of file" />
</module>
<module name="RegexpMultiline">
<property name="format" value="(\r\n\r\n\r\n|\r\r\r|\n\n\n)" />
<property name="message" value="There are multiple blank lines" />
</module>
<module name="RegexpSingleline">
<!-- \s matches whitespace character, $ matches end of line. -->
@ -91,7 +95,6 @@
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="ModifierOrder"/>