diff --git a/.gitignore b/.gitignore index 764e1b1..b0f846d 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,5 @@ check-style-report.json check-style-report.xml coverage.json lcov.info -display.hxml \ No newline at end of file +display.hxml +codecov.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 78de8dd..9b1a564 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,24 @@ ## dev branch / next version (1.x.x) +## version 1.0.29 (2020-11-01) + - Added TokenTreeDef ([#191](https://github.com/HaxeCheckstyle/tokentree/issues/191)) - Added support for abstract classes / interfaces ([#195](https://github.com/HaxeCheckstyle/tokentree/issues/195)) +- Added hasTempStore function ([#199](https://github.com/HaxeCheckstyle/tokentree/issues/199)) - 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) + [#198](https://github.com/HaxeCheckstyle/tokentree/issues/198)) +- Fixed Dollar handling ([#199](https://github.com/HaxeCheckstyle/tokentree/issues/199)) +- Fixed expression handling after BkClose ([#199](https://github.com/HaxeCheckstyle/tokentree/issues/199)) +- Fixed expression handling after BrClose ([#199](https://github.com/HaxeCheckstyle/tokentree/issues/199)) +- Fixed POpen type detection ([#199](https://github.com/HaxeCheckstyle/tokentree/issues/199)) +- Fixed new handling ([#199](https://github.com/HaxeCheckstyle/tokentree/issues/199)) +- Fixed sharp handling for function type hint ([#199](https://github.com/HaxeCheckstyle/tokentree/issues/199)) +- Fixed macro complextype ([#199](https://github.com/HaxeCheckstyle/tokentree/issues/199)) +- Fixed array access on new ([#199](https://github.com/HaxeCheckstyle/tokentree/issues/199)) +- Fixed arrow functions ([#199](https://github.com/HaxeCheckstyle/tokentree/issues/199)) - 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)) diff --git a/haxelib.json b/haxelib.json index 59c2190..ac39c4c 100644 --- a/haxelib.json +++ b/haxelib.json @@ -8,7 +8,7 @@ "AlexHaxe" ], "releasenote": "fixed @in handling, detects more POpen types - see CHANGELOG for details", - "version": "1.0.28", + "version": "1.0.29", "url": "https://github.com/HaxeCheckstyle/tokentree", "dependencies": {} } \ No newline at end of file diff --git a/package.json b/package.json index fbfec3e..c35c62d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tokentree", - "version": "1.0.28", + "version": "1.0.29", "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 5d74082..86628f9 100644 --- a/src/tokentree/TokenStream.hx +++ b/src/tokentree/TokenStream.hx @@ -96,6 +96,10 @@ class TokenStream { } } + public function hasTempStore():Bool { + return tempStore.length > 0; + } + public function getTempStore():Array { return tempStore; } diff --git a/src/tokentree/utils/TokenTreeCheckUtils.hx b/src/tokentree/utils/TokenTreeCheckUtils.hx index 256ba42..1272d18 100644 --- a/src/tokentree/utils/TokenTreeCheckUtils.hx +++ b/src/tokentree/utils/TokenTreeCheckUtils.hx @@ -49,8 +49,7 @@ class TokenTreeCheckUtils { public static function isOpGtTypedefExtension(token:TokenTree):Bool { return switch (token.tok) { - case Binop(OpGt): (token.access().parent().matches(BrOpen).parent() - .matches(Binop(OpAssign)).parent().isCIdent().parent().matches(Kwd(KwdTypedef)) + case Binop(OpGt): (token.access().parent().matches(BrOpen).parent().matches(Binop(OpAssign)).parent().isCIdent().parent().matches(Kwd(KwdTypedef)) .token != null); default: false; } @@ -199,8 +198,7 @@ class TokenTreeCheckUtils { if (!child.tok.match(At)) { continue; } - var enumTok = child.access().firstChild().matches(DblDot).firstChild() - .matches(Kwd(KwdEnum)); + var enumTok = child.access().firstChild().matches(DblDot).firstChild().matches(Kwd(KwdEnum)); if (!enumTok.exists()) { continue; } @@ -216,8 +214,7 @@ class TokenTreeCheckUtils { **/ public static function isTypeStructure(typedefToken:TokenTree):Bool { var afterAssign = typedefToken.access().firstChild().isCIdent().firstOf(Binop(OpAssign)).firstChild(); - return afterAssign.matches(BrOpen).exists() - || afterAssign.isCIdent().firstOf(Binop(OpAnd)).exists(); + return afterAssign.matches(BrOpen).exists() || afterAssign.isCIdent().firstOf(Binop(OpAnd)).exists(); } public static function isTypeEnum(enumToken:TokenTree):Bool { @@ -234,8 +231,7 @@ class TokenTreeCheckUtils { } public static function isTypeMacroClass(classToken:TokenTree):Bool { - return classToken.tok.match(Kwd(KwdClass)) - && classToken.access().parent().matches(Kwd(KwdMacro)).exists(); + return classToken.tok.match(Kwd(KwdClass)) && classToken.access().parent().matches(Kwd(KwdMacro)).exists(); } public static function isBrOpenAnonTypeOrTypedef(token:TokenTree):Bool { @@ -534,13 +530,8 @@ class TokenTreeCheckUtils { if (hasAtParent(token)) { return At; } - var lastChild:TokenTree = token.getLastChild(); - if (lastChild != null) { - switch (lastChild.tok) { - case Arrow: - return Parameter; - default: - } + if (token.hasChildren() && checkPOpenForArrowChildren(token)) { + return Parameter; } while ((parent != null) && (parent.tok != Root)) { switch (parent.tok) { @@ -589,7 +580,14 @@ class TokenTreeCheckUtils { switch (parent.parent.tok) { case Kwd(KwdFunction): if (parent.previousSibling == null) { - return Parameter; + var pOpen:Null = parent.access().firstOf(POpen).token; + if (pOpen == null) { + return Parameter; + } + if (pOpen.index == token.index) { + return Parameter; + } + return Expression; } return Call; case Kwd(KwdAbstract): return Parameter; @@ -608,6 +606,26 @@ class TokenTreeCheckUtils { return Expression; } + static function checkPOpenForArrowChildren(token:TokenTree):Bool { + var skip:Bool = true; + for (child in token.children) { + switch (child.tok) { + case PClose: + skip = false; + default: + } + if (skip) { + continue; + } + switch (child.tok) { + case Arrow: + return true; + default: + } + } + return false; + } + public static function hasAtParent(token:TokenTree):Bool { var parent:TokenTree = token.parent; while (parent.tok != Root) { diff --git a/src/tokentree/walk/WalkArrayAccess.hx b/src/tokentree/walk/WalkArrayAccess.hx index 3477f33..6ec903b 100644 --- a/src/tokentree/walk/WalkArrayAccess.hx +++ b/src/tokentree/walk/WalkArrayAccess.hx @@ -43,5 +43,10 @@ class WalkArrayAccess { } } bkOpen.addChild(stream.consumeTokenDef(BkClose)); + switch (stream.token()) { + case BkOpen | Dot | Binop(_) | Const(CIdent("is")): + WalkStatement.walkStatementContinue(stream, bkOpen); + default: + } } } \ No newline at end of file diff --git a/src/tokentree/walk/WalkBlock.hx b/src/tokentree/walk/WalkBlock.hx index 2c356a1..07b7a3d 100644 --- a/src/tokentree/walk/WalkBlock.hx +++ b/src/tokentree/walk/WalkBlock.hx @@ -15,6 +15,7 @@ class WalkBlock { parent.addChild(openTok); stream.applyTempStore(openTok); walkBlockContinue(stream, openTok); + stream.applyTempStore(openTok); } else { WalkStatement.walkStatement(stream, parent); @@ -56,7 +57,7 @@ class WalkBlock { return; default: } - WalkStatement.walkStatementContinue(stream, parent); + walkAfterBlock(stream, parent); if (stream.hasMore()) { switch (stream.token()) { case Semicolon: @@ -67,4 +68,43 @@ class WalkBlock { } } } + + @:access(tokentree.walk.WalkStatement) + static function walkAfterBlock(stream:TokenStream, parent:TokenTree) { + if (!stream.hasMore()) return; + switch (stream.token()) { + case Dot: + WalkStatement.walkStatementWithoutSemicolon(stream, parent); + case DblDot: + WalkStatement.walkDblDot(stream, parent); + case Semicolon: + return; + case Arrow: + WalkStatement.walkStatementWithoutSemicolon(stream, parent); + case Binop(_): + WalkStatement.walkStatementWithoutSemicolon(stream, parent); + case Const(CIdent("is")): + WalkStatement.walkStatementWithoutSemicolon(stream, parent); + case Unop(_): + if (parent.isCIdentOrCString()) { + WalkStatement.walkStatementWithoutSemicolon(stream, parent); + } + case Question: + WalkQuestion.walkQuestion(stream, parent); + case POpen: + WalkStatement.walkStatementWithoutSemicolon(stream, parent); + case CommentLine(_), Comment(_): + var nextTokDef:Null = stream.peekNonCommentToken(); + if (nextTokDef == null) { + return; + } + switch (nextTokDef) { + case Dot, DblDot, Binop(_), Unop(_), Question: + WalkComment.walkComment(stream, parent); + WalkStatement.walkStatementContinue(stream, parent); + default: + } + default: + } + } } \ No newline at end of file diff --git a/src/tokentree/walk/WalkClass.hx b/src/tokentree/walk/WalkClass.hx index 4ffb1f2..46d6988 100644 --- a/src/tokentree/walk/WalkClass.hx +++ b/src/tokentree/walk/WalkClass.hx @@ -62,7 +62,12 @@ class WalkClass { WalkFinal.walkFinal(stream, parent); #end case Comment(_), CommentLine(_): - parent.addChild(stream.consumeToken()); + if (stream.hasTempStore()) { + stream.consumeToTempStore(); + } + else { + parent.addChild(stream.consumeToken()); + } default: switch (TokenStream.MODE) { case Relaxed: WalkStatement.walkStatement(stream, parent); diff --git a/src/tokentree/walk/WalkFile.hx b/src/tokentree/walk/WalkFile.hx index c4a1d37..225ce14 100644 --- a/src/tokentree/walk/WalkFile.hx +++ b/src/tokentree/walk/WalkFile.hx @@ -18,7 +18,12 @@ class WalkFile { case At: stream.addToTempStore(WalkAt.walkAt(stream)); case Comment(_), CommentLine(_): - WalkComment.walkComment(stream, parent); + if (stream.hasTempStore()) { + stream.consumeToTempStore(); + } + else { + WalkComment.walkComment(stream, parent); + } case Kwd(KwdClass), Kwd(KwdInterface), Kwd(KwdEnum), Kwd(KwdTypedef), Kwd(KwdAbstract): WalkType.walkType(stream, parent); case PClose, BrClose, BkClose, Semicolon, Comma: diff --git a/src/tokentree/walk/WalkFunction.hx b/src/tokentree/walk/WalkFunction.hx index af4dca8..0e9f408 100644 --- a/src/tokentree/walk/WalkFunction.hx +++ b/src/tokentree/walk/WalkFunction.hx @@ -21,6 +21,17 @@ class WalkFunction { WalkComment.walkComment(stream, name); WalkFunction.walkFunctionParameters(stream, name); WalkComment.walkComment(stream, name); + + switch (stream.token()) { + case Sharp(_): + WalkSharp.walkSharp(stream, name, WalkStatement.walkStatement); + switch (stream.token()) { + case DblDot | BrOpen: + default: return; + } + default: + } + if (stream.tokenForMatch().match(DblDot)) { var dblDot:Null = stream.consumeToken(); name.addChild(dblDot); diff --git a/src/tokentree/walk/WalkInterface.hx b/src/tokentree/walk/WalkInterface.hx index ac7fd6e..199a218 100644 --- a/src/tokentree/walk/WalkInterface.hx +++ b/src/tokentree/walk/WalkInterface.hx @@ -40,7 +40,12 @@ class WalkInterface { WalkFinal.walkFinal(stream, parent); #end case Comment(_), CommentLine(_): - parent.addChild(stream.consumeToken()); + if (stream.hasTempStore()) { + stream.consumeToTempStore(); + } + else { + parent.addChild(stream.consumeToken()); + } default: stream.consumeToTempStore(); } diff --git a/src/tokentree/walk/WalkNew.hx b/src/tokentree/walk/WalkNew.hx index 04f32c4..3031886 100644 --- a/src/tokentree/walk/WalkNew.hx +++ b/src/tokentree/walk/WalkNew.hx @@ -15,8 +15,11 @@ class WalkNew { default: } WalkComment.walkComment(stream, name); - if (stream.tokenForMatch().match(Dot)) { - WalkStatement.walkStatement(stream, name); + + switch (stream.token()) { + case Dot | Binop(_) | Const(CIdent("is")) | BkOpen: + WalkStatement.walkStatement(stream, name); + default: } } } \ No newline at end of file diff --git a/src/tokentree/walk/WalkPOpen.hx b/src/tokentree/walk/WalkPOpen.hx index 7dbd1d6..4493a68 100644 --- a/src/tokentree/walk/WalkPOpen.hx +++ b/src/tokentree/walk/WalkPOpen.hx @@ -9,6 +9,11 @@ class WalkPOpen { if (walkTrailingComments) { WalkComment.walkComment(stream, parent); } + switch (stream.token()) { + case Arrow: + WalkStatement.walkStatementContinue(stream, pOpen); + default: + } return pOpen; } diff --git a/src/tokentree/walk/WalkQuestion.hx b/src/tokentree/walk/WalkQuestion.hx index 6144cc9..dee499c 100644 --- a/src/tokentree/walk/WalkQuestion.hx +++ b/src/tokentree/walk/WalkQuestion.hx @@ -12,6 +12,7 @@ class WalkQuestion { } WalkStatement.walkStatement(stream, question); WalkComment.walkComment(stream, question); + if (!stream.tokenForMatch().match(DblDot)) return; var dblDotTok:TokenTree = stream.consumeTokenDef(DblDot); question.addChild(dblDotTok); WalkStatement.walkStatement(stream, dblDotTok); @@ -20,29 +21,29 @@ class WalkQuestion { public static function isTernary(parent:TokenTree):Bool { var lastChild:Null = parent.getLastChild(); if (lastChild == null) { - return switch (parent.tok) { - case Const(_): true; - default: false; + switch (parent.tok) { + case Const(_): + return true; + default: + lastChild = parent; } } - else { - return switch (lastChild.tok) { - case Const(_): true; - case BkOpen: true; - case BrOpen: true; - case Binop(OpAdd), Binop(OpSub): true; - case Unop(_): true; - case Kwd(KwdCast): true; - case Kwd(KwdNew): true; - case Kwd(KwdTrue), Kwd(KwdFalse), Kwd(KwdNull): true; - case Kwd(KwdThis), Kwd(KwdMacro), Kwd(KwdUntyped): true; - case Kwd(KwdFunction): true; - case Dollar(_): true; - case POpen: true; - case PClose: true; - case DblDot: true; - default: false; - } + return switch (lastChild.tok) { + case Const(_): true; + case BkOpen: true; + case BrOpen: true; + case Binop(OpAdd), Binop(OpSub): true; + case Unop(_): true; + case Kwd(KwdCast): true; + case Kwd(KwdNew): true; + case Kwd(KwdTrue), Kwd(KwdFalse), Kwd(KwdNull): true; + case Kwd(KwdThis), Kwd(KwdMacro), Kwd(KwdUntyped): true; + case Kwd(KwdFunction): true; + case Dollar(_): true; + case POpen: true; + case PClose: true; + case DblDot: true; + default: false; } } } \ No newline at end of file diff --git a/src/tokentree/walk/WalkStatement.hx b/src/tokentree/walk/WalkStatement.hx index e4bd1e6..09171a7 100644 --- a/src/tokentree/walk/WalkStatement.hx +++ b/src/tokentree/walk/WalkStatement.hx @@ -69,7 +69,7 @@ class WalkStatement { parent.addChild(newChild); if (!stream.hasMore()) return; switch (stream.token()) { - case Dot: walkStatementWithoutSemicolon(stream, newChild); + case Dot | Binop(_) | Const(CIdent("is")): walkStatementWithoutSemicolon(stream, newChild); default: } return; @@ -89,12 +89,7 @@ class WalkStatement { walkStatementContinue(stream, parent); return; case Dollar(name): - var dollarTok:TokenTree = stream.consumeToken(); - parent.addChild(dollarTok); - if (stream.tokenForMatch().match(DblDot)) { - return; - } - WalkBlock.walkBlock(stream, dollarTok); + walkDollarStatement(stream, parent); return; case POpen: walkPOpen(stream, parent); @@ -115,6 +110,13 @@ class WalkStatement { case Dot: wantMore = true; case DblDot: + switch (parent.tok) { + case Dot: return; + case Kwd(KwdMacro): + walkDblDot(stream, parent); + return; + default: + } if (parent.tok.match(Dot)) { return; } @@ -247,6 +249,7 @@ class WalkStatement { parent.addChild(newChild); switch (stream.token()) { case Binop(OpBoolAnd), Binop(OpBoolOr): walkOpBool(stream, newChild); + case Question: WalkQuestion.walkQuestion(stream, newChild); case Binop(_): walkStatementWithoutSemicolon(stream, newChild); default: } @@ -261,12 +264,6 @@ class WalkStatement { parent.addChild(newChild); walkStatementContinue(stream, newChild); return false; - // case Kwd(KwdReturn): - // trace(stream.token()); - // var newChild:TokenTree = stream.consumeToken(); - // parent.addChild(newChild); - // // walkStatementContinue(stream, newChild); - // return true; default: return true; } @@ -308,7 +305,7 @@ class WalkStatement { } else { switch (parent.tok) { - case Kwd(KwdIf), Kwd(KwdSwitch), Kwd(KwdFor), Kwd(KwdWhile): + case Kwd(KwdIf) | Kwd(KwdSwitch) | Kwd(KwdFor) | Kwd(KwdWhile): switch (stream.token()) { case Binop(OpSub): return; case Binop(_): @@ -342,6 +339,16 @@ class WalkStatement { return parent; case Kwd(KwdCase): return parent; + case Kwd(KwdMacro): + parent = findQuestionParent(parent.parent); + if (parent == null) { + return null; + } + switch (parent.tok) { + case Kwd(KwdCase) | Kwd(KwdDefault) | Question: return parent; + default: return null; + } + return null; case Kwd(KwdDefault): return parent; case Binop(_): @@ -433,4 +440,14 @@ class WalkStatement { } walkStatementWithoutSemicolon(stream, token); } + + static function walkDollarStatement(stream:TokenStream, parent:TokenTree) { + var dollarTok:TokenTree = stream.consumeToken(); + parent.addChild(dollarTok); + switch (stream.token()) { + case POpen | BrOpen | BkOpen | Binop(_) | Const(CIdent("is")): + WalkBlock.walkBlock(stream, dollarTok); + default: + } + } } \ No newline at end of file diff --git a/src/tokentree/walk/WalkTypedefBody.hx b/src/tokentree/walk/WalkTypedefBody.hx index 6c10e4c..14fc8b4 100644 --- a/src/tokentree/walk/WalkTypedefBody.hx +++ b/src/tokentree/walk/WalkTypedefBody.hx @@ -34,7 +34,12 @@ class WalkTypedefBody { case Binop(OpGt): walkStructureExtension(stream, openTok); case Comment(_), CommentLine(_): - WalkComment.walkComment(stream, openTok); + if (stream.hasTempStore()) { + stream.consumeToTempStore(); + } + else { + WalkComment.walkComment(stream, openTok); + } case Kwd(KwdFunction): WalkFunction.walkFunction(stream, openTok); case Kwd(KwdVar): diff --git a/test/tokentree/TokenTreeBuilderParsingTest.hx b/test/tokentree/TokenTreeBuilderParsingTest.hx index 6f78c1f..bdf8d22 100644 --- a/test/tokentree/TokenTreeBuilderParsingTest.hx +++ b/test/tokentree/TokenTreeBuilderParsingTest.hx @@ -119,6 +119,8 @@ class TokenTreeBuilderParsingTest implements ITest { assertCodeParses(IS_OPERATOR); assertCodeParses(ABSTRACT_CLASS); assertCodeParses(SEMICOLON_BINOP); + assertCodeParses(NEW_ARRAY_ACCESS); + assertCodeParses(MACRO_COMPLEXTYPE); } public function assertCodeParses(code:String, ?pos:PosInfos) { @@ -128,7 +130,7 @@ class TokenTreeBuilderParsingTest implements ITest { Assert.isTrue(builder.isStreamEmpty(), pos); } catch (e:Any) { - Assert.fail("code should not throw execption: ", pos); + Assert.fail('code should not throw execption: $e', pos); } } @@ -1629,4 +1631,16 @@ import #if haxe4 js.lib.Promise #else js.Promise #end as JsPromise; } } "; + + var NEW_ARRAY_ACCESS = " + class Test { + function main() { + new JQuery ('#id') [0].scrollIntoView (); + } + }"; + + var MACRO_COMPLEXTYPE = " + class Test { + var retType = macro : Map; + }"; } \ No newline at end of file diff --git a/test/tokentree/utils/TokenTreeCheckUtilsTest.hx b/test/tokentree/utils/TokenTreeCheckUtilsTest.hx index 230bee9..8ae3c9e 100644 --- a/test/tokentree/utils/TokenTreeCheckUtilsTest.hx +++ b/test/tokentree/utils/TokenTreeCheckUtilsTest.hx @@ -156,7 +156,7 @@ class TokenTreeCheckUtilsTest implements ITest { default: GoDeeper; } }); - Assert.equals(10, allArrows.length); + Assert.equals(12, allArrows.length); for (ar in allArrows) { Assert.equals(ArrowType.ArrowFunction, TokenTreeCheckUtils.getArrowType(ar)); } @@ -241,7 +241,7 @@ class TokenTreeCheckUtilsTest implements ITest { default: GoDeeper; } }); - Assert.equals(64, allBr.length); + Assert.equals(66, allBr.length); var index:Int = 0; Assert.equals(ColonType.ObjectLiteral, TokenTreeCheckUtils.getColonType(allBr[index++])); Assert.equals(ColonType.TypeCheck, TokenTreeCheckUtils.getColonType(allBr[index++])); @@ -348,6 +348,11 @@ class TokenTreeCheckUtilsTest implements ITest { // public static function element(name:String):AngularElement; Assert.equals(ColonType.TypeHint, TokenTreeCheckUtils.getColonType(allBr[index++])); Assert.equals(ColonType.TypeHint, TokenTreeCheckUtils.getColonType(allBr[index++])); + + // foo((data:Some) -> { + Assert.equals(ColonType.TypeHint, TokenTreeCheckUtils.getColonType(allBr[index++])); + // }, (error : Error) -> { + Assert.equals(ColonType.TypeHint, TokenTreeCheckUtils.getColonType(allBr[index++])); } @Test @@ -361,7 +366,7 @@ class TokenTreeCheckUtilsTest implements ITest { default: GoDeeper; } }); - Assert.equals(28, allBr.length); + Assert.equals(36, allBr.length); var index:Int = 0; Assert.equals(POpenType.Expression, TokenTreeCheckUtils.getPOpenType(null)); @@ -382,6 +387,17 @@ class TokenTreeCheckUtilsTest implements ITest { Assert.equals(POpenType.IfCondition, TokenTreeCheckUtils.getPOpenType(allBr[index++])); Assert.equals(POpenType.ForLoop, TokenTreeCheckUtils.getPOpenType(allBr[index++])); + // foo((data : Some) -> { + // trace(1); + // }, (error:Error) -> { + // trace(2); + // }); + Assert.equals(POpenType.Call, TokenTreeCheckUtils.getPOpenType(allBr[index++])); + Assert.equals(POpenType.Parameter, TokenTreeCheckUtils.getPOpenType(allBr[index++])); + Assert.equals(POpenType.Call, TokenTreeCheckUtils.getPOpenType(allBr[index++])); + Assert.equals(POpenType.Parameter, TokenTreeCheckUtils.getPOpenType(allBr[index++])); + Assert.equals(POpenType.Call, TokenTreeCheckUtils.getPOpenType(allBr[index++])); + // return e2 == null ? {t: HDyn} : bar(e2); Assert.equals(POpenType.Call, TokenTreeCheckUtils.getPOpenType(allBr[index++])); @@ -417,6 +433,13 @@ class TokenTreeCheckUtilsTest implements ITest { // } catch (e) Assert.equals(POpenType.Catch, TokenTreeCheckUtils.getPOpenType(allBr[index++])); + // public function connect():Void + Assert.equals(POpenType.Parameter, TokenTreeCheckUtils.getPOpenType(allBr[index++])); + // (switch handlers[name] { + Assert.equals(POpenType.Expression, TokenTreeCheckUtils.getPOpenType(allBr[index++])); + // }).push({target: target, method: method}); + Assert.equals(POpenType.Call, TokenTreeCheckUtils.getPOpenType(allBr[index++])); + // @:default(false) @:optional var disableFormatting:Bool; Assert.equals(POpenType.At, TokenTreeCheckUtils.getPOpenType(allBr[index++])); // @:default(auto) @:optional var emptyLines:EmptyLinesConfig; @@ -699,6 +722,11 @@ abstract TokenTreeCheckUtilsTests(String) to String { return { x: a -> a; } + foo((data:Some) -> { + trace(1); + }, (error:Error) -> { + trace(2); + }); } } "; @@ -836,6 +864,16 @@ abstract TokenTreeCheckUtilsTests(String) to String { @:overload(function(element:js.html.Element):AngularElement {}) public static function element(name:String):AngularElement; } + + class Main { + static function main() { + foo((data:Some) -> { + trace(1); + }, (error:Error) -> { + trace(2); + }); + } + } "; var MIXED_POPEN_TYPES = " @@ -845,6 +883,11 @@ abstract TokenTreeCheckUtilsTests(String) to String { var item = ({title: 'Edit settings '} : vscode.MessageItem); var output = (result.stderr:Buffer).toString().trim(); if (output == null) for (i in items) {} + foo((data:Some) -> { + trace(1); + }, (error:Error) -> { + trace(2); + }); return e2 == null ? {t: HDyn} : bar(e2); } @@ -864,6 +907,11 @@ abstract TokenTreeCheckUtilsTests(String) to String { } } catch (e) } + public function connect():Void + (switch handlers[name] { + case null: handlers[name] = []; + case v: v; + }).push({target: target, method: method}); } typedef FormatterConfig = { /**