Skip to content

Commit e9ba15c

Browse files
chipshortAlexHaxe
authored andcommitted
Fix parser errors (#395)
1 parent 76f1819 commit e9ba15c

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/checkstyle/token/walk/WalkFunction.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class WalkFunction {
3434
parent.addChild(pOpen);
3535
var progress:TokenStreamProgress = new TokenStreamProgress(stream);
3636
while (progress.streamHasChanged()) {
37+
WalkComment.walkComment(stream, pOpen);
3738
if (stream.is(PClose)) break;
3839
WalkFieldDef.walkFieldDef(stream, pOpen);
3940
}

src/checkstyle/token/walk/WalkStatement.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class WalkStatement {
156156

157157
static function findQuestionParent(token:TokenTree):TokenTree {
158158
var parent:TokenTree = token;
159-
while (parent.tok != null) {
159+
while (parent != null && parent.tok != null) {
160160
switch (parent.tok) {
161161
case Question: return parent;
162162
case Comma: return null;

test/token/TokenTreeBuilderParsingTest.hx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class TokenTreeBuilderParsingTest {
3030
assertCodeParses(OBJECT_WITH_ARRAY);
3131
assertCodeParses(MACRO_REIFICATION);
3232
assertCodeParses(BLOCK_METADATA);
33+
assertCodeParses(COMMENTS_IN_FUNCTION_PARAMS);
3334
}
3435

3536
public function assertCodeParses(code:String, ?pos:PosInfos) {
@@ -393,4 +394,11 @@ abstract TokenTreeBuilderParsingTests(String) to String {
393394
}
394395
}";
395396

397+
var COMMENTS_IN_FUNCTION_PARAMS = "
398+
class Test {
399+
function test( /* comment */ a:String /* comment */) { }
400+
function test2( /* comment */ /* comment */) { }
401+
}
402+
";
403+
396404
}

0 commit comments

Comments
 (0)