Fix parsing error which was triggered when a comment line is on a
line with out newline character. Thanks to Evgeny Mandrikov for patch #3367782.
This commit is contained in:
parent
a77365f1b8
commit
3c988d95d9
|
|
@ -1599,7 +1599,7 @@ SL_COMMENT
|
|||
: "//"
|
||||
{ mCommentListener.reportSingleLineComment("//", getLine(),
|
||||
getColumn() - 3); }
|
||||
(~('\n'|'\r'))* ('\n'|'\r'('\n')?)
|
||||
(~('\n'|'\r'))* ('\n'|'\r'('\n')?|)
|
||||
{$setType(Token.SKIP); newline();}
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package com.puppycrawl.tools.checkstyle.grammars;
|
||||
|
||||
public class LineCommentAtTheEndOfFile
|
||||
{
|
||||
} // EOF on this line
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2011 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.grammars;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Checks that file can be parsed, when it ends on line-comment but without
|
||||
* new-line.
|
||||
*
|
||||
* @author Evgeny Mandrikov
|
||||
*/
|
||||
public class LineCommentAtTheEndOfFileTest
|
||||
extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testCanParse()
|
||||
throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(MemberNameCheck.class);
|
||||
final String[] expected = {};
|
||||
verify(checkConfig, getPath("grammars/LineCommentAtTheEndOfFile.java"),
|
||||
expected);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,29 @@
|
|||
</properties>
|
||||
|
||||
<body>
|
||||
<section name="Release 5.5">
|
||||
<p>New features:</p>
|
||||
<ul>
|
||||
<li>
|
||||
...
|
||||
</li>
|
||||
</ul>
|
||||
<p>Bug fixes:</p>
|
||||
<ul>
|
||||
<li>
|
||||
Fix parsing error <code>unexpected char: 0xFFFF</code> which was
|
||||
triggered when a comment line is on a line with out newline character.
|
||||
Thanks to Evgeny Mandrikov for patch #3367782.
|
||||
</li>
|
||||
</ul>
|
||||
<p>Notes:</p>
|
||||
<ul>
|
||||
<li>
|
||||
...
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section name="Release 5.4">
|
||||
<p>New features:</p>
|
||||
<ul>
|
||||
|
|
|
|||
Loading…
Reference in New Issue