From bbd35619eda4ffcd6c8a9d2faadb7d8d4dcea85b Mon Sep 17 00:00:00 2001 From: AlexHaxe Date: Wed, 2 Oct 2024 21:52:50 +0200 Subject: [PATCH] fixed operator keyword used in Haxe 3 code --- CHANGELOG.md | 4 ++++ haxelib.json | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- src/tokentree/TokenStream.hx | 3 +++ test/tokentree/TokenTreeBuilderParsingTest.hx | 9 +++++++++ 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47b01e7..5ddbd4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## dev branch / next version (1.x.x) +## version 1.2.15 (2024-10-02) + +- Fixed operator keyword used in Haxe 3 code + ## version 1.2.14 (2024-09-18) - Fixed getArrowType running into a null pointer exception with conditionals diff --git a/haxelib.json b/haxelib.json index c3e42d3..3126e18 100644 --- a/haxelib.json +++ b/haxelib.json @@ -7,8 +7,8 @@ "contributors": [ "AlexHaxe" ], - "releasenote": "fixed metadata for parens - see CHANGELOG for details", - "version": "1.2.14", + "releasenote": "fixed operator keyword - see CHANGELOG for details", + "version": "1.2.15", "url": "https://github.com/HaxeCheckstyle/tokentree", "dependencies": {} } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 33fa662..589d96d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tokentree", - "version": "1.2.14", + "version": "1.2.15", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "tokentree", - "version": "1.2.14", + "version": "1.2.15", "license": "MIT", "devDependencies": { "lix": "^15.12.0" diff --git a/package.json b/package.json index f283d32..a326e5b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tokentree", - "version": "1.2.14", + "version": "1.2.15", "description": "TokenTree library used by haxe-checkstyle, haxe-formatter and haxe-languageserver", "repository": { "type": "git", diff --git a/src/tokentree/TokenStream.hx b/src/tokentree/TokenStream.hx index 1aa65cc..3806fcd 100644 --- a/src/tokentree/TokenStream.hx +++ b/src/tokentree/TokenStream.hx @@ -52,6 +52,9 @@ class TokenStream { return consumeToken(); case Const(CIdent(_)): return consumeToken(); + case Kwd(KwdOperator): + // pre 4.0.0 code might still use `operator` as an identifier + return consumeToken(); default: switch (MODE) { case Relaxed: return createDummyToken(Const(CIdent("autoInsert"))); diff --git a/test/tokentree/TokenTreeBuilderParsingTest.hx b/test/tokentree/TokenTreeBuilderParsingTest.hx index 5121e0e..af01190 100644 --- a/test/tokentree/TokenTreeBuilderParsingTest.hx +++ b/test/tokentree/TokenTreeBuilderParsingTest.hx @@ -147,6 +147,7 @@ class TokenTreeBuilderParsingTest implements ITest { assertCodeParses(TRUE); assertCodeParses(FALSE); assertCodeParses(NULL); + assertCodeParses(OPERATOR_KEYWORD_HAXE3); } public function assertCodeParses(code:String, ?pos:PosInfos) { @@ -1915,4 +1916,12 @@ import #if haxe4 js.lib.Promise #else js.Promise #end as JsPromise; return Expr(); } }"; + + var OPERATOR_KEYWORD_HAXE3 = " + class Main { + #if (haxe_ver < '4.0.0') + public var operator(get, set):CairoOperator; + #end + } + "; } \ No newline at end of file