Skip to content

Commit

Permalink
Fixed semicolon with multiple binops (#197)
Browse files Browse the repository at this point in the history
* fixed semicolon with multiple binops
* use Haxe 4.1.4 with gh actions
* disabled Haxe nightly
  • Loading branch information
AlexHaxe authored Sep 19, 2020
1 parent afc7afd commit 0a43102
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 11 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/tokentree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
haxe-version: ['3.4.7', '4.0.5', '4.1.2', 'nightly']
haxe-version: ['3.4.7', '4.0.5', '4.1.4']
# haxe-version: ['3.4.7', '4.0.5', '4.1.4', 'nightly']
steps:
- uses: actions/checkout@v1
- name: Use Node.js 10
Expand Down Expand Up @@ -68,5 +69,5 @@ jobs:
- name: Run Node version with --check
run: npx neko checkstyle/run.n -s src -s test
- name: Upload results to codecov
if: success() && (matrix.haxe-version == '4.1.2' || matrix.haxe-version == '3.4.7')
if: success() && (matrix.haxe-version == '4.1.4' || matrix.haxe-version == '3.4.7')
run: bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
2 changes: 1 addition & 1 deletion .haxerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "4.1.2",
"version": "4.1.4",
"resolveLibs": "scoped"
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Fixed negative const / Binop(OpSub) detection ([#189](https://github.com/HaxeCheckstyle/tokentree/issues/189))
- Fixed final with multiple vars ([#191](https://github.com/HaxeCheckstyle/tokentree/issues/191))
- Fixed is operator ([#194](https://github.com/HaxeCheckstyle/tokentree/issues/194))
- Fixed semicolon with multiple binops ([#197](https://github.com/HaxeCheckstyle/tokentree/issues/197))
- Refactored enums to use CamelCase ([#191](https://github.com/HaxeCheckstyle/tokentree/issues/191))
- Refactored to reduce usage of Type.enumEq ([#195](https://github.com/HaxeCheckstyle/tokentree/issues/195) + [#196](https://github.com/HaxeCheckstyle/tokentree/issues/196))
- Removed `is` operator ([#195](https://github.com/HaxeCheckstyle/tokentree/issues/195))
Expand Down
2 changes: 1 addition & 1 deletion haxe_libraries/hxjsonast.hxml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-D hxjsonast=1.0.1
# @install: lix --silent download "haxelib:/hxjsonast#1.0.1" into hxjsonast/1.0.1/haxelib
-cp ${HAXE_LIBCACHE}/hxjsonast/1.0.1/haxelib/src
-D hxjsonast=1.0.1
6 changes: 3 additions & 3 deletions haxe_libraries/json2object.hxml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-D json2object=3.6.4
# @install: lix --silent download "haxelib:/json2object#3.6.4" into json2object/3.6.4/haxelib
# @install: lix --silent download "haxelib:/json2object#3.8.1" into json2object/3.8.1/haxelib
-lib hxjsonast
-cp ${HAXE_LIBCACHE}/json2object/3.6.4/haxelib/src
-cp ${HAXE_LIBCACHE}/json2object/3.8.1/haxelib/src
-D json2object=3.8.1
6 changes: 3 additions & 3 deletions haxe_libraries/test-adapter.hxml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-D test-adapter=1.2.6
# @install: lix --silent download "haxelib:/test-adapter#1.2.6" into test-adapter/1.2.6/haxelib
# @install: lix --silent download "haxelib:/test-adapter#1.2.9" into test-adapter/1.2.9/haxelib
-lib json2object
-cp ${HAXE_LIBCACHE}/test-adapter/1.2.6/haxelib/
-cp ${HAXE_LIBCACHE}/test-adapter/1.2.9/haxelib/
-D test-adapter=1.2.9
--macro _testadapter.Macro.init()
7 changes: 6 additions & 1 deletion src/tokentree/walk/WalkStatement.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ class WalkStatement {
walkStatementWithoutSemicolon(stream, parent);
if (stream.tokenForMatch().match(Semicolon)) {
var semicolon:TokenTree = stream.consumeToken();
var lastChild:Null<TokenTree> = parent.getLastChild();

var lastChild:Null<TokenTree> = switch (parent.tok) {
case Binop(_): parent.parent.getLastChild();
default: parent.getLastChild();
}

if (lastChild == null) {
lastChild = parent;
}
Expand Down
12 changes: 12 additions & 0 deletions test/tokentree/TokenTreeBuilderParsingTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class TokenTreeBuilderParsingTest {
assertCodeParses(METADATA_IN);
assertCodeParses(IS_OPERATOR);
assertCodeParses(ABSTRACT_CLASS);
assertCodeParses(SEMICOLON_BINOP);
}

public function assertCodeParses(code:String, ?pos:PosInfos) {
Expand Down Expand Up @@ -1616,4 +1617,15 @@ import #if haxe4 js.lib.Promise #else js.Promise #end as JsPromise;
@:structInit abstract class Abstract {}
abstract interface I {}
";

var SEMICOLON_BINOP = "
class Main {
function foobar() {
switch foo {
case bar:
a = b - a + 1;
}
}
}
";
}

0 comments on commit 0a43102

Please sign in to comment.