From fdf249b506dfc4a2c854cf20dfe213f26c0f2cce Mon Sep 17 00:00:00 2001 From: AlexHaxe Date: Fri, 22 Jan 2021 21:32:43 +0100 Subject: [PATCH] Fix parens after curly (#206) * fixed parens after curlies --- CHANGELOG.md | 4 ++++ haxelib.json | 4 ++-- package-lock.json | 2 +- package.json | 2 +- src/tokentree/walk/WalkBlock.hx | 6 +++++- test/tokentree/TokenTreeBuilderParsingTest.hx | 13 +++++++++++++ 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6533d67..a584b5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## dev branch / next version (1.x.x) +## version 1.1.1 (2021-01-22) + +- Fixed POpen after block curlies ([#206](https://github.com/HaxeCheckstyle/tokentree/issues/206)) + ## version 1.1.0 (2020-12-23) - Retired Haxe 3.4.7 compile support ([#202](https://github.com/HaxeCheckstyle/tokentree/issues/202)) diff --git a/haxelib.json b/haxelib.json index 624e78e..cc921f4 100644 --- a/haxelib.json +++ b/haxelib.json @@ -7,8 +7,8 @@ "contributors": [ "AlexHaxe" ], - "releasenote": "retired Haxe 3 compilation support and bugfixes - see CHANGELOG for details", - "version": "1.1.0", + "releasenote": "fixed parens after curlies - see CHANGELOG for details", + "version": "1.1.1", "url": "https://github.com/HaxeCheckstyle/tokentree", "dependencies": {} } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 2d5a664..5730f43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "tokentree", - "version": "1.1.0", + "version": "1.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 6c11583..b5a44a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tokentree", - "version": "1.1.0", + "version": "1.1.1", "description": "TokenTree library used by haxe-checkstyle, haxe-formatter and haxe-languageserver", "repository": { "type": "git", diff --git a/src/tokentree/walk/WalkBlock.hx b/src/tokentree/walk/WalkBlock.hx index 07b7a3d..a7b2e59 100644 --- a/src/tokentree/walk/WalkBlock.hx +++ b/src/tokentree/walk/WalkBlock.hx @@ -92,7 +92,11 @@ class WalkBlock { case Question: WalkQuestion.walkQuestion(stream, parent); case POpen: - WalkStatement.walkStatementWithoutSemicolon(stream, parent); + switch (parent.parent.tok) { + case Dollar(_): + WalkStatement.walkStatementWithoutSemicolon(stream, parent); + default: + } case CommentLine(_), Comment(_): var nextTokDef:Null = stream.peekNonCommentToken(); if (nextTokDef == null) { diff --git a/test/tokentree/TokenTreeBuilderParsingTest.hx b/test/tokentree/TokenTreeBuilderParsingTest.hx index bac1b53..3333f2e 100644 --- a/test/tokentree/TokenTreeBuilderParsingTest.hx +++ b/test/tokentree/TokenTreeBuilderParsingTest.hx @@ -126,6 +126,7 @@ class TokenTreeBuilderParsingTest implements ITest { assertCodeParses(FUNCTION_TYPE_PARAM); assertCodeParses(OVERLOAD_FUNCTION); assertCodeParses(SPREAD_OPERATOR); + assertCodeParses(PARENS_AFTER_BLOCK); } @Test @@ -1729,4 +1730,16 @@ import #if haxe4 js.lib.Promise #else js.Promise #end as JsPromise; return super.methodWithRest(...rest.append(999)); } "; + + var PARENS_AFTER_BLOCK = " + class Test { + public static function main() { + macro function() { + $i{field.name}(); + } + if (true) {} + (f : Dynamic).foo = true; + } + } + "; } \ No newline at end of file