diff --git a/.travis.yml b/.travis.yml index 256bf64..e9b296a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,8 @@ matrix: - yes | haxelib git haxeparser https://github.com/simn/haxeparser - haxelib install compiletime 2.6.0 - haxelib install hxargs 3.0.2 - - haxelib git mcover https://github.com/AlexHaxe/mcover haxe_4_thread src - haxelib install munit + - haxelib install mcover - haxelib install mconsole - haxelib git hxnodejs https://github.com/HaxeFoundation/hxnodejs.git master - haxelib install test-adapter @@ -34,9 +34,9 @@ matrix: install: - haxelib git hxparse https://github.com/simn/hxparse - yes | haxelib git haxeparser https://github.com/simn/haxeparser - - haxelib git mcover https://github.com/AlexHaxe/mcover haxe_4_thread src - - haxelib git munit https://github.com/AlexHaxe/MassiveUnit.git haxe_4_thread src - haxelib git hxnodejs https://github.com/HaxeFoundation/hxnodejs.git master + - haxelib install munit + - haxelib install mcover - haxelib install mlib - haxelib install mconsole - haxelib install compiletime 2.6.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 215c2cf..712416d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## dev branch / next version (1.x.x) +- Fixed conditionals using dot idents without parens [#159](https://github.com/HaxeCheckstyle/tokentree/issues/159) + ## version 1.0.20 (2019-05-17) - Fixed potential null pointer in `TokenTreeAccessHelper.findParent` [#157](https://github.com/HaxeCheckstyle/tokentree/issues/157) diff --git a/src/tokentree/walk/WalkSharp.hx b/src/tokentree/walk/WalkSharp.hx index 9f65b0b..5932362 100644 --- a/src/tokentree/walk/WalkSharp.hx +++ b/src/tokentree/walk/WalkSharp.hx @@ -110,6 +110,18 @@ class WalkSharp { case Kwd(_), Const(CIdent(_)): childToken = stream.consumeToken(); parent.addChild(childToken); + if (!stream.hasMore()) return; + switch (stream.token()) { + case Dot: + default: return; + } + var pos:Null = stream.getTokenPos(); + if (pos == null) return; + if (pos.min == childToken.pos.max + 1) continue; + + var dot:TokenTree = stream.consumeToken(); + childToken.addChild(dot); + WalkSharp.walkSharpIfExpr(stream, dot); return; default: return; diff --git a/test/tokentree/TokenTreeBuilderParsingTest.hx b/test/tokentree/TokenTreeBuilderParsingTest.hx index b991ec5..57b02df 100644 --- a/test/tokentree/TokenTreeBuilderParsingTest.hx +++ b/test/tokentree/TokenTreeBuilderParsingTest.hx @@ -96,6 +96,7 @@ class TokenTreeBuilderParsingTest { assertCodeParses(TERNARY_WITH_RETURN); assertCodeParses(TRY_CATCH_WITH_COMMENT); assertCodeParses(TERNARY_WITH_OP_BOOL); + assertCodeParses(DOT_IDENT_CONDITIONAL); } public function assertCodeParses(code:String, ?pos:PosInfos) { @@ -1343,4 +1344,14 @@ abstract TokenTreeBuilderParsingTests(String) to String { } } "; + + var DOT_IDENT_CONDITIONAL = " + class Main { + static function main() { + #if target.sys + trace('Test'); + #end + } + } + "; } \ No newline at end of file